From 75ef6a33ed1eebc9feb0f37f51365f496e17ac2c Mon Sep 17 00:00:00 2001 From: Thomas Feuvrier <thomas.feuvrier@c-s.fr> Date: Mon, 22 May 2006 14:57:04 +0000 Subject: [PATCH] nomsg --- Utilities/GDAL/.cvsignore | 10 + Utilities/GDAL/GNUmakefile | 205 + Utilities/GDAL/alg/.cvsignore | 2 + Utilities/GDAL/alg/GNUmakefile | 28 + Utilities/GDAL/alg/contour.cpp | 1510 ++ Utilities/GDAL/alg/gdal_alg.h | 320 + Utilities/GDAL/alg/gdal_crs.c | 925 ++ Utilities/GDAL/alg/gdal_nrgcrs.c | 299 + Utilities/GDAL/alg/gdal_rpc.cpp | 275 + Utilities/GDAL/alg/gdal_tps.cpp | 383 + Utilities/GDAL/alg/gdalchecksum.cpp | 117 + Utilities/GDAL/alg/gdaldither.cpp | 378 + Utilities/GDAL/alg/gdalmediancut.cpp | 539 + Utilities/GDAL/alg/gdalrasterize.cpp | 408 + Utilities/GDAL/alg/gdalsimplewarp.cpp | 465 + Utilities/GDAL/alg/gdaltransformer.cpp | 1806 +++ Utilities/GDAL/alg/gdalwarper.cpp | 1153 ++ Utilities/GDAL/alg/gdalwarper.h | 418 + Utilities/GDAL/alg/gdalwarpkernel.cpp | 3780 +++++ Utilities/GDAL/alg/gdalwarpoperation.cpp | 1959 +++ Utilities/GDAL/alg/gvgcpfit.h | 94 + Utilities/GDAL/alg/llrasterize.cpp | 252 + Utilities/GDAL/alg/makefile.vc | 23 + Utilities/GDAL/alg/thinplatespline.cpp | 588 + Utilities/GDAL/alg/thinplatespline.h | 190 + Utilities/GDAL/bridge/.cvsignore | 1 + Utilities/GDAL/bridge/Makefile | 11 + Utilities/GDAL/bridge/bridge_test.cpp | 392 + Utilities/GDAL/bridge/gbgetsymbol.cpp | 138 + Utilities/GDAL/bridge/gdalbridge.cpp | 555 + Utilities/GDAL/bridge/gdalbridge.h | 750 + Utilities/GDAL/config.guess | 1497 ++ Utilities/GDAL/doc/ERMapperlogo_small.gif | Bin 0 -> 1106 bytes Utilities/GDAL/doc/api.dox | 84 + Utilities/GDAL/doc/credits.dox | 148 + Utilities/GDAL/doc/download.dox | 91 + Utilities/GDAL/doc/examples.dox | 28 + Utilities/GDAL/doc/faq.dox | 205 + Utilities/GDAL/doc/gdal_building.dox | 292 + Utilities/GDAL/doc/gdal_datamodel.dox | 310 + Utilities/GDAL/doc/gdal_drivertut.dox | 1023 ++ Utilities/GDAL/doc/gdal_footer.html | 6 + Utilities/GDAL/doc/gdal_tutorial.dox | 611 + Utilities/GDAL/doc/gdal_utilities.dox | 1081 ++ Utilities/GDAL/doc/governance.dox | 44 + Utilities/GDAL/doc/index.dox | 158 + Utilities/GDAL/doc/ogr/style_pen1.gif | Bin 0 -> 132 bytes Utilities/GDAL/doc/ogr/style_pen2.gif | Bin 0 -> 117 bytes Utilities/GDAL/doc/ogr/style_pen3.gif | Bin 0 -> 122 bytes Utilities/GDAL/doc/ogr/style_textanchor.gif | Bin 0 -> 1538 bytes Utilities/GDAL/doc/ru/gdal_building_ru.dox | 312 + Utilities/GDAL/doc/ru/gdal_datamodel_ru.dox | 252 + Utilities/GDAL/doc/ru/gdal_tutorial_ru.dox | 616 + Utilities/GDAL/doc/ru/index_ru.dox | 155 + Utilities/GDAL/doc/vb6_tutorial.dox | 524 + Utilities/GDAL/doc/warptut.dox | 364 + Utilities/GDAL/doc/wince_port.dox | 180 + Utilities/GDAL/frmts/GNUmakefile | 27 + Utilities/GDAL/frmts/aigrid/.cvsignore | 1 + Utilities/GDAL/frmts/aigrid/GNUmakefile | 30 + Utilities/GDAL/frmts/aigrid/Makefile.dist | 19 + Utilities/GDAL/frmts/aigrid/aigccitt.c | 1926 +++ Utilities/GDAL/frmts/aigrid/aigdataset.cpp | 673 + Utilities/GDAL/frmts/aigrid/aigopen.c | 336 + Utilities/GDAL/frmts/aigrid/aigrid.h | 162 + Utilities/GDAL/frmts/aigrid/aitest.c | 231 + Utilities/GDAL/frmts/aigrid/gridlib.c | 1064 ++ Utilities/GDAL/frmts/aigrid/makefile.vc | 19 + Utilities/GDAL/frmts/ceos/GNUmakefile | 17 + Utilities/GDAL/frmts/ceos/ceosdataset.cpp | 264 + Utilities/GDAL/frmts/ceos/ceosopen.c | 355 + Utilities/GDAL/frmts/ceos/ceosopen.h | 115 + Utilities/GDAL/frmts/ceos/ceostest.c | 84 + Utilities/GDAL/frmts/ceos/makefile.vc | 13 + Utilities/GDAL/frmts/dted/GNUmakefile | 18 + Utilities/GDAL/frmts/dted/dted_api.c | 617 + Utilities/GDAL/frmts/dted/dted_api.h | 211 + Utilities/GDAL/frmts/dted/dted_create.c | 328 + Utilities/GDAL/frmts/dted/dted_ptstream.c | 655 + Utilities/GDAL/frmts/dted/dted_test.c | 145 + Utilities/GDAL/frmts/dted/dteddataset.cpp | 626 + Utilities/GDAL/frmts/dted/frmt_dted.html | 30 + Utilities/GDAL/frmts/dted/makefile.vc | 18 + Utilities/GDAL/frmts/formats_list.html | 441 + Utilities/GDAL/frmts/hdf4/GNUmakefile | 26 + Utilities/GDAL/frmts/hdf4/frmt_hdf4.html | 272 + Utilities/GDAL/frmts/hdf4/hdf-eos/EHapi.c | 3543 +++++ Utilities/GDAL/frmts/hdf4/hdf-eos/GDapi.c | 12180 ++++++++++++++++ Utilities/GDAL/frmts/hdf4/hdf-eos/GNUmakefile | 22 + .../GDAL/frmts/hdf4/hdf-eos/HDFEOSVersion.h | 18 + Utilities/GDAL/frmts/hdf4/hdf-eos/HdfEosDef.h | 311 + Utilities/GDAL/frmts/hdf4/hdf-eos/README | 19 + Utilities/GDAL/frmts/hdf4/hdf-eos/SWapi.c | 12160 +++++++++++++++ Utilities/GDAL/frmts/hdf4/hdf-eos/ease.h | 18 + Utilities/GDAL/frmts/hdf4/hdf-eos/gctp_wrap.c | 149 + Utilities/GDAL/frmts/hdf4/hdf-eos/makefile.vc | 16 + Utilities/GDAL/frmts/hdf4/hdf4dataset.cpp | 1177 ++ Utilities/GDAL/frmts/hdf4/hdf4dataset.h | 157 + .../GDAL/frmts/hdf4/hdf4imagedataset.cpp | 2772 ++++ Utilities/GDAL/frmts/hdf4/makefile.vc | 18 + Utilities/GDAL/frmts/hfa/.cvsignore | 3 + Utilities/GDAL/frmts/hfa/BUILD.TXT | 34 + Utilities/GDAL/frmts/hfa/GNUmakefile | 72 + .../hfa/addtiffo_src/rawblockedimage.cpp | 406 + .../frmts/hfa/addtiffo_src/rawblockedimage.h | 108 + .../frmts/hfa/addtiffo_src/tif_overview.cpp | 562 + Utilities/GDAL/frmts/hfa/buildwin.bat | 68 + Utilities/GDAL/frmts/hfa/frmt_hfa.html | 65 + Utilities/GDAL/frmts/hfa/geoextra.c | 575 + Utilities/GDAL/frmts/hfa/hfa.h | 332 + Utilities/GDAL/frmts/hfa/hfa_overviews.cpp | 127 + Utilities/GDAL/frmts/hfa/hfa_p.h | 505 + Utilities/GDAL/frmts/hfa/hfaband.cpp | 1716 +++ Utilities/GDAL/frmts/hfa/hfacompress.cpp | 288 + Utilities/GDAL/frmts/hfa/hfadataset.cpp | 2915 ++++ Utilities/GDAL/frmts/hfa/hfadictionary.cpp | 275 + Utilities/GDAL/frmts/hfa/hfaentry.cpp | 857 ++ Utilities/GDAL/frmts/hfa/hfafield.cpp | 1185 ++ Utilities/GDAL/frmts/hfa/hfaopen.cpp | 2618 ++++ Utilities/GDAL/frmts/hfa/hfatest.cpp | 242 + Utilities/GDAL/frmts/hfa/hfatype.cpp | 502 + Utilities/GDAL/frmts/hfa/img2tif.cpp | 1137 ++ Utilities/GDAL/frmts/hfa/img2tif.txt | 38 + Utilities/GDAL/frmts/hfa/img2tif_build.sh | 24 + Utilities/GDAL/frmts/hfa/imggeotiff.c | 881 ++ Utilities/GDAL/frmts/hfa/makefile.vc | 17 + Utilities/GDAL/frmts/hfa/tst1tif.sh | 42 + Utilities/GDAL/frmts/hfa/tst_hfa.sh | 29 + Utilities/GDAL/frmts/hfa/tst_img2tif_1.sh | 62 + Utilities/GDAL/frmts/idrisi/GNUmakefile | 15 + Utilities/GDAL/frmts/idrisi/IdrisiDataset.cpp | 2084 +++ Utilities/GDAL/frmts/idrisi/frmt_Idrisi.html | 57 + Utilities/GDAL/frmts/idrisi/makefile.vc | 15 + Utilities/GDAL/frmts/idrisi/rdc.txt | 126 + Utilities/GDAL/frmts/idrisi/rst.txt | 76 + Utilities/GDAL/frmts/jp2kak/GNUmakefile | 28 + Utilities/GDAL/frmts/jp2kak/dbg_file_source.h | 106 + Utilities/GDAL/frmts/jp2kak/frmt_jp2kak.html | 107 + Utilities/GDAL/frmts/jp2kak/jp2kak_roi.h | 76 + Utilities/GDAL/frmts/jp2kak/jp2kakdataset.cpp | 2369 +++ Utilities/GDAL/frmts/jp2kak/makefile.vc | 17 + Utilities/GDAL/frmts/jp2kak/subfile_source.h | 166 + Utilities/GDAL/frmts/leveller/GNUmakefile | 13 + .../GDAL/frmts/leveller/frmt_leveller.html | 33 + .../GDAL/frmts/leveller/levellerdataset.cpp | 705 + Utilities/GDAL/frmts/leveller/makefile.vc | 13 + Utilities/GDAL/frmts/makefile.vc | 95 + Utilities/GDAL/frmts/netcdf/GNUmakefile | 13 + Utilities/GDAL/frmts/netcdf/gmtdataset.cpp | 599 + Utilities/GDAL/frmts/netcdf/makefile.vc | 14 + Utilities/GDAL/frmts/netcdf/netcdfdataset.cpp | 2413 +++ Utilities/GDAL/frmts/netcdf/netcdfdataset.h | 178 + Utilities/GDAL/frmts/nitf/.cvsignore | 1 + Utilities/GDAL/frmts/nitf/makefile.vc | 22 + Utilities/GDAL/frmts/nitf/mgrs.c | 1112 ++ Utilities/GDAL/frmts/nitf/nitffile.c | 963 ++ Utilities/GDAL/frmts/nitf/nitfimage.c | 2076 +++ Utilities/GDAL/frmts/raw/GNUmakefile | 23 + Utilities/GDAL/frmts/raw/atlsci_spheroid.cpp | 177 + Utilities/GDAL/frmts/raw/atlsci_spheroid.h | 87 + Utilities/GDAL/frmts/raw/btdataset.cpp | 970 ++ Utilities/GDAL/frmts/raw/cpgdataset.cpp | 1676 +++ Utilities/GDAL/frmts/raw/dipxdataset.cpp | 354 + Utilities/GDAL/frmts/raw/doq1dataset.cpp | 437 + Utilities/GDAL/frmts/raw/doq2dataset.cpp | 492 + Utilities/GDAL/frmts/raw/ehdrdataset.cpp | 995 ++ Utilities/GDAL/frmts/raw/envidataset.cpp | 1405 ++ Utilities/GDAL/frmts/raw/fastdataset.cpp | 874 ++ Utilities/GDAL/frmts/raw/frmt_fast.html | 179 + Utilities/GDAL/frmts/raw/frmt_mff2.html | 241 + Utilities/GDAL/frmts/raw/fujibasdataset.cpp | 248 + Utilities/GDAL/frmts/raw/gscdataset.cpp | 239 + Utilities/GDAL/frmts/raw/hkvdataset.cpp | 2013 +++ Utilities/GDAL/frmts/raw/idadataset.cpp | 979 ++ Utilities/GDAL/frmts/raw/isis2dataset.cpp | 1029 ++ Utilities/GDAL/frmts/raw/landataset.cpp | 650 + Utilities/GDAL/frmts/raw/makefile.vc | 18 + Utilities/GDAL/frmts/raw/mffdataset.cpp | 1680 +++ Utilities/GDAL/frmts/raw/ndfdataset.cpp | 376 + Utilities/GDAL/frmts/raw/pauxdataset.cpp | 1114 ++ Utilities/GDAL/frmts/raw/pnmdataset.cpp | 445 + Utilities/GDAL/frmts/raw/rawdataset.cpp | 1097 ++ Utilities/GDAL/frmts/raw/rawdataset.h | 202 + Utilities/GDAL/frmts/sdts/.cvsignore | 8 + Utilities/GDAL/frmts/sdts/Doxyfile | 255 + Utilities/GDAL/frmts/sdts/GNUmakefile | 71 + Utilities/GDAL/frmts/sdts/Makefile.in | 133 + Utilities/GDAL/frmts/sdts/aclocal.m4 | 15 + Utilities/GDAL/frmts/sdts/configure.in | 18 + Utilities/GDAL/frmts/sdts/makefile.vc | 34 + Utilities/GDAL/frmts/sdts/makefile.vc.dist | 47 + Utilities/GDAL/frmts/sdts/sdts2shp.cpp | 901 ++ Utilities/GDAL/frmts/sdts/sdts_al.h | 756 + Utilities/GDAL/frmts/sdts/sdts_main.dox | 226 + Utilities/GDAL/frmts/sdts/sdts_tut.dox | 469 + Utilities/GDAL/frmts/sdts/sdtsattrreader.cpp | 262 + Utilities/GDAL/frmts/sdts/sdtscatd.cpp | 374 + Utilities/GDAL/frmts/sdts/sdtsdataset.cpp | 413 + .../GDAL/frmts/sdts/sdtsindexedreader.cpp | 291 + Utilities/GDAL/frmts/sdts/sdtsiref.cpp | 312 + Utilities/GDAL/frmts/sdts/sdtslib.cpp | 290 + Utilities/GDAL/frmts/sdts/sdtslinereader.cpp | 394 + Utilities/GDAL/frmts/sdts/sdtspointreader.cpp | 247 + .../GDAL/frmts/sdts/sdtspolygonreader.cpp | 674 + .../GDAL/frmts/sdts/sdtsrasterreader.cpp | 609 + Utilities/GDAL/frmts/sdts/sdtstransfer.cpp | 730 + Utilities/GDAL/frmts/sdts/sdtsxref.cpp | 114 + Utilities/GDAL/frmts/usgsdem/CDED.notes | 106 + Utilities/GDAL/frmts/usgsdem/GNUmakefile | 13 + .../GDAL/frmts/usgsdem/frmt_usgsdem.html | 110 + Utilities/GDAL/frmts/usgsdem/makefile.vc | 15 + .../GDAL/frmts/usgsdem/usgsdem_create.cpp | 1619 ++ .../GDAL/frmts/usgsdem/usgsdemdataset.cpp | 688 + Utilities/GDAL/frmts/zlib/GNUmakefile | 15 + Utilities/GDAL/frmts/zlib/README | 148 + Utilities/GDAL/frmts/zlib/adler32.c | 48 + Utilities/GDAL/frmts/zlib/compress.c | 68 + Utilities/GDAL/frmts/zlib/crc32.c | 162 + Utilities/GDAL/frmts/zlib/deflate.c | 1350 ++ Utilities/GDAL/frmts/zlib/deflate.h | 318 + Utilities/GDAL/frmts/zlib/gzio.c | 875 ++ Utilities/GDAL/frmts/zlib/infblock.c | 401 + Utilities/GDAL/frmts/zlib/infblock.h | 39 + Utilities/GDAL/frmts/zlib/infcodes.c | 257 + Utilities/GDAL/frmts/zlib/infcodes.h | 27 + Utilities/GDAL/frmts/zlib/inffast.c | 170 + Utilities/GDAL/frmts/zlib/inffast.h | 17 + Utilities/GDAL/frmts/zlib/inffixed.h | 151 + Utilities/GDAL/frmts/zlib/inflate.c | 366 + Utilities/GDAL/frmts/zlib/inftrees.c | 455 + Utilities/GDAL/frmts/zlib/inftrees.h | 58 + Utilities/GDAL/frmts/zlib/infutil.c | 87 + Utilities/GDAL/frmts/zlib/infutil.h | 98 + Utilities/GDAL/frmts/zlib/makefile.vc | 16 + Utilities/GDAL/frmts/zlib/trees.c | 1214 ++ Utilities/GDAL/frmts/zlib/trees.h | 128 + Utilities/GDAL/frmts/zlib/uncompr.c | 58 + Utilities/GDAL/frmts/zlib/zconf.h | 279 + Utilities/GDAL/frmts/zlib/zlib.h | 893 ++ Utilities/GDAL/frmts/zlib/zutil.c | 225 + Utilities/GDAL/frmts/zlib/zutil.h | 220 + Utilities/GDAL/install-sh | 256 + Utilities/GDAL/ltmain.sh | 6401 ++++++++ Utilities/GDAL/makefile.vc | 204 + Utilities/GDAL/nmake-wince.opt | 145 + Utilities/GDAL/rfc/RFC1_PMC.dox | 96 + Utilities/GDAL/rfc/rfc_list.dox | 13 + Utilities/GDAL/swig/GNUmakefile | 32 + Utilities/GDAL/swig/SWIGmake.base | 17 + Utilities/GDAL/swig/csharp/GNUmakefile | 24 + Utilities/GDAL/swig/csharp/const/makefile.vc | 14 + Utilities/GDAL/swig/csharp/gdal/makefile.vc | 14 + Utilities/GDAL/swig/csharp/gdalconst_wrap.c | 1015 ++ Utilities/GDAL/swig/csharp/makefile.vc | 71 + Utilities/GDAL/swig/csharp/ogr/makefile.vc | 14 + Utilities/GDAL/swig/csharp/osr/makefile.vc | 14 + Utilities/GDAL/swig/include/Band.i | 282 + Utilities/GDAL/swig/include/ColorTable.i | 64 + Utilities/GDAL/swig/include/Dataset.i | 247 + Utilities/GDAL/swig/include/Driver.i | 117 + Utilities/GDAL/swig/include/MajorObject.i | 65 + Utilities/GDAL/swig/include/README.typemaps | 87 + Utilities/GDAL/swig/include/cpl.i | 115 + Utilities/GDAL/swig/include/cpl_exceptions.i | 60 + .../GDAL/swig/include/csharp/gdal_csharp.i | 47 + .../GDAL/swig/include/csharp/ogr_csharp.i | 24 + .../swig/include/csharp/typemaps_csharp.i | 269 + Utilities/GDAL/swig/include/gdal.i | 568 + Utilities/GDAL/swig/include/gdal_typemaps.i | 53 + Utilities/GDAL/swig/include/gdalconst.i | 107 + Utilities/GDAL/swig/include/java/gdal_java.i | 94 + .../GDAL/swig/include/java/gdalconst_java.i | 40 + Utilities/GDAL/swig/include/java/ogr_java.i | 65 + Utilities/GDAL/swig/include/java/osr_java.i | 60 + .../GDAL/swig/include/java/typemaps_java.i | 682 + Utilities/GDAL/swig/include/ogr.i | 1319 ++ Utilities/GDAL/swig/include/ogr_error_map.i | 47 + Utilities/GDAL/swig/include/osr.i | 684 + Utilities/GDAL/swig/include/perl/gdal_perl.i | 37 + Utilities/GDAL/swig/include/perl/ogr_perl.i | 40 + .../GDAL/swig/include/perl/typemaps_perl.i | 667 + Utilities/GDAL/swig/include/php/gdal_php.i | 22 + Utilities/GDAL/swig/include/php/ogr_php.i | 22 + .../GDAL/swig/include/php/typemaps_php.i | 453 + .../GDAL/swig/include/python/gdal_python.i | 136 + .../GDAL/swig/include/python/ogr_python.i | 248 + .../GDAL/swig/include/python/osr_python.i | 82 + .../swig/include/python/typemaps_python.i | 844 ++ Utilities/GDAL/swig/include/ruby/gdal_ruby.i | 143 + Utilities/GDAL/swig/include/ruby/ogr_ruby.i | 218 + Utilities/GDAL/swig/include/ruby/osr_ruby.i | 62 + .../GDAL/swig/include/ruby/typemaps_ruby.i | 747 + Utilities/GDAL/swig/java/GNUmakefile | 55 + Utilities/GDAL/swig/java/apps/GDALtest.java | 336 + Utilities/GDAL/swig/java/apps/gdalinfo.java | 458 + Utilities/GDAL/swig/java/build.xml | 27 + Utilities/GDAL/swig/java/const/makefile.vc | 18 + Utilities/GDAL/swig/java/gdal/makefile.vc | 19 + Utilities/GDAL/swig/java/gdal_wrap.cpp | 4485 ++++++ Utilities/GDAL/swig/java/gdalconst_wrap.c | 1680 +++ Utilities/GDAL/swig/java/java.opt | 9 + Utilities/GDAL/swig/java/makefile.vc | 66 + Utilities/GDAL/swig/java/ogr/makefile.vc | 17 + Utilities/GDAL/swig/java/ogr_wrap.cpp | 5449 +++++++ .../GDAL/swig/java/org/gdal/gdal/Band.java | 126 + .../swig/java/org/gdal/gdal/ColorTable.java | 89 + .../GDAL/swig/java/org/gdal/gdal/Dataset.java | 110 + .../GDAL/swig/java/org/gdal/gdal/Driver.java | 58 + .../GDAL/swig/java/org/gdal/gdal/GCP.java | 96 + .../swig/java/org/gdal/gdal/MajorObject.java | 56 + .../gdal/gdal/SWIGTYPE_p_CPLErrorHandler.java | 26 + .../org/gdal/gdal/SWIGTYPE_p_CPLXMLNode.java | 26 + .../gdal/gdal/SWIGTYPE_p_FALSE_IS_ERR.java | 26 + .../java/org/gdal/gdal/SWIGTYPE_p_GByte.java | 26 + .../java/org/gdal/gdal/SWIGTYPE_p_int.java | 26 + .../GDAL/swig/java/org/gdal/gdal/gdal.java | 287 + .../GDAL/swig/java/org/gdal/gdal/gdalJNI.java | 178 + .../java/org/gdal/gdalconst/gdalconst.java | 12 + .../gdal/gdalconst/gdalconstConstants.java | 84 + .../java/org/gdal/gdalconst/gdalconstJNI.java | 102 + .../swig/java/org/gdal/ogr/DataSource.java | 100 + .../GDAL/swig/java/org/gdal/ogr/Driver.java | 63 + .../GDAL/swig/java/org/gdal/ogr/Feature.java | 165 + .../swig/java/org/gdal/ogr/FeatureDefn.java | 73 + .../swig/java/org/gdal/ogr/FieldDefn.java | 88 + .../GDAL/swig/java/org/gdal/ogr/Geometry.java | 234 + .../GDAL/swig/java/org/gdal/ogr/Layer.java | 135 + .../java/org/gdal/ogr/SWIGTYPE_p_GIntBig.java | 26 + .../GDAL/swig/java/org/gdal/ogr/ogr.java | 70 + .../swig/java/org/gdal/ogr/ogrConstants.java | 61 + .../GDAL/swig/java/org/gdal/ogr/ogrJNI.java | 238 + .../gdal/osr/CoordinateTransformation.java | 48 + .../java/org/gdal/osr/SWIGTYPE_p_double.java | 26 + .../java/org/gdal/osr/SpatialReference.java | 273 + .../GDAL/swig/java/org/gdal/osr/osr.java | 28 + .../swig/java/org/gdal/osr/osrConstants.java | 95 + .../GDAL/swig/java/org/gdal/osr/osrJNI.java | 181 + Utilities/GDAL/swig/java/osr/makefile.vc | 17 + Utilities/GDAL/swig/java/osr_wrap.cpp | 4756 ++++++ Utilities/GDAL/swig/makefile.vc | 90 + Utilities/GDAL/swig/perl/GNUmakefile | 52 + Utilities/GDAL/swig/perl/Makefile.PL | 18 + Utilities/GDAL/swig/perl/gdal.pm | 364 + Utilities/GDAL/swig/perl/gdal.pod | 464 + Utilities/GDAL/swig/perl/gdal_wrap.cpp | 9543 ++++++++++++ Utilities/GDAL/swig/perl/gdalconst.pm | 126 + Utilities/GDAL/swig/perl/gdalconst.pod | 216 + Utilities/GDAL/swig/perl/gdalconst_wrap.c | 2137 +++ Utilities/GDAL/swig/perl/index.html | 80 + Utilities/GDAL/swig/perl/ogr.pm | 470 + Utilities/GDAL/swig/perl/ogr.pod | 619 + Utilities/GDAL/swig/perl/ogr_wrap.cpp | 10898 ++++++++++++++ Utilities/GDAL/swig/perl/osr.pm | 274 + Utilities/GDAL/swig/perl/osr.pod | 398 + Utilities/GDAL/swig/perl/osr_wrap.cpp | 6464 ++++++++ Utilities/GDAL/swig/perl/test.pl | 667 + Utilities/GDAL/swig/php/GNUmakefile | 44 + Utilities/GDAL/swig/php/gdal.php | 24 + Utilities/GDAL/swig/php/gdal_wrap.cpp | 7659 ++++++++++ Utilities/GDAL/swig/php/gdalconst.php | 24 + Utilities/GDAL/swig/php/gdalconst_wrap.c | 1113 ++ Utilities/GDAL/swig/php/ogr.php | 24 + Utilities/GDAL/swig/php/ogr_wrap.cpp | 9323 ++++++++++++ Utilities/GDAL/swig/php/osr.php | 24 + Utilities/GDAL/swig/php/osr_wrap.cpp | 5279 +++++++ Utilities/GDAL/swig/php/php_gdal.h | 212 + Utilities/GDAL/swig/php/php_gdalconst.h | 49 + Utilities/GDAL/swig/php/php_ogr.h | 335 + Utilities/GDAL/swig/php/php_osr.h | 176 + Utilities/GDAL/swig/python/.cvsignore | 2 + Utilities/GDAL/swig/python/GNUmakefile | 27 + Utilities/GDAL/swig/python/gdal.py | 730 + Utilities/GDAL/swig/python/gdal_py.h | 113 + Utilities/GDAL/swig/python/gdal_wrap.cpp | 8577 +++++++++++ Utilities/GDAL/swig/python/gdalconst.py | 112 + Utilities/GDAL/swig/python/gdalconst_wrap.c | 2139 +++ Utilities/GDAL/swig/python/gdalnumeric.cpp | 63 + Utilities/GDAL/swig/python/numpydataset.cpp | 427 + Utilities/GDAL/swig/python/ogr.py | 1029 ++ Utilities/GDAL/swig/python/ogr_wrap.cpp | 8007 ++++++++++ Utilities/GDAL/swig/python/osr.py | 434 + Utilities/GDAL/swig/python/osr_wrap.cpp | 5768 ++++++++ Utilities/GDAL/swig/python/setup.py | 153 + Utilities/GDAL/swig/ruby/.cvsignore | 9 + Utilities/GDAL/swig/ruby/GNUmakefile | 26 + Utilities/GDAL/swig/ruby/RubyMakefile.mk | 57 + Utilities/GDAL/swig/ruby/gdal_wrap.cpp | 8731 +++++++++++ Utilities/GDAL/swig/ruby/gdalconst_wrap.c | 1734 +++ Utilities/GDAL/swig/ruby/makefile.vc | 67 + Utilities/GDAL/swig/ruby/ogr_wrap.cpp | 9865 +++++++++++++ Utilities/GDAL/swig/ruby/osr_wrap.cpp | 5898 ++++++++ 391 files changed, 281657 insertions(+) create mode 100644 Utilities/GDAL/.cvsignore create mode 100644 Utilities/GDAL/GNUmakefile create mode 100644 Utilities/GDAL/alg/.cvsignore create mode 100644 Utilities/GDAL/alg/GNUmakefile create mode 100644 Utilities/GDAL/alg/contour.cpp create mode 100644 Utilities/GDAL/alg/gdal_alg.h create mode 100644 Utilities/GDAL/alg/gdal_crs.c create mode 100644 Utilities/GDAL/alg/gdal_nrgcrs.c create mode 100644 Utilities/GDAL/alg/gdal_rpc.cpp create mode 100755 Utilities/GDAL/alg/gdal_tps.cpp create mode 100644 Utilities/GDAL/alg/gdalchecksum.cpp create mode 100644 Utilities/GDAL/alg/gdaldither.cpp create mode 100644 Utilities/GDAL/alg/gdalmediancut.cpp create mode 100644 Utilities/GDAL/alg/gdalrasterize.cpp create mode 100644 Utilities/GDAL/alg/gdalsimplewarp.cpp create mode 100644 Utilities/GDAL/alg/gdaltransformer.cpp create mode 100644 Utilities/GDAL/alg/gdalwarper.cpp create mode 100644 Utilities/GDAL/alg/gdalwarper.h create mode 100644 Utilities/GDAL/alg/gdalwarpkernel.cpp create mode 100644 Utilities/GDAL/alg/gdalwarpoperation.cpp create mode 100644 Utilities/GDAL/alg/gvgcpfit.h create mode 100644 Utilities/GDAL/alg/llrasterize.cpp create mode 100644 Utilities/GDAL/alg/makefile.vc create mode 100644 Utilities/GDAL/alg/thinplatespline.cpp create mode 100644 Utilities/GDAL/alg/thinplatespline.h create mode 100644 Utilities/GDAL/bridge/.cvsignore create mode 100644 Utilities/GDAL/bridge/Makefile create mode 100644 Utilities/GDAL/bridge/bridge_test.cpp create mode 100644 Utilities/GDAL/bridge/gbgetsymbol.cpp create mode 100644 Utilities/GDAL/bridge/gdalbridge.cpp create mode 100644 Utilities/GDAL/bridge/gdalbridge.h create mode 100755 Utilities/GDAL/config.guess create mode 100644 Utilities/GDAL/doc/ERMapperlogo_small.gif create mode 100644 Utilities/GDAL/doc/api.dox create mode 100644 Utilities/GDAL/doc/credits.dox create mode 100644 Utilities/GDAL/doc/download.dox create mode 100644 Utilities/GDAL/doc/examples.dox create mode 100644 Utilities/GDAL/doc/faq.dox create mode 100644 Utilities/GDAL/doc/gdal_building.dox create mode 100644 Utilities/GDAL/doc/gdal_datamodel.dox create mode 100644 Utilities/GDAL/doc/gdal_drivertut.dox create mode 100644 Utilities/GDAL/doc/gdal_footer.html create mode 100644 Utilities/GDAL/doc/gdal_tutorial.dox create mode 100644 Utilities/GDAL/doc/gdal_utilities.dox create mode 100644 Utilities/GDAL/doc/governance.dox create mode 100644 Utilities/GDAL/doc/index.dox create mode 100644 Utilities/GDAL/doc/ogr/style_pen1.gif create mode 100644 Utilities/GDAL/doc/ogr/style_pen2.gif create mode 100644 Utilities/GDAL/doc/ogr/style_pen3.gif create mode 100644 Utilities/GDAL/doc/ogr/style_textanchor.gif create mode 100644 Utilities/GDAL/doc/ru/gdal_building_ru.dox create mode 100644 Utilities/GDAL/doc/ru/gdal_datamodel_ru.dox create mode 100644 Utilities/GDAL/doc/ru/gdal_tutorial_ru.dox create mode 100644 Utilities/GDAL/doc/ru/index_ru.dox create mode 100644 Utilities/GDAL/doc/vb6_tutorial.dox create mode 100644 Utilities/GDAL/doc/warptut.dox create mode 100644 Utilities/GDAL/doc/wince_port.dox create mode 100644 Utilities/GDAL/frmts/GNUmakefile create mode 100644 Utilities/GDAL/frmts/aigrid/.cvsignore create mode 100644 Utilities/GDAL/frmts/aigrid/GNUmakefile create mode 100644 Utilities/GDAL/frmts/aigrid/Makefile.dist create mode 100644 Utilities/GDAL/frmts/aigrid/aigccitt.c create mode 100644 Utilities/GDAL/frmts/aigrid/aigdataset.cpp create mode 100644 Utilities/GDAL/frmts/aigrid/aigopen.c create mode 100644 Utilities/GDAL/frmts/aigrid/aigrid.h create mode 100644 Utilities/GDAL/frmts/aigrid/aitest.c create mode 100644 Utilities/GDAL/frmts/aigrid/gridlib.c create mode 100644 Utilities/GDAL/frmts/aigrid/makefile.vc create mode 100644 Utilities/GDAL/frmts/ceos/GNUmakefile create mode 100644 Utilities/GDAL/frmts/ceos/ceosdataset.cpp create mode 100644 Utilities/GDAL/frmts/ceos/ceosopen.c create mode 100644 Utilities/GDAL/frmts/ceos/ceosopen.h create mode 100644 Utilities/GDAL/frmts/ceos/ceostest.c create mode 100644 Utilities/GDAL/frmts/ceos/makefile.vc create mode 100644 Utilities/GDAL/frmts/dted/GNUmakefile create mode 100644 Utilities/GDAL/frmts/dted/dted_api.c create mode 100644 Utilities/GDAL/frmts/dted/dted_api.h create mode 100644 Utilities/GDAL/frmts/dted/dted_create.c create mode 100644 Utilities/GDAL/frmts/dted/dted_ptstream.c create mode 100644 Utilities/GDAL/frmts/dted/dted_test.c create mode 100644 Utilities/GDAL/frmts/dted/dteddataset.cpp create mode 100644 Utilities/GDAL/frmts/dted/frmt_dted.html create mode 100644 Utilities/GDAL/frmts/dted/makefile.vc create mode 100644 Utilities/GDAL/frmts/formats_list.html create mode 100644 Utilities/GDAL/frmts/hdf4/GNUmakefile create mode 100644 Utilities/GDAL/frmts/hdf4/frmt_hdf4.html create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/EHapi.c create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/GDapi.c create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/GNUmakefile create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/HDFEOSVersion.h create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/HdfEosDef.h create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/README create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/SWapi.c create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/ease.h create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/gctp_wrap.c create mode 100644 Utilities/GDAL/frmts/hdf4/hdf-eos/makefile.vc create mode 100644 Utilities/GDAL/frmts/hdf4/hdf4dataset.cpp create mode 100644 Utilities/GDAL/frmts/hdf4/hdf4dataset.h create mode 100644 Utilities/GDAL/frmts/hdf4/hdf4imagedataset.cpp create mode 100644 Utilities/GDAL/frmts/hdf4/makefile.vc create mode 100644 Utilities/GDAL/frmts/hfa/.cvsignore create mode 100644 Utilities/GDAL/frmts/hfa/BUILD.TXT create mode 100644 Utilities/GDAL/frmts/hfa/GNUmakefile create mode 100644 Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.cpp create mode 100644 Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.h create mode 100644 Utilities/GDAL/frmts/hfa/addtiffo_src/tif_overview.cpp create mode 100755 Utilities/GDAL/frmts/hfa/buildwin.bat create mode 100644 Utilities/GDAL/frmts/hfa/frmt_hfa.html create mode 100644 Utilities/GDAL/frmts/hfa/geoextra.c create mode 100644 Utilities/GDAL/frmts/hfa/hfa.h create mode 100644 Utilities/GDAL/frmts/hfa/hfa_overviews.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfa_p.h create mode 100644 Utilities/GDAL/frmts/hfa/hfaband.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfacompress.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfadataset.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfadictionary.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfaentry.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfafield.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfaopen.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfatest.cpp create mode 100644 Utilities/GDAL/frmts/hfa/hfatype.cpp create mode 100644 Utilities/GDAL/frmts/hfa/img2tif.cpp create mode 100644 Utilities/GDAL/frmts/hfa/img2tif.txt create mode 100755 Utilities/GDAL/frmts/hfa/img2tif_build.sh create mode 100644 Utilities/GDAL/frmts/hfa/imggeotiff.c create mode 100644 Utilities/GDAL/frmts/hfa/makefile.vc create mode 100755 Utilities/GDAL/frmts/hfa/tst1tif.sh create mode 100755 Utilities/GDAL/frmts/hfa/tst_hfa.sh create mode 100755 Utilities/GDAL/frmts/hfa/tst_img2tif_1.sh create mode 100644 Utilities/GDAL/frmts/idrisi/GNUmakefile create mode 100644 Utilities/GDAL/frmts/idrisi/IdrisiDataset.cpp create mode 100644 Utilities/GDAL/frmts/idrisi/frmt_Idrisi.html create mode 100644 Utilities/GDAL/frmts/idrisi/makefile.vc create mode 100644 Utilities/GDAL/frmts/idrisi/rdc.txt create mode 100644 Utilities/GDAL/frmts/idrisi/rst.txt create mode 100644 Utilities/GDAL/frmts/jp2kak/GNUmakefile create mode 100644 Utilities/GDAL/frmts/jp2kak/dbg_file_source.h create mode 100644 Utilities/GDAL/frmts/jp2kak/frmt_jp2kak.html create mode 100644 Utilities/GDAL/frmts/jp2kak/jp2kak_roi.h create mode 100644 Utilities/GDAL/frmts/jp2kak/jp2kakdataset.cpp create mode 100644 Utilities/GDAL/frmts/jp2kak/makefile.vc create mode 100644 Utilities/GDAL/frmts/jp2kak/subfile_source.h create mode 100644 Utilities/GDAL/frmts/leveller/GNUmakefile create mode 100644 Utilities/GDAL/frmts/leveller/frmt_leveller.html create mode 100644 Utilities/GDAL/frmts/leveller/levellerdataset.cpp create mode 100644 Utilities/GDAL/frmts/leveller/makefile.vc create mode 100644 Utilities/GDAL/frmts/makefile.vc create mode 100644 Utilities/GDAL/frmts/netcdf/GNUmakefile create mode 100644 Utilities/GDAL/frmts/netcdf/gmtdataset.cpp create mode 100644 Utilities/GDAL/frmts/netcdf/makefile.vc create mode 100644 Utilities/GDAL/frmts/netcdf/netcdfdataset.cpp create mode 100644 Utilities/GDAL/frmts/netcdf/netcdfdataset.h create mode 100644 Utilities/GDAL/frmts/nitf/.cvsignore create mode 100644 Utilities/GDAL/frmts/nitf/makefile.vc create mode 100644 Utilities/GDAL/frmts/nitf/mgrs.c create mode 100644 Utilities/GDAL/frmts/nitf/nitffile.c create mode 100644 Utilities/GDAL/frmts/nitf/nitfimage.c create mode 100644 Utilities/GDAL/frmts/raw/GNUmakefile create mode 100644 Utilities/GDAL/frmts/raw/atlsci_spheroid.cpp create mode 100644 Utilities/GDAL/frmts/raw/atlsci_spheroid.h create mode 100644 Utilities/GDAL/frmts/raw/btdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/cpgdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/dipxdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/doq1dataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/doq2dataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/ehdrdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/envidataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/fastdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/frmt_fast.html create mode 100644 Utilities/GDAL/frmts/raw/frmt_mff2.html create mode 100644 Utilities/GDAL/frmts/raw/fujibasdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/gscdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/hkvdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/idadataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/isis2dataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/landataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/makefile.vc create mode 100644 Utilities/GDAL/frmts/raw/mffdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/ndfdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/pauxdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/pnmdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/rawdataset.cpp create mode 100644 Utilities/GDAL/frmts/raw/rawdataset.h create mode 100644 Utilities/GDAL/frmts/sdts/.cvsignore create mode 100644 Utilities/GDAL/frmts/sdts/Doxyfile create mode 100644 Utilities/GDAL/frmts/sdts/GNUmakefile create mode 100644 Utilities/GDAL/frmts/sdts/Makefile.in create mode 100644 Utilities/GDAL/frmts/sdts/aclocal.m4 create mode 100644 Utilities/GDAL/frmts/sdts/configure.in create mode 100644 Utilities/GDAL/frmts/sdts/makefile.vc create mode 100644 Utilities/GDAL/frmts/sdts/makefile.vc.dist create mode 100644 Utilities/GDAL/frmts/sdts/sdts2shp.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdts_al.h create mode 100644 Utilities/GDAL/frmts/sdts/sdts_main.dox create mode 100644 Utilities/GDAL/frmts/sdts/sdts_tut.dox create mode 100644 Utilities/GDAL/frmts/sdts/sdtsattrreader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtscatd.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtsdataset.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtsindexedreader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtsiref.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtslib.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtslinereader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtspointreader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtspolygonreader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtsrasterreader.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtstransfer.cpp create mode 100644 Utilities/GDAL/frmts/sdts/sdtsxref.cpp create mode 100644 Utilities/GDAL/frmts/usgsdem/CDED.notes create mode 100644 Utilities/GDAL/frmts/usgsdem/GNUmakefile create mode 100644 Utilities/GDAL/frmts/usgsdem/frmt_usgsdem.html create mode 100644 Utilities/GDAL/frmts/usgsdem/makefile.vc create mode 100644 Utilities/GDAL/frmts/usgsdem/usgsdem_create.cpp create mode 100644 Utilities/GDAL/frmts/usgsdem/usgsdemdataset.cpp create mode 100644 Utilities/GDAL/frmts/zlib/GNUmakefile create mode 100644 Utilities/GDAL/frmts/zlib/README create mode 100644 Utilities/GDAL/frmts/zlib/adler32.c create mode 100644 Utilities/GDAL/frmts/zlib/compress.c create mode 100644 Utilities/GDAL/frmts/zlib/crc32.c create mode 100644 Utilities/GDAL/frmts/zlib/deflate.c create mode 100644 Utilities/GDAL/frmts/zlib/deflate.h create mode 100644 Utilities/GDAL/frmts/zlib/gzio.c create mode 100644 Utilities/GDAL/frmts/zlib/infblock.c create mode 100644 Utilities/GDAL/frmts/zlib/infblock.h create mode 100644 Utilities/GDAL/frmts/zlib/infcodes.c create mode 100644 Utilities/GDAL/frmts/zlib/infcodes.h create mode 100644 Utilities/GDAL/frmts/zlib/inffast.c create mode 100644 Utilities/GDAL/frmts/zlib/inffast.h create mode 100644 Utilities/GDAL/frmts/zlib/inffixed.h create mode 100644 Utilities/GDAL/frmts/zlib/inflate.c create mode 100644 Utilities/GDAL/frmts/zlib/inftrees.c create mode 100644 Utilities/GDAL/frmts/zlib/inftrees.h create mode 100644 Utilities/GDAL/frmts/zlib/infutil.c create mode 100644 Utilities/GDAL/frmts/zlib/infutil.h create mode 100644 Utilities/GDAL/frmts/zlib/makefile.vc create mode 100644 Utilities/GDAL/frmts/zlib/trees.c create mode 100644 Utilities/GDAL/frmts/zlib/trees.h create mode 100644 Utilities/GDAL/frmts/zlib/uncompr.c create mode 100644 Utilities/GDAL/frmts/zlib/zconf.h create mode 100644 Utilities/GDAL/frmts/zlib/zlib.h create mode 100644 Utilities/GDAL/frmts/zlib/zutil.c create mode 100644 Utilities/GDAL/frmts/zlib/zutil.h create mode 100755 Utilities/GDAL/install-sh create mode 100644 Utilities/GDAL/ltmain.sh create mode 100644 Utilities/GDAL/makefile.vc create mode 100644 Utilities/GDAL/nmake-wince.opt create mode 100644 Utilities/GDAL/rfc/RFC1_PMC.dox create mode 100644 Utilities/GDAL/rfc/rfc_list.dox create mode 100644 Utilities/GDAL/swig/GNUmakefile create mode 100644 Utilities/GDAL/swig/SWIGmake.base create mode 100644 Utilities/GDAL/swig/csharp/GNUmakefile create mode 100644 Utilities/GDAL/swig/csharp/const/makefile.vc create mode 100644 Utilities/GDAL/swig/csharp/gdal/makefile.vc create mode 100644 Utilities/GDAL/swig/csharp/gdalconst_wrap.c create mode 100644 Utilities/GDAL/swig/csharp/makefile.vc create mode 100644 Utilities/GDAL/swig/csharp/ogr/makefile.vc create mode 100644 Utilities/GDAL/swig/csharp/osr/makefile.vc create mode 100644 Utilities/GDAL/swig/include/Band.i create mode 100644 Utilities/GDAL/swig/include/ColorTable.i create mode 100644 Utilities/GDAL/swig/include/Dataset.i create mode 100644 Utilities/GDAL/swig/include/Driver.i create mode 100644 Utilities/GDAL/swig/include/MajorObject.i create mode 100644 Utilities/GDAL/swig/include/README.typemaps create mode 100644 Utilities/GDAL/swig/include/cpl.i create mode 100644 Utilities/GDAL/swig/include/cpl_exceptions.i create mode 100644 Utilities/GDAL/swig/include/csharp/gdal_csharp.i create mode 100644 Utilities/GDAL/swig/include/csharp/ogr_csharp.i create mode 100644 Utilities/GDAL/swig/include/csharp/typemaps_csharp.i create mode 100644 Utilities/GDAL/swig/include/gdal.i create mode 100644 Utilities/GDAL/swig/include/gdal_typemaps.i create mode 100644 Utilities/GDAL/swig/include/gdalconst.i create mode 100644 Utilities/GDAL/swig/include/java/gdal_java.i create mode 100644 Utilities/GDAL/swig/include/java/gdalconst_java.i create mode 100644 Utilities/GDAL/swig/include/java/ogr_java.i create mode 100644 Utilities/GDAL/swig/include/java/osr_java.i create mode 100644 Utilities/GDAL/swig/include/java/typemaps_java.i create mode 100644 Utilities/GDAL/swig/include/ogr.i create mode 100644 Utilities/GDAL/swig/include/ogr_error_map.i create mode 100644 Utilities/GDAL/swig/include/osr.i create mode 100644 Utilities/GDAL/swig/include/perl/gdal_perl.i create mode 100644 Utilities/GDAL/swig/include/perl/ogr_perl.i create mode 100644 Utilities/GDAL/swig/include/perl/typemaps_perl.i create mode 100644 Utilities/GDAL/swig/include/php/gdal_php.i create mode 100644 Utilities/GDAL/swig/include/php/ogr_php.i create mode 100644 Utilities/GDAL/swig/include/php/typemaps_php.i create mode 100644 Utilities/GDAL/swig/include/python/gdal_python.i create mode 100644 Utilities/GDAL/swig/include/python/ogr_python.i create mode 100644 Utilities/GDAL/swig/include/python/osr_python.i create mode 100644 Utilities/GDAL/swig/include/python/typemaps_python.i create mode 100644 Utilities/GDAL/swig/include/ruby/gdal_ruby.i create mode 100644 Utilities/GDAL/swig/include/ruby/ogr_ruby.i create mode 100644 Utilities/GDAL/swig/include/ruby/osr_ruby.i create mode 100644 Utilities/GDAL/swig/include/ruby/typemaps_ruby.i create mode 100644 Utilities/GDAL/swig/java/GNUmakefile create mode 100644 Utilities/GDAL/swig/java/apps/GDALtest.java create mode 100644 Utilities/GDAL/swig/java/apps/gdalinfo.java create mode 100644 Utilities/GDAL/swig/java/build.xml create mode 100644 Utilities/GDAL/swig/java/const/makefile.vc create mode 100644 Utilities/GDAL/swig/java/gdal/makefile.vc create mode 100644 Utilities/GDAL/swig/java/gdal_wrap.cpp create mode 100644 Utilities/GDAL/swig/java/gdalconst_wrap.c create mode 100644 Utilities/GDAL/swig/java/java.opt create mode 100644 Utilities/GDAL/swig/java/makefile.vc create mode 100644 Utilities/GDAL/swig/java/ogr/makefile.vc create mode 100644 Utilities/GDAL/swig/java/ogr_wrap.cpp create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/Band.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/ColorTable.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/Dataset.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/Driver.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/GCP.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/MajorObject.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLErrorHandler.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLXMLNode.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_FALSE_IS_ERR.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_GByte.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_int.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/gdal.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdal/gdalJNI.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconst.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstConstants.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstJNI.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/DataSource.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/Driver.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/Feature.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/FeatureDefn.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/FieldDefn.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/Geometry.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/Layer.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/SWIGTYPE_p_GIntBig.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/ogr.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/ogrConstants.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/ogr/ogrJNI.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/CoordinateTransformation.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/SWIGTYPE_p_double.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/SpatialReference.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/osr.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/osrConstants.java create mode 100644 Utilities/GDAL/swig/java/org/gdal/osr/osrJNI.java create mode 100644 Utilities/GDAL/swig/java/osr/makefile.vc create mode 100644 Utilities/GDAL/swig/java/osr_wrap.cpp create mode 100644 Utilities/GDAL/swig/makefile.vc create mode 100644 Utilities/GDAL/swig/perl/GNUmakefile create mode 100644 Utilities/GDAL/swig/perl/Makefile.PL create mode 100644 Utilities/GDAL/swig/perl/gdal.pm create mode 100644 Utilities/GDAL/swig/perl/gdal.pod create mode 100644 Utilities/GDAL/swig/perl/gdal_wrap.cpp create mode 100644 Utilities/GDAL/swig/perl/gdalconst.pm create mode 100644 Utilities/GDAL/swig/perl/gdalconst.pod create mode 100644 Utilities/GDAL/swig/perl/gdalconst_wrap.c create mode 100644 Utilities/GDAL/swig/perl/index.html create mode 100644 Utilities/GDAL/swig/perl/ogr.pm create mode 100644 Utilities/GDAL/swig/perl/ogr.pod create mode 100644 Utilities/GDAL/swig/perl/ogr_wrap.cpp create mode 100644 Utilities/GDAL/swig/perl/osr.pm create mode 100644 Utilities/GDAL/swig/perl/osr.pod create mode 100644 Utilities/GDAL/swig/perl/osr_wrap.cpp create mode 100644 Utilities/GDAL/swig/perl/test.pl create mode 100644 Utilities/GDAL/swig/php/GNUmakefile create mode 100644 Utilities/GDAL/swig/php/gdal.php create mode 100644 Utilities/GDAL/swig/php/gdal_wrap.cpp create mode 100644 Utilities/GDAL/swig/php/gdalconst.php create mode 100644 Utilities/GDAL/swig/php/gdalconst_wrap.c create mode 100644 Utilities/GDAL/swig/php/ogr.php create mode 100644 Utilities/GDAL/swig/php/ogr_wrap.cpp create mode 100644 Utilities/GDAL/swig/php/osr.php create mode 100644 Utilities/GDAL/swig/php/osr_wrap.cpp create mode 100644 Utilities/GDAL/swig/php/php_gdal.h create mode 100644 Utilities/GDAL/swig/php/php_gdalconst.h create mode 100644 Utilities/GDAL/swig/php/php_ogr.h create mode 100644 Utilities/GDAL/swig/php/php_osr.h create mode 100644 Utilities/GDAL/swig/python/.cvsignore create mode 100644 Utilities/GDAL/swig/python/GNUmakefile create mode 100644 Utilities/GDAL/swig/python/gdal.py create mode 100644 Utilities/GDAL/swig/python/gdal_py.h create mode 100644 Utilities/GDAL/swig/python/gdal_wrap.cpp create mode 100644 Utilities/GDAL/swig/python/gdalconst.py create mode 100644 Utilities/GDAL/swig/python/gdalconst_wrap.c create mode 100644 Utilities/GDAL/swig/python/gdalnumeric.cpp create mode 100644 Utilities/GDAL/swig/python/numpydataset.cpp create mode 100644 Utilities/GDAL/swig/python/ogr.py create mode 100644 Utilities/GDAL/swig/python/ogr_wrap.cpp create mode 100644 Utilities/GDAL/swig/python/osr.py create mode 100644 Utilities/GDAL/swig/python/osr_wrap.cpp create mode 100644 Utilities/GDAL/swig/python/setup.py create mode 100644 Utilities/GDAL/swig/ruby/.cvsignore create mode 100644 Utilities/GDAL/swig/ruby/GNUmakefile create mode 100644 Utilities/GDAL/swig/ruby/RubyMakefile.mk create mode 100644 Utilities/GDAL/swig/ruby/gdal_wrap.cpp create mode 100644 Utilities/GDAL/swig/ruby/gdalconst_wrap.c create mode 100755 Utilities/GDAL/swig/ruby/makefile.vc create mode 100644 Utilities/GDAL/swig/ruby/ogr_wrap.cpp create mode 100644 Utilities/GDAL/swig/ruby/osr_wrap.cpp diff --git a/Utilities/GDAL/.cvsignore b/Utilities/GDAL/.cvsignore new file mode 100644 index 0000000000..eb1509ec00 --- /dev/null +++ b/Utilities/GDAL/.cvsignore @@ -0,0 +1,10 @@ +GDALmake.opt +config.status +man +*.lib +*.pdb +*.dll +*.exp +*.ilk + + diff --git a/Utilities/GDAL/GNUmakefile b/Utilities/GDAL/GNUmakefile new file mode 100644 index 0000000000..a9e736c2ff --- /dev/null +++ b/Utilities/GDAL/GNUmakefile @@ -0,0 +1,205 @@ + +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/alg/.cvsignore b/Utilities/GDAL/alg/.cvsignore new file mode 100644 index 0000000000..e19f123392 --- /dev/null +++ b/Utilities/GDAL/alg/.cvsignore @@ -0,0 +1,2 @@ +*.lo + diff --git a/Utilities/GDAL/alg/GNUmakefile b/Utilities/GDAL/alg/GNUmakefile new file mode 100644 index 0000000000..f755d550a4 --- /dev/null +++ b/Utilities/GDAL/alg/GNUmakefile @@ -0,0 +1,28 @@ + +include ../GDALmake.opt + +OBJ = gdalmediancut.o gdaldither.o gdal_crs.o gdaltransformer.o \ + gdalsimplewarp.o gdalwarper.o gdalwarpkernel.o \ + gdalwarpoperation.o gdalchecksum.o gdal_rpc.o gdal_tps.o \ + thinplatespline.o llrasterize.o gdalrasterize.o + +ifeq ($(OGR_ENABLED),yes) +OBJ += contour.o +endif + + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + $(RM) *.o + +docs: + (cd ..; $(MAKE) docs) + +install: + for f in *.h ; do $(INSTALL_DATA) $$f $(INST_INCLUDE) ; done + +lib: $(OBJ) + (cd .. ; $(MAKE) force-lib) diff --git a/Utilities/GDAL/alg/contour.cpp b/Utilities/GDAL/alg/contour.cpp new file mode 100644 index 0000000000..7378a4bc37 --- /dev/null +++ b/Utilities/GDAL/alg/contour.cpp @@ -0,0 +1,1510 @@ +/****************************************************************************** + * $Id: contour.cpp,v 1.6 2006/03/03 03:49:38 fwarmerdam Exp $ + * + * Project: Contour Generation + * Purpose: Core algorithm implementation for contour line generation. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * Copyright (c) 2003, Applied Coherent Technology Corporation, www.actgate.com + * + * 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: contour.cpp,v $ + * Revision 1.6 2006/03/03 03:49:38 fwarmerdam + * Do not perterb nodata values even if they fall on a contour interval. + * + * Revision 1.5 2003/10/16 17:47:06 warmerda + * Added algorithm details to GDALContourGenerate(). + * + * Revision 1.4 2003/10/16 17:41:13 warmerda + * Added docs for GDALContourGenerate() + * + * Revision 1.3 2003/10/16 16:44:05 warmerda + * added support for fixed levels + * + * Revision 1.2 2003/10/15 20:40:58 warmerda + * reworked to avoid quadratic behavior in the number of contours + * + * Revision 1.1 2003/10/10 19:44:46 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "ogr_api.h" + +CPL_CVSID("$Id: contour.cpp,v 1.6 2006/03/03 03:49:38 fwarmerdam Exp $"); + +// The amount of a contour interval that pixels should be fudged by if they +// match a contour level exactly. + +#define FUDGE_EXACT 0.001 + +// The amount of a pixel that line ends need to be within to be considered to +// match for joining purposes. + +#define JOIN_DIST 0.0001 + +/************************************************************************/ +/* GDALContourItem */ +/************************************************************************/ +class GDALContourItem +{ +public: + int bRecentlyAccessed; + double dfLevel; + + int nPoints; + int nMaxPoints; + double *padfX; + double *padfY; + + double dfTailX; + + GDALContourItem( double dfLevel ); + ~GDALContourItem(); + + int AddSegment( double dfXStart, double dfYStart, + double dfXEnd, double dfYEnd ); + void MakeRoomFor( int ); + int Merge( GDALContourItem * ); +}; + +/************************************************************************/ +/* GDALContourLevel */ +/************************************************************************/ +class GDALContourLevel +{ + double dfLevel; + + int nEntryMax; + int nEntryCount; + GDALContourItem **papoEntries; + +public: + GDALContourLevel( double ); + ~GDALContourLevel(); + + double GetLevel() { return dfLevel; } + int GetContourCount() { return nEntryCount; } + GDALContourItem *GetContour( int i) { return papoEntries[i]; } + void AdjustContour( int ); + void RemoveContour( int ); + int FindContour( double dfX, double dfY ); + int InsertContour( GDALContourItem * ); +}; + +/************************************************************************/ +/* GDALContourGenerator */ +/************************************************************************/ +class GDALContourGenerator +{ + int nWidth; + int nHeight; + int iLine; + + double *padfLastLine; + double *padfThisLine; + + int nLevelMax; + int nLevelCount; + GDALContourLevel **papoLevels; + + int iLastLevel; + + int bNoDataActive; + double dfNoDataValue; + + int bFixedLevels; + double dfContourInterval; + double dfContourOffset; + + CPLErr AddSegment( double dfLevel, + double dfXStart, double dfYStart, + double dfXEnd, double dfYEnd ); + + CPLErr ProcessPixel( int iPixel ); + CPLErr ProcessRect( double, double, double, + double, double, double, + double, double, double, + double, double, double ); + + void Intersect( double, double, double, + double, double, double, + double, double, int *, double *, double * ); + + GDALContourLevel *FindLevel( double dfLevel ); + +public: + GDALContourWriter pfnWriter; + void *pWriterCBData; + + GDALContourGenerator( int nWidth, int nHeight, + GDALContourWriter pfnWriter, void *pWriterCBData ); + ~GDALContourGenerator(); + + void SetNoData( double dfNoDataValue ); + void SetContourLevels( double dfContourInterval, + double dfContourOffset = 0.0 ) + { this->dfContourInterval = dfContourInterval; + this->dfContourOffset = dfContourOffset; } + + void SetFixedLevels( int, double * ); + CPLErr FeedLine( double *padfScanline ); + CPLErr EjectContours( int bOnlyUnused = FALSE ); + +}; + +/************************************************************************/ +/* GDAL_CG_Create() */ +/************************************************************************/ + +GDALContourGeneratorH +GDAL_CT_Create( int nWidth, int nHeight, int bNoDataSet, double dfNoDataValue, + double dfContourInterval, double dfContourBase, + GDALContourWriter pfnWriter, void *pCBData ) + +{ + GDALContourGenerator *poCG = new GDALContourGenerator( nWidth, nHeight, + pfnWriter, pCBData ); + + if( bNoDataSet ) + poCG->SetNoData( dfNoDataValue ); + + poCG->SetContourLevels( dfContourInterval, dfContourBase ); + return (GDALContourGeneratorH) poCG; +} + +/************************************************************************/ +/* GDAL_CG_FeedLine() */ +/************************************************************************/ + +CPLErr GDAL_CG_FeedLine( GDALContourGeneratorH hCG, double *padfScanline ) + +{ + return ((GDALContourGenerator *) hCG)->FeedLine( padfScanline ); +} + +/************************************************************************/ +/* GDAL_CG_Destroy() */ +/************************************************************************/ + +void GDAL_CG_Destroy( GDALContourGeneratorH hCG ) + +{ + delete ((GDALContourGenerator *) hCG); +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALContourGenerator */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* GDALContourGenerator() */ +/************************************************************************/ + +GDALContourGenerator::GDALContourGenerator( int nWidthIn, int nHeightIn, + GDALContourWriter pfnWriterIn, + void *pWriterCBDataIn ) +{ + nWidth = nWidthIn; + nHeight = nHeightIn; + + padfLastLine = (double *) CPLCalloc(sizeof(double),nWidth); + padfThisLine = (double *) CPLCalloc(sizeof(double),nWidth); + + pfnWriter = pfnWriterIn; + pWriterCBData = pWriterCBDataIn; + + iLine = -1; + + bNoDataActive = FALSE; + dfNoDataValue = -1000000.0; + dfContourInterval = 10.0; + dfContourOffset = 0.0; + + nLevelMax = 0; + nLevelCount = 0; + papoLevels = NULL; + bFixedLevels = FALSE; +} + +/************************************************************************/ +/* ~GDALContourGenerator() */ +/************************************************************************/ + +GDALContourGenerator::~GDALContourGenerator() + +{ + +} + +/************************************************************************/ +/* SetFixedLevels() */ +/************************************************************************/ + +void GDALContourGenerator::SetFixedLevels( int nFixedLevelCount, + double *padfFixedLevels ) + +{ + bFixedLevels = TRUE; + for( int i = 0; i < nFixedLevelCount; i++ ) + FindLevel( padfFixedLevels[i] ); +} + +/************************************************************************/ +/* SetNoData() */ +/************************************************************************/ + +void GDALContourGenerator::SetNoData( double dfNewValue ) + +{ + bNoDataActive = TRUE; + dfNoDataValue = dfNewValue; +} + +/************************************************************************/ +/* ProcessPixel() */ +/************************************************************************/ + +CPLErr GDALContourGenerator::ProcessPixel( int iPixel ) + +{ + double dfUpLeft, dfUpRight, dfLoLeft, dfLoRight; + int bSubdivide = FALSE; + +/* -------------------------------------------------------------------- */ +/* Collect the four corner pixel values. Value left or right */ +/* of the scanline are taken from the nearest pixel on the */ +/* scanline itself. */ +/* -------------------------------------------------------------------- */ + dfUpLeft = padfLastLine[MAX(0,iPixel-1)]; + dfUpRight = padfLastLine[MIN(nWidth-1,iPixel)]; + + dfLoLeft = padfThisLine[MAX(0,iPixel-1)]; + dfLoRight = padfThisLine[MIN(nWidth-1,iPixel)]; + +/* -------------------------------------------------------------------- */ +/* Check if we have any nodata values. */ +/* -------------------------------------------------------------------- */ + if( bNoDataActive + && ( dfUpLeft == dfNoDataValue + || dfLoLeft == dfNoDataValue + || dfLoRight == dfNoDataValue + || dfUpRight == dfNoDataValue ) ) + bSubdivide = TRUE; + +/* -------------------------------------------------------------------- */ +/* Check if we have any nodata, if so, go to a special case of */ +/* code. */ +/* -------------------------------------------------------------------- */ + if( iPixel > 0 && iPixel < nWidth + && iLine > 0 && iLine < nHeight && !bSubdivide ) + { + return ProcessRect( dfUpLeft, iPixel - 0.5, iLine - 0.5, + dfLoLeft, iPixel - 0.5, iLine + 0.5, + dfLoRight, iPixel + 0.5, iLine + 0.5, + dfUpRight, iPixel + 0.5, iLine - 0.5 ); + } + +/* -------------------------------------------------------------------- */ +/* Prepare subdivisions. */ +/* -------------------------------------------------------------------- */ + int nGoodCount = 0; + double dfASum = 0.0; + double dfCenter, dfTop=0.0, dfRight=0.0, dfLeft=0.0, dfBottom=0.0; + + if( dfUpLeft != dfNoDataValue ) + { + dfASum += dfUpLeft; + nGoodCount++; + } + + if( dfLoLeft != dfNoDataValue ) + { + dfASum += dfLoLeft; + nGoodCount++; + } + + if( dfLoRight != dfNoDataValue ) + { + dfASum += dfLoRight; + nGoodCount++; + } + + if( dfUpRight != dfNoDataValue ) + { + dfASum += dfUpRight; + nGoodCount++; + } + + if( nGoodCount == 0.0 ) + return CE_None; + + dfCenter = dfASum / nGoodCount; + + if( dfUpLeft != dfNoDataValue ) + { + if( dfUpRight != dfNoDataValue ) + dfTop = (dfUpLeft + dfUpRight) / 2.0; + else + dfTop = dfUpLeft; + + if( dfLoLeft != dfNoDataValue ) + dfLeft = (dfUpLeft + dfLoLeft) / 2.0; + else + dfLeft = dfUpLeft; + } + else + { + dfTop = dfUpRight; + dfLeft = dfLoLeft; + } + + if( dfLoRight != dfNoDataValue ) + { + if( dfUpRight != dfNoDataValue ) + dfRight = (dfLoRight + dfUpRight) / 2.0; + else + dfRight = dfLoRight; + + if( dfLoLeft != dfNoDataValue ) + dfBottom = (dfLoRight + dfLoLeft) / 2.0; + else + dfBottom = dfLoRight; + } + else + { + dfBottom = dfLoLeft;; + dfRight = dfUpRight; + } + +/* -------------------------------------------------------------------- */ +/* Process any quadrants that aren't "nodata" anchored. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr = CE_None; + + if( dfUpLeft != dfNoDataValue && iPixel > 0 && iLine > 0 ) + { + eErr = ProcessRect( dfUpLeft, iPixel - 0.5, iLine - 0.5, + dfLeft, iPixel - 0.5, iLine, + dfCenter, iPixel, iLine, + dfTop, iPixel, iLine - 0.5 ); + } + + if( dfLoLeft != dfNoDataValue && eErr == CE_None + && iPixel > 0 && iLine < nHeight ) + { + eErr = ProcessRect( dfLeft, iPixel - 0.5, iLine, + dfLoLeft, iPixel - 0.5, iLine + 0.5, + dfBottom, iPixel, iLine + 0.5, + dfCenter, iPixel, iLine ); + } + + if( dfLoRight != dfNoDataValue && iPixel < nWidth && iLine < nHeight ) + { + eErr = ProcessRect( dfCenter, iPixel, iLine, + dfBottom, iPixel, iLine + 0.5, + dfLoRight, iPixel + 0.5, iLine + 0.5, + dfRight, iPixel + 0.5, iLine ); + } + + if( dfUpRight != dfNoDataValue && iPixel < nWidth && iLine > 0 ) + { + eErr = ProcessRect( dfTop, iPixel, iLine - 0.5, + dfCenter, iPixel, iLine, + dfRight, iPixel + 0.5, iLine, + dfUpRight, iPixel + 0.5, iLine - 0.5 ); + } + + return eErr; +} + +/************************************************************************/ +/* ProcessRect() */ +/************************************************************************/ + +CPLErr GDALContourGenerator::ProcessRect( + double dfUpLeft, double dfUpLeftX, double dfUpLeftY, + double dfLoLeft, double dfLoLeftX, double dfLoLeftY, + double dfLoRight, double dfLoRightX, double dfLoRightY, + double dfUpRight, double dfUpRightX, double dfUpRightY ) + +{ +/* -------------------------------------------------------------------- */ +/* Identify the range of elevations over this rect. */ +/* -------------------------------------------------------------------- */ + int iStartLevel, iEndLevel; + + double dfMin = MIN(MIN(dfUpLeft,dfUpRight),MIN(dfLoLeft,dfLoRight)); + double dfMax = MAX(MAX(dfUpLeft,dfUpRight),MAX(dfLoLeft,dfLoRight)); + + +/* -------------------------------------------------------------------- */ +/* Compute the set of levels to compute contours for. */ +/* -------------------------------------------------------------------- */ + + /* + ** If we are using fixed levels, then find the min/max in the levels + ** table. + */ + if( bFixedLevels ) + { + int nStart=0, nEnd=nLevelCount-1, nMiddle; + + iStartLevel = -1; + while( nStart <= nEnd ) + { + nMiddle = (nEnd + nStart) / 2; + + double dfMiddleLevel = papoLevels[nMiddle]->GetLevel(); + + if( dfMiddleLevel < dfMin ) + nStart = nMiddle + 1; + else if( dfMiddleLevel > dfMin ) + nEnd = nMiddle - 1; + else + { + iStartLevel = nMiddle; + break; + } + } + + if( iStartLevel == -1 ) + iStartLevel = nEnd + 1; + + iEndLevel = iStartLevel; + while( iEndLevel < nLevelCount-1 + && papoLevels[iEndLevel+1]->GetLevel() < dfMax ) + iEndLevel++; + + if( iStartLevel >= nLevelCount ) + return CE_None; + + CPLAssert( iStartLevel >= 0 && iStartLevel < nLevelCount ); + CPLAssert( iEndLevel >= 0 && iEndLevel < nLevelCount ); + } + + /* + ** Otherwise figure out the start and end using the base and offset. + */ + else + { + iStartLevel = (int) + ceil((dfMin - dfContourOffset) / dfContourInterval); + iEndLevel = (int) + floor((dfMax - dfContourOffset) / dfContourInterval); + } + + if( iStartLevel > iEndLevel ) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* Loop over them. */ +/* -------------------------------------------------------------------- */ + int iLevel; + + for( iLevel = iStartLevel; iLevel <= iEndLevel; iLevel++ ) + { + double dfLevel; + + if( bFixedLevels ) + dfLevel = papoLevels[iLevel]->GetLevel(); + else + dfLevel = iLevel * dfContourInterval + dfContourOffset; + + int nPoints = 0; + double adfX[4], adfY[4]; + CPLErr eErr; + + Intersect( dfUpLeft, dfUpLeftX, dfUpLeftY, + dfLoLeft, dfLoLeftX, dfLoLeftY, + dfLoRight, dfLevel, &nPoints, adfX, adfY ); + Intersect( dfLoLeft, dfLoLeftX, dfLoLeftY, + dfLoRight, dfLoRightX, dfLoRightY, + dfUpRight, dfLevel, &nPoints, adfX, adfY ); + Intersect( dfLoRight, dfLoRightX, dfLoRightY, + dfUpRight, dfUpRightX, dfUpRightY, + dfUpLeft, dfLevel, &nPoints, adfX, adfY ); + Intersect( dfUpRight, dfUpRightX, dfUpRightY, + dfUpLeft, dfUpLeftX, dfUpLeftY, + dfLoLeft, dfLevel, &nPoints, adfX, adfY ); + + if( nPoints == 1 || nPoints == 3 ) + CPLDebug( "CONTOUR", "Got nPoints = %d", nPoints ); + + if( nPoints >= 2 ) + { + eErr = AddSegment( dfLevel, adfX[0], adfY[0], adfX[1], adfY[1] ); + + if( eErr != CE_None ) + return eErr; + } + + if( nPoints == 4 ) + { + eErr = AddSegment( dfLevel, adfX[2], adfY[2], adfX[3], adfY[3] ); + if( eErr != CE_None ) + return eErr; + } + } + + return CE_None; +} + +/************************************************************************/ +/* Intersect() */ +/************************************************************************/ + +void GDALContourGenerator::Intersect( double dfVal1, double dfX1, double dfY1, + double dfVal2, double dfX2, double dfY2, + double dfNext, + double dfLevel, int *pnPoints, + double *padfX, double *padfY ) + +{ + if( dfVal1 < dfLevel && dfVal2 >= dfLevel ) + { + double dfRatio = (dfLevel - dfVal1) / (dfVal2 - dfVal1); + + padfX[*pnPoints] = dfX1 * (1.0 - dfRatio) + dfX2 * dfRatio; + padfY[*pnPoints] = dfY1 * (1.0 - dfRatio) + dfY2 * dfRatio; + (*pnPoints)++; + } + else if( dfVal1 > dfLevel && dfVal2 <= dfLevel ) + { + double dfRatio = (dfLevel - dfVal2) / (dfVal1 - dfVal2); + + padfX[*pnPoints] = dfX2 * (1.0 - dfRatio) + dfX1 * dfRatio; + padfY[*pnPoints] = dfY2 * (1.0 - dfRatio) + dfY1 * dfRatio; + (*pnPoints)++; + } + else if( dfVal1 == dfLevel && dfVal2 == dfLevel && dfNext != dfLevel ) + { + padfX[*pnPoints] = dfX2; + padfY[*pnPoints] = dfY2; + (*pnPoints)++; + } +} + +/************************************************************************/ +/* AddSegment() */ +/************************************************************************/ + +CPLErr GDALContourGenerator::AddSegment( double dfLevel, + double dfX1, double dfY1, + double dfX2, double dfY2 ) + +{ + GDALContourLevel *poLevel = FindLevel( dfLevel ); + GDALContourItem *poTarget; + int iTarget; + +/* -------------------------------------------------------------------- */ +/* Check all active contours for any that this might attach */ +/* to. Eventually this should be recoded to find the contours */ +/* of the correct level more efficiently. */ +/* -------------------------------------------------------------------- */ + + if( dfY1 < dfY2 ) + iTarget = poLevel->FindContour( dfX1, dfY1 ); + else + iTarget = poLevel->FindContour( dfX2, dfY2 ); + + if( iTarget != -1 ) + { + poTarget = poLevel->GetContour( iTarget ); + + poTarget->AddSegment( dfX1, dfY1, dfX2, dfY2 ); + + poLevel->AdjustContour( iTarget ); + + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* No existing contour found, lets create a new one. */ +/* -------------------------------------------------------------------- */ + poTarget = new GDALContourItem( dfLevel ); + + poTarget->AddSegment( dfX1, dfY1, dfX2, dfY2 ); + + poLevel->InsertContour( poTarget ); + + return CE_None; +} + +/************************************************************************/ +/* FeedLine() */ +/************************************************************************/ + +CPLErr GDALContourGenerator::FeedLine( double *padfScanline ) + +{ +/* -------------------------------------------------------------------- */ +/* Switch current line to "lastline" slot, and copy new data */ +/* into new "this line". */ +/* -------------------------------------------------------------------- */ + double *padfTempLine = padfLastLine; + padfLastLine = padfThisLine; + padfThisLine = padfTempLine; + +/* -------------------------------------------------------------------- */ +/* If this is the end of the lines (NULL passed in), copy the */ +/* last line. */ +/* -------------------------------------------------------------------- */ + if( padfScanline == NULL ) + { + memcpy( padfThisLine, padfLastLine, sizeof(double) * nWidth ); + } + else + { + memcpy( padfThisLine, padfScanline, sizeof(double) * nWidth ); + } + +/* -------------------------------------------------------------------- */ +/* Perturb any values that occur exactly on level boundaries. */ +/* -------------------------------------------------------------------- */ + int iPixel; + + for( iPixel = 0; iPixel < nWidth; iPixel++ ) + { + if( bNoDataActive && padfThisLine[iPixel] == dfNoDataValue ) + continue; + + double dfLevel = (padfThisLine[iPixel] - dfContourOffset) + / dfContourInterval; + + if( dfLevel - (int) dfLevel == 0.0 ) + { + padfThisLine[iPixel] += dfContourInterval * FUDGE_EXACT; + } + } + +/* -------------------------------------------------------------------- */ +/* If this is the first line we need to initialize the previous */ +/* line from the first line of data. */ +/* -------------------------------------------------------------------- */ + if( iLine == -1 ) + { + memcpy( padfLastLine, padfThisLine, sizeof(double) * nWidth ); + iLine = 0; + } + +/* -------------------------------------------------------------------- */ +/* Clear the recently used flags on the contours so we can */ +/* check later which ones were touched for this scanline. */ +/* -------------------------------------------------------------------- */ + int iLevel, iContour; + + for( iLevel = 0; iLevel < nLevelCount; iLevel++ ) + { + GDALContourLevel *poLevel = papoLevels[iLevel]; + + for( iContour = 0; iContour < poLevel->GetContourCount(); iContour++ ) + poLevel->GetContour( iContour )->bRecentlyAccessed = FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Process each pixel. */ +/* -------------------------------------------------------------------- */ + for( iPixel = 0; iPixel < nWidth+1; iPixel++ ) + { + CPLErr eErr = ProcessPixel( iPixel ); + if( eErr != CE_None ) + return eErr; + } + +/* -------------------------------------------------------------------- */ +/* eject any pending contours. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr = EjectContours( padfScanline != NULL ); + + iLine++; + + if( iLine == nHeight && eErr == CE_None ) + return FeedLine( NULL ); + else + return eErr; +} + +/************************************************************************/ +/* EjectContours() */ +/************************************************************************/ + +CPLErr GDALContourGenerator::EjectContours( int bOnlyUnused ) + +{ + int iLevel; + CPLErr eErr = CE_None; + +/* -------------------------------------------------------------------- */ +/* Process all contours of all levels that match our criteria */ +/* -------------------------------------------------------------------- */ + for( iLevel = 0; iLevel < nLevelCount && eErr == CE_None; iLevel++ ) + { + GDALContourLevel *poLevel = papoLevels[iLevel]; + int iContour; + + for( iContour = 0; + iContour < poLevel->GetContourCount() && eErr == CE_None; + /* increment in loop if we don't consume it. */ ) + { + int iC2; + GDALContourItem *poTarget = poLevel->GetContour( iContour ); + + if( bOnlyUnused && poTarget->bRecentlyAccessed ) + { + iContour++; + continue; + } + + poLevel->RemoveContour( iContour ); + + // Try to find another contour we can merge with in this level. + + for( iC2 = 0; iC2 < poLevel->GetContourCount(); iC2++ ) + { + GDALContourItem *poOther = poLevel->GetContour( iC2 ); + + if( poOther->Merge( poTarget ) ) + break; + } + + // If we didn't merge it, then eject (write) it out. + if( iC2 == poLevel->GetContourCount() ) + { + if( pfnWriter != NULL ) + { + eErr = pfnWriter( poTarget->dfLevel, poTarget->nPoints, + poTarget->padfX, poTarget->padfY, + pWriterCBData ); + } + } + + delete poTarget; + } + } + + return eErr; +} + +/************************************************************************/ +/* FindLevel() */ +/************************************************************************/ + +GDALContourLevel *GDALContourGenerator::FindLevel( double dfLevel ) + +{ + int nStart=0, nEnd=nLevelCount-1, nMiddle; + +/* -------------------------------------------------------------------- */ +/* Binary search to find the requested level. */ +/* -------------------------------------------------------------------- */ + while( nStart <= nEnd ) + { + nMiddle = (nEnd + nStart) / 2; + + double dfMiddleLevel = papoLevels[nMiddle]->GetLevel(); + + if( dfMiddleLevel < dfLevel ) + nStart = nMiddle + 1; + else if( dfMiddleLevel > dfLevel ) + nEnd = nMiddle - 1; + else + return papoLevels[nMiddle]; + } + +/* -------------------------------------------------------------------- */ +/* Didn't find the level, create a new one and insert it in */ +/* order. */ +/* -------------------------------------------------------------------- */ + GDALContourLevel *poLevel = new GDALContourLevel( dfLevel ); + + if( nLevelMax == nLevelCount ) + { + nLevelMax = nLevelMax * 2 + 10; + papoLevels = (GDALContourLevel **) + CPLRealloc( papoLevels, sizeof(void*) * nLevelMax ); + } + + if( nLevelCount - nEnd - 1 > 0 ) + memmove( papoLevels + nEnd + 2, papoLevels + nEnd + 1, + (nLevelCount - nEnd - 1) * sizeof(void*) ); + papoLevels[nEnd+1] = poLevel; + nLevelCount++; + + return poLevel; +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALContourLevel */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* GDALContourLevel() */ +/************************************************************************/ + +GDALContourLevel::GDALContourLevel( double dfLevelIn ) + +{ + dfLevel = dfLevelIn; + nEntryMax = 0; + nEntryCount = 0; + papoEntries = NULL; +} + +/************************************************************************/ +/* ~GDALContourLevel() */ +/************************************************************************/ + +GDALContourLevel::~GDALContourLevel() + +{ + CPLAssert( nEntryCount == 0 ); + CPLFree( papoEntries ); +} + +/************************************************************************/ +/* AdjustContour() */ +/* */ +/* Assume the indicated contour's tail may have changed, and */ +/* adjust it up or down in the list of contours to re-establish */ +/* proper ordering. */ +/************************************************************************/ + +void GDALContourLevel::AdjustContour( int iChanged ) + +{ + while( iChanged > 0 + && papoEntries[iChanged]->dfTailX < papoEntries[iChanged-1]->dfTailX ) + { + GDALContourItem *poTemp = papoEntries[iChanged]; + papoEntries[iChanged] = papoEntries[iChanged-1]; + papoEntries[iChanged-1] = poTemp; + iChanged--; + } + + while( iChanged < nEntryCount-1 + && papoEntries[iChanged]->dfTailX > papoEntries[iChanged+1]->dfTailX ) + { + GDALContourItem *poTemp = papoEntries[iChanged]; + papoEntries[iChanged] = papoEntries[iChanged+1]; + papoEntries[iChanged+1] = poTemp; + iChanged++; + } +} + +/************************************************************************/ +/* RemoveContour() */ +/************************************************************************/ + +void GDALContourLevel::RemoveContour( int iTarget ) + +{ + if( iTarget < nEntryCount ) + memmove( papoEntries + iTarget, papoEntries + iTarget + 1, + (nEntryCount - iTarget - 1) * sizeof(void*) ); + nEntryCount--; +} + +/************************************************************************/ +/* FindContour() */ +/* */ +/* Perform a binary search to find the requested "tail" */ +/* location. If not available return -1. In theory there can */ +/* be more than one contour with the same tail X and different */ +/* Y tails ... ensure we check against them all. */ +/************************************************************************/ + +int GDALContourLevel::FindContour( double dfX, double dfY ) + +{ + int nStart = 0, nEnd = nEntryCount-1, nMiddle; + + while( nEnd >= nStart ) + { + nMiddle = (nEnd + nStart) / 2; + + double dfMiddleX = papoEntries[nMiddle]->dfTailX; + + if( dfMiddleX < dfX ) + nStart = nMiddle + 1; + else if( dfMiddleX > dfX ) + nEnd = nMiddle - 1; + else + { + while( nMiddle > 0 + && fabs(papoEntries[nMiddle]->dfTailX-dfX) < JOIN_DIST ) + nMiddle--; + + while( nMiddle < nEntryCount + && fabs(papoEntries[nMiddle]->dfTailX-dfX) < JOIN_DIST ) + { + if( fabs(papoEntries[nMiddle]->padfY[papoEntries[nMiddle]->nPoints-1] - dfY) < JOIN_DIST ) + return nMiddle; + nMiddle++; + } + + return -1; + } + } + + return -1; +} + +/************************************************************************/ +/* InsertContour() */ +/* */ +/* Ensure the newly added contour is placed in order according */ +/* to the X value relative to the other contours. */ +/************************************************************************/ + +int GDALContourLevel::InsertContour( GDALContourItem *poNewContour ) + +{ +/* -------------------------------------------------------------------- */ +/* Find where to insert by binary search. */ +/* -------------------------------------------------------------------- */ + int nStart = 0, nEnd = nEntryCount-1, nMiddle; + + while( nEnd >= nStart ) + { + nMiddle = (nEnd + nStart) / 2; + + double dfMiddleX = papoEntries[nMiddle]->dfTailX; + + if( dfMiddleX < poNewContour->dfLevel ) + nStart = nMiddle + 1; + else if( dfMiddleX > poNewContour->dfLevel ) + nEnd = nMiddle - 1; + else + { + nEnd = nMiddle - 1; + break; + } + } + +/* -------------------------------------------------------------------- */ +/* Do we need to grow the array? */ +/* -------------------------------------------------------------------- */ + if( nEntryMax == nEntryCount ) + { + nEntryMax = nEntryMax * 2 + 10; + papoEntries = (GDALContourItem **) + CPLRealloc( papoEntries, sizeof(void*) * nEntryMax ); + } + +/* -------------------------------------------------------------------- */ +/* Insert the new contour at the appropriate location. */ +/* -------------------------------------------------------------------- */ + if( nEntryCount - nEnd - 1 > 0 ) + memmove( papoEntries + nEnd + 2, papoEntries + nEnd + 1, + (nEntryCount - nEnd - 1) * sizeof(void*) ); + papoEntries[nEnd+1] = poNewContour; + nEntryCount++; + + return nEnd+1; +} + + +/************************************************************************/ +/* ==================================================================== */ +/* GDALContourItem */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* GDALContourItem() */ +/************************************************************************/ + +GDALContourItem::GDALContourItem( double dfLevelIn ) + +{ + dfLevel = dfLevelIn; + bRecentlyAccessed = FALSE; + nPoints = 0; + nMaxPoints = 0; + padfX = NULL; + padfY = NULL; + + dfTailX = 0.0; +} + +/************************************************************************/ +/* ~GDALContourItem() */ +/************************************************************************/ + +GDALContourItem::~GDALContourItem() + +{ + CPLFree( padfX ); + CPLFree( padfY ); +} + +/************************************************************************/ +/* AddSegment() */ +/************************************************************************/ + +int GDALContourItem::AddSegment( double dfXStart, double dfYStart, + double dfXEnd, double dfYEnd ) + +{ + MakeRoomFor( nPoints + 1 ); + +/* -------------------------------------------------------------------- */ +/* If there are no segments, just add now. */ +/* -------------------------------------------------------------------- */ + if( nPoints == 0 ) + { + nPoints = 2; + + padfX[0] = dfXStart; + padfY[0] = dfYStart; + padfX[1] = dfXEnd; + padfY[1] = dfYEnd; + bRecentlyAccessed = TRUE; + + dfTailX = padfX[1]; + + return TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Try to matching up with one of the ends, and insert. */ +/* -------------------------------------------------------------------- */ + if( fabs(padfX[nPoints-1]-dfXStart) < JOIN_DIST + && fabs(padfY[nPoints-1]-dfYStart) < JOIN_DIST ) + { + padfX[nPoints] = dfXEnd; + padfY[nPoints] = dfYEnd; + nPoints++; + + bRecentlyAccessed = TRUE; + + dfTailX = dfXEnd; + + return TRUE; + } + else if( fabs(padfX[nPoints-1]-dfXEnd) < JOIN_DIST + && fabs(padfY[nPoints-1]-dfYEnd) < JOIN_DIST ) + { + padfX[nPoints] = dfXStart; + padfY[nPoints] = dfYStart; + nPoints++; + + bRecentlyAccessed = TRUE; + + dfTailX = dfXStart; + + return TRUE; + } + else + return FALSE; +} + +/************************************************************************/ +/* Merge() */ +/************************************************************************/ + +int GDALContourItem::Merge( GDALContourItem *poOther ) + +{ + if( poOther->dfLevel != dfLevel ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Try to matching up with one of the ends, and insert. */ +/* -------------------------------------------------------------------- */ + if( fabs(padfX[nPoints-1]-poOther->padfX[0]) < JOIN_DIST + && fabs(padfY[nPoints-1]-poOther->padfY[0]) < JOIN_DIST ) + { + MakeRoomFor( nPoints + poOther->nPoints - 1 ); + + memcpy( padfX + nPoints, poOther->padfX + 1, + sizeof(double) * (poOther->nPoints-1) ); + memcpy( padfY + nPoints, poOther->padfY + 1, + sizeof(double) * (poOther->nPoints-1) ); + nPoints += poOther->nPoints - 1; + + bRecentlyAccessed = TRUE; + + dfTailX = padfX[nPoints-1]; + + return TRUE; + } + else if( fabs(padfX[0]-poOther->padfX[poOther->nPoints-1]) < JOIN_DIST + && fabs(padfY[0]-poOther->padfY[poOther->nPoints-1]) < JOIN_DIST ) + { + MakeRoomFor( nPoints + poOther->nPoints - 1 ); + + memmove( padfX + poOther->nPoints - 1, padfX, + sizeof(double) * nPoints ); + memmove( padfY + poOther->nPoints - 1, padfY, + sizeof(double) * nPoints ); + memcpy( padfX, poOther->padfX, + sizeof(double) * (poOther->nPoints-1) ); + memcpy( padfY, poOther->padfY, + sizeof(double) * (poOther->nPoints-1) ); + nPoints += poOther->nPoints - 1; + + bRecentlyAccessed = TRUE; + + dfTailX = padfX[nPoints-1]; + + return TRUE; + } + else if( fabs(padfX[nPoints-1]-poOther->padfX[poOther->nPoints-1]) < JOIN_DIST + && fabs(padfY[nPoints-1]-poOther->padfY[poOther->nPoints-1]) < JOIN_DIST ) + { + int i; + + MakeRoomFor( nPoints + poOther->nPoints - 1 ); + + for( i = 0; i < poOther->nPoints-1; i++ ) + { + padfX[i+nPoints] = poOther->padfX[poOther->nPoints-i-2]; + padfY[i+nPoints] = poOther->padfY[poOther->nPoints-i-2]; + } + + nPoints += poOther->nPoints - 1; + + bRecentlyAccessed = TRUE; + + dfTailX = padfX[nPoints-1]; + + return TRUE; + } + else if( fabs(padfX[0]-poOther->padfX[0]) < JOIN_DIST + && fabs(padfY[0]-poOther->padfY[0]) < JOIN_DIST ) + { + int i; + + MakeRoomFor( nPoints + poOther->nPoints - 1 ); + + memmove( padfX + poOther->nPoints - 1, padfX, + sizeof(double) * nPoints ); + memmove( padfY + poOther->nPoints - 1, padfY, + sizeof(double) * nPoints ); + + for( i = 0; i < poOther->nPoints-1; i++ ) + { + padfX[i] = poOther->padfX[poOther->nPoints - i - 1]; + padfY[i] = poOther->padfY[poOther->nPoints - i - 1]; + } + + nPoints += poOther->nPoints - 1; + + bRecentlyAccessed = TRUE; + + dfTailX = padfX[nPoints-1]; + + return TRUE; + } + else + return FALSE; +} + +/************************************************************************/ +/* MakeRoomFor() */ +/************************************************************************/ + +void GDALContourItem::MakeRoomFor( int nNewPoints ) + +{ + if( nNewPoints > nMaxPoints ) + { + nMaxPoints = nNewPoints * 2 + 50; + padfX = (double *) CPLRealloc(padfX,sizeof(double) * nMaxPoints); + padfY = (double *) CPLRealloc(padfY,sizeof(double) * nMaxPoints); + } +} + +/************************************************************************/ +/* ==================================================================== */ +/* Additional C Callable Functions */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* OGRContourWriter() */ +/************************************************************************/ + +CPLErr OGRContourWriter( double dfLevel, + int nPoints, double *padfX, double *padfY, + void *pInfo ) + +{ + OGRContourWriterInfo *poInfo = (OGRContourWriterInfo *) pInfo; + OGRFeatureH hFeat; + OGRGeometryH hGeom; + int iPoint; + + hFeat = OGR_F_Create( OGR_L_GetLayerDefn( poInfo->hLayer ) ); + + if( poInfo->nIDField != -1 ) + OGR_F_SetFieldInteger( hFeat, poInfo->nIDField, poInfo->nNextID++ ); + + if( poInfo->nElevField != -1 ) + OGR_F_SetFieldDouble( hFeat, poInfo->nElevField, dfLevel ); + + hGeom = OGR_G_CreateGeometry( wkbLineString ); + + for( iPoint = nPoints-1; iPoint >= 0; iPoint-- ) + { + OGR_G_SetPoint( hGeom, iPoint, + poInfo->adfGeoTransform[0] + + poInfo->adfGeoTransform[1] * padfX[iPoint] + + poInfo->adfGeoTransform[2] * padfY[iPoint], + poInfo->adfGeoTransform[3] + + poInfo->adfGeoTransform[4] * padfX[iPoint] + + poInfo->adfGeoTransform[5] * padfY[iPoint], + dfLevel ); + } + + OGR_F_SetGeometryDirectly( hFeat, hGeom ); + + OGR_L_CreateFeature( poInfo->hLayer, hFeat ); + OGR_F_Destroy( hFeat ); + + return CE_None; +} + +/************************************************************************/ +/* GDALContourGenerate() */ +/************************************************************************/ + +/** + * Create vector contours from raster DEM. + * + * This algorithm will generate contours vectors for the input raster band + * on the requested set of contour levels. The vector contours are written + * to the passed in OGR vector layer. Also, a NODATA value may be specified + * to identify pixels that should not be considered in contour line generation. + * + * The gdal/apps/gdal_contour.cpp mainline can be used as an example of + * how to use this function. + * + * ALGORITHM RULES + +For contouring purposes raster pixel values are assumed to represent a point +value at the center of the corresponding pixel region. For the purpose of +contour generation we virtually connect each pixel center to the values to +the left, right, top and bottom. We assume that the pixel value is linearly +interpolated between the pixel centers along each line, and determine where +(if any) contour lines will appear onlong these line segements. Then the +contour crossings are connected. + +This means that contour lines nodes won't actually be on pixel edges, but +rather along vertical and horizontal lines connecting the pixel centers. + +\verbatim +General Case: + + 5 | | 3 + -- + ---------------- + -- + | | + | | + | | + | | + 10 + | + |\ | + | \ | + -- + -+-------------- + -- + 12 | 10 | 1 + + +Saddle Point: + + 5 | | 12 + -- + -------------+-- + -- + | \ | + | \| + | + + | | + + | + |\ | + | \ | + -- + -+-------------- + -- + 12 | | 1 + +or: + + 5 | | 12 + -- + -------------+-- + -- + | __/ | + | ___/ | + | ___/ __+ + | / __/ | + +' __/ | + | __/ | + | ,__/ | + -- + -+-------------- + -- + 12 | | 1 +\endverbatim + +Nodata: + +In the "nodata" case we treat the whole nodata pixel as a no-mans land. +We extend the corner pixels near the nodata out to half way and then +construct extra lines from those points to the center which is assigned +an averaged value from the two nearby points (in this case (12+3+5)/3). + +\verbatim + 5 | | 3 + -- + ---------------- + -- + | | + | | + | 6.7 | + | +---------+ 3 + 10 +___ | + | \____+ 10 + | | + -- + -------+ + + 12 | 12 (nodata) + +\endverbatim + + * + * @param hBand The band to read raster data from. The whole band will be + * processed. + * + * @param dfContourInterval The elevation interval between contours generated. + * + * @param dfContourBase The "base" relative to which contour intervals are + * applied. This is normally zero, but could be different. To generate 10m + * contours at 5, 15, 25, ... the ContourBase would be 5. + * + * @param nFixedLevelCount The number of fixed levels. If this is greater than + * zero, then fixed levels will be used, and ContourInterval and ContourBase + * are ignored. + * + * @param padfFixedLevels The list of fixed contour levels at which contours + * should be generated. It will contain FixedLevelCount entries, and may be + * NULL if fixed levels are disabled (FixedLevelCount = 0). + * + * @param bUseNoData If TRUE the dfNoDataValue will be used. + * + * @param dfNoDataValue the value to use as a "nodata" value. That is, a + * pixel value which should be ignored in generating contours as if the value + * of the pixel were not known. + * + * @param hLayer the layer to which new contour vectors will be written. + * Each contour will have a LINESTRING geometry attached to it. This + * is really of type OGRLayerH, but void * is used to avoid pulling the + * ogr_api.h file in here. + * + * @param iIDField if not -1 this will be used as a field index to indicate + * where a unique id should be written for each feature (contour) written. + * + * @param iElevField if not -1 this will be used as a field index to indicate + * where the elevation value of the contour should be written. + * + * @param pfnProgress a GDALProgressFunc that may be used to report progress + * to the user, or to interrupt the algorithm. May be NULL if not required. + * + * @param pProgressArg the callback data for the pfnProgress function. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALContourGenerate( GDALRasterBandH hBand, + double dfContourInterval, double dfContourBase, + int nFixedLevelCount, double *padfFixedLevels, + int bUseNoData, double dfNoDataValue, + void *hLayer, int iIDField, int iElevField, + GDALProgressFunc pfnProgress, void *pProgressArg ) + +{ + OGRContourWriterInfo oCWI; + + if( pfnProgress == NULL ) + pfnProgress = GDALDummyProgress; + + if( !pfnProgress( 0.0, "", pProgressArg ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Setup contour writer information. */ +/* -------------------------------------------------------------------- */ + GDALDatasetH hSrcDS; + + oCWI.hLayer = (OGRLayerH) hLayer; + + oCWI.nElevField = iElevField; + oCWI.nIDField = iIDField; + + hSrcDS = GDALGetBandDataset( hBand ); + GDALGetGeoTransform( hSrcDS, oCWI.adfGeoTransform ); + oCWI.nNextID = 0; + +/* -------------------------------------------------------------------- */ +/* Setup contour generator. */ +/* -------------------------------------------------------------------- */ + int nXSize = GDALGetRasterBandXSize( hBand ); + int nYSize = GDALGetRasterBandYSize( hBand ); + + GDALContourGenerator oCG( nXSize, nYSize, OGRContourWriter, &oCWI ); + + if( nFixedLevelCount > 0 ) + oCG.SetFixedLevels( nFixedLevelCount, padfFixedLevels ); + else + oCG.SetContourLevels( dfContourInterval, dfContourBase ); + + if( bUseNoData ) + oCG.SetNoData( dfNoDataValue ); + +/* -------------------------------------------------------------------- */ +/* Feed the data into the contour generator. */ +/* -------------------------------------------------------------------- */ + int iLine; + double *padfScanline; + CPLErr eErr = CE_None; + + padfScanline = (double *) CPLMalloc(sizeof(double) * nXSize); + + for( iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) + { + GDALRasterIO( hBand, GF_Read, 0, iLine, nXSize, 1, + padfScanline, nXSize, 1, GDT_Float64, 0, 0 ); + eErr = oCG.FeedLine( padfScanline ); + + if( eErr == CE_None + && !pfnProgress( (iLine+1) / (double) nYSize, "", pProgressArg ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + + CPLFree( padfScanline ); + + return eErr; +} diff --git a/Utilities/GDAL/alg/gdal_alg.h b/Utilities/GDAL/alg/gdal_alg.h new file mode 100644 index 0000000000..7d0c6525b3 --- /dev/null +++ b/Utilities/GDAL/alg/gdal_alg.h @@ -0,0 +1,320 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Image Processing Algorithms + * Purpose: Prototypes, and definitions for various GDAL based algorithms. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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: gdal_alg.h,v $ + * Revision 1.24 2005/10/28 18:30:28 fwarmerdam + * added progress func for rasterize + * + * Revision 1.23 2005/10/28 17:46:29 fwarmerdam + * Added rasterize related stuff + * + * Revision 1.22 2005/08/02 22:19:41 fwarmerdam + * approx transformer now can own its subtransformer + * + * Revision 1.21 2005/04/11 17:36:53 fwarmerdam + * added GDALDestroyTransformer + * + * Revision 1.20 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.19 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.18 2004/08/11 19:00:06 warmerda + * added GDALSetGenImgProjTransformerDstGeoTransform + * + * Revision 1.17 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.16 2003/12/15 15:59:25 warmerda + * added CPL_DLL on contour stuff. + * + * Revision 1.15 2003/10/16 16:44:05 warmerda + * added support for fixed levels + * + * Revision 1.14 2003/10/15 20:22:16 warmerda + * removed C++ contour definitions + * + * Revision 1.13 2003/10/14 15:25:01 warmerda + * added contour stuff + * + * Revision 1.12 2003/06/03 19:42:20 warmerda + * modified rpc api + * + * Revision 1.11 2003/06/03 17:36:47 warmerda + * Added RPC entry points + * + * Revision 1.10 2003/03/02 05:24:35 warmerda + * added GDALChecksumImage + * + * Revision 1.9 2002/12/09 18:56:10 warmerda + * added missing CPL_DLL + * + * Revision 1.8 2002/12/09 16:08:32 warmerda + * added approximating transformer + * + * Revision 1.7 2002/12/07 22:58:42 warmerda + * added initialization support for simple warper + * + * Revision 1.6 2002/12/07 17:09:38 warmerda + * added order flag to GenImgProjTransformer + * + * Revision 1.5 2002/12/06 21:43:12 warmerda + * tweak prototypes + * + * Revision 1.4 2002/12/05 21:44:35 warmerda + * fixed prototype + * + * Revision 1.3 2002/12/05 05:43:28 warmerda + * added warp/transformer definition + * + * Revision 1.2 2001/02/02 21:19:25 warmerda + * added CPL_DLL for functions + * + * Revision 1.1 2001/01/22 22:30:59 warmerda + * New + */ + +#ifndef GDAL_ALG_H_INCLUDED +#define GDAL_ALG_H_INCLUDED + +/** + * \file gdal_alg.h + * + * Public (C callable) GDAL algorithm entry points, and definitions. + */ + +#include "gdal.h" +#include "cpl_minixml.h" +#include "ogr_api.h" + +CPL_C_START + +int CPL_DLL CPL_STDCALL GDALComputeMedianCutPCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + int (*pfnIncludePixel)(int,int,void*), + int nColors, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +int CPL_DLL CPL_STDCALL GDALDitherRGB2PCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + GDALRasterBandH hTarget, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +int CPL_DLL CPL_STDCALL GDALChecksumImage( GDALRasterBandH hBand, + int nXOff, int nYOff, int nXSize, int nYSize ); + + +/* + * Warp Related. + */ + +typedef int +(*GDALTransformerFunc)( void *pTransformerArg, + int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +typedef struct { + char szSignature[4]; + char *pszClassName; + GDALTransformerFunc pfnTransform; + void (*pfnCleanup)( void * ); + CPLXMLNode *(*pfnSerialize)( void * ); +} GDALTransformerInfo; + +void CPL_DLL GDALDestroyTransformer( void *pTransformerArg ); + + +/* High level transformer for going from image coordinates on one file + to image coordiantes on another, potentially doing reprojection, + utilizing GCPs or using the geotransform. */ + +void CPL_DLL * +GDALCreateGenImgProjTransformer( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + int bGCPUseOK, double dfGCPErrorThreshold, + int nOrder ); +void CPL_DLL GDALSetGenImgProjTransformerDstGeoTransform( void *, + const double * ); +void CPL_DLL GDALDestroyGenImgProjTransformer( void * ); +int CPL_DLL GDALGenImgProjTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Geo to geo reprojection transformer. */ +void CPL_DLL * +GDALCreateReprojectionTransformer( const char *pszSrcWKT, + const char *pszDstWKT ); +void CPL_DLL GDALDestroyReprojectionTransformer( void * ); +int CPL_DLL GDALReprojectionTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* GCP based transformer ... forward is to georef coordinates */ +void CPL_DLL * +GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int nReqOrder, int bReversed ); +void CPL_DLL GDALDestroyGCPTransformer( void *pTransformArg ); +int CPL_DLL GDALGCPTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Thin Plate Spine transformer ... forward is to georef coordinates */ + +void CPL_DLL * +GDALCreateTPSTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int bReversed ); +void CPL_DLL GDALDestroyTPSTransformer( void *pTransformArg ); +int CPL_DLL GDALTPSTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* RPC based transformer ... src is pixel/line/elev, dst is long/lat/elev */ + +void CPL_DLL * +GDALCreateRPCTransformer( GDALRPCInfo *psRPC, int bReversed, + double dfPixErrThreshold ); +void CPL_DLL GDALDestroyRPCTransformer( void *pTransformArg ); +int CPL_DLL GDALRPCTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + +/* Approximate transformer */ +void CPL_DLL * +GDALCreateApproxTransformer( GDALTransformerFunc pfnRawTransformer, + void *pRawTransformerArg, double dfMaxError ); +void CPL_DLL GDALApproxTransformerOwnsSubtransformer( void *pCBData, + int bOwnFlag ); +void CPL_DLL GDALDestroyApproxTransformer( void *pApproxArg ); +int CPL_DLL GDALApproxTransform( + void *pTransformArg, int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); + + + + +int CPL_DLL CPL_STDCALL +GDALSimpleImageWarp( GDALDatasetH hSrcDS, + GDALDatasetH hDstDS, + int nBandCount, int *panBandList, + GDALTransformerFunc pfnTransform, + void *pTransformArg, + GDALProgressFunc pfnProgress, + void *pProgressArg, + char **papszWarpOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALSuggestedWarpOutput( GDALDatasetH hSrcDS, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeoTransformOut, + int *pnPixels, int *pnLines ); + +CPLXMLNode CPL_DLL * +GDALSerializeTransformer( GDALTransformerFunc pfnFunc, void *pTransformArg ); +CPLErr CPL_DLL GDALDeserializeTransformer( CPLXMLNode *psTree, + GDALTransformerFunc *ppfnFunc, + void **ppTransformArg ); + + +/* -------------------------------------------------------------------- */ +/* Contour Line Generation */ +/* -------------------------------------------------------------------- */ + +typedef CPLErr (*GDALContourWriter)( double dfLevel, int nPoints, + double *padfX, double *padfY, void * ); + +typedef void *GDALContourGeneratorH; + +GDALContourGeneratorH CPL_DLL +GDAL_CG_Create( int nWidth, int nHeight, + int bNoDataSet, double dfNoDataValue, + double dfContourInterval, double dfContourBase, + GDALContourWriter pfnWriter, void *pCBData ); +CPLErr CPL_DLL GDAL_CG_FeedLine( GDALContourGeneratorH hCG, + double *padfScanline ); +void CPL_DLL GDAL_CG_Destroy( GDALContourGeneratorH hCG ); + +typedef struct +{ + void *hLayer; + + double adfGeoTransform[6]; + + int nElevField; + int nIDField; + int nNextID; +} OGRContourWriterInfo; + +CPLErr CPL_DLL +OGRContourWriter( double, int, double *, double *, void *pInfo ); + +CPLErr CPL_DLL +GDALContourGenerate( GDALRasterBandH hBand, + double dfContourInterval, double dfContourBase, + int nFixedLevelCount, double *padfFixedLevels, + int bUseNoData, double dfNoDataValue, + void *hLayer, int iIDField, int iElevField, + GDALProgressFunc pfnProgress, void *pProgressArg ); + +/* -------------------------------------------------------------------- */ +/* Low level rasterizer API. */ +/* -------------------------------------------------------------------- */ +typedef void (*llScanlineFunc)( void *pCBData, int nY, int nXStart, int nXEnd); + + +void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, + llScanlineFunc pfnScanlineFunc, void *pCBData ); + +/* -------------------------------------------------------------------- */ +/* High level API - GvShapes burned into GDAL raster. */ +/* -------------------------------------------------------------------- */ + +CPLErr CPL_DLL +GDALRasterizeGeometries( GDALDatasetH hDS, + int nBandCount, int *panBandList, + int nGeomCount, OGRGeometryH *pahGeometries, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeomBurnValue, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressArg ); + +CPL_C_END + +#endif /* ndef GDAL_ALG_H_INCLUDED */ diff --git a/Utilities/GDAL/alg/gdal_crs.c b/Utilities/GDAL/alg/gdal_crs.c new file mode 100644 index 0000000000..720f532db6 --- /dev/null +++ b/Utilities/GDAL/alg/gdal_crs.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * $Id$ + * + * Project: Mapinfo Image Warper + * Purpose: Implemention of the GDALTransformer wrapper around CRS.C functions + * to build a polynomial transformation based on ground control + * points. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + *************************************************************************** + + CRS.C - Center for Remote Sensing rectification routines + + Written By: Brian J. Buckley + + At: The Center for Remote Sensing + Michigan State University + 302 Berkey Hall + East Lansing, MI 48824 + (517)353-7195 + + Written: 12/19/91 + + Last Update: 12/26/91 Brian J. Buckley + Last Update: 1/24/92 Brian J. Buckley + Added printout of trnfile. Triggered by BDEBUG. + Last Update: 1/27/92 Brian J. Buckley + Fixed bug so that only the active control points were used. + + + Copyright (c) 1992, Michigan State University + + 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: gdal_crs.c,v $ + * Revision 1.8 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.7 2004/08/11 19:01:56 warmerda + * default to 2nd order if we have enough points for 3rd order but 0 requested + * + * Revision 1.6 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.5 2004/03/19 15:22:02 warmerda + * Fixed double free of padfRasterX. Submitted by Scott Reynolds. + * + * Revision 1.4 2002/12/07 17:09:50 warmerda + * re-enable 3rd order even though unstable + * + * Revision 1.3 2002/12/06 17:58:00 warmerda + * fix a few bugs + * + * Revision 1.2 2002/12/05 05:46:08 warmerda + * fixed linkage problem + * + * Revision 1.1 2002/12/05 05:43:23 warmerda + * New + * + */ + +#include "gdal_alg.h" +#include "cpl_conv.h" +#include "cpl_minixml.h" +#include "cpl_string.h" + +CPL_CVSID("$Id$"); + +#define MAXORDER 3 + +struct Control_Points +{ + int count; + double *e1; + double *n1; + double *e2; + double *n2; + int *status; +}; + +CPL_C_START +CPLXMLNode *GDALSerializeGCPTransformer( void *pTransformArg ); +void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ); +CPL_C_END + +/* crs.c */ +static int CRS_georef(double, double, double *, double *, + double [], double [], int); +static int CRS_compute_georef_equations(struct Control_Points *, + double [], double [], double [], double [], int); + +typedef struct +{ + GDALTransformerInfo sTI; + + double adfToGeoX[20]; + double adfToGeoY[20]; + + double adfFromGeoX[20]; + double adfFromGeoY[20]; + + int nOrder; + int bReversed; + + int nGCPCount; + GDAL_GCP *pasGCPList; + +} GCPTransformInfo; + + +/************************************************************************/ +/* GDALCreateGCPTransformer() */ +/************************************************************************/ + +/** + * Create GCP based polynomial transformer. + * + * Computes least squares fit polynomials from a provided set of GCPs, + * and stores the coefficients for later transformation of points between + * pixel/line and georeferenced coordinates. + * + * The return value should be used as a TransformArg in combination with + * the transformation function GDALGCPTransform which fits the + * GDALTransformerFunc signature. The returned transform argument should + * be deallocated with GDALDestroyGCPTransformer when no longer needed. + * + * This function may fail (returning NULL) if the provided set of GCPs + * are inadequate for the requested order, the determinate is zero or they + * are otherwise "ill conditioned". + * + * Note that 2nd order requires at least 6 GCPs, and 3rd order requires at + * least 10 gcps. If nReqOrder is 0 the highest order possible with the + * provided gcp count will be used. + * + * @param nGCPCount the number of GCPs in pasGCPList. + * @param pasGCPList an array of GCPs to be used as input. + * @param nReqOrder the requested polynomial order. It should be 1, 2 or 3. + * + * @return the transform argument or NULL if creation fails. + */ + +void *GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int nReqOrder, int bReversed ) + +{ + GCPTransformInfo *psInfo; + double *padfGeoX, *padfGeoY, *padfRasterX, *padfRasterY; + int *panStatus, iGCP; + struct Control_Points sPoints; + + if( nReqOrder == 0 ) + { + if( nGCPCount >= 10 ) + nReqOrder = 2; /*for now we avoid 3rd order since it is unstable*/ + else if( nGCPCount >= 6 ) + nReqOrder = 2; + else + nReqOrder = 1; + } + + psInfo = (GCPTransformInfo *) CPLCalloc(sizeof(GCPTransformInfo),1); + psInfo->bReversed = bReversed; + psInfo->nOrder = nReqOrder; + + psInfo->pasGCPList = GDALDuplicateGCPs( nGCPCount, pasGCPList ); + psInfo->nGCPCount = nGCPCount; + + strcpy( psInfo->sTI.szSignature, "GTI" ); + psInfo->sTI.pszClassName = "GDALGCPTransformer"; + psInfo->sTI.pfnTransform = GDALGCPTransform; + psInfo->sTI.pfnCleanup = GDALDestroyGCPTransformer; + psInfo->sTI.pfnSerialize = GDALSerializeGCPTransformer; + +/* -------------------------------------------------------------------- */ +/* Allocate and initialize the working points list. */ +/* -------------------------------------------------------------------- */ + padfGeoX = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfGeoY = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfRasterX = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfRasterY = (double *) CPLCalloc(sizeof(double),nGCPCount); + panStatus = (int *) CPLCalloc(sizeof(int),nGCPCount); + + for( iGCP = 0; iGCP < nGCPCount; iGCP++ ) + { + panStatus[iGCP] = 1; + padfGeoX[iGCP] = pasGCPList[iGCP].dfGCPX; + padfGeoY[iGCP] = pasGCPList[iGCP].dfGCPY; + padfRasterX[iGCP] = pasGCPList[iGCP].dfGCPPixel; + padfRasterY[iGCP] = pasGCPList[iGCP].dfGCPLine; + } + + sPoints.count = nGCPCount; + sPoints.e1 = padfRasterX; + sPoints.n1 = padfRasterY; + sPoints.e2 = padfGeoX; + sPoints.n2 = padfGeoY; + sPoints.status = panStatus; + +/* -------------------------------------------------------------------- */ +/* Compute the forward and reverse polynomials. */ +/* -------------------------------------------------------------------- */ + if( CRS_compute_georef_equations( &sPoints, + psInfo->adfToGeoX, psInfo->adfToGeoY, + psInfo->adfFromGeoX, psInfo->adfFromGeoY, + nReqOrder ) != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to compute polynomial equations of desired order\n" + "for provided control points." ); + goto CleanupAfterError; + } + + return psInfo; + + CleanupAfterError: + CPLFree( padfGeoX ); + CPLFree( padfGeoY ); + CPLFree( padfRasterX ); + CPLFree( padfRasterY ); + CPLFree( panStatus ); + + CPLFree( psInfo ); + return NULL; +} + +/************************************************************************/ +/* GDALDestroyGCPTransformer() */ +/************************************************************************/ + +/** + * Destroy GCP transformer. + * + * This function is used to destroy information about a GCP based + * polynomial transformation created with GDALCreateGCPTransformer(). + * + * @param pTransformArg the transform arg previously returned by + * GDALCreateGCPTransformer(). + */ + +void GDALDestroyGCPTransformer( void *pTransformArg ) + +{ + GCPTransformInfo *psInfo = (GCPTransformInfo *) pTransformArg; + + GDALDeinitGCPs( psInfo->nGCPCount, psInfo->pasGCPList ); + CPLFree( psInfo->pasGCPList ); + + CPLFree( pTransformArg ); +} + +/************************************************************************/ +/* GDALGCPTransform() */ +/************************************************************************/ + +/** + * Transforms point based on GCP derived polynomial model. + * + * This function matches the GDALTransformerFunc signature, and can be + * used to transform one or more points from pixel/line coordinates to + * georeferenced coordinates (SrcToDst) or vice versa (DstToSrc). + * + * @param pTransformArg return value from GDALCreateGCPTransformer(). + * @param bDstToSrc TRUE if transformation is from the destination + * (georeferenced) coordinates to pixel/line or FALSE when transforming + * from pixel/line to georeferenced coordinates. + * @param nPointCount the number of values in the x, y and z arrays. + * @param x array containing the X values to be transformed. + * @param y array containing the Y values to be transformed. + * @param z array containing the Z values to be transformed. + * @param panSuccess array in which a flag indicating success (TRUE) or + * failure (FALSE) of the transformation are placed. + * + * @return TRUE. + */ + +int GDALGCPTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *x, double *y, double *z, + int *panSuccess ) + +{ + int i; + GCPTransformInfo *psInfo = (GCPTransformInfo *) pTransformArg; + + if( psInfo->bReversed ) + bDstToSrc = !bDstToSrc; + + for( i = 0; i < nPointCount; i++ ) + { + if( bDstToSrc ) + { + CRS_georef( x[i], y[i], x + i, y + i, + psInfo->adfFromGeoX, psInfo->adfFromGeoY, + psInfo->nOrder ); + } + else + { + CRS_georef( x[i], y[i], x + i, y + i, + psInfo->adfToGeoX, psInfo->adfToGeoY, + psInfo->nOrder ); + } + panSuccess[i] = TRUE; + } + + return TRUE; +} + +/************************************************************************/ +/* GDALSerializeGCPTransformer() */ +/************************************************************************/ + +CPLXMLNode *GDALSerializeGCPTransformer( void *pTransformArg ) + +{ + CPLXMLNode *psTree; + GCPTransformInfo *psInfo = (GCPTransformInfo *) pTransformArg; + + psTree = CPLCreateXMLNode( NULL, CXT_Element, "GCPTransformer" ); + +/* -------------------------------------------------------------------- */ +/* Serialize Order and bReversed. */ +/* -------------------------------------------------------------------- */ + CPLCreateXMLElementAndValue( + psTree, "Order", + CPLSPrintf( "%d", psInfo->nOrder ) ); + + CPLCreateXMLElementAndValue( + psTree, "Reversed", + CPLSPrintf( "%d", psInfo->bReversed ) ); + +/* -------------------------------------------------------------------- */ +/* Attach GCP List. */ +/* -------------------------------------------------------------------- */ + if( psInfo->nGCPCount > 0 ) + { + int iGCP; + CPLXMLNode *psGCPList = CPLCreateXMLNode( psTree, CXT_Element, + "GCPList" ); + + for( iGCP = 0; iGCP < psInfo->nGCPCount; iGCP++ ) + { + CPLXMLNode *psXMLGCP; + GDAL_GCP *psGCP = psInfo->pasGCPList + iGCP; + + psXMLGCP = CPLCreateXMLNode( psGCPList, CXT_Element, "GCP" ); + + CPLSetXMLValue( psXMLGCP, "#Id", psGCP->pszId ); + + if( psGCP->pszInfo != NULL && strlen(psGCP->pszInfo) > 0 ) + CPLSetXMLValue( psXMLGCP, "Info", psGCP->pszInfo ); + + CPLSetXMLValue( psXMLGCP, "#Pixel", + CPLSPrintf( "%.4f", psGCP->dfGCPPixel ) ); + + CPLSetXMLValue( psXMLGCP, "#Line", + CPLSPrintf( "%.4f", psGCP->dfGCPLine ) ); + + CPLSetXMLValue( psXMLGCP, "#X", + CPLSPrintf( "%.12E", psGCP->dfGCPX ) ); + + CPLSetXMLValue( psXMLGCP, "#Y", + CPLSPrintf( "%.12E", psGCP->dfGCPY ) ); + + if( psGCP->dfGCPZ != 0.0 ) + CPLSetXMLValue( psXMLGCP, "#GCPZ", + CPLSPrintf( "%.12E", psGCP->dfGCPZ ) ); + } + } + + return psTree; +} + +/************************************************************************/ +/* GDALDeserializeReprojectionTransformer() */ +/************************************************************************/ + +void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ) + +{ + GDAL_GCP *pasGCPList = 0; + int nGCPCount = 0; + void *pResult; + int nReqOrder; + int bReversed; + + /* -------------------------------------------------------------------- */ + /* Check for GCPs. */ + /* -------------------------------------------------------------------- */ + CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); + + if( psGCPList != NULL ) + { + int nGCPMax = 0; + CPLXMLNode *psXMLGCP; + + // Count GCPs. + for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; + psXMLGCP = psXMLGCP->psNext ) + nGCPMax++; + + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax); + + for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; + psXMLGCP = psXMLGCP->psNext ) + { + GDAL_GCP *psGCP = pasGCPList + nGCPCount; + + if( !EQUAL(psXMLGCP->pszValue,"GCP") || + psXMLGCP->eType != CXT_Element ) + continue; + + GDALInitGCPs( 1, psGCP ); + + CPLFree( psGCP->pszId ); + psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id","")); + + CPLFree( psGCP->pszInfo ); + psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info","")); + + psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0")); + psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0")); + + psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0")); + psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0")); + psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0")); + nGCPCount++; + } + } + +/* -------------------------------------------------------------------- */ +/* Get other flags. */ +/* -------------------------------------------------------------------- */ + nReqOrder = atoi(CPLGetXMLValue(psTree,"Order","3")); + bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); + +/* -------------------------------------------------------------------- */ +/* Generate transformation. */ +/* -------------------------------------------------------------------- */ + pResult = GDALCreateGCPTransformer( nGCPCount, pasGCPList, nReqOrder, + bReversed ); + +/* -------------------------------------------------------------------- */ +/* Cleanup GCP copy. */ +/* -------------------------------------------------------------------- */ + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + + return pResult; +} + +/************************************************************************/ +/* ==================================================================== */ +/* Everything below this point derived from the CRS.C from GRASS. */ +/* ==================================================================== */ +/************************************************************************/ + + +/* STRUCTURE FOR USE INTERNALLY WITH THESE FUNCTIONS. THESE FUNCTIONS EXPECT + SQUARE MATRICES SO ONLY ONE VARIABLE IS GIVEN (N) FOR THE MATRIX SIZE */ + +struct MATRIX +{ + int n; /* SIZE OF THIS MATRIX (N x N) */ + double *v; +}; + +/* CALCULATE OFFSET INTO ARRAY BASED ON R/C */ + +#define M(row,col) m->v[(((row)-1)*(m->n))+(col)-1] + + +#define MSUCCESS 1 /* SUCCESS */ +#define MNPTERR 0 /* NOT ENOUGH POINTS */ +#define MUNSOLVABLE -1 /* NOT SOLVABLE */ +#define MMEMERR -2 /* NOT ENOUGH MEMORY */ +#define MPARMERR -3 /* PARAMETER ERROR */ +#define MINTERR -4 /* INTERNAL ERROR */ + +/***************************************************************************/ +/* + FUNCTION PROTOTYPES FOR STATIC (INTERNAL) FUNCTIONS +*/ +/***************************************************************************/ + +static int calccoef(struct Control_Points *,double *,double *,int); +static int calcls(struct Control_Points *,struct MATRIX *, + double *,double *,double *,double *); +static int exactdet(struct Control_Points *,struct MATRIX *, + double *,double *,double *,double *); +static int solvemat(struct MATRIX *,double *,double *,double *,double *); +static double term(int,double,double); + +/***************************************************************************/ +/* + TRANSFORM A SINGLE COORDINATE PAIR. +*/ +/***************************************************************************/ + +static int +CRS_georef ( + double e1, /* EASTINGS TO BE TRANSFORMED */ + double n1, /* NORTHINGS TO BE TRANSFORMED */ + double *e, /* EASTINGS TO BE TRANSFORMED */ + double *n, /* NORTHINGS TO BE TRANSFORMED */ + double E[], /* EASTING COEFFICIENTS */ + double N[], /* NORTHING COEFFICIENTS */ + int order /* ORDER OF TRANSFORMATION TO BE PERFORMED, MUST MATCH THE + ORDER USED TO CALCULATE THE COEFFICIENTS */ +) + { + double e3, e2n, en2, n3, e2, en, n2; + + switch(order) + { + case 1: + + *e = E[0] + E[1] * e1 + E[2] * n1; + *n = N[0] + N[1] * e1 + N[2] * n1; + break; + + case 2: + + e2 = e1 * e1; + n2 = n1 * n1; + en = e1 * n1; + + *e = E[0] + E[1] * e1 + E[2] * n1 + + E[3] * e2 + E[4] * en + E[5] * n2; + *n = N[0] + N[1] * e1 + N[2] * n1 + + N[3] * e2 + N[4] * en + N[5] * n2; + break; + + case 3: + + e2 = e1 * e1; + en = e1 * n1; + n2 = n1 * n1; + e3 = e1 * e2; + e2n = e2 * n1; + en2 = e1 * n2; + n3 = n1 * n2; + + *e = E[0] + + E[1] * e1 + E[2] * n1 + + E[3] * e2 + E[4] * en + E[5] * n2 + + E[6] * e3 + E[7] * e2n + E[8] * en2 + E[9] * n3; + *n = N[0] + + N[1] * e1 + N[2] * n1 + + N[3] * e2 + N[4] * en + N[5] * n2 + + N[6] * e3 + N[7] * e2n + N[8] * en2 + N[9] * n3; + break; + + default: + + return(MPARMERR); + break; + } + + return(MSUCCESS); + } + +/***************************************************************************/ +/* + COMPUTE THE GEOREFFERENCING COEFFICIENTS BASED ON A SET OF CONTROL POINTS +*/ +/***************************************************************************/ + +static int +CRS_compute_georef_equations (struct Control_Points *cp, + double E12[], double N12[], + double E21[], double N21[], + int order) +{ + double *tempptr; + int status; + + if(order < 1 || order > MAXORDER) + return(MPARMERR); + + /* CALCULATE THE FORWARD TRANSFORMATION COEFFICIENTS */ + + status = calccoef(cp,E12,N12,order); + if(status != MSUCCESS) + return(status); + + /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS */ + + tempptr = cp->e1; + cp->e1 = cp->e2; + cp->e2 = tempptr; + tempptr = cp->n1; + cp->n1 = cp->n2; + cp->n2 = tempptr; + + /* CALCULATE THE BACKWARD TRANSFORMATION COEFFICIENTS */ + + status = calccoef(cp,E21,N21,order); + + /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS BACK */ + + tempptr = cp->e1; + cp->e1 = cp->e2; + cp->e2 = tempptr; + tempptr = cp->n1; + cp->n1 = cp->n2; + cp->n2 = tempptr; + + return(status); +} + +/***************************************************************************/ +/* + COMPUTE THE GEOREFFERENCING COEFFICIENTS BASED ON A SET OF CONTROL POINTS +*/ +/***************************************************************************/ + +static int +calccoef (struct Control_Points *cp, double E[], double N[], int order) +{ + struct MATRIX m; + double *a; + double *b; + int numactive; /* NUMBER OF ACTIVE CONTROL POINTS */ + int status, i; + + /* CALCULATE THE NUMBER OF VALID CONTROL POINTS */ + + for(i = numactive = 0 ; i < cp->count ; i++) + { + if(cp->status[i] > 0) + numactive++; + } + + /* CALCULATE THE MINIMUM NUMBER OF CONTROL POINTS NEEDED TO DETERMINE + A TRANSFORMATION OF THIS ORDER */ + + m.n = ((order + 1) * (order + 2)) / 2; + + if(numactive < m.n) + return(MNPTERR); + + /* INITIALIZE MATRIX */ + + m.v = (double *)CPLCalloc(m.n*m.n,sizeof(double)); + if(m.v == NULL) + { + return(MMEMERR); + } + a = (double *)CPLCalloc(m.n,sizeof(double)); + if(a == NULL) + { + CPLFree((char *)m.v); + return(MMEMERR); + } + b = (double *)CPLCalloc(m.n,sizeof(double)); + if(b == NULL) + { + CPLFree((char *)m.v); + CPLFree((char *)a); + return(MMEMERR); + } + + if(numactive == m.n) + status = exactdet(cp,&m,a,b,E,N); + else + status = calcls(cp,&m,a,b,E,N); + + CPLFree((char *)m.v); + CPLFree((char *)a); + CPLFree((char *)b); + + return(status); +} + +/***************************************************************************/ +/* + CALCULATE THE TRANSFORMATION COEFFICIENTS WITH EXACTLY THE MINIMUM + NUMBER OF CONTROL POINTS REQUIRED FOR THIS TRANSFORMATION. +*/ +/***************************************************************************/ + +static int exactdet ( + struct Control_Points *cp, + struct MATRIX *m, + double a[], + double b[], + double E[], /* EASTING COEFFICIENTS */ + double N[] /* NORTHING COEFFICIENTS */ +) + { + int pntnow, currow, j; + + currow = 1; + for(pntnow = 0 ; pntnow < cp->count ; pntnow++) + { + if(cp->status[pntnow] > 0) + { + /* POPULATE MATRIX M */ + + for(j = 1 ; j <= m->n ; j++) + { + M(currow,j) = term(j,cp->e1[pntnow],cp->n1[pntnow]); + } + + /* POPULATE MATRIX A AND B */ + + a[currow-1] = cp->e2[pntnow]; + b[currow-1] = cp->n2[pntnow]; + + currow++; + } + } + + if(currow - 1 != m->n) + return(MINTERR); + + return(solvemat(m,a,b,E,N)); + } + +/***************************************************************************/ +/* + CALCULATE THE TRANSFORMATION COEFFICIENTS WITH MORE THAN THE MINIMUM + NUMBER OF CONTROL POINTS REQUIRED FOR THIS TRANSFORMATION. THIS + ROUTINE USES THE LEAST SQUARES METHOD TO COMPUTE THE COEFFICIENTS. +*/ +/***************************************************************************/ + +static int calcls ( + struct Control_Points *cp, + struct MATRIX *m, + double a[], + double b[], + double E[], /* EASTING COEFFICIENTS */ + double N[] /* NORTHING COEFFICIENTS */ +) +{ + int i, j, n, numactive = 0; + + /* INITIALIZE THE UPPER HALF OF THE MATRIX AND THE TWO COLUMN VECTORS */ + + for(i = 1 ; i <= m->n ; i++) + { + for(j = i ; j <= m->n ; j++) + M(i,j) = 0.0; + a[i-1] = b[i-1] = 0.0; + } + + /* SUM THE UPPER HALF OF THE MATRIX AND THE COLUMN VECTORS ACCORDING TO + THE LEAST SQUARES METHOD OF SOLVING OVER DETERMINED SYSTEMS */ + + for(n = 0 ; n < cp->count ; n++) + { + if(cp->status[n] > 0) + { + numactive++; + for(i = 1 ; i <= m->n ; i++) + { + for(j = i ; j <= m->n ; j++) + M(i,j) += term(i,cp->e1[n],cp->n1[n]) * term(j,cp->e1[n],cp->n1[n]); + + a[i-1] += cp->e2[n] * term(i,cp->e1[n],cp->n1[n]); + b[i-1] += cp->n2[n] * term(i,cp->e1[n],cp->n1[n]); + } + } + } + + if(numactive <= m->n) + return(MINTERR); + + /* TRANSPOSE VALUES IN UPPER HALF OF M TO OTHER HALF */ + + for(i = 2 ; i <= m->n ; i++) + { + for(j = 1 ; j < i ; j++) + M(i,j) = M(j,i); + } + + return(solvemat(m,a,b,E,N)); +} + +/***************************************************************************/ +/* + CALCULATE THE X/Y TERM BASED ON THE TERM NUMBER + +ORDER\TERM 1 2 3 4 5 6 7 8 9 10 + 1 e0n0 e1n0 e0n1 + 2 e0n0 e1n0 e0n1 e2n0 e1n1 e0n2 + 3 e0n0 e1n0 e0n1 e2n0 e1n1 e0n2 e3n0 e2n1 e1n2 e0n3 +*/ +/***************************************************************************/ + +static double term (int term, double e, double n) +{ + switch(term) + { + case 1: return((double)1.0); + case 2: return((double)e); + case 3: return((double)n); + case 4: return((double)(e*e)); + case 5: return((double)(e*n)); + case 6: return((double)(n*n)); + case 7: return((double)(e*e*e)); + case 8: return((double)(e*e*n)); + case 9: return((double)(e*n*n)); + case 10: return((double)(n*n*n)); + } + return((double)0.0); +} + +/***************************************************************************/ +/* + SOLVE FOR THE 'E' AND 'N' COEFFICIENTS BY USING A SOMEWHAT MODIFIED + GAUSSIAN ELIMINATION METHOD. + + | M11 M12 ... M1n | | E0 | | a0 | + | M21 M22 ... M2n | | E1 | = | a1 | + | . . . . | | . | | . | + | Mn1 Mn2 ... Mnn | | En-1 | | an-1 | + + and + + | M11 M12 ... M1n | | N0 | | b0 | + | M21 M22 ... M2n | | N1 | = | b1 | + | . . . . | | . | | . | + | Mn1 Mn2 ... Mnn | | Nn-1 | | bn-1 | +*/ +/***************************************************************************/ + +static int solvemat (struct MATRIX *m, + double a[], double b[], double E[], double N[]) +{ + int i, j, i2, j2, imark; + double factor, temp; + double pivot; /* ACTUAL VALUE OF THE LARGEST PIVOT CANDIDATE */ + + for(i = 1 ; i <= m->n ; i++) + { + j = i; + + /* find row with largest magnitude value for pivot value */ + + pivot = M(i,j); + imark = i; + for(i2 = i + 1 ; i2 <= m->n ; i2++) + { + temp = fabs(M(i2,j)); + if(temp > fabs(pivot)) + { + pivot = M(i2,j); + imark = i2; + } + } + + /* if the pivot is very small then the points are nearly co-linear */ + /* co-linear points result in an undefined matrix, and nearly */ + /* co-linear points results in a solution with rounding error */ + + if(pivot == 0.0) + return(MUNSOLVABLE); + + /* if row with highest pivot is not the current row, switch them */ + + if(imark != i) + { + for(j2 = 1 ; j2 <= m->n ; j2++) + { + temp = M(imark,j2); + M(imark,j2) = M(i,j2); + M(i,j2) = temp; + } + + temp = a[imark-1]; + a[imark-1] = a[i-1]; + a[i-1] = temp; + + temp = b[imark-1]; + b[imark-1] = b[i-1]; + b[i-1] = temp; + } + + /* compute zeros above and below the pivot, and compute + values for the rest of the row as well */ + + for(i2 = 1 ; i2 <= m->n ; i2++) + { + if(i2 != i) + { + factor = M(i2,j) / pivot; + for(j2 = j ; j2 <= m->n ; j2++) + M(i2,j2) -= factor * M(i,j2); + a[i2-1] -= factor * a[i-1]; + b[i2-1] -= factor * b[i-1]; + } + } + } + + /* SINCE ALL OTHER VALUES IN THE MATRIX ARE ZERO NOW, CALCULATE THE + COEFFICIENTS BY DIVIDING THE COLUMN VECTORS BY THE DIAGONAL VALUES. */ + + for(i = 1 ; i <= m->n ; i++) + { + E[i-1] = a[i-1] / M(i,i); + N[i-1] = b[i-1] / M(i,i); + } + + return(MSUCCESS); +} diff --git a/Utilities/GDAL/alg/gdal_nrgcrs.c b/Utilities/GDAL/alg/gdal_nrgcrs.c new file mode 100644 index 0000000000..99832db4c0 --- /dev/null +++ b/Utilities/GDAL/alg/gdal_nrgcrs.c @@ -0,0 +1,299 @@ +/****************************************************************************** + * $Id$ + * + * Project: Mapinfo Image Warper + * Purpose: Implemention of the GDALTransformer wrapper around CRS.C functions + * to build a polynomial transformation based on ground control + * points. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + *************************************************************************** + * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdal_nrgcrs.c,v $ + * Revision 1.3 2006/03/21 20:56:00 fwarmerdam + * cleanup headers + * + * Revision 1.2 2004/09/16 15:54:32 fwarmerdam + * added stub serialization support + * + * Revision 1.1 2002/12/11 18:21:18 dron + * New + * + * + */ + +#include "gdal_alg.h" +#include "cpl_conv.h" +#include "cpl_minixml.h" + +extern int TwoDPolyFit( double *, double *, int, int, double *, double *, double * ); +extern double TwoDPolyEval( double *, int, double, double ); + +typedef struct +{ + double adfToGeoX[20]; + double adfToGeoY[20]; + + double adfFromGeoX[20]; + double adfFromGeoY[20]; + + int nOrder; + int bReversed; + +} GCPTransformInfo; + + +/************************************************************************/ +/* GDALCreateGCPTransformer() */ +/************************************************************************/ + +/** + * Create GCP based polynomial transformer. + * + * Computes least squares fit polynomials from a provided set of GCPs, + * and stores the coefficients for later transformation of points between + * pixel/line and georeferenced coordinates. + * + * The return value should be used as a TransformArg in combination with + * the transformation function GDALGCPTransform which fits the + * GDALTransformerFunc signature. The returned transform argument should + * be deallocated with GDALDestroyGCPTransformer when no longer needed. + * + * This function may fail (returning NULL) if the provided set of GCPs + * are inadequate for the requested order, the determinate is zero or they + * are otherwise "ill conditioned". + * + * Note that 2nd order requires at least 6 GCPs, and 3rd order requires at + * least 10 gcps. If nReqOrder is 0 the highest order possible with the + * provided gcp count will be used. + * + * @param nGCPCount the number of GCPs in pasGCPList. + * @param pasGCPList an array of GCPs to be used as input. + * @param nReqOrder the requested polynomial order. It should be 1, 2 or 3. + * + * @return the transform argument or NULL if creation fails. + */ + +void *GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int nReqOrder, int bReversed ) + +{ + GCPTransformInfo *psInfo; + double *padfGeoX, *padfGeoY, *padfRasterX, *padfRasterY; + int *panStatus, iGCP; + double rms_err; + + if( nReqOrder == 0 ) + { + if( nGCPCount >= 10 ) + nReqOrder = 3; + else if( nGCPCount >= 6 ) + nReqOrder = 2; + else + nReqOrder = 1; + } + + psInfo = (GCPTransformInfo *) CPLCalloc(sizeof(GCPTransformInfo),1); + psInfo->bReversed = bReversed; + psInfo->nOrder = nReqOrder; + +/* -------------------------------------------------------------------- */ +/* Allocate and initialize the working points list. */ +/* -------------------------------------------------------------------- */ + padfGeoX = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfGeoY = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfRasterX = (double *) CPLCalloc(sizeof(double),nGCPCount); + padfRasterY = (double *) CPLCalloc(sizeof(double),nGCPCount); + panStatus = (int *) CPLCalloc(sizeof(int),nGCPCount); + + for( iGCP = 0; iGCP < nGCPCount; iGCP++ ) + { + panStatus[iGCP] = 1; + padfGeoX[iGCP] = pasGCPList[iGCP].dfGCPX; + padfGeoY[iGCP] = pasGCPList[iGCP].dfGCPY; + padfRasterX[iGCP] = pasGCPList[iGCP].dfGCPPixel; + padfRasterY[iGCP] = pasGCPList[iGCP].dfGCPLine; + } + +/* -------------------------------------------------------------------- */ +/* Compute the forward and reverse polynomials. */ +/* -------------------------------------------------------------------- */ + if ( TwoDPolyFit( &rms_err, psInfo->adfFromGeoX, nReqOrder, nGCPCount, + padfRasterX, padfGeoX, padfGeoY ) < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to compute polynomial equations of desired order\n" + "for provided control points." ); + goto CleanupAfterError; + } + if ( TwoDPolyFit( &rms_err, psInfo->adfFromGeoY, nReqOrder, nGCPCount, + padfRasterY, padfGeoX, padfGeoY ) < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to compute polynomial equations of desired order\n" + "for provided control points." ); + goto CleanupAfterError; + } + if ( TwoDPolyFit( &rms_err, psInfo->adfToGeoX, nReqOrder, nGCPCount, + padfGeoX, padfRasterX, padfRasterY ) < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to compute polynomial equations of desired order\n" + "for provided control points." ); + goto CleanupAfterError; + } + if ( TwoDPolyFit( &rms_err, psInfo->adfToGeoY, nReqOrder, nGCPCount, + padfGeoY, padfRasterX, padfRasterY ) < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to compute polynomial equations of desired order\n" + "for provided control points." ); + goto CleanupAfterError; + } + +/* -------------------------------------------------------------------- */ +/* Dump residuals. */ +/* -------------------------------------------------------------------- */ + CPLDebug( "GDALCreateGCPTransformer", + "Number of GCPs %d, transformation order %d", + nGCPCount, psInfo->nOrder ); + + for( iGCP = 0; iGCP < nGCPCount; iGCP++ ) + { + double x = pasGCPList[iGCP].dfGCPX; + double y = pasGCPList[iGCP].dfGCPY; + double z = pasGCPList[iGCP].dfGCPZ; + int bSuccess; + GDALGCPTransform( psInfo, TRUE, 1, &x, &y, &z, &bSuccess ); + CPLDebug( "GDALCreateGCPTransformer", + "GCP %d. Residuals: X: %f, Y: %f", iGCP, + pasGCPList[iGCP].dfGCPPixel - x, pasGCPList[iGCP].dfGCPLine - y ); + } + + return psInfo; + + CleanupAfterError: + CPLFree( padfGeoX ); + CPLFree( padfGeoY ); + CPLFree( padfRasterX ); + CPLFree( padfRasterX ); + CPLFree( panStatus ); + + CPLFree( psInfo ); + return NULL; +} + +/************************************************************************/ +/* GDALDestroyGCPTransformer() */ +/************************************************************************/ + +/** + * Destroy GCP transformer. + * + * This function is used to destroy information about a GCP based + * polynomial transformation created with GDALCreateGCPTransformer(). + * + * @param pTransformArg the transform arg previously returned by + * GDALCreateGCPTransformer(). + */ + +void GDALDestroyGCPTransformer( void *pTransformArg ) + +{ + CPLFree( pTransformArg ); +} + +/************************************************************************/ +/* GDALGCPTransform() */ +/************************************************************************/ + +/** + * Transforms point based on GCP derived polynomial model. + * + * This function matches the GDALTransformerFunc signature, and can be + * used to transform one or more points from pixel/line coordinates to + * georeferenced coordinates (SrcToDst) or vice versa (DstToSrc). + * + * @param pTransformArg return value from GDALCreateGCPTransformer(). + * @param bDstToSrc TRUE if transformation is from the destination + * (georeferenced) coordinates to pixel/line or FALSE when transforming + * from pixel/line to georeferenced coordinates. + * @param nPointCount the number of values in the x, y and z arrays. + * @param x array containing the X values to be transformed. + * @param y array containing the Y values to be transformed. + * @param z array containing the Z values to be transformed. + * @param panSuccess array in which a flag indicating success (TRUE) or + * failure (FALSE) of the transformation are placed. + * + * @return TRUE. + */ + +int GDALGCPTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *x, double *y, double *z, + int *panSuccess ) + +{ + int i; + double X, Y; + GCPTransformInfo *psInfo = (GCPTransformInfo *) pTransformArg; + + if( psInfo->bReversed ) + bDstToSrc = !bDstToSrc; + + for( i = 0; i < nPointCount; i++ ) + { + X = x[i]; + Y = y[i]; + if( bDstToSrc ) + { + x[i] = TwoDPolyEval( psInfo->adfFromGeoX, psInfo->nOrder, X, Y ); + y[i] = TwoDPolyEval( psInfo->adfFromGeoY, psInfo->nOrder, X, Y ); + } + else + { + x[i] = TwoDPolyEval( psInfo->adfToGeoX, psInfo->nOrder, X, Y ); + y[i] = TwoDPolyEval( psInfo->adfToGeoY, psInfo->nOrder, X, Y ); + } + z[i] = 0; + panSuccess[i] = TRUE; + } + + return TRUE; +} + +CPLXMLNode *GDALSerializeGCPTransformer( void *pTransformArg ) + +{ + CPLError( CE_Failure, CPLE_AppDefined, + "serialization not supported for this type of gcp transformer."); + return NULL; +} + +void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ) + +{ + CPLError( CE_Failure, CPLE_AppDefined, + "deserialization not supported for this type of gcp transformer."); + return NULL; +} diff --git a/Utilities/GDAL/alg/gdal_rpc.cpp b/Utilities/GDAL/alg/gdal_rpc.cpp new file mode 100644 index 0000000000..4551f10ea0 --- /dev/null +++ b/Utilities/GDAL/alg/gdal_rpc.cpp @@ -0,0 +1,275 @@ +/****************************************************************************** + * $Id: gdal_rpc.cpp,v 1.3 2004/12/26 16:12:21 fwarmerdam Exp $ + * + * Project: Image Warper + * Purpose: Implements a rational polynomail (RPC) based transformer. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdal_rpc.cpp,v $ + * Revision 1.3 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.2 2003/06/03 19:41:58 warmerda + * working implmentation, but inverse is still not iteratively solved + * + * Revision 1.1 2003/06/03 17:36:43 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: gdal_rpc.cpp,v 1.3 2004/12/26 16:12:21 fwarmerdam Exp $"); + +/************************************************************************/ +/* RPCComputeTerms() */ +/************************************************************************/ + +static void RPCComputeTerms( double dfLong, double dfLat, double dfHeight, + double *padfTerms ) + +{ + padfTerms[0] = 1.0; + padfTerms[1] = dfLong; + padfTerms[2] = dfLat; + padfTerms[3] = dfHeight; + padfTerms[4] = dfLong * dfLat; + padfTerms[5] = dfLong * dfHeight; + padfTerms[6] = dfLat * dfHeight; + padfTerms[7] = dfLong * dfLong; + padfTerms[8] = dfLat * dfLat; + padfTerms[9] = dfHeight * dfHeight; + + padfTerms[10] = dfLong * dfLat * dfHeight; + padfTerms[11] = dfLong * dfLong * dfLong; + padfTerms[12] = dfLong * dfLat * dfLat; + padfTerms[13] = dfLong * dfHeight * dfHeight; + padfTerms[14] = dfLong * dfLong * dfLat; + padfTerms[15] = dfLat * dfLat * dfLat; + padfTerms[16] = dfLat * dfHeight * dfHeight; + padfTerms[17] = dfLong * dfLong * dfHeight; + padfTerms[18] = dfLat * dfLat * dfHeight; + padfTerms[19] = dfHeight * dfHeight * dfHeight; +} + +/************************************************************************/ +/* RPCEvaluate() */ +/************************************************************************/ + +static double RPCEvaluate( double *padfTerms, double *padfCoefs ) + +{ + double dfSum = 0.0; + int i; + + for( i = 0; i < 20; i++ ) + dfSum += padfTerms[i] * padfCoefs[i]; + + return dfSum; +} + +/************************************************************************/ +/* RPCTransformPoint() */ +/************************************************************************/ + +static void RPCTransformPoint( GDALRPCInfo *psRPC, + double dfLong, double dfLat, double dfHeight, + double *pdfPixel, double *pdfLine ) + +{ + double dfResultX, dfResultY; + double adfTerms[20]; + + RPCComputeTerms( + (dfLong - psRPC->dfLONG_OFF) / psRPC->dfLONG_SCALE, + (dfLat - psRPC->dfLAT_OFF) / psRPC->dfLAT_SCALE, + (dfHeight - psRPC->dfHEIGHT_OFF) / psRPC->dfHEIGHT_SCALE, + adfTerms ); + + dfResultX = RPCEvaluate( adfTerms, psRPC->adfSAMP_NUM_COEFF ) + / RPCEvaluate( adfTerms, psRPC->adfSAMP_DEN_COEFF ); + + dfResultY = RPCEvaluate( adfTerms, psRPC->adfLINE_NUM_COEFF ) + / RPCEvaluate( adfTerms, psRPC->adfLINE_DEN_COEFF ); + + *pdfPixel = dfResultX * psRPC->dfSAMP_SCALE + psRPC->dfSAMP_OFF; + *pdfLine = dfResultY * psRPC->dfLINE_SCALE + psRPC->dfLINE_OFF; +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALRPCTransformer */ +/* ==================================================================== */ +/************************************************************************/ + +typedef struct { + + GDALTransformerInfo sTI; + + GDALRPCInfo sRPC; + + double adfPLToLatLongGeoTransform[6]; + + int bReversed; + + double dfPixErrThreshold; + +} GDALRPCTransformInfo; + +/************************************************************************/ +/* GDALCreateRPCTransformer() */ +/************************************************************************/ + +void *GDALCreateRPCTransformer( GDALRPCInfo *psRPCInfo, int bReversed, + double dfPixErrThreshold ) + +{ + GDALRPCTransformInfo *psTransform; + +/* -------------------------------------------------------------------- */ +/* Initialize core info. */ +/* -------------------------------------------------------------------- */ + psTransform = (GDALRPCTransformInfo *) + CPLCalloc(sizeof(GDALRPCTransformInfo),1); + + memcpy( &(psTransform->sRPC), psRPCInfo, sizeof(GDALRPCInfo) ); + psTransform->bReversed = bReversed; + psTransform->dfPixErrThreshold = dfPixErrThreshold; + + strcpy( psTransform->sTI.szSignature, "GTI" ); + psTransform->sTI.pszClassName = "GDALRPCTransformer"; + psTransform->sTI.pfnTransform = GDALRPCTransform; + psTransform->sTI.pfnCleanup = GDALDestroyRPCTransformer; + psTransform->sTI.pfnSerialize = NULL; + +/* -------------------------------------------------------------------- */ +/* Establish a reference point for calcualating an affine */ +/* geotransform approximate transformation. */ +/* -------------------------------------------------------------------- */ + double adfGTFromLL[6], dfRefPixel, dfRefLine; + + double dfRefLong = (psRPCInfo->dfMIN_LONG + psRPCInfo->dfMAX_LONG) * 0.5; + double dfRefLat = (psRPCInfo->dfMIN_LAT + psRPCInfo->dfMAX_LAT ) * 0.5; + + RPCTransformPoint( psRPCInfo, dfRefLong, dfRefLat, 0.0, + &dfRefPixel, &dfRefLine ); + +/* -------------------------------------------------------------------- */ +/* Transform nearby locations to establish affine direction */ +/* vectors. */ +/* -------------------------------------------------------------------- */ + double dfRefPixelDelta, dfRefLineDelta, dfLLDelta = 0.0001; + + RPCTransformPoint( psRPCInfo, dfRefLong+dfLLDelta, dfRefLat, 0.0, + &dfRefPixelDelta, &dfRefLineDelta ); + adfGTFromLL[1] = (dfRefPixelDelta - dfRefPixel) / dfLLDelta; + adfGTFromLL[2] = (dfRefLineDelta - dfRefLine) / dfLLDelta; + + RPCTransformPoint( psRPCInfo, dfRefLong, dfRefLat+dfLLDelta, 0.0, + &dfRefPixelDelta, &dfRefLineDelta ); + adfGTFromLL[4] = (dfRefPixelDelta - dfRefPixel) / dfLLDelta; + adfGTFromLL[5] = (dfRefLineDelta - dfRefLine) / dfLLDelta; + + adfGTFromLL[0] = dfRefPixel + - adfGTFromLL[1] * dfRefLong - adfGTFromLL[2] * dfRefLat; + adfGTFromLL[3] = dfRefLine + - adfGTFromLL[4] * dfRefLong - adfGTFromLL[5] * dfRefLat; + + GDALInvGeoTransform( adfGTFromLL, psTransform->adfPLToLatLongGeoTransform); + + return psTransform; +} + +/************************************************************************/ +/* GDALDestroyReprojectionTransformer() */ +/************************************************************************/ + +void GDALDestroyRPCTransformer( void *pTransformAlg ) + +{ + CPLFree( pTransformAlg ); +} + +/************************************************************************/ +/* GDALRPCTransform() */ +/************************************************************************/ + +int GDALRPCTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *padfX, double *padfY, double *padfZ, + int *panSuccess ) + +{ + GDALRPCTransformInfo *psTransform = (GDALRPCTransformInfo *) pTransformArg; + GDALRPCInfo *psRPC = &(psTransform->sRPC); + int i; + + if( psTransform->bReversed ) + bDstToSrc = !bDstToSrc; + +/* -------------------------------------------------------------------- */ +/* The simple case is transforming from lat/long to pixel/line. */ +/* Just apply the equations directly. */ +/* -------------------------------------------------------------------- */ + if( bDstToSrc ) + { + for( i = 0; i < nPointCount; i++ ) + { + RPCTransformPoint( psRPC, padfX[i], padfY[i], padfZ[i], + padfX + i, padfY + i ); + panSuccess[i] = TRUE; + } + + return TRUE; + } + +/* -------------------------------------------------------------------- */ +/* The more complicated issue is how to reverse this. For now */ +/* we use a dead simple linear approximation. In the case of */ +/* image warping, this direction is only used to pick bound for */ +/* the newly created output file anyways. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nPointCount; i++ ) + { + double dfResultX, dfResultY; + + dfResultX = psTransform->adfPLToLatLongGeoTransform[0] + + psTransform->adfPLToLatLongGeoTransform[1] * padfX[i] + + psTransform->adfPLToLatLongGeoTransform[2] * padfY[i]; + + dfResultY = psTransform->adfPLToLatLongGeoTransform[3] + + psTransform->adfPLToLatLongGeoTransform[4] * padfX[i] + + psTransform->adfPLToLatLongGeoTransform[5] * padfY[i]; + + padfX[i] = dfResultX; + padfY[i] = dfResultY; + + panSuccess[i] = TRUE; + } + + return TRUE; +} diff --git a/Utilities/GDAL/alg/gdal_tps.cpp b/Utilities/GDAL/alg/gdal_tps.cpp new file mode 100755 index 0000000000..d7be76813e --- /dev/null +++ b/Utilities/GDAL/alg/gdal_tps.cpp @@ -0,0 +1,383 @@ +/****************************************************************************** + * $Id: gdal_tps.cpp,v 1.6 2004/12/31 02:01:58 fwarmerdam Exp $ + * + * Project: High Performance Image Reprojector + * Purpose: Thin Plate Spline transformer (GDAL wrapper portion) + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdal_tps.cpp,v $ + * Revision 1.6 2004/12/31 02:01:58 fwarmerdam + * Removed unused variables. + * + * Revision 1.5 2004/12/30 21:18:12 fwarmerdam + * Updated credits. + * + * Revision 1.4 2004/12/30 20:29:43 fwarmerdam + * Added a credit. + * + * Revision 1.3 2004/12/30 20:28:20 fwarmerdam + * Added some documentation. + * + * Revision 1.2 2004/12/30 20:21:13 fwarmerdam + * dos to unix + * + * Revision 1.1 2004/12/26 16:12:58 fwarmerdam + * New + * + */ + +#include "thinplatespline.h" +#include "gdal_alg.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: gdal_tps.cpp,v 1.6 2004/12/31 02:01:58 fwarmerdam Exp $"); + +CPL_C_START +CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg ); +void *GDALDeserializeTPSTransformer( CPLXMLNode *psTree ); +CPL_C_END + +typedef struct +{ + GDALTransformerInfo sTI; + + VizGeorefSpline2D *poForward; + VizGeorefSpline2D *poReverse; + + int bReversed; + + int nGCPCount; + GDAL_GCP *pasGCPList; + +} TPSTransformInfo; + +/************************************************************************/ +/* GDALCreateTPSTransformer() */ +/************************************************************************/ + +/** + * Create Thin Plate Spline transformer from GCPs. + * + * The thin plate spline transformer produces exact transformation + * at all control points and smoothly varying transformations between + * control points with greatest influence from local control points. + * It is suitable for for many applications not well modelled by polynomial + * transformations. + * + * Creating the TPS transformer involves solving systems of linear equations + * related to the number of control points involved. This solution is + * computed within this function call. It can be quite an expensive operation + * for large numbers of GCPs. For instance, for reference, it takes on the + * order of 10s for 400 GCPs on a 2GHz Athlon processor. + * + * TPS Transformers are serializable. + * + * The GDAL Thin Plate Spline transformer is based on code provided by + * Gilad Ronnen on behalf of VIZRT Inc (http://www.visrt.com). Incorporation + * of the algorithm into GDAL was supported by the Centro di Ecologia Alpina + * (http://www.cealp.it). + * + * @param nGCPCount the number of GCPs in pasGCPList. + * @param pasGCPList an array of GCPs to be used as input. + * @Param bReversed + * + * @return the transform argument or NULL if creation fails. + */ + +void *GDALCreateTPSTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, + int bReversed ) + +{ + TPSTransformInfo *psInfo; + int iGCP; + +/* -------------------------------------------------------------------- */ +/* Allocate transform info. */ +/* -------------------------------------------------------------------- */ + psInfo = (TPSTransformInfo *) CPLCalloc(sizeof(TPSTransformInfo),1); + + psInfo->pasGCPList = GDALDuplicateGCPs( nGCPCount, pasGCPList ); + psInfo->nGCPCount = nGCPCount; + + psInfo->bReversed = bReversed; + psInfo->poForward = new VizGeorefSpline2D( 2 ); + psInfo->poReverse = new VizGeorefSpline2D( 2 ); + + strcpy( psInfo->sTI.szSignature, "GTI" ); + psInfo->sTI.pszClassName = "GDALTPSTransformer"; + psInfo->sTI.pfnTransform = GDALTPSTransform; + psInfo->sTI.pfnCleanup = GDALDestroyTPSTransformer; + psInfo->sTI.pfnSerialize = GDALSerializeTPSTransformer; + +/* -------------------------------------------------------------------- */ +/* Attach all the points to the transformation. */ +/* -------------------------------------------------------------------- */ + for( iGCP = 0; iGCP < nGCPCount; iGCP++ ) + { + double afPL[2], afXY[2]; + + afPL[0] = pasGCPList[iGCP].dfGCPPixel; + afPL[1] = pasGCPList[iGCP].dfGCPLine; + afXY[0] = pasGCPList[iGCP].dfGCPX; + afXY[1] = pasGCPList[iGCP].dfGCPY; + + if( bReversed ) + { + psInfo->poReverse->add_point( afPL[0], afPL[1], afXY ); + psInfo->poForward->add_point( afXY[0], afXY[1], afPL ); + } + else + { + psInfo->poForward->add_point( afPL[0], afPL[1], afXY ); + psInfo->poReverse->add_point( afXY[0], afXY[1], afPL ); + } + } + + psInfo->poForward->solve(); + psInfo->poReverse->solve(); + + return psInfo; +} + +/************************************************************************/ +/* GDALDestroyTPSTransformer() */ +/************************************************************************/ + +/** + * Destroy TPS transformer. + * + * This function is used to destroy information about a GCP based + * polynomial transformation created with GDALCreateTPSTransformer(). + * + * @param pTransformArg the transform arg previously returned by + * GDALCreateTPSTransformer(). + */ + +void GDALDestroyTPSTransformer( void *pTransformArg ) + +{ + TPSTransformInfo *psInfo = (TPSTransformInfo *) pTransformArg; + + delete psInfo->poForward; + delete psInfo->poReverse; + + GDALDeinitGCPs( psInfo->nGCPCount, psInfo->pasGCPList ); + CPLFree( psInfo->pasGCPList ); + + CPLFree( pTransformArg ); +} + +/************************************************************************/ +/* GDALTPSTransform() */ +/************************************************************************/ + +/** + * Transforms point based on GCP derived polynomial model. + * + * This function matches the GDALTransformerFunc signature, and can be + * used to transform one or more points from pixel/line coordinates to + * georeferenced coordinates (SrcToDst) or vice versa (DstToSrc). + * + * @param pTransformArg return value from GDALCreateTPSTransformer(). + * @param bDstToSrc TRUE if transformation is from the destination + * (georeferenced) coordinates to pixel/line or FALSE when transforming + * from pixel/line to georeferenced coordinates. + * @param nPointCount the number of values in the x, y and z arrays. + * @param x array containing the X values to be transformed. + * @param y array containing the Y values to be transformed. + * @param z array containing the Z values to be transformed. + * @param panSuccess array in which a flag indicating success (TRUE) or + * failure (FALSE) of the transformation are placed. + * + * @return TRUE. + */ + +int GDALTPSTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *x, double *y, double *z, + int *panSuccess ) + +{ + int i; + TPSTransformInfo *psInfo = (TPSTransformInfo *) pTransformArg; + + for( i = 0; i < nPointCount; i++ ) + { + double xy_out[2]; + + if( bDstToSrc ) + { + psInfo->poReverse->get_point( x[i], y[i], xy_out ); + x[i] = xy_out[0]; + y[i] = xy_out[1]; + } + else + { + psInfo->poForward->get_point( x[i], y[i], xy_out ); + x[i] = xy_out[0]; + y[i] = xy_out[1]; + } + panSuccess[i] = TRUE; + } + + return TRUE; +} + +/************************************************************************/ +/* GDALSerializeTPSTransformer() */ +/************************************************************************/ + +CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg ) + +{ + CPLXMLNode *psTree; + TPSTransformInfo *psInfo = (TPSTransformInfo *) pTransformArg; + + psTree = CPLCreateXMLNode( NULL, CXT_Element, "TPSTransformer" ); + +/* -------------------------------------------------------------------- */ +/* Serialize bReversed. */ +/* -------------------------------------------------------------------- */ + CPLCreateXMLElementAndValue( + psTree, "Reversed", + CPLSPrintf( "%d", psInfo->bReversed ) ); + +/* -------------------------------------------------------------------- */ +/* Attach GCP List. */ +/* -------------------------------------------------------------------- */ + if( psInfo->nGCPCount > 0 ) + { + int iGCP; + CPLXMLNode *psGCPList = CPLCreateXMLNode( psTree, CXT_Element, + "GCPList" ); + + for( iGCP = 0; iGCP < psInfo->nGCPCount; iGCP++ ) + { + CPLXMLNode *psXMLGCP; + GDAL_GCP *psGCP = psInfo->pasGCPList + iGCP; + + psXMLGCP = CPLCreateXMLNode( psGCPList, CXT_Element, "GCP" ); + + CPLSetXMLValue( psXMLGCP, "#Id", psGCP->pszId ); + + if( psGCP->pszInfo != NULL && strlen(psGCP->pszInfo) > 0 ) + CPLSetXMLValue( psXMLGCP, "Info", psGCP->pszInfo ); + + CPLSetXMLValue( psXMLGCP, "#Pixel", + CPLSPrintf( "%.4f", psGCP->dfGCPPixel ) ); + + CPLSetXMLValue( psXMLGCP, "#Line", + CPLSPrintf( "%.4f", psGCP->dfGCPLine ) ); + + CPLSetXMLValue( psXMLGCP, "#X", + CPLSPrintf( "%.12E", psGCP->dfGCPX ) ); + + CPLSetXMLValue( psXMLGCP, "#Y", + CPLSPrintf( "%.12E", psGCP->dfGCPY ) ); + + if( psGCP->dfGCPZ != 0.0 ) + CPLSetXMLValue( psXMLGCP, "#GCPZ", + CPLSPrintf( "%.12E", psGCP->dfGCPZ ) ); + } + } + + return psTree; +} + +/************************************************************************/ +/* GDALDeserializeTPSTransformer() */ +/************************************************************************/ + +void *GDALDeserializeTPSTransformer( CPLXMLNode *psTree ) + +{ + GDAL_GCP *pasGCPList = 0; + int nGCPCount = 0; + void *pResult; + int bReversed; + + /* -------------------------------------------------------------------- */ + /* Check for GCPs. */ + /* -------------------------------------------------------------------- */ + CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" ); + + if( psGCPList != NULL ) + { + int nGCPMax = 0; + CPLXMLNode *psXMLGCP; + + // Count GCPs. + for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; + psXMLGCP = psXMLGCP->psNext ) + nGCPMax++; + + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax); + + for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL; + psXMLGCP = psXMLGCP->psNext ) + { + GDAL_GCP *psGCP = pasGCPList + nGCPCount; + + if( !EQUAL(psXMLGCP->pszValue,"GCP") || + psXMLGCP->eType != CXT_Element ) + continue; + + GDALInitGCPs( 1, psGCP ); + + CPLFree( psGCP->pszId ); + psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id","")); + + CPLFree( psGCP->pszInfo ); + psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info","")); + + psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0")); + psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0")); + + psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0")); + psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0")); + psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0")); + nGCPCount++; + } + } + +/* -------------------------------------------------------------------- */ +/* Get other flags. */ +/* -------------------------------------------------------------------- */ + bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); + +/* -------------------------------------------------------------------- */ +/* Generate transformation. */ +/* -------------------------------------------------------------------- */ + pResult = GDALCreateTPSTransformer( nGCPCount, pasGCPList, bReversed ); + +/* -------------------------------------------------------------------- */ +/* Cleanup GCP copy. */ +/* -------------------------------------------------------------------- */ + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + + return pResult; +} diff --git a/Utilities/GDAL/alg/gdalchecksum.cpp b/Utilities/GDAL/alg/gdalchecksum.cpp new file mode 100644 index 0000000000..e7d1ff224f --- /dev/null +++ b/Utilities/GDAL/alg/gdalchecksum.cpp @@ -0,0 +1,117 @@ +/****************************************************************************** + * $Id: gdalchecksum.cpp,v 1.5 2005/04/04 15:24:16 fwarmerdam Exp $ + * + * Project: GDAL + * Purpose: Compute simple checksum for a region of image data. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, 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: gdalchecksum.cpp,v $ + * Revision 1.5 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.4 2004/12/30 20:40:54 fwarmerdam + * Added documentation. + * + * Revision 1.3 2003/05/02 16:02:06 dron + * Memory leak fixed. + * + * Revision 1.2 2003/03/13 16:47:20 warmerda + * fixed bug in non-complex case + * + * Revision 1.1 2003/03/02 03:56:21 warmerda + * New + * + */ + +#include "gdal_alg.h" +#include "cpl_conv.h" + +CPL_CVSID("$Id: gdalchecksum.cpp,v 1.5 2005/04/04 15:24:16 fwarmerdam Exp $"); + +/************************************************************************/ +/* GDALChecksumImage() */ +/************************************************************************/ + +/** + * Compute checksum for image region. + * + * Computes a 16bit (0-65535) checksum from a region of raster data on a GDAL + * supported band. Floating point data is converted to 32bit integer + * so decimal portions of such raster data will not affect the checksum. + * Real and Imaginary components of complex bands influence the result. + * + * @param hBand the raster band to read from. + * @param nXOff pixel offset of window to read. + * @param nYOff line offset of window to read. + * @param nXSize pixel size of window to read. + * @param nYSize line size of window to read. + * + * @return Checksum value. + */ + +int CPL_STDCALL +GDALChecksumImage( GDALRasterBandH hBand, + int nXOff, int nYOff, int nXSize, int nYSize ) + +{ + const static int anPrimes[11] = + { 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43 }; + + int iLine, i, nChecksum = 0, iPrime = 0, nCount; + int *panLineData; + int bComplex = GDALDataTypeIsComplex( GDALGetRasterDataType( hBand ) ); + + panLineData = (GInt32 *) CPLMalloc(nXSize * sizeof(GInt32) * 2); + + for( iLine = nYOff; iLine < nYOff + nYSize; iLine++ ) + { + if( bComplex ) + { + GDALRasterIO( hBand, GF_Read, nXOff, iLine, nXSize, 1, + panLineData, nXSize, 1, GDT_CInt32, 0, 0 ); + nCount = nXSize * 2; + } + else + { + GDALRasterIO( hBand, GF_Read, nXOff, iLine, nXSize, 1, + panLineData, nXSize, 1, GDT_Int32, 0, 0 ); + nCount = nXSize; + } + + for( i = 0; i < nCount; i++ ) + { + nChecksum += (panLineData[i] % anPrimes[iPrime++]); + if( iPrime > 10 ) + iPrime = 0; + + nChecksum &= 0xffff; + } + } + + CPLFree( panLineData ); + + return nChecksum; +} + diff --git a/Utilities/GDAL/alg/gdaldither.cpp b/Utilities/GDAL/alg/gdaldither.cpp new file mode 100644 index 0000000000..c7b62659a7 --- /dev/null +++ b/Utilities/GDAL/alg/gdaldither.cpp @@ -0,0 +1,378 @@ +/****************************************************************************** + * $Id: gdaldither.cpp,v 1.7 2005/04/04 15:24:16 fwarmerdam Exp $ + * + * Project: CIETMap Phase 2 + * Purpose: Convert RGB (24bit) to a pseudo-colored approximation using + * Floyd-Steinberg dithering (error diffusion). + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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. + ****************************************************************************** + * + * Notes: + * + * [1] Floyd-Steinberg dither: + * I should point out that the actual fractions we used were, assuming + * you are at X, moving left to right: + * + * X 7/16 + * 3/16 5/16 1/16 + * + * Note that the error goes to four neighbors, not three. I think this + * will probably do better (at least for black and white) than the + * 3/8-3/8-1/4 distribution, at the cost of greater processing. I have + * seen the 3/8-3/8-1/4 distribution described as "our" algorithm before, + * but I have no idea who the credit really belongs to. + * -- + * Lou Steinberg + * + * $Log: gdaldither.cpp,v $ + * Revision 1.7 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.6 2004/04/27 13:38:07 warmerda + * Fixed typo in docs. + * + * Revision 1.5 2003/07/08 15:27:47 warmerda + * avoid warnings + * + * Revision 1.4 2003/03/02 05:24:53 warmerda + * fixed comment + * + * Revision 1.3 2003/02/06 04:56:35 warmerda + * added documentation + * + * Revision 1.2 2001/07/18 04:43:13 warmerda + * added CPL_CVSID + * + * Revision 1.1 2001/01/22 22:30:59 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" + +CPL_CVSID("$Id: gdaldither.cpp,v 1.7 2005/04/04 15:24:16 fwarmerdam Exp $"); + +#define C_LEVELS 32 +#define C_SHIFT 3 + +static void FindNearestColor( int nColors, int *panPCT, GByte *pabyColorMap ); + +/************************************************************************/ +/* GDALDitherRGB2PCT() */ +/************************************************************************/ + +/** + * 24bit to 8bit conversion with dithering. + * + * This functions utilizes Floyd-Steinberg dithering in the process of + * converting a 24bit RGB image into a pseudocolored 8bit image using a + * provided color table. + * + * The red, green and blue input bands do not necessarily need to come + * from the same file, but they must be the same width and height. They will + * be clipped to 8bit during reading, so non-eight bit bands are generally + * inappropriate. Likewise the hTarget band will be written with 8bit values + * and must match the width and height of the source bands. + * + * @param hRed Red input band. + * @param hGreen Green input band. + * @param hBlue Blue input band. + * @param hTarget Output band. + * @param hColorTable the color table to use with the output band. + * @param pfnProgress callback for reporting algorithm progress matching the + * GDALProgressFunc() semantics. May be NULL. + * @param pProgressArg callback argument passed to pfnProgress. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +int CPL_STDCALL +GDALDitherRGB2PCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + GDALRasterBandH hTarget, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ) + +{ + int nXSize, nYSize; + +/* -------------------------------------------------------------------- */ +/* Validate parameters. */ +/* -------------------------------------------------------------------- */ + nXSize = GDALGetRasterBandXSize( hRed ); + nYSize = GDALGetRasterBandYSize( hRed ); + + if( GDALGetRasterBandXSize( hGreen ) != nXSize + || GDALGetRasterBandYSize( hGreen ) != nYSize + || GDALGetRasterBandXSize( hBlue ) != nXSize + || GDALGetRasterBandYSize( hBlue ) != nYSize ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "Green or blue band doesn't match size of red band.\n" ); + + return CE_Failure; + } + + if( GDALGetRasterBandXSize( hTarget ) != nXSize + || GDALGetRasterBandYSize( hTarget ) != nYSize ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALDitherRGB2PCT(): " + "Target band doesn't match size of source bands.\n" ); + + return CE_Failure; + } + + if( pfnProgress == NULL ) + pfnProgress = GDALDummyProgress; + +/* -------------------------------------------------------------------- */ +/* Setup more direct colormap. */ +/* -------------------------------------------------------------------- */ + int nColors, anPCT[768], iColor; + + nColors = GDALGetColorEntryCount( hColorTable ); + for( iColor = 0; iColor < nColors; iColor++ ) + { + GDALColorEntry sEntry; + + GDALGetColorEntryAsRGB( hColorTable, iColor, &sEntry ); + + anPCT[iColor ] = sEntry.c1; + anPCT[iColor+256] = sEntry.c2; + anPCT[iColor+512] = sEntry.c3; + } + +/* -------------------------------------------------------------------- */ +/* Build a 24bit to 8 bit color mapping. */ +/* -------------------------------------------------------------------- */ + GByte *pabyColorMap; + + pabyColorMap = (GByte *) CPLMalloc(C_LEVELS * C_LEVELS * C_LEVELS + * sizeof(int)); + + FindNearestColor( nColors, anPCT, pabyColorMap ); + +/* -------------------------------------------------------------------- */ +/* Setup various variables. */ +/* -------------------------------------------------------------------- */ + GByte *pabyRed, *pabyGreen, *pabyBlue, *pabyIndex; + int *panError; + + pabyRed = (GByte *) CPLMalloc(nXSize); + pabyGreen = (GByte *) CPLMalloc(nXSize); + pabyBlue = (GByte *) CPLMalloc(nXSize); + + pabyIndex = (GByte *) CPLMalloc(nXSize); + + panError = (int *) CPLCalloc(sizeof(int),(nXSize+2) * 3); + +/* ==================================================================== */ +/* Loop over all scanlines of data to process. */ +/* ==================================================================== */ + int iScanline; + + for( iScanline = 0; iScanline < nYSize; iScanline++ ) + { + int nLastRedError, nLastGreenError, nLastBlueError, i; + +/* -------------------------------------------------------------------- */ +/* Report progress */ +/* -------------------------------------------------------------------- */ + if( !pfnProgress( iScanline / (double) nYSize, NULL, pProgressArg ) ) + { + CPLFree( pabyRed ); + CPLFree( pabyGreen ); + CPLFree( pabyBlue ); + CPLFree( panError ); + CPLFree( pabyIndex ); + CPLFree( pabyColorMap ); + + CPLError( CE_Failure, CPLE_UserInterrupt, "User Terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Read source data. */ +/* -------------------------------------------------------------------- */ + GDALRasterIO( hRed, GF_Read, 0, iScanline, nXSize, 1, + pabyRed, nXSize, 1, GDT_Byte, 0, 0 ); + GDALRasterIO( hGreen, GF_Read, 0, iScanline, nXSize, 1, + pabyGreen, nXSize, 1, GDT_Byte, 0, 0 ); + GDALRasterIO( hBlue, GF_Read, 0, iScanline, nXSize, 1, + pabyBlue, nXSize, 1, GDT_Byte, 0, 0 ); + +/* -------------------------------------------------------------------- */ +/* Apply the error from the previous line to this one. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nXSize; i++ ) + { + pabyRed[i] = (GByte) + MAX(0,MIN(255,(pabyRed[i] + panError[i*3+0+3]))); + pabyGreen[i] = (GByte) + MAX(0,MIN(255,(pabyGreen[i] + panError[i*3+1+3]))); + pabyBlue[i] = (GByte) + MAX(0,MIN(255,(pabyBlue[i] + panError[i*3+2+3]))); + } + + memset( panError, 0, sizeof(int) * (nXSize+2) * 3 ); + +/* -------------------------------------------------------------------- */ +/* Figure out the nearest color to the RGB value. */ +/* -------------------------------------------------------------------- */ + nLastRedError = 0; + nLastGreenError = 0; + nLastBlueError = 0; + + for( i = 0; i < nXSize; i++ ) + { + int iIndex, nError, nSixth, iRed, iGreen, iBlue; + int nRedValue, nGreenValue, nBlueValue; + + nRedValue = MAX(0,MIN(255, pabyRed[i] + nLastRedError)); + nGreenValue = MAX(0,MIN(255, pabyGreen[i] + nLastGreenError)); + nBlueValue = MAX(0,MIN(255, pabyBlue[i] + nLastBlueError)); + + iRed = nRedValue * C_LEVELS / 256; + iGreen = nGreenValue * C_LEVELS / 256; + iBlue = nBlueValue * C_LEVELS / 256; + + iIndex = pabyColorMap[iRed + iGreen * C_LEVELS + + iBlue * C_LEVELS * C_LEVELS]; + + pabyIndex[i] = (GByte) iIndex; + +/* -------------------------------------------------------------------- */ +/* Compute Red error, and carry it on to the next error line. */ +/* -------------------------------------------------------------------- */ + nError = nRedValue - anPCT[iIndex ]; + nSixth = nError / 6; + + panError[i*3 ] += nSixth; + panError[i*3+6 ] = nSixth; + panError[i*3+3 ] += nError - 5 * nSixth; + + nLastRedError = 2 * nSixth; + +/* -------------------------------------------------------------------- */ +/* Compute Green error, and carry it on to the next error line. */ +/* -------------------------------------------------------------------- */ + nError = nGreenValue - anPCT[iIndex+256]; + nSixth = nError / 6; + + panError[i*3 +1] += nSixth; + panError[i*3+6+1] = nSixth; + panError[i*3+3+1] += nError - 5 * nSixth; + + nLastGreenError = 2 * nSixth; + +/* -------------------------------------------------------------------- */ +/* Compute Blue error, and carry it on to the next error line. */ +/* -------------------------------------------------------------------- */ + nError = nBlueValue - anPCT[iIndex+512]; + nSixth = nError / 6; + + panError[i*3 +2] += nSixth; + panError[i*3+6+2] = nSixth; + panError[i*3+3+2] += nError - 5 * nSixth; + + nLastBlueError = 2 * nSixth; + } + +/* -------------------------------------------------------------------- */ +/* Write results. */ +/* -------------------------------------------------------------------- */ + GDALRasterIO( hTarget, GF_Write, 0, iScanline, nXSize, 1, + pabyIndex, nXSize, 1, GDT_Byte, 0, 0 ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup */ +/* -------------------------------------------------------------------- */ + CPLFree( pabyRed ); + CPLFree( pabyGreen ); + CPLFree( pabyBlue ); + CPLFree( pabyIndex ); + CPLFree( panError ); + + CPLFree( pabyColorMap ); + + pfnProgress( 1.0, NULL, pProgressArg ); + + return CE_None; +} + +/************************************************************************/ +/* FindNearestColor() */ +/* */ +/* Finear near PCT color for any RGB color. */ +/************************************************************************/ + +static void FindNearestColor( int nColors, int *panPCT, GByte *pabyColorMap ) + +{ + int iBlue, iGreen, iRed; + int iColor; + +/* -------------------------------------------------------------------- */ +/* Loop over all the cells in the high density cube. */ +/* -------------------------------------------------------------------- */ + for( iBlue = 0; iBlue < C_LEVELS; iBlue++ ) + { + for( iGreen = 0; iGreen < C_LEVELS; iGreen++ ) + { + for( iRed = 0; iRed < C_LEVELS; iRed++ ) + { + int nRedValue, nGreenValue, nBlueValue; + int nBestDist = 768, nBestIndex = 0; + + nRedValue = (iRed * 255) / (C_LEVELS-1); + nGreenValue = (iGreen * 255) / (C_LEVELS-1); + nBlueValue = (iBlue * 255) / (C_LEVELS-1); + + for( iColor = 0; iColor < nColors; iColor++ ) + { + int nThisDist; + + nThisDist = ABS(nRedValue - panPCT[iColor ]) + + ABS(nGreenValue - panPCT[iColor+256]) + + ABS(nBlueValue - panPCT[iColor+512]); + + if( nThisDist < nBestDist ) + { + nBestIndex = iColor; + nBestDist = nThisDist; + } + } + + pabyColorMap[iRed + iGreen*C_LEVELS + + iBlue*C_LEVELS*C_LEVELS] = (GByte)nBestIndex; + } + } + } +} + diff --git a/Utilities/GDAL/alg/gdalmediancut.cpp b/Utilities/GDAL/alg/gdalmediancut.cpp new file mode 100644 index 0000000000..2c1466cc71 --- /dev/null +++ b/Utilities/GDAL/alg/gdalmediancut.cpp @@ -0,0 +1,539 @@ +/****************************************************************************** + * $Id: gdalmediancut.cpp,v 1.6 2005/04/04 15:24:16 fwarmerdam Exp $ + * + * Project: CIETMap Phase 2 + * Purpose: Use median cut algorithm to generate an near-optimal PCT for a + * given RGB image. Implemented as function GDALComputeMedianCutPCT. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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. + ****************************************************************************** + * + * This code was based on the tiffmedian.c code from libtiff (www.libtiff.org) + * which was based on a paper by Paul Heckbert: + * + * "Color Image Quantization for Frame Buffer Display", Paul + * Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307. + * + * $Log: gdalmediancut.cpp,v $ + * Revision 1.6 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.5 2003/07/08 15:28:32 warmerda + * avoid warnings + * + * Revision 1.4 2003/02/06 04:56:35 warmerda + * added documentation + * + * Revision 1.3 2002/04/16 17:48:36 warmerda + * Ensure everything is initialized. + * + * Revision 1.2 2001/07/18 04:43:13 warmerda + * added CPL_CVSID + * + * Revision 1.1 2001/01/22 22:30:59 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" + +CPL_CVSID("$Id: gdalmediancut.cpp,v 1.6 2005/04/04 15:24:16 fwarmerdam Exp $"); + +#define MAX_CMAP_SIZE 256 + +#define COLOR_DEPTH 8 +#define MAX_COLOR 256 + +#define GMC_B_DEPTH 5 /* # bits/pixel to use */ +#define GMC_B_LEN (1L<<GMC_B_DEPTH) + +#define C_DEPTH 2 +#define C_LEN (1L<<C_DEPTH) /* # cells/color to use */ + +#define COLOR_SHIFT (COLOR_DEPTH-GMC_B_DEPTH) + +typedef struct colorbox { + struct colorbox *next, *prev; + int rmin, rmax; + int gmin, gmax; + int bmin, bmax; + int total; +} Colorbox; + +static int num_colors; +static int (*histogram)[GMC_B_LEN][GMC_B_LEN]; +static Colorbox *freeboxes; +static Colorbox *usedboxes; + +static void splitbox(Colorbox*); +static void shrinkbox(Colorbox*); +static Colorbox* largest_box(void); + +/************************************************************************/ +/* GDALComputeMedianCutPCT() */ +/************************************************************************/ + +/** + * Compute optimal PCT for RGB image. + * + * This function implements a median cut algorithm to compute an "optimal" + * pseudocolor table for representing an input RGB image. This PCT could + * then be used with GDALDitherRGB2PCT() to convert a 24bit RGB image into + * an eightbit pseudo-colored image. + * + * This code was based on the tiffmedian.c code from libtiff (www.libtiff.org) + * which was based on a paper by Paul Heckbert: + * + * \verbatim + * "Color Image Quantization for Frame Buffer Display", Paul + * Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307. + * \endverbatim + * + * The red, green and blue input bands do not necessarily need to come + * from the same file, but they must be the same width and height. They will + * be clipped to 8bit during reading, so non-eight bit bands are generally + * inappropriate. + * + * @param hRed Red input band. + * @param hGreen Green input band. + * @param hBlue Blue input band. + * @param pfnIncludePixel function used to test which pixels should be included + * in the analysis. At this time this argument is ignored and all pixels are + * utilized. This should normally be NULL. + * @param nColors the desired number of colors to be returned (2-256). + * @param hColorTable the colors will be returned in this color table object. + * @param pfnProgress callback for reporting algorithm progress matching the + * GDALProgressFunc() semantics. May be NULL. + * @param pProgressArg callback argument passed to pfnProgress. + * + * @return returns CE_None on success or CE_Failure if an error occurs. + */ + +int CPL_STDCALL +GDALComputeMedianCutPCT( GDALRasterBandH hRed, + GDALRasterBandH hGreen, + GDALRasterBandH hBlue, + int (*pfnIncludePixel)(int,int,void*), + int nColors, + GDALColorTableH hColorTable, + GDALProgressFunc pfnProgress, + void * pProgressArg ) + +{ + int nXSize, nYSize; + +/* -------------------------------------------------------------------- */ +/* Validate parameters. */ +/* -------------------------------------------------------------------- */ + nXSize = GDALGetRasterBandXSize( hRed ); + nYSize = GDALGetRasterBandYSize( hRed ); + + if( GDALGetRasterBandXSize( hGreen ) != nXSize + || GDALGetRasterBandYSize( hGreen ) != nYSize + || GDALGetRasterBandXSize( hBlue ) != nXSize + || GDALGetRasterBandYSize( hBlue ) != nYSize ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "Green or blue band doesn't match size of red band.\n" ); + + return CE_Failure; + } + + if( pfnIncludePixel != NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALComputeMedianCutPCT() doesn't currently support " + " pfnIncludePixel function." ); + + return CE_Failure; + } + + if( pfnProgress == NULL ) + pfnProgress = GDALDummyProgress; + + histogram = (int (*)[GMC_B_LEN][GMC_B_LEN]) + CPLCalloc(GMC_B_LEN * GMC_B_LEN * GMC_B_LEN,sizeof(int)); + +/* ==================================================================== */ +/* STEP 1: crate empty boxes. */ +/* ==================================================================== */ + int i; + Colorbox *box_list, *ptr; + + num_colors = nColors; + usedboxes = NULL; + box_list = freeboxes = (Colorbox *)CPLMalloc(num_colors*sizeof (Colorbox)); + freeboxes[0].next = &freeboxes[1]; + freeboxes[0].prev = NULL; + for (i = 1; i < num_colors-1; ++i) { + freeboxes[i].next = &freeboxes[i+1]; + freeboxes[i].prev = &freeboxes[i-1]; + } + freeboxes[num_colors-1].next = NULL; + freeboxes[num_colors-1].prev = &freeboxes[num_colors-2]; + +/* ==================================================================== */ +/* Build histogram. */ +/* ==================================================================== */ + GByte *pabyRedLine, *pabyGreenLine, *pabyBlueLine; + int iLine, iPixel; + +/* -------------------------------------------------------------------- */ +/* Initialize the box datastructures. */ +/* -------------------------------------------------------------------- */ + ptr = freeboxes; + freeboxes = ptr->next; + if (freeboxes) + freeboxes->prev = NULL; + ptr->next = usedboxes; + usedboxes = ptr; + if (ptr->next) + ptr->next->prev = ptr; + + ptr->rmin = ptr->gmin = ptr->bmin = 999; + ptr->rmax = ptr->gmax = ptr->bmax = -1; + ptr->total = nXSize * nYSize; + + memset( histogram, 0, sizeof(int) * GMC_B_LEN * GMC_B_LEN * GMC_B_LEN ); + +/* -------------------------------------------------------------------- */ +/* Collect histogram. */ +/* -------------------------------------------------------------------- */ + pabyRedLine = (GByte *) CPLMalloc(nXSize); + pabyGreenLine = (GByte *) CPLMalloc(nXSize); + pabyBlueLine = (GByte *) CPLMalloc(nXSize); + + for( iLine = 0; iLine < nYSize; iLine++ ) + { + if( !pfnProgress( iLine / (double) nYSize, + "Generating Histogram", pProgressArg ) ) + { + CPLFree( pabyRedLine ); + CPLFree( pabyGreenLine ); + CPLFree( pabyBlueLine ); + + CPLError( CE_Failure, CPLE_UserInterrupt, "User Terminated" ); + return CE_Failure; + } + + GDALRasterIO( hRed, GF_Read, 0, iLine, nXSize, 1, + pabyRedLine, nXSize, 1, GDT_Byte, 0, 0 ); + GDALRasterIO( hGreen, GF_Read, 0, iLine, nXSize, 1, + pabyGreenLine, nXSize, 1, GDT_Byte, 0, 0 ); + GDALRasterIO( hBlue, GF_Read, 0, iLine, nXSize, 1, + pabyBlueLine, nXSize, 1, GDT_Byte, 0, 0 ); + + for( iPixel = 0; iPixel < nXSize; iPixel++ ) + { + int nRed, nGreen, nBlue; + + nRed = pabyRedLine[iPixel] >> COLOR_SHIFT; + nGreen = pabyGreenLine[iPixel] >> COLOR_SHIFT; + nBlue = pabyBlueLine[iPixel] >> COLOR_SHIFT; + + ptr->rmin = MIN(ptr->rmin, nRed); + ptr->gmin = MIN(ptr->gmin, nGreen); + ptr->bmin = MIN(ptr->bmin, nBlue); + ptr->rmax = MAX(ptr->rmax, nRed); + ptr->gmax = MAX(ptr->gmax, nGreen); + ptr->bmax = MAX(ptr->bmax, nBlue); + + histogram[nRed][nGreen][nBlue]++; + } + } + + CPLFree( pabyRedLine ); + CPLFree( pabyGreenLine ); + CPLFree( pabyBlueLine ); + + if( !pfnProgress( 1.0, "Generating Histogram", pProgressArg ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User Terminated" ); + return CE_Failure; + } + +/* ==================================================================== */ +/* STEP 3: continually subdivide boxes until no more free */ +/* boxes remain or until all colors assigned. */ +/* ==================================================================== */ + while (freeboxes != NULL) { + ptr = largest_box(); + if (ptr != NULL) + splitbox(ptr); + else + freeboxes = NULL; + } + +/* ==================================================================== */ +/* STEP 4: assign colors to all boxes */ +/* ==================================================================== */ + for (i = 0, ptr = usedboxes; ptr != NULL; ++i, ptr = ptr->next) + { + GDALColorEntry sEntry; + + sEntry.c1 = (GByte) (((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2); + sEntry.c2 = (GByte) (((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2); + sEntry.c3 = (GByte) (((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2); + GDALSetColorEntry( hColorTable, i, &sEntry ); + } + + /* We're done with the boxes now */ + CPLFree(box_list); + freeboxes = usedboxes = NULL; + + CPLFree( histogram ); + + return CE_None; +} + +/************************************************************************/ +/* largest_box() */ +/************************************************************************/ + +static Colorbox * +largest_box(void) +{ + register Colorbox *p, *b; + register int size; + + b = NULL; + size = -1; + for (p = usedboxes; p != NULL; p = p->next) + if ((p->rmax > p->rmin || p->gmax > p->gmin || + p->bmax > p->bmin) && p->total > size) + size = (b = p)->total; + return (b); +} + +/************************************************************************/ +/* splitbox() */ +/************************************************************************/ +static void +splitbox(Colorbox* ptr) +{ + int hist2[GMC_B_LEN]; + int first=0, last=0; + register Colorbox *new_cb; + register int *iptr, *histp; + register int i, j; + register int ir,ig,ib; + register int sum, sum1, sum2; + enum { RED, GREEN, BLUE } axis; + + /* + * See which axis is the largest, do a histogram along that + * axis. Split at median point. Contract both new boxes to + * fit points and return + */ + i = ptr->rmax - ptr->rmin; + if (i >= ptr->gmax - ptr->gmin && i >= ptr->bmax - ptr->bmin) + axis = RED; + else if (ptr->gmax - ptr->gmin >= ptr->bmax - ptr->bmin) + axis = GREEN; + else + axis = BLUE; + /* get histogram along longest axis */ + switch (axis) { + case RED: + histp = &hist2[ptr->rmin]; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + *histp = 0; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + iptr = &histogram[ir][ig][ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) + *histp += *iptr++; + } + histp++; + } + first = ptr->rmin; + last = ptr->rmax; + break; + case GREEN: + histp = &hist2[ptr->gmin]; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + *histp = 0; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + iptr = &histogram[ir][ig][ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) + *histp += *iptr++; + } + histp++; + } + first = ptr->gmin; + last = ptr->gmax; + break; + case BLUE: + histp = &hist2[ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) { + *histp = 0; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + iptr = &histogram[ir][ptr->gmin][ib]; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + *histp += *iptr; + iptr += GMC_B_LEN; + } + } + histp++; + } + first = ptr->bmin; + last = ptr->bmax; + break; + } + /* find median point */ + sum2 = ptr->total / 2; + histp = &hist2[first]; + sum = 0; + for (i = first; i <= last && (sum += *histp++) < sum2; ++i) + ; + if (i == first) + i++; + + /* Create new box, re-allocate points */ + new_cb = freeboxes; + freeboxes = new_cb->next; + if (freeboxes) + freeboxes->prev = NULL; + if (usedboxes) + usedboxes->prev = new_cb; + new_cb->next = usedboxes; + usedboxes = new_cb; + + histp = &hist2[first]; + for (sum1 = 0, j = first; j < i; j++) + sum1 += *histp++; + for (sum2 = 0, j = i; j <= last; j++) + sum2 += *histp++; + new_cb->total = sum1; + ptr->total = sum2; + + new_cb->rmin = ptr->rmin; + new_cb->rmax = ptr->rmax; + new_cb->gmin = ptr->gmin; + new_cb->gmax = ptr->gmax; + new_cb->bmin = ptr->bmin; + new_cb->bmax = ptr->bmax; + switch (axis) { + case RED: + new_cb->rmax = i-1; + ptr->rmin = i; + break; + case GREEN: + new_cb->gmax = i-1; + ptr->gmin = i; + break; + case BLUE: + new_cb->bmax = i-1; + ptr->bmin = i; + break; + } + shrinkbox(new_cb); + shrinkbox(ptr); +} + +/************************************************************************/ +/* shrinkbox() */ +/************************************************************************/ +static void +shrinkbox(Colorbox* box) +{ + register int *histp, ir, ig, ib; + + if (box->rmax > box->rmin) { + for (ir = box->rmin; ir <= box->rmax; ++ir) + for (ig = box->gmin; ig <= box->gmax; ++ig) { + histp = &histogram[ir][ig][box->bmin]; + for (ib = box->bmin; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->rmin = ir; + goto have_rmin; + } + } + have_rmin: + if (box->rmax > box->rmin) + for (ir = box->rmax; ir >= box->rmin; --ir) + for (ig = box->gmin; ig <= box->gmax; ++ig) { + histp = &histogram[ir][ig][box->bmin]; + ib = box->bmin; + for (; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->rmax = ir; + goto have_rmax; + } + } + } + have_rmax: + if (box->gmax > box->gmin) { + for (ig = box->gmin; ig <= box->gmax; ++ig) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][ig][box->bmin]; + for (ib = box->bmin; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->gmin = ig; + goto have_gmin; + } + } + have_gmin: + if (box->gmax > box->gmin) + for (ig = box->gmax; ig >= box->gmin; --ig) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][ig][box->bmin]; + ib = box->bmin; + for (; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->gmax = ig; + goto have_gmax; + } + } + } + have_gmax: + if (box->bmax > box->bmin) { + for (ib = box->bmin; ib <= box->bmax; ++ib) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][box->gmin][ib]; + for (ig = box->gmin; ig <= box->gmax; ++ig) { + if (*histp != 0) { + box->bmin = ib; + goto have_bmin; + } + histp += GMC_B_LEN; + } + } + have_bmin: + if (box->bmax > box->bmin) + for (ib = box->bmax; ib >= box->bmin; --ib) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][box->gmin][ib]; + ig = box->gmin; + for (; ig <= box->gmax; ++ig) { + if (*histp != 0) { + box->bmax = ib; + goto have_bmax; + } + histp += GMC_B_LEN; + } + } + } + have_bmax: + ; +} diff --git a/Utilities/GDAL/alg/gdalrasterize.cpp b/Utilities/GDAL/alg/gdalrasterize.cpp new file mode 100644 index 0000000000..8974deee9d --- /dev/null +++ b/Utilities/GDAL/alg/gdalrasterize.cpp @@ -0,0 +1,408 @@ +/****************************************************************************** + * $Id: gdalrasterize.cpp,v 1.2 2005/10/28 18:30:28 fwarmerdam Exp $ + * + * Project: GDAL + * Purpose: Vector rasterization. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdalrasterize.cpp,v $ + * Revision 1.2 2005/10/28 18:30:28 fwarmerdam + * added progress func for rasterize + * + * Revision 1.1 2005/10/28 17:46:08 fwarmerdam + * New + * + */ + +#include "gdal_alg.h" +#include "gdal_priv.h" +#include "ogr_geometry.h" +#include "ogr_api.h" +#include <vector> + +typedef struct { + unsigned char * pabyChunkBuf; + int nXSize; + int nYSize; + int nBands; + GDALDataType eType; + double *padfBurnValue; +} GDALRasterizeInfo; + +/************************************************************************/ +/* gvBurnScanline() */ +/************************************************************************/ + +void gvBurnScanline( void *pCBData, int nY, int nXStart, int nXEnd ) + +{ + GDALRasterizeInfo *psInfo = (GDALRasterizeInfo *) pCBData; + int iBand; + + if( nXStart > nXEnd ) + return; + + CPLAssert( nY >= 0 && nY < psInfo->nYSize ); + CPLAssert( nXStart <= nXEnd ); + CPLAssert( nXStart < psInfo->nXSize ); + + /* CPLAssert( nXEnd > 0 ); */ + CPLAssert( nXEnd >= 0 ); + + if( nXStart < 0 ) + nXStart = 0; + if( nXEnd >= psInfo->nXSize ) + nXEnd = psInfo->nXSize - 1; + + if( psInfo->eType == GDT_Byte ) + { + for( iBand = 0; iBand < psInfo->nBands; iBand++ ) + { + unsigned char *pabyInsert; + unsigned char nBurnValue = (unsigned char) + psInfo->padfBurnValue[iBand]; + + pabyInsert = psInfo->pabyChunkBuf + + iBand * psInfo->nXSize * psInfo->nYSize + + nY * psInfo->nXSize + nXStart; + + memset( pabyInsert, nBurnValue, nXEnd - nXStart + 1 ); + } + } + else + { + for( iBand = 0; iBand < psInfo->nBands; iBand++ ) + { + int nPixels = nXEnd - nXStart + 1; + float *pafInsert; + float fBurnValue = (float) psInfo->padfBurnValue[iBand]; + + pafInsert = ((float *) psInfo->pabyChunkBuf) + + iBand * psInfo->nXSize * psInfo->nYSize + + nY * psInfo->nXSize + nXStart; + + while( nPixels-- > 0 ) + *(pafInsert++) = fBurnValue; + } + } +} + +/************************************************************************/ +/* GDALCollectRingsFromGeometry() */ +/************************************************************************/ + +static void GDALCollectRingsFromGeometry( + OGRGeometry *poShape, + std::vector<double> &aPointX, std::vector<double> &aPointY, + std::vector<int> &aPartSize ) + +{ + if( poShape == NULL ) + return; + + OGRwkbGeometryType eFlatType = wkbFlatten(poShape->getGeometryType()); + int i; + + if( EQUAL(poShape->getGeometryName(),"LINEARRING") ) + { + OGRLinearRing *poRing = (OGRLinearRing *) poShape; + int nOldCount = aPointX.size(); + + aPointX.reserve(nOldCount + poRing->getNumPoints()); + aPointY.reserve(nOldCount + poRing->getNumPoints()); + for( i = poRing->getNumPoints()-1; i >= 0; i-- ) + { + aPointX.push_back( poRing->getX(i) ); + aPointY.push_back( poRing->getY(i) ); + } + aPartSize.push_back( poRing->getNumPoints() ); + } + else if( eFlatType == wkbPolygon ) + { + OGRPolygon *poPolygon = (OGRPolygon *) poShape; + + GDALCollectRingsFromGeometry( poPolygon->getExteriorRing(), + aPointX, aPointY, aPartSize ); + + for( i = 0; i < poPolygon->getNumInteriorRings(); i++ ) + GDALCollectRingsFromGeometry( poPolygon->getInteriorRing(i), + aPointX, aPointY, aPartSize ); + } + + else if( eFlatType == wkbMultiPolygon + || eFlatType == wkbGeometryCollection ) + { + OGRGeometryCollection *poGC = (OGRGeometryCollection *) poShape; + + for( i = 0; i < poGC->getNumGeometries(); i++ ) + GDALCollectRingsFromGeometry( poGC->getGeometryRef(i), + aPointX, aPointY, aPartSize ); + } + else + { + CPLDebug( "GDAL", "Rasterizer ignoring non-polygonal geometry." ); + } +} + +/************************************************************************/ +/* gv_rasterize_one_shape() */ +/************************************************************************/ +static void +gv_rasterize_new_one_shape( unsigned char *pabyChunkBuf, int nYOff, int nYSize, + int nBands, GDALDataType eType, GDALDataset *poDS, + OGRGeometry *poShape, double *padfBurnValue, + GDALTransformerFunc pfnTransformer, + void *pTransformArg ) + +{ + GDALRasterizeInfo sInfo; + + sInfo.nXSize = poDS->GetRasterXSize(); + sInfo.nYSize = nYSize; + sInfo.nBands = nBands; + sInfo.pabyChunkBuf = pabyChunkBuf; + sInfo.eType = eType; + sInfo.padfBurnValue = padfBurnValue; + +/* -------------------------------------------------------------------- */ +/* Transform polygon geometries into a set of rings and a part */ +/* size list. */ +/* -------------------------------------------------------------------- */ + std::vector<double> aPointX; + std::vector<double> aPointY; + std::vector<int> aPartSize; + + GDALCollectRingsFromGeometry( poShape, aPointX, aPointY, aPartSize ); + +/* -------------------------------------------------------------------- */ +/* Transform points if needed. */ +/* -------------------------------------------------------------------- */ + if( pfnTransformer != NULL ) + { + int *panSuccess = (int *) CPLCalloc(sizeof(int),aPointX.size()); + + // TODO: we need to add all appropriate error checking at some point. + pfnTransformer( pTransformArg, FALSE, aPointX.size(), + &(aPointX[0]), &(aPointY[0]), NULL, panSuccess ); + CPLFree( panSuccess ); + } + +/* -------------------------------------------------------------------- */ +/* Shift to account for the buffer offset of this buffer. */ +/* -------------------------------------------------------------------- */ + unsigned int i; + + for( i = 0; i < aPointY.size(); i++ ) + aPointY[i] -= nYOff; + +/* -------------------------------------------------------------------- */ +/* Perform the rasterization. We assume that the vector<> will */ +/* be contiguous. I'm not convinced that is guaranteed. */ +/* -------------------------------------------------------------------- */ + GDALdllImageFilledPolygon( sInfo.nXSize, nYSize, + aPartSize.size(), &(aPartSize[0]), + &(aPointX[0]), &(aPointY[0]), + gvBurnScanline, &sInfo ); +} + +/************************************************************************/ +/* GDALRasterizeGeometries() */ +/************************************************************************/ + +/** + * Burn geometries into raster. + * + * Rasterize a list of geometric objects into a raster dataset. The + * geometries are passed as an array of OGRGeometry objects. + * + * If the geometries are in the georferenced coordinates of the raster + * dataset, then the pfnTransform may be passed in NULL and one will be + * derived internally from the geotransform of the dataset. The transform + * needs to transform the geometry locations into pixel/line coordinates + * on the raster dataset. + * + * The output raster may be of any GDAL supported datatype, though currently + * internally the burning is done either as GDT_Byte or GDT_Float32. This + * may be improved in the future. An explicit list of burn values for + * each geometry for each band must be passed in. + * + * Currently only polygon, multipolygon and geometrycollections of polygons + * or multipolygons are supported. In the future support for points + * and lines may be added. + * + * @param hDS output data, must be opened in update mode. + * @param nBandCount the number of bands to be updated. + * @param panBandList the list of bands to be updated. + * @param nGeomCount the number of geometries being passed in pahGeometries. + * @param pahGeometries the array of geometries to burn in. + * @param pfnTransformer transformation to apply to geometries to put into + * pixel/line coordinates on raster. If NULL a geotransform based one will + * be created internally. + * @param pTransformerArg callback data for transformer. + * @param padfGeomBurnValue the array of values to burn into the raster. + * There should nBandCount values for each geometry. + * @param papszOption special options controlling rasterization, currently + * none are defined. + * @param pfnProgress the progress function to report completion. + * @param pProgressArg callback data for progress function. + * + * @return CE_None on success or CE_Failure on error. + */ + +CPLErr GDALRasterizeGeometries( GDALDatasetH hDS, + int nBandCount, int *panBandList, + int nGeomCount, OGRGeometryH *pahGeometries, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeomBurnValue, + char **papszOptions, + GDALProgressFunc pfnProgress, + void *pProgressArg ) + +{ + GDALDataType eType; + int nYChunkSize, nScanlineBytes; + unsigned char *pabyChunkBuf; + int iY; + GDALDataset *poDS = (GDALDataset *) hDS; + + if( pfnProgress == NULL ) + pfnProgress = GDALDummyProgress; + +/* -------------------------------------------------------------------- */ +/* Do some rudimentary arg checking. */ +/* -------------------------------------------------------------------- */ + if( nBandCount == 0 || nGeomCount == 0 ) + return CE_None; + + // prototype band. + GDALRasterBand *poBand = poDS->GetRasterBand( panBandList[0] ); + +/* -------------------------------------------------------------------- */ +/* If we have no transformer, assume the geometries are in file */ +/* georeferenced coordinates, and create a transformer to */ +/* convert that to pixel/line coordinates. */ +/* */ +/* We really just need to apply an affine transform, but for */ +/* simplicity we use the more general GenImgProjTransformer. */ +/* -------------------------------------------------------------------- */ + int bNeedToFreeTransformer = FALSE; + + if( pfnTransformer == NULL ) + { + bNeedToFreeTransformer = TRUE; + + pTransformArg = + GDALCreateGenImgProjTransformer( NULL, NULL, hDS, NULL, + FALSE, 0.0, 0); + pfnTransformer = GDALGenImgProjTransform; + } + +/* -------------------------------------------------------------------- */ +/* Establish a chunksize to operate on. The larger the chunk */ +/* size the less times we need to make a pass through all the */ +/* shapes. */ +/* -------------------------------------------------------------------- */ + if( poBand->GetRasterDataType() == GDT_Byte ) + eType = GDT_Byte; + else + eType = GDT_Float32; + + nScanlineBytes = nBandCount * poDS->GetRasterXSize() + * (GDALGetDataTypeSize(eType)/8); + nYChunkSize = 10000000 / nScanlineBytes; + if( nYChunkSize > poBand->GetYSize() ) + nYChunkSize = poBand->GetYSize(); + + pabyChunkBuf = (unsigned char *) VSIMalloc(nYChunkSize * nScanlineBytes); + if( pabyChunkBuf == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Unable to allocate rasterization buffer." ); + return CE_Failure; + } + +/* ==================================================================== */ +/* Loop over image in designated chunks. */ +/* ==================================================================== */ + CPLErr eErr = CE_None; + + pfnProgress( 0.0, NULL, pProgressArg ); + + for( iY = 0; + iY < poDS->GetRasterYSize() && eErr == CE_None; + iY += nYChunkSize ) + { + int nThisYChunkSize; + int iShape; + + nThisYChunkSize = nYChunkSize; + if( nThisYChunkSize + iY > poDS->GetRasterYSize() ) + nThisYChunkSize = poDS->GetRasterYSize() - iY; + + eErr = + poDS->RasterIO(GF_Read, + 0, iY, poDS->GetRasterXSize(), nThisYChunkSize, + pabyChunkBuf,poDS->GetRasterXSize(),nThisYChunkSize, + eType, nBandCount, panBandList, + 0, 0, 0 ); + if( eErr != CE_None ) + break; + + for( iShape = 0; iShape < nGeomCount; iShape++ ) + { + gv_rasterize_new_one_shape( pabyChunkBuf, iY, nThisYChunkSize, + nBandCount, eType, poDS, + (OGRGeometry *) pahGeometries[iShape], + padfGeomBurnValue + iShape*nBandCount, + pfnTransformer, pTransformArg ); + } + + eErr = + poDS->RasterIO( GF_Write, + 0, iY, poBand->GetXSize(), nThisYChunkSize, + pabyChunkBuf, poBand->GetXSize(), nThisYChunkSize, + eType, nBandCount, panBandList, + 0, 0, 0 ); + + if( !pfnProgress((iY+nThisYChunkSize)/((double)poDS->GetRasterYSize()), + "", pProgressArg ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* cleanup */ +/* -------------------------------------------------------------------- */ + VSIFree( pabyChunkBuf ); + + if( bNeedToFreeTransformer ) + GDALDestroyTransformer( pTransformArg ); + + return eErr; +} + diff --git a/Utilities/GDAL/alg/gdalsimplewarp.cpp b/Utilities/GDAL/alg/gdalsimplewarp.cpp new file mode 100644 index 0000000000..f28500a7a2 --- /dev/null +++ b/Utilities/GDAL/alg/gdalsimplewarp.cpp @@ -0,0 +1,465 @@ +/****************************************************************************** + * $Id: gdalsimplewarp.cpp,v 1.9 2006/03/21 20:56:00 fwarmerdam Exp $ + * + * Project: Mapinfo Image Warper + * Purpose: Simple (source in memory) warp algorithm. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2002, i3 - information integration and imaging, Fort Collin,CO + * + * 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: gdalsimplewarp.cpp,v $ + * Revision 1.9 2006/03/21 20:56:00 fwarmerdam + * cleanup headers + * + * Revision 1.8 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.7 2003/07/08 15:33:04 warmerda + * avoid warnings + * + * Revision 1.6 2003/02/24 17:30:58 warmerda + * added REMAP support + * + * Revision 1.5 2003/02/06 04:56:35 warmerda + * added documentation + * + * Revision 1.4 2002/12/07 22:58:42 warmerda + * added initialization support for simple warper + * + * Revision 1.3 2002/12/06 21:43:28 warmerda + * removed luts + * + * Revision 1.2 2002/12/05 21:44:19 warmerda + * initial implementation + * + * Revision 1.1 2002/12/05 05:43:23 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: gdalsimplewarp.cpp,v 1.9 2006/03/21 20:56:00 fwarmerdam Exp $"); + +static void +GDALSimpleWarpRemapping( int nBandCount, GByte **papabySrcData, + int nSrcXSize, int nSrcYSize, + char **papszWarpOptions ); + +/************************************************************************/ +/* GDALSimpleImageWarp() */ +/************************************************************************/ + +/** + * Perform simple image warp. + * + * Copies an image from a source dataset to a destination dataset applying + * an application defined transformation. This algorithm is called simple + * because it lacks many options such as resampling kernels (other than + * nearest neighbour), support for data types other than 8bit, and the + * ability to warp images without holding the entire source and destination + * image in memory. + * + * The following option(s) may be passed in papszWarpOptions. + * <ul> + * <li> "INIT=v[,v...]": This option indicates that the output dataset should + * be initialized to the indicated value in any area valid data is not written. + * Distinct values may be listed for each band separated by columns. + * </ul> + * + * @param hSrcDS the source image dataset. + * @param hDstDS the destination image dataset. + * @param nBandCount the number of bands to be warped. If zero, all bands + * will be processed. + * @param panBandList the list of bands to translate. + * @param pfnTransform the transformation function to call. See + * GDALTransformerFunc(). + * @param pTransformArg the callback handle to pass to pfnTransform. + * @param pfnProgress the function used to report progress. See + * GDALProgressFunc(). + * @param pProgressArg the callback handle to pass to pfnProgress. + * @param papszWarpOptions additional options controlling the warp. + * + * @return TRUE if the operation completes, or FALSE if an error occurs. + */ + +int CPL_STDCALL +GDALSimpleImageWarp( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, + int nBandCount, int *panBandList, + GDALTransformerFunc pfnTransform, void *pTransformArg, + GDALProgressFunc pfnProgress, void *pProgressArg, + char **papszWarpOptions ) + +{ + int iBand, bCancelled = FALSE; + +/* -------------------------------------------------------------------- */ +/* If no bands provided assume we should process all bands. */ +/* -------------------------------------------------------------------- */ + if( nBandCount == 0 ) + { + int nResult; + + nBandCount = GDALGetRasterCount( hSrcDS ); + panBandList = (int *) CPLCalloc(sizeof(int),nBandCount); + + for( iBand = 0; iBand < nBandCount; iBand++ ) + panBandList[iBand] = iBand+1; + + nResult = GDALSimpleImageWarp( hSrcDS, hDstDS, nBandCount, panBandList, + pfnTransform, pTransformArg, + pfnProgress, pProgressArg, + papszWarpOptions ); + CPLFree( panBandList ); + return nResult; + } + +/* -------------------------------------------------------------------- */ +/* Post initial progress. */ +/* -------------------------------------------------------------------- */ + if( pfnProgress ) + { + if( !pfnProgress( 0.0, "", pProgressArg ) ) + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Load the source image band(s). */ +/* -------------------------------------------------------------------- */ + int nSrcXSize = GDALGetRasterXSize(hSrcDS); + int nSrcYSize = GDALGetRasterYSize(hSrcDS); + GByte **papabySrcData; + + papabySrcData = (GByte **) CPLCalloc(nBandCount,sizeof(int)); + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + papabySrcData[iBand] = (GByte *) VSIMalloc(nSrcXSize*nSrcYSize); + + GDALRasterIO( GDALGetRasterBand(hSrcDS,panBandList[iBand]), GF_Read, + 0, 0, nSrcXSize, nSrcYSize, + papabySrcData[iBand], nSrcXSize, nSrcYSize, GDT_Byte, + 0, 0 ); + } + +/* -------------------------------------------------------------------- */ +/* Check for remap request(s). */ +/* -------------------------------------------------------------------- */ + GDALSimpleWarpRemapping( nBandCount, papabySrcData, nSrcXSize, nSrcYSize, + papszWarpOptions ); + +/* -------------------------------------------------------------------- */ +/* Allocate scanline buffers for output image. */ +/* -------------------------------------------------------------------- */ + int nDstXSize = GDALGetRasterXSize( hDstDS ); + int nDstYSize = GDALGetRasterYSize( hDstDS ); + GByte **papabyDstLine; + + papabyDstLine = (GByte **) CPLCalloc(nBandCount,sizeof(int)); + + for( iBand = 0; iBand < nBandCount; iBand++ ) + papabyDstLine[iBand] = (GByte *) CPLMalloc( nDstXSize ); + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* -------------------------------------------------------------------- */ +/* Establish the value we will use to initialize the bands. We */ +/* default to -1 indicating the initial value should be read */ +/* and preserved from the source file, but allow this to be */ +/* overridden by passed */ +/* option(s). */ +/* -------------------------------------------------------------------- */ + int *panBandInit; + + panBandInit = (int *) CPLCalloc(sizeof(int),nBandCount); + if( CSLFetchNameValue( papszWarpOptions, "INIT" ) ) + { + int iBand, nTokenCount; + char **papszTokens = + CSLTokenizeStringComplex( CSLFetchNameValue( papszWarpOptions, + "INIT" ), + " ,", FALSE, FALSE ); + + nTokenCount = CSLCount(papszTokens); + + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + if( nTokenCount == 0 ) + panBandInit[iBand] = 0; + else + panBandInit[iBand] = + atoi(papszTokens[MIN(iBand,nTokenCount-1)]); + } + + CSLDestroy(papszTokens); + } + +/* -------------------------------------------------------------------- */ +/* Loop over all the scanlines in the output image. */ +/* -------------------------------------------------------------------- */ + int iDstY; + + for( iDstY = 0; iDstY < nDstYSize; iDstY++ ) + { + int iDstX; + + // Clear output buffer to "transparent" value. Shouldn't we + // really be reading from the destination file to support overlay? + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + if( panBandInit[iBand] == -1 ) + GDALRasterIO( GDALGetRasterBand(hDstDS,iBand+1), GF_Read, + 0, iDstY, nDstXSize, 1, + papabyDstLine[iBand], nDstXSize, 1, GDT_Byte, + 0, 0 ); + else + memset( papabyDstLine[iBand], panBandInit[iBand], nDstXSize ); + } + + // Set point to transform. + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5; + padfY[iDstX] = iDstY + 0.5; + padfZ[iDstX] = 0.0; + } + + // Transform the points from destination pixel/line coordinates + // to source pixel/line coordinates. + pfnTransform( pTransformArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + + // Loop over the output scanline. + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < 0.0 || padfY[iDstX] < 0.0 ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = (int) padfX[iDstX]; + iSrcY = (int) padfY[iDstX]; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + + for( iBand = 0; iBand < nBandCount; iBand++ ) + papabyDstLine[iBand][iDstX] = papabySrcData[iBand][iSrcOffset]; + } + + // Write scanline to disk. + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + GDALRasterIO( GDALGetRasterBand(hDstDS,iBand+1), GF_Write, + 0, iDstY, nDstXSize, 1, + papabyDstLine[iBand], nDstXSize, 1, GDT_Byte, 0, 0 ); + } + + if( pfnProgress != NULL ) + { + if( !pfnProgress( (iDstY+1) / (double) nDstYSize, + "", pProgressArg ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + bCancelled = TRUE; + break; + } + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup working buffers. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + CPLFree( papabyDstLine[iBand] ); + CPLFree( papabySrcData[iBand] ); + } + + CPLFree( papabyDstLine ); + CPLFree( papabySrcData ); + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return !bCancelled; +} + +/************************************************************************/ +/* GDALSimpleWarpRemapping() */ +/* */ +/* This function implements any raster remapping requested in */ +/* the options list. The remappings are applied to the source */ +/* data before warping. Two kinds are support ... REMAP */ +/* commands which remap selected pixel values for any band and */ +/* REMAP_MULTI which only remap pixels matching the input in */ +/* all bands at once (ie. to remap an RGB value to another). */ +/************************************************************************/ + +static void +GDALSimpleWarpRemapping( int nBandCount, GByte **papabySrcData, + int nSrcXSize, int nSrcYSize, + char **papszWarpOptions ) + +{ + +/* ==================================================================== */ +/* Process any and all single value REMAP commands. */ +/* ==================================================================== */ + int iRemap; + char **papszRemaps = CSLFetchNameValueMultiple( papszWarpOptions, + "REMAP" ); + + for( iRemap = 0; iRemap < CSLCount(papszRemaps); iRemap++ ) + { + +/* -------------------------------------------------------------------- */ +/* What are the pixel values to map from and to? */ +/* -------------------------------------------------------------------- */ + char **papszTokens = CSLTokenizeString( papszRemaps[iRemap] ); + int nFromValue, nToValue; + + if( CSLCount(papszTokens) != 2 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Ill formed REMAP `%s' ignored in GDALSimpleWarpRemapping()", + papszRemaps[iRemap] ); + continue; + } + + nFromValue = atoi(papszTokens[0]); + nToValue = atoi(papszTokens[1]); + + CSLDestroy( papszTokens ); + +/* -------------------------------------------------------------------- */ +/* Pass over each band searching for matches. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < nBandCount; iBand++ ) + { + GByte *pabyData = papabySrcData[iBand]; + int nPixelCount = nSrcXSize * nSrcYSize; + + while( nPixelCount != 0 ) + { + if( *pabyData == nFromValue ) + *pabyData = (GByte) nToValue; + + pabyData++; + nPixelCount--; + } + } + } + + CSLDestroy( papszRemaps ); + +/* ==================================================================== */ +/* Process any and all REMAP_MULTI commands. */ +/* ==================================================================== */ + papszRemaps = CSLFetchNameValueMultiple( papszWarpOptions, + "REMAP_MULTI" ); + + for( iRemap = 0; iRemap < CSLCount(papszRemaps); iRemap++ ) + { +/* -------------------------------------------------------------------- */ +/* What are the pixel values to map from and to? */ +/* -------------------------------------------------------------------- */ + char **papszTokens = CSLTokenizeString( papszRemaps[iRemap] ); + int *panFromValue, *panToValue; + int nMapBandCount, iBand; + + if( CSLCount(papszTokens) % 2 == 1 + || CSLCount(papszTokens) == 0 + || CSLCount(papszTokens) > nBandCount * 2 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Ill formed REMAP_MULTI `%s' ignored in GDALSimpleWarpRemapping()", + papszRemaps[iRemap] ); + continue; + } + + nMapBandCount = CSLCount(papszTokens) / 2; + + panFromValue = (int *) CPLMalloc(sizeof(int) * nMapBandCount ); + panToValue = (int *) CPLMalloc(sizeof(int) * nMapBandCount ); + + for( iBand = 0; iBand < nMapBandCount; iBand++ ) + { + panFromValue[iBand] = atoi(papszTokens[iBand]); + panToValue[iBand] = atoi(papszTokens[iBand+nMapBandCount]); + } + + CSLDestroy( papszTokens ); + +/* -------------------------------------------------------------------- */ +/* Search for matching values to replace. */ +/* -------------------------------------------------------------------- */ + int nPixelCount = nSrcXSize * nSrcYSize; + int iPixel; + + for( iPixel = 0; iPixel < nPixelCount; iPixel++ ) + { + if( papabySrcData[0][iPixel] != panFromValue[0] ) + continue; + + int bMatch = TRUE; + + for( iBand = 1; iBand < nMapBandCount; iBand++ ) + { + if( papabySrcData[iBand][iPixel] != panFromValue[iBand] ) + bMatch = FALSE; + } + + if( !bMatch ) + continue; + + for( iBand = 0; iBand < nMapBandCount; iBand++ ) + papabySrcData[iBand][iPixel] = (GByte) panToValue[iBand]; + } + + CPLFree( panFromValue ); + CPLFree( panToValue ); + } + + CSLDestroy( papszRemaps ); +} diff --git a/Utilities/GDAL/alg/gdaltransformer.cpp b/Utilities/GDAL/alg/gdaltransformer.cpp new file mode 100644 index 0000000000..22cea64462 --- /dev/null +++ b/Utilities/GDAL/alg/gdaltransformer.cpp @@ -0,0 +1,1806 @@ +/****************************************************************************** + * $Id: gdaltransformer.cpp,v 1.24 2005/10/28 17:47:28 fwarmerdam Exp $ + * + * Project: Mapinfo Image Warper + * Purpose: Implementation of one or more GDALTrasformerFunc types, including + * the GenImgProj (general image reprojector) transformer. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2002, i3 - information integration and imaging + * Fort Collin, CO + * + * 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: gdaltransformer.cpp,v $ + * Revision 1.24 2005/10/28 17:47:28 fwarmerdam + * GenImgTransformer now supports NULL hSrcDS. Also now actually pulls + * coordinate systems from hSrcDS or hDstDS if not provided. + * + * Revision 1.23 2005/08/02 22:21:06 fwarmerdam + * Approx transformer can now own and cleanup it's subtransformer. + * GenImg transformer now deserialized with property GTI signature. + * + * Revision 1.22 2005/04/11 17:36:53 fwarmerdam + * added GDALDestroyTransformer + * + * Revision 1.21 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.20 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.19 2004/11/05 04:55:48 fwarmerdam + * We can't compute the diagonal based on the first and last corner points + * if either didn't transform successfully. Just fallback to using the + * diagonal of the min/max window even though it is slightly less precise. + * + * Revision 1.18 2004/08/13 14:50:06 warmerda + * use SetFromUserInput() for SourceSRS and TargetSRS + * + * Revision 1.17 2004/08/11 20:42:05 warmerda + * dont declare static funcs in CPL_C area + * + * Revision 1.16 2004/08/11 19:00:37 warmerda + * added GDALSetGenImgProjTransformerDstGeoTransform + * + * Revision 1.15 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.14 2004/03/28 16:02:04 warmerda + * added GDALApplyGeoTransform() + * + * Revision 1.13 2004/03/28 15:50:01 warmerda + * Added docs for GDALInvGeoTransform(). + * + * Revision 1.12 2004/01/24 09:33:33 warmerda + * Added support for internal grid in GDALSuggestedWarpOutput() for cases + * where alot of points around the edge fail to transform. + * Added use of OGRCoordinateTransformation::TransformEx() to capture per-point + * reprojection errors. + * Ensure that approximate transformer reverts to exact transformer if any of + * the 3 points fail to transform. + * + * Revision 1.11 2003/07/08 15:29:14 warmerda + * avoid warnings + * + * Revision 1.10 2003/06/03 19:42:54 warmerda + * added partial support for RPC in GenImgProjTransformer + * + * Revision 1.9 2003/02/06 04:56:35 warmerda + * added documentation + * + * Revision 1.8 2002/12/13 15:55:27 warmerda + * fix suggested output to preserve orig size exact on null transform + * + * Revision 1.7 2002/12/13 04:57:49 warmerda + * remove approx transformer debug output + * + * Revision 1.6 2002/12/09 16:08:32 warmerda + * added approximating transformer + * + * Revision 1.5 2002/12/07 17:09:38 warmerda + * added order flag to GenImgProjTransformer + * + * Revision 1.4 2002/12/06 21:43:56 warmerda + * added GCP support to general transformer + * + * Revision 1.3 2002/12/05 21:45:01 warmerda + * fixed a few GenImgProj bugs + * + * Revision 1.2 2002/12/05 16:37:46 warmerda + * fixed method name + * + * Revision 1.1 2002/12/05 05:43:23 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: gdaltransformer.cpp,v 1.24 2005/10/28 17:47:28 fwarmerdam Exp $"); +CPL_C_START +CPLXMLNode *GDALSerializeGCPTransformer( void *pTransformArg ); +void *GDALDeserializeGCPTransformer( CPLXMLNode *psTree ); +CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg ); +void *GDALDeserializeTPSTransformer( CPLXMLNode *psTree ); +CPL_C_END + +static CPLXMLNode *GDALSerializeReprojectionTransformer( void *pTransformArg ); +static void *GDALDeserializeReprojectionTransformer( CPLXMLNode *psTree ); + +static CPLXMLNode *GDALSerializeGenImgProjTransformer( void *pTransformArg ); +static void *GDALDeserializeGenImgProjTransformer( CPLXMLNode *psTree ); + +/************************************************************************/ +/* GDALTransformFunc */ +/* */ +/* Documentation for GDALTransformFunc typedef. */ +/************************************************************************/ + +/*! + +\typedef int GDALTransformerFunc + +Generic signature for spatial point transformers. + +This function signature is used for a variety of functions that accept +passed in functions used to transform point locations between two coordinate +spaces. + +The GDALCreateGenImgProjTransformer(), GDALCreateReprojectionTransformer(), +GDALCreateGCPTransformer() and GDALCreateApproxTransformer() functions can +be used to prepare argument data for some built-in transformers. As well, +applications can implement their own transformers to the following signature. + +\code +typedef int +(*GDALTransformerFunc)( void *pTransformerArg, + int bDstToSrc, int nPointCount, + double *x, double *y, double *z, int *panSuccess ); +\endcode + +@param pTransformerArg application supplied callback data used by the +transformer. + +@param bDstToSrc if TRUE the transformation will be from the destination +coordinate space to the source coordinate system, otherwise the transformation +will be from the source coordinate system to the destination coordinate system. + +@param nPointCount number of points in the x, y and z arrays. + +@param x input X coordinates. Results returned in same array. + +@param y input Y coordinates. Results returned in same array. + +@param z input Z coordinates. Results returned in same array. + +@param panSuccess array of ints in which success (TRUE) or failure (FALSE) +flags are returned for the translation of each point. + +@return TRUE if the overall transformation succeeds (though some individual +points may have failed) or FALSE if the overall transformation fails. + +*/ + +/************************************************************************/ +/* GDALSuggestedWarpOutput() */ +/************************************************************************/ + +/** + * Suggest output file size. + * + * This function is used to suggest the size, and georeferenced extents + * appropriate given the indicated transformation and input file. It walks + * the edges of the input file (approximately 20 sample points along each + * edge) transforming into output coordinates in order to get an extents box. + * + * Then a resolution is computed with the intent that the length of the + * distance from the top left corner of the output imagery to the bottom right + * corner would represent the same number of pixels as in the source image. + * Note that if the image is somewhat rotated the diagonal taken isnt of the + * whole output bounding rectangle, but instead of the locations where the + * top/left and bottom/right corners transform. The output pixel size is + * always square. This is intended to approximately preserve the resolution + * of the input data in the output file. + * + * The values returned in padfGeoTransformOut, pnPixels and pnLines are + * the suggested number of pixels and lines for the output file, and the + * geotransform relating those pixels to the output georeferenced coordinates. + * + * The trickiest part of using the function is ensuring that the + * transformer created is from source file pixel/line coordinates to + * output file georeferenced coordinates. This can be accomplished with + * GDALCreateGenImProjTransformer() by passing a NULL for the hDstDS. + * + * @param hSrcDS the input image (it is assumed the whole input images is + * being transformed). + * @param pfnTransformer the transformer function. + * @param pTransformArg the callback data for the transformer function. + * @param padfGeoTransformOut the array of six doubles in which the suggested + * geotransform is returned. + * @param pnPixels int in which the suggest pixel width of output is returned. + * @param pnLines int in which the suggest pixel height of output is returned. + * + * @return CE_None if successful or CE_Failure otherwise. + */ + + +CPLErr CPL_STDCALL +GDALSuggestedWarpOutput( GDALDatasetH hSrcDS, + GDALTransformerFunc pfnTransformer, + void *pTransformArg, + double *padfGeoTransformOut, + int *pnPixels, int *pnLines ) + +{ +/* -------------------------------------------------------------------- */ +/* Setup sample points all around the edge of the input raster. */ +/* -------------------------------------------------------------------- */ + int nSamplePoints=0, abSuccess[441]; + double adfX[441], adfY[441], adfZ[441], dfRatio; + int nInXSize = GDALGetRasterXSize( hSrcDS ); + int nInYSize = GDALGetRasterYSize( hSrcDS ); + + // Take 20 steps + for( dfRatio = 0.0; dfRatio <= 1.01; dfRatio += 0.05 ) + { + + // Ensure we end exactly at the end. + if( dfRatio > 0.99 ) + dfRatio = 1.0; + + // Along top + adfX[nSamplePoints] = dfRatio * nInXSize; + adfY[nSamplePoints] = 0.0; + adfZ[nSamplePoints++] = 0.0; + + // Along bottom + adfX[nSamplePoints] = dfRatio * nInXSize; + adfY[nSamplePoints] = nInYSize; + adfZ[nSamplePoints++] = 0.0; + + // Along left + adfX[nSamplePoints] = 0.0; + adfY[nSamplePoints] = dfRatio * nInYSize; + adfZ[nSamplePoints++] = 0.0; + + // Along right + adfX[nSamplePoints] = nInXSize; + adfY[nSamplePoints] = dfRatio * nInYSize; + adfZ[nSamplePoints++] = 0.0; + } + + CPLAssert( nSamplePoints == 84 ); + +/* -------------------------------------------------------------------- */ +/* Transform them to the output coordinate system. */ +/* -------------------------------------------------------------------- */ + int nFailedCount = 0, i; + + if( !pfnTransformer( pTransformArg, FALSE, nSamplePoints, + adfX, adfY, adfZ, abSuccess ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "GDALSuggestedWarpOutput() failed because the passed\n" + "transformer failed." ); + return CE_Failure; + } + + for( i = 0; i < nSamplePoints; i++ ) + { + if( !abSuccess[i] ) + nFailedCount++; + } + +/* -------------------------------------------------------------------- */ +/* If any of the edge points failed to transform, we need to */ +/* build a fairly detailed internal grid of points instead to */ +/* help identify the area that is transformable. */ +/* -------------------------------------------------------------------- */ + if( nFailedCount > 0 ) + { + double dfRatio2; + nSamplePoints = 0; + + // Take 20 steps + for( dfRatio = 0.0; dfRatio <= 1.01; dfRatio += 0.05 ) + { + // Ensure we end exactly at the end. + if( dfRatio > 0.99 ) + dfRatio = 1.0; + + for( dfRatio2 = 0.0; dfRatio2 <= 1.01; dfRatio2 += 0.05 ) + { + // Ensure we end exactly at the end. + if( dfRatio2 > 0.99 ) + dfRatio2 = 1.0; + + // Along top + adfX[nSamplePoints] = dfRatio2 * nInXSize; + adfY[nSamplePoints] = dfRatio * nInYSize; + adfZ[nSamplePoints++] = 0.0; + } + } + + CPLAssert( nSamplePoints == 441 ); + + if( !pfnTransformer( pTransformArg, FALSE, nSamplePoints, + adfX, adfY, adfZ, abSuccess ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "GDALSuggestedWarpOutput() failed because the passed\n" + "transformer failed." ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Collect the bounds, ignoring any failed points. */ +/* -------------------------------------------------------------------- */ + double dfMinXOut=0, dfMinYOut=0, dfMaxXOut=0, dfMaxYOut=0; + int bGotInitialPoint = FALSE; + + nFailedCount = 0; + for( i = 0; i < nSamplePoints; i++ ) + { + if( !abSuccess[i] ) + { + nFailedCount++; + continue; + } + + if( !bGotInitialPoint ) + { + bGotInitialPoint = TRUE; + dfMinXOut = dfMaxXOut = adfX[i]; + dfMinYOut = dfMaxYOut = adfY[i]; + } + else + { + dfMinXOut = MIN(dfMinXOut,adfX[i]); + dfMinYOut = MIN(dfMinYOut,adfY[i]); + dfMaxXOut = MAX(dfMaxXOut,adfX[i]); + dfMaxYOut = MAX(dfMaxYOut,adfY[i]); + } + } + + if( nFailedCount > nSamplePoints - 10 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Too many points (%d out of %d) failed to transform,\n" + "unable to compute output bounds.", + nFailedCount, nSamplePoints ); + return CE_Failure; + } + + if( nFailedCount > 0 ) + CPLDebug( "GDAL", + "GDALSuggestedWarpOutput(): %d out of %d points failed to transform.", + nFailedCount, nSamplePoints ); + +/* -------------------------------------------------------------------- */ +/* Compute the distance in "georeferenced" units from the top */ +/* corner of the transformed input image to the bottom left */ +/* corner of the transformed input. Use this distance to */ +/* compute an approximate pixel size in the output */ +/* georeferenced coordinates. */ +/* -------------------------------------------------------------------- */ + double dfDiagonalDist, dfDeltaX, dfDeltaY; + + if( abSuccess[0] && abSuccess[nSamplePoints-1] ) + { + dfDeltaX = adfX[nSamplePoints-1] - adfX[0]; + dfDeltaY = adfY[nSamplePoints-1] - adfY[0]; + } + else + { + dfDeltaX = dfMaxXOut - dfMinXOut; + dfDeltaY = dfMaxYOut - dfMinYOut; + } + + dfDiagonalDist = sqrt( dfDeltaX * dfDeltaX + dfDeltaY * dfDeltaY ); + +/* -------------------------------------------------------------------- */ +/* Compute a pixel size from this. */ +/* -------------------------------------------------------------------- */ + double dfPixelSize; + + dfPixelSize = dfDiagonalDist + / sqrt(((double)nInXSize)*nInXSize + ((double)nInYSize)*nInYSize); + + *pnPixels = (int) ((dfMaxXOut - dfMinXOut) / dfPixelSize + 0.5); + *pnLines = (int) ((dfMaxYOut - dfMinYOut) / dfPixelSize + 0.5); + +/* -------------------------------------------------------------------- */ +/* Set the output geotransform. */ +/* -------------------------------------------------------------------- */ + padfGeoTransformOut[0] = dfMinXOut; + padfGeoTransformOut[1] = dfPixelSize; + padfGeoTransformOut[2] = 0.0; + padfGeoTransformOut[3] = dfMaxYOut; + padfGeoTransformOut[4] = 0.0; + padfGeoTransformOut[5] = - dfPixelSize; + + return CE_None; +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALGenImgProjTransformer */ +/* ==================================================================== */ +/************************************************************************/ + +typedef struct { + + GDALTransformerInfo sTI; + + double adfSrcGeoTransform[6]; + double adfSrcInvGeoTransform[6]; + + void *pSrcGCPTransformArg; + void *pSrcRPCTransformArg; + void *pSrcTPSTransformArg; + + void *pReprojectArg; + + double adfDstGeoTransform[6]; + double adfDstInvGeoTransform[6]; + + void *pDstGCPTransformArg; + +} GDALGenImgProjTransformInfo; + +/************************************************************************/ +/* GDALCreateGenImgProjTransformer() */ +/************************************************************************/ + +/** + * Create image to image transformer. + * + * This function creates a transformation object that maps from pixel/line + * coordinates on one image to pixel/line coordinates on another image. The + * images may potentially be georeferenced in different coordinate systems, + * and may used GCPs to map between their pixel/line coordinates and + * georeferenced coordinates (as opposed to the default assumption that their + * geotransform should be used). + * + * This transformer potentially performs three concatenated transformations. + * + * The first stage is from source image pixel/line coordinates to source + * image georeferenced coordinates, and may be done using the geotransform, + * or if not defined using a polynomial model derived from GCPs. If GCPs + * are used this stage is accomplished using GDALGCPTransform(). + * + * The second stage is to change projections from the source coordinate system + * to the destination coordinate system, assuming they differ. This is + * accomplished internally using GDALReprojectionTransform(). + * + * The third stage is converting from destination image georeferenced + * coordinates to destination image coordinates. This is done using the + * destination image geotransform, or if not available, using a polynomial + * model derived from GCPs. If GCPs are used this stage is accomplished using + * GDALGCPTransform(). This stage is skipped if hDstDS is NULL when the + * transformation is created. + * + * @param hSrcDS source dataset, or NULL. + * @param pszSrcWKT the coordinate system for the source dataset. If NULL, + * it will be read from the dataset itself. + * @param hDstDS destination dataset (or NULL). + * @param pszDstWKT the coordinate system for the destination dataset. If + * NULL, and hDstDS not NULL, it will be read from the destination dataset. + * @param bGCPUseOK TRUE if GCPs should be used if the geotransform is not + * available on the source dataset (not destination). + * @param dfGCPErrorThreshold the maximum error allowed for the GCP model + * to be considered valid. Exact semantics not yet defined. + * @param nOrder the maximum order to use for GCP derived polynomials if + * possible. Use 0 to autoselect, or -1 for thin plate splines. + * + * @return handle suitable for use GDALGenImgProjTransform(), and to be + * deallocated with GDALDestroyGenImgProjTransformer(). + */ + +void * +GDALCreateGenImgProjTransformer( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + int bGCPUseOK, double dfGCPErrorThreshold, + int nOrder ) + +{ + GDALGenImgProjTransformInfo *psInfo; + char **papszMD; + GDALRPCInfo sRPCInfo; + +/* -------------------------------------------------------------------- */ +/* Initialize the transform info. */ +/* -------------------------------------------------------------------- */ + psInfo = (GDALGenImgProjTransformInfo *) + CPLCalloc(sizeof(GDALGenImgProjTransformInfo),1); + + strcpy( psInfo->sTI.szSignature, "GTI" ); + psInfo->sTI.pszClassName = "GDALGenImgProjTransformer"; + psInfo->sTI.pfnTransform = GDALGenImgProjTransform; + psInfo->sTI.pfnCleanup = GDALDestroyGenImgProjTransformer; + psInfo->sTI.pfnSerialize = GDALSerializeGenImgProjTransformer; + +/* -------------------------------------------------------------------- */ +/* Get forward and inverse geotransform for the source image. */ +/* -------------------------------------------------------------------- */ + if( hSrcDS == NULL ) + { + psInfo->adfSrcGeoTransform[0] = 0.0; + psInfo->adfSrcGeoTransform[1] = 1.0; + psInfo->adfSrcGeoTransform[2] = 0.0; + psInfo->adfSrcGeoTransform[3] = 0.0; + psInfo->adfSrcGeoTransform[4] = 0.0; + psInfo->adfSrcGeoTransform[5] = 1.0; + memcpy( psInfo->adfSrcInvGeoTransform, psInfo->adfSrcGeoTransform, + sizeof(double) * 6 ); + } + + else if( GDALGetGeoTransform( hSrcDS, psInfo->adfSrcGeoTransform ) + == CE_None + && (psInfo->adfSrcGeoTransform[0] != 0.0 + || psInfo->adfSrcGeoTransform[1] != 1.0 + || psInfo->adfSrcGeoTransform[2] != 0.0 + || psInfo->adfSrcGeoTransform[3] != 0.0 + || psInfo->adfSrcGeoTransform[4] != 0.0 + || ABS(psInfo->adfSrcGeoTransform[5]) != 1.0) ) + { + GDALInvGeoTransform( psInfo->adfSrcGeoTransform, + psInfo->adfSrcInvGeoTransform ); + } + + else if( bGCPUseOK && GDALGetGCPCount( hSrcDS ) > 0 && nOrder >= 0 ) + { + if( nOrder == -1 ) + psInfo->pSrcTPSTransformArg = + GDALCreateTPSTransformer( GDALGetGCPCount( hSrcDS ), + GDALGetGCPs( hSrcDS ), FALSE ); + else + psInfo->pSrcGCPTransformArg = + GDALCreateGCPTransformer( GDALGetGCPCount( hSrcDS ), + GDALGetGCPs( hSrcDS ), nOrder, + FALSE ); + if( psInfo->pSrcGCPTransformArg == NULL ) + { + GDALDestroyGenImgProjTransformer( psInfo ); + return NULL; + } + } + + else if( bGCPUseOK && GDALGetGCPCount( hSrcDS ) > 0 && nOrder == -1 ) + { + psInfo->pSrcTPSTransformArg = + GDALCreateTPSTransformer( GDALGetGCPCount( hSrcDS ), + GDALGetGCPs( hSrcDS ), FALSE ); + if( psInfo->pSrcTPSTransformArg == NULL ) + { + GDALDestroyGenImgProjTransformer( psInfo ); + return NULL; + } + } + + else if( bGCPUseOK && (papszMD = GDALGetMetadata( hSrcDS, "" )) != NULL + && GDALExtractRPCInfo( papszMD, &sRPCInfo ) ) + { + psInfo->pSrcRPCTransformArg = + GDALCreateRPCTransformer( &sRPCInfo, FALSE, 0.1 ); + if( psInfo->pSrcRPCTransformArg == NULL ) + { + GDALDestroyGenImgProjTransformer( psInfo ); + return NULL; + } + } + + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to compute a transformation between pixel/line\n" + "and georeferenced coordinates for %s.\n" + "There is no affine transformation and no GCPs.", + GDALGetDescription( hSrcDS ) ); + + GDALDestroyGenImgProjTransformer( psInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Setup reprojection. */ +/* -------------------------------------------------------------------- */ + if( pszSrcWKT == NULL && hSrcDS != NULL ) + pszSrcWKT = GDALGetProjectionRef( hSrcDS ); + + if( pszDstWKT == NULL && hDstDS != NULL ) + pszDstWKT = GDALGetProjectionRef( hDstDS ); + + if( pszSrcWKT != NULL && strlen(pszSrcWKT) > 0 + && pszDstWKT != NULL && strlen(pszDstWKT) > 0 + && !EQUAL(pszSrcWKT,pszDstWKT) ) + { + psInfo->pReprojectArg = + GDALCreateReprojectionTransformer( pszSrcWKT, pszDstWKT ); + } + +/* -------------------------------------------------------------------- */ +/* Get forward and inverse geotransform for destination image. */ +/* If we have no destination use a unit transform. */ +/* -------------------------------------------------------------------- */ + if( hDstDS ) + { + GDALGetGeoTransform( hDstDS, psInfo->adfDstGeoTransform ); + GDALInvGeoTransform( psInfo->adfDstGeoTransform, + psInfo->adfDstInvGeoTransform ); + } + else + { + psInfo->adfDstGeoTransform[0] = 0.0; + psInfo->adfDstGeoTransform[1] = 1.0; + psInfo->adfDstGeoTransform[2] = 0.0; + psInfo->adfDstGeoTransform[3] = 0.0; + psInfo->adfDstGeoTransform[4] = 0.0; + psInfo->adfDstGeoTransform[5] = 1.0; + memcpy( psInfo->adfDstInvGeoTransform, psInfo->adfDstGeoTransform, + sizeof(double) * 6 ); + } + + return psInfo; +} + +/************************************************************************/ +/* GDALSetGenImgProjTransformerDstGeoTransform() */ +/************************************************************************/ + +/** + * Set GenImgProj output geotransform. + * + * Normally the "destination geotransform", or transformation between + * georeferenced output coordinates and pixel/line coordinates on the + * destination file is extracted from the destination file by + * GDALCreateGenImgProjTransformer() and stored in the GenImgProj private + * info. However, sometimes it is inconvenient to have an output file + * handle with appropriate geotransform information when creating the + * transformation. For these cases, this function can be used to apply + * the destination geotransform. + * + * @param hTransformArg the handle to update. + * @param padfGeoTransform the destination geotransform to apply (six doubles). + */ + +void GDALSetGenImgProjTransformerDstGeoTransform( + void *hTransformArg, const double *padfGeoTransform ) + +{ + GDALGenImgProjTransformInfo *psInfo = + (GDALGenImgProjTransformInfo *) hTransformArg; + + memcpy( psInfo->adfDstGeoTransform, padfGeoTransform, sizeof(double) * 6 ); + GDALInvGeoTransform( psInfo->adfDstGeoTransform, + psInfo->adfDstInvGeoTransform ); +} + +/************************************************************************/ +/* GDALDestroyGenImgProjTransformer() */ +/************************************************************************/ + +/** + * GenImgProjTransformer deallocator. + * + * This function is used to deallocate the handle created with + * GDALCreateGenImgProjTransformer(). + * + * @param hTransformArg the handle to deallocate. + */ + +void GDALDestroyGenImgProjTransformer( void *hTransformArg ) + +{ + GDALGenImgProjTransformInfo *psInfo = + (GDALGenImgProjTransformInfo *) hTransformArg; + + if( psInfo->pSrcGCPTransformArg != NULL ) + GDALDestroyGCPTransformer( psInfo->pSrcGCPTransformArg ); + + if( psInfo->pSrcTPSTransformArg != NULL ) + GDALDestroyTPSTransformer( psInfo->pSrcTPSTransformArg ); + + if( psInfo->pDstGCPTransformArg != NULL ) + GDALDestroyGCPTransformer( psInfo->pDstGCPTransformArg ); + + if( psInfo->pReprojectArg != NULL ) + GDALDestroyReprojectionTransformer( psInfo->pReprojectArg ); + + CPLFree( psInfo ); +} + +/************************************************************************/ +/* GDALGenImgProjTransform() */ +/************************************************************************/ + +/** + * Perform general image reprojection transformation. + * + * Actually performs the transformation setup in + * GDALCreateGenImgProjTransformer(). This function matches the signature + * required by the GDALTransformerFunc(), and more details on the arguments + * can be found in that topic. + */ + +int GDALGenImgProjTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *padfX, double *padfY, double *padfZ, + int *panSuccess ) +{ + GDALGenImgProjTransformInfo *psInfo = + (GDALGenImgProjTransformInfo *) pTransformArg; + int i; + double *padfGeoTransform; + void *pGCPTransformArg; + void *pRPCTransformArg; + void *pTPSTransformArg; + +/* -------------------------------------------------------------------- */ +/* Convert from src (dst) pixel/line to src (dst) */ +/* georeferenced coordinates. */ +/* -------------------------------------------------------------------- */ + if( bDstToSrc ) + { + padfGeoTransform = psInfo->adfDstGeoTransform; + pGCPTransformArg = psInfo->pDstGCPTransformArg; + pRPCTransformArg = NULL; + pTPSTransformArg = NULL; + } + else + { + padfGeoTransform = psInfo->adfSrcGeoTransform; + pGCPTransformArg = psInfo->pSrcGCPTransformArg; + pRPCTransformArg = psInfo->pSrcRPCTransformArg; + pTPSTransformArg = psInfo->pSrcTPSTransformArg; + } + + if( pGCPTransformArg != NULL ) + { + if( !GDALGCPTransform( pGCPTransformArg, FALSE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else if( pTPSTransformArg != NULL ) + { + if( !GDALTPSTransform( pTPSTransformArg, FALSE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else if( pRPCTransformArg != NULL ) + { + if( !GDALRPCTransform( pRPCTransformArg, FALSE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else + { + for( i = 0; i < nPointCount; i++ ) + { + double dfNewX, dfNewY; + + dfNewX = padfGeoTransform[0] + + padfX[i] * padfGeoTransform[1] + + padfY[i] * padfGeoTransform[2]; + dfNewY = padfGeoTransform[3] + + padfX[i] * padfGeoTransform[4] + + padfY[i] * padfGeoTransform[5]; + + padfX[i] = dfNewX; + padfY[i] = dfNewY; + } + } + +/* -------------------------------------------------------------------- */ +/* Reproject if needed. */ +/* -------------------------------------------------------------------- */ + if( psInfo->pReprojectArg ) + { + if( !GDALReprojectionTransform( psInfo->pReprojectArg, bDstToSrc, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else + { + for( i = 0; i < nPointCount; i++ ) + panSuccess[i] = 1; + } + +/* -------------------------------------------------------------------- */ +/* Convert dst (src) georef coordinates back to pixel/line. */ +/* -------------------------------------------------------------------- */ + if( bDstToSrc ) + { + padfGeoTransform = psInfo->adfSrcInvGeoTransform; + pGCPTransformArg = psInfo->pSrcGCPTransformArg; + pRPCTransformArg = psInfo->pSrcRPCTransformArg; + pTPSTransformArg = psInfo->pSrcTPSTransformArg; + } + else + { + padfGeoTransform = psInfo->adfDstInvGeoTransform; + pGCPTransformArg = psInfo->pDstGCPTransformArg; + pRPCTransformArg = NULL; + pTPSTransformArg = NULL; + } + + if( pGCPTransformArg != NULL ) + { + if( !GDALGCPTransform( pGCPTransformArg, TRUE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else if( pTPSTransformArg != NULL ) + { + if( !GDALTPSTransform( pTPSTransformArg, TRUE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else if( pRPCTransformArg != NULL ) + { + if( !GDALRPCTransform( pRPCTransformArg, TRUE, + nPointCount, padfX, padfY, padfZ, + panSuccess ) ) + return FALSE; + } + else + { + for( i = 0; i < nPointCount; i++ ) + { + double dfNewX, dfNewY; + + dfNewX = padfGeoTransform[0] + + padfX[i] * padfGeoTransform[1] + + padfY[i] * padfGeoTransform[2]; + dfNewY = padfGeoTransform[3] + + padfX[i] * padfGeoTransform[4] + + padfY[i] * padfGeoTransform[5]; + + padfX[i] = dfNewX; + padfY[i] = dfNewY; + } + } + + return TRUE; +} + +/************************************************************************/ +/* GDALSerializeGenImgProjTransformer() */ +/************************************************************************/ + +static CPLXMLNode * +GDALSerializeGenImgProjTransformer( void *pTransformArg ) + +{ + char szWork[200]; + CPLXMLNode *psTree; + GDALGenImgProjTransformInfo *psInfo = + (GDALGenImgProjTransformInfo *) pTransformArg; + + psTree = CPLCreateXMLNode( NULL, CXT_Element, "GenImgProjTransformer" ); + +/* -------------------------------------------------------------------- */ +/* Handle GCP transformation. */ +/* -------------------------------------------------------------------- */ + if( psInfo->pSrcGCPTransformArg != NULL ) + { + CPLXMLNode *psTransformerContainer; + CPLXMLNode *psTransformer; + + psTransformerContainer = + CPLCreateXMLNode( psTree, CXT_Element, "SrcGCPTransformer" ); + + psTransformer = GDALSerializeTransformer( GDALGCPTransform, + psInfo->pSrcGCPTransformArg); + if( psTransformer != NULL ) + CPLAddXMLChild( psTransformerContainer, psTransformer ); + } + +/* -------------------------------------------------------------------- */ +/* Handle TPS transformation. */ +/* -------------------------------------------------------------------- */ + else if( psInfo->pSrcTPSTransformArg != NULL ) + { + CPLXMLNode *psTransformerContainer; + CPLXMLNode *psTransformer; + + psTransformerContainer = + CPLCreateXMLNode( psTree, CXT_Element, "SrcTPSTransformer" ); + + psTransformer = + GDALSerializeTransformer( NULL, psInfo->pSrcTPSTransformArg); + if( psTransformer != NULL ) + CPLAddXMLChild( psTransformerContainer, psTransformer ); + } + +/* -------------------------------------------------------------------- */ +/* Handle source geotransforms. */ +/* -------------------------------------------------------------------- */ + else + { + sprintf( szWork, "%.16g,%.16g,%.16g,%.16g,%.16g,%.16g", + psInfo->adfSrcGeoTransform[0], + psInfo->adfSrcGeoTransform[1], + psInfo->adfSrcGeoTransform[2], + psInfo->adfSrcGeoTransform[3], + psInfo->adfSrcGeoTransform[4], + psInfo->adfSrcGeoTransform[5] ); + CPLCreateXMLElementAndValue( psTree, "SrcGeoTransform", szWork ); + + sprintf( szWork, "%.16g,%.16g,%.16g,%.16g,%.16g,%.16g", + psInfo->adfSrcInvGeoTransform[0], + psInfo->adfSrcInvGeoTransform[1], + psInfo->adfSrcInvGeoTransform[2], + psInfo->adfSrcInvGeoTransform[3], + psInfo->adfSrcInvGeoTransform[4], + psInfo->adfSrcInvGeoTransform[5] ); + CPLCreateXMLElementAndValue( psTree, "SrcInvGeoTransform", szWork ); + } + +/* -------------------------------------------------------------------- */ +/* Handle destination geotransforms. */ +/* -------------------------------------------------------------------- */ + sprintf( szWork, "%.16g,%.16g,%.16g,%.16g,%.16g,%.16g", + psInfo->adfDstGeoTransform[0], + psInfo->adfDstGeoTransform[1], + psInfo->adfDstGeoTransform[2], + psInfo->adfDstGeoTransform[3], + psInfo->adfDstGeoTransform[4], + psInfo->adfDstGeoTransform[5] ); + CPLCreateXMLElementAndValue( psTree, "DstGeoTransform", szWork ); + + sprintf( szWork, "%.16g,%.16g,%.16g,%.16g,%.16g,%.16g", + psInfo->adfDstInvGeoTransform[0], + psInfo->adfDstInvGeoTransform[1], + psInfo->adfDstInvGeoTransform[2], + psInfo->adfDstInvGeoTransform[3], + psInfo->adfDstInvGeoTransform[4], + psInfo->adfDstInvGeoTransform[5] ); + CPLCreateXMLElementAndValue( psTree, "DstInvGeoTransform", szWork ); + +/* -------------------------------------------------------------------- */ +/* Do we have a reprojection transformer? */ +/* -------------------------------------------------------------------- */ + if( psInfo->pReprojectArg != NULL ) + { + CPLXMLNode *psTransformerContainer; + CPLXMLNode *psTransformer; + + psTransformerContainer = + CPLCreateXMLNode( psTree, CXT_Element, "ReprojectTransformer" ); + + psTransformer = GDALSerializeTransformer( GDALReprojectionTransform, + psInfo->pReprojectArg ); + if( psTransformer != NULL ) + CPLAddXMLChild( psTransformerContainer, psTransformer ); + } + + return psTree; +} + +/************************************************************************/ +/* GDALDeserializeGenImgProjTransformer() */ +/************************************************************************/ + +void *GDALDeserializeGenImgProjTransformer( CPLXMLNode *psTree ) + +{ + GDALGenImgProjTransformInfo *psInfo; + CPLXMLNode *psSubtree; + +/* -------------------------------------------------------------------- */ +/* Initialize the transform info. */ +/* -------------------------------------------------------------------- */ + psInfo = (GDALGenImgProjTransformInfo *) + CPLCalloc(sizeof(GDALGenImgProjTransformInfo),1); + + strcpy( psInfo->sTI.szSignature, "GTI" ); + psInfo->sTI.pszClassName = "GDALGenImgProjTransformer"; + psInfo->sTI.pfnTransform = GDALGenImgProjTransform; + psInfo->sTI.pfnCleanup = GDALDestroyGenImgProjTransformer; + psInfo->sTI.pfnSerialize = GDALSerializeGenImgProjTransformer; + +/* -------------------------------------------------------------------- */ +/* SrcGeotransform */ +/* -------------------------------------------------------------------- */ + if( CPLGetXMLNode( psTree, "SrcGeoTransform" ) != NULL ) + { + sscanf( CPLGetXMLValue( psTree, "SrcGeoTransform", "" ), + "%lg,%lg,%lg,%lg,%lg,%lg", + psInfo->adfSrcGeoTransform + 0, + psInfo->adfSrcGeoTransform + 1, + psInfo->adfSrcGeoTransform + 2, + psInfo->adfSrcGeoTransform + 3, + psInfo->adfSrcGeoTransform + 4, + psInfo->adfSrcGeoTransform + 5 ); + + if( CPLGetXMLNode( psTree, "SrcInvGeoTransform" ) != NULL ) + { + sscanf( CPLGetXMLValue( psTree, "SrcInvGeoTransform", "" ), + "%lg,%lg,%lg,%lg,%lg,%lg", + psInfo->adfSrcInvGeoTransform + 0, + psInfo->adfSrcInvGeoTransform + 1, + psInfo->adfSrcInvGeoTransform + 2, + psInfo->adfSrcInvGeoTransform + 3, + psInfo->adfSrcInvGeoTransform + 4, + psInfo->adfSrcInvGeoTransform + 5 ); + + } + else + GDALInvGeoTransform( psInfo->adfSrcGeoTransform, + psInfo->adfSrcInvGeoTransform ); + } + +/* -------------------------------------------------------------------- */ +/* Src GCP Transform */ +/* -------------------------------------------------------------------- */ + psSubtree = CPLGetXMLNode( psTree, "SrcGCPTransformer" ); + if( psSubtree != NULL && psSubtree->psChild != NULL ) + { + psInfo->pSrcGCPTransformArg = + GDALDeserializeGCPTransformer( psSubtree->psChild ); + } + +/* -------------------------------------------------------------------- */ +/* Src TPS Transform */ +/* -------------------------------------------------------------------- */ + psSubtree = CPLGetXMLNode( psTree, "SrcTPSTransformer" ); + if( psSubtree != NULL && psSubtree->psChild != NULL ) + { + psInfo->pSrcTPSTransformArg = + GDALDeserializeTPSTransformer( psSubtree->psChild ); + } + +/* -------------------------------------------------------------------- */ +/* DstGeotransform */ +/* -------------------------------------------------------------------- */ + if( CPLGetXMLNode( psTree, "DstGeoTransform" ) != NULL ) + { + sscanf( CPLGetXMLValue( psTree, "DstGeoTransform", "" ), + "%lg,%lg,%lg,%lg,%lg,%lg", + psInfo->adfDstGeoTransform + 0, + psInfo->adfDstGeoTransform + 1, + psInfo->adfDstGeoTransform + 2, + psInfo->adfDstGeoTransform + 3, + psInfo->adfDstGeoTransform + 4, + psInfo->adfDstGeoTransform + 5 ); + + if( CPLGetXMLNode( psTree, "DstInvGeoTransform" ) != NULL ) + { + sscanf( CPLGetXMLValue( psTree, "DstInvGeoTransform", "" ), + "%lg,%lg,%lg,%lg,%lg,%lg", + psInfo->adfDstInvGeoTransform + 0, + psInfo->adfDstInvGeoTransform + 1, + psInfo->adfDstInvGeoTransform + 2, + psInfo->adfDstInvGeoTransform + 3, + psInfo->adfDstInvGeoTransform + 4, + psInfo->adfDstInvGeoTransform + 5 ); + + } + else + GDALInvGeoTransform( psInfo->adfDstGeoTransform, + psInfo->adfDstInvGeoTransform ); + } + +/* -------------------------------------------------------------------- */ +/* Reproject transformer */ +/* -------------------------------------------------------------------- */ + psSubtree = CPLGetXMLNode( psTree, "ReprojectTransformer" ); + if( psSubtree != NULL && psSubtree->psChild != NULL ) + { + psInfo->pReprojectArg = + GDALDeserializeReprojectionTransformer( psSubtree->psChild ); + } + + return psInfo; +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALReprojectionTransformer */ +/* ==================================================================== */ +/************************************************************************/ + +typedef struct { + GDALTransformerInfo sTI; + + OGRCoordinateTransformation *poForwardTransform; + OGRCoordinateTransformation *poReverseTransform; +} GDALReprojectionTransformInfo; + +/************************************************************************/ +/* GDALCreateReprojectionTransformer() */ +/************************************************************************/ + +/** + * Create reprojection transformer. + * + * Creates a callback data structure suitable for use with + * GDALReprojectionTransformation() to represent a transformation from + * one geographic or projected coordinate system to another. On input + * the coordinate systems are described in OpenGIS WKT format. + * + * Internally the OGRCoordinateTransformation object is used to implement + * the reprojection. + * + * @param pszSrcWKT the coordinate system for the source coordinate system. + * @param pszDstWKT the coordinate system for the destination coordinate + * system. + * + * @return Handle for use with GDALReprojectionTransform(), or NULL if the + * system fails to initialize the reprojection. + **/ + +void *GDALCreateReprojectionTransformer( const char *pszSrcWKT, + const char *pszDstWKT ) + +{ + OGRSpatialReference oSrcSRS, oDstSRS; + OGRCoordinateTransformation *poForwardTransform; + +/* -------------------------------------------------------------------- */ +/* Ingest the SRS definitions. */ +/* -------------------------------------------------------------------- */ + if( oSrcSRS.importFromWkt( (char **) &pszSrcWKT ) != OGRERR_NONE ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to import coordinate system `%s'.", + pszSrcWKT ); + return NULL; + } + if( oDstSRS.importFromWkt( (char **) &pszDstWKT ) != OGRERR_NONE ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to import coordinate system `%s'.", + pszSrcWKT ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Build the forward coordinate transformation. */ +/* -------------------------------------------------------------------- */ + poForwardTransform = OGRCreateCoordinateTransformation(&oSrcSRS,&oDstSRS); + + if( poForwardTransform == NULL ) + // OGRCreateCoordinateTransformation() will report errors on its own. + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a structure to hold the transform info, and also */ +/* build reverse transform. We assume that if the forward */ +/* transform can be created, then so can the reverse one. */ +/* -------------------------------------------------------------------- */ + GDALReprojectionTransformInfo *psInfo; + + psInfo = (GDALReprojectionTransformInfo *) + CPLCalloc(sizeof(GDALReprojectionTransformInfo),1); + + psInfo->poForwardTransform = poForwardTransform; + psInfo->poReverseTransform = + OGRCreateCoordinateTransformation(&oDstSRS,&oSrcSRS); + + strcpy( psInfo->sTI.szSignature, "GTI" ); + psInfo->sTI.pszClassName = "GDALReprojectionTransformer"; + psInfo->sTI.pfnTransform = GDALReprojectionTransform; + psInfo->sTI.pfnCleanup = GDALDestroyReprojectionTransformer; + psInfo->sTI.pfnSerialize = GDALSerializeReprojectionTransformer; + + return psInfo; +} + +/************************************************************************/ +/* GDALDestroyReprojectionTransformer() */ +/************************************************************************/ + +/** + * Destroy reprojection transformation. + * + * @param pTransformArg the transformation handle returned by + * GDALCreateReprojectionTransformer(). + */ + +void GDALDestroyReprojectionTransformer( void *pTransformAlg ) + +{ + GDALReprojectionTransformInfo *psInfo = + (GDALReprojectionTransformInfo *) pTransformAlg; + + if( psInfo->poForwardTransform ) + delete psInfo->poForwardTransform; + + if( psInfo->poReverseTransform ) + delete psInfo->poReverseTransform; + + CPLFree( psInfo ); +} + +/************************************************************************/ +/* GDALReprojectionTransform() */ +/************************************************************************/ + +/** + * Perform reprojection transformation. + * + * Actually performs the reprojection transformation described in + * GDALCreateReprojectionTransformer(). This function matches the + * GDALTransformerFunc() signature. Details of the arguments are described + * there. + */ + +int GDALReprojectionTransform( void *pTransformArg, int bDstToSrc, + int nPointCount, + double *padfX, double *padfY, double *padfZ, + int *panSuccess ) + +{ + GDALReprojectionTransformInfo *psInfo = + (GDALReprojectionTransformInfo *) pTransformArg; + int bSuccess; + + if( bDstToSrc ) + bSuccess = psInfo->poReverseTransform->TransformEx( + nPointCount, padfX, padfY, padfZ, panSuccess ); + else + bSuccess = psInfo->poForwardTransform->TransformEx( + nPointCount, padfX, padfY, padfZ, panSuccess ); + + return bSuccess; +} + +/************************************************************************/ +/* GDALSerializeReprojectionTransformer() */ +/************************************************************************/ + +static CPLXMLNode * +GDALSerializeReprojectionTransformer( void *pTransformArg ) + +{ + CPLXMLNode *psTree; + GDALReprojectionTransformInfo *psInfo = + (GDALReprojectionTransformInfo *) pTransformArg; + + psTree = CPLCreateXMLNode( NULL, CXT_Element, "ReprojectionTransformer" ); + +/* -------------------------------------------------------------------- */ +/* Handle SourceCS. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference *poSRS; + char *pszWKT = NULL; + + poSRS = psInfo->poForwardTransform->GetSourceCS(); + poSRS->exportToWkt( &pszWKT ); + CPLCreateXMLElementAndValue( psTree, "SourceSRS", pszWKT ); + CPLFree( pszWKT ); + +/* -------------------------------------------------------------------- */ +/* Handle DestinationCS. */ +/* -------------------------------------------------------------------- */ + poSRS = psInfo->poForwardTransform->GetTargetCS(); + poSRS->exportToWkt( &pszWKT ); + CPLCreateXMLElementAndValue( psTree, "TargetSRS", pszWKT ); + CPLFree( pszWKT ); + + return psTree; +} + +/************************************************************************/ +/* GDALDeserializeReprojectionTransformer() */ +/************************************************************************/ + +static void * +GDALDeserializeReprojectionTransformer( CPLXMLNode *psTree ) + +{ + const char *pszSourceSRS = CPLGetXMLValue( psTree, "SourceSRS", NULL ); + const char *pszTargetSRS= CPLGetXMLValue( psTree, "TargetSRS", NULL ); + char *pszSourceWKT = NULL, *pszTargetWKT = NULL; + void *pResult = NULL; + + if( pszSourceSRS != NULL ) + { + OGRSpatialReference oSRS; + + if( oSRS.SetFromUserInput( pszSourceSRS ) == OGRERR_NONE ) + oSRS.exportToWkt( &pszSourceWKT ); + } + + if( pszTargetSRS != NULL ) + { + OGRSpatialReference oSRS; + + if( oSRS.SetFromUserInput( pszTargetSRS ) == OGRERR_NONE ) + oSRS.exportToWkt( &pszTargetWKT ); + } + + if( pszSourceWKT != NULL && pszTargetWKT != NULL ) + { + pResult = GDALCreateReprojectionTransformer( pszSourceWKT, + pszTargetWKT ); + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "ReprojectionTransformer definition missing either\n" + "SourceSRS or TargetSRS definition." ); + } + + CPLFree( pszSourceWKT ); + CPLFree( pszTargetWKT ); + + return pResult; +} + +/************************************************************************/ +/* ==================================================================== */ +/* Approximate transformer. */ +/* ==================================================================== */ +/************************************************************************/ + +typedef struct +{ + GDALTransformerInfo sTI; + + GDALTransformerFunc pfnBaseTransformer; + void *pBaseCBData; + double dfMaxError; + + int bOwnSubtransformer; +} ApproxTransformInfo; + +/************************************************************************/ +/* GDALSerializeApproxTransformer() */ +/************************************************************************/ + +static CPLXMLNode * +GDALSerializeApproxTransformer( void *pTransformArg ) + +{ + CPLXMLNode *psTree; + ApproxTransformInfo *psInfo = (ApproxTransformInfo *) pTransformArg; + + psTree = CPLCreateXMLNode( NULL, CXT_Element, "ApproxTransformer" ); + +/* -------------------------------------------------------------------- */ +/* Attach max error. */ +/* -------------------------------------------------------------------- */ + CPLCreateXMLElementAndValue( psTree, "MaxError", + CPLSPrintf( "%g", psInfo->dfMaxError ) ); + +/* -------------------------------------------------------------------- */ +/* Capture underlying transformer. */ +/* -------------------------------------------------------------------- */ + CPLXMLNode *psTransformerContainer; + CPLXMLNode *psTransformer; + + psTransformerContainer = + CPLCreateXMLNode( psTree, CXT_Element, "BaseTransformer" ); + + psTransformer = GDALSerializeTransformer( psInfo->pfnBaseTransformer, + psInfo->pBaseCBData ); + if( psTransformer != NULL ) + CPLAddXMLChild( psTransformerContainer, psTransformer ); + + return psTree; +} + +/************************************************************************/ +/* GDALCreateApproxTransformer() */ +/************************************************************************/ + +/** + * Create an approximating transformer. + * + * This function creates a context for an approximated transformer. Basically + * a high precision transformer is supplied as input and internally linear + * approximations are computed to generate results to within a defined + * precision. + * + * The approximation is actually done at the point where GDALApproxTransform() + * calls are made, and depend on the assumption that the roughly linear. The + * first and last point passed in must be the extreme values and the + * intermediate values should describe a curve between the end points. The + * approximator transforms and center using the approximate transformer, and + * then compares the true middle transformed value to a linear approximation + * based on the end points. If the error is within the supplied threshold + * then the end points are used to linearly approximate all the values + * otherwise the inputs points are split into two smaller sets, and the + * function recursively called till a sufficiently small set of points if found + * that the linear approximation is OK, or that all the points are exactly + * computed. + * + * This function is very suitable for approximating transformation results + * from output pixel/line space to input coordinates for warpers that operate + * on one input scanline at a time. Care should be taken using it in other + * circumstances as little internal validation is done, in order to keep things + * fast. + * + * @param pfnBaseTransformer the high precision transformer which should be + * approximated. + * @param pBaseTransformArg the callback argument for the high precision + * transformer. + * @param dfMaxError the maximum cartesian error in the "output" space that + * is to be accepted in the linear approximation. + * + * @return callback pointer suitable for use with GDALApproxTransform(). It + * should be deallocated with GDALDestroyApproxTransformer(). + */ + +void *GDALCreateApproxTransformer( GDALTransformerFunc pfnBaseTransformer, + void *pBaseTransformArg, double dfMaxError) + +{ + ApproxTransformInfo *psATInfo; + + psATInfo = (ApproxTransformInfo*) CPLMalloc(sizeof(ApproxTransformInfo)); + psATInfo->pfnBaseTransformer = pfnBaseTransformer; + psATInfo->pBaseCBData = pBaseTransformArg; + psATInfo->dfMaxError = dfMaxError; + psATInfo->bOwnSubtransformer = FALSE; + + strcpy( psATInfo->sTI.szSignature, "GTI" ); + psATInfo->sTI.pszClassName = "GDALApproxTransformer"; + psATInfo->sTI.pfnTransform = GDALApproxTransform; + psATInfo->sTI.pfnCleanup = GDALDestroyApproxTransformer; + psATInfo->sTI.pfnSerialize = GDALSerializeApproxTransformer; + + return psATInfo; +} + +/************************************************************************/ +/* GDALApproxTransformerOwnsSubtransformer() */ +/************************************************************************/ + +void GDALApproxTransformerOwnsSubtransformer( void *pCBData, int bOwnFlag ) + +{ + ApproxTransformInfo *psATInfo = (ApproxTransformInfo *) pCBData; + + psATInfo->bOwnSubtransformer = bOwnFlag; +} + +/************************************************************************/ +/* GDALDestroyApproxTransformer() */ +/************************************************************************/ + +/** + * Cleanup approximate transformer. + * + * Deallocates the resources allocated by GDALCreateApproxTransformer(). + * + * @param pCBData callback data originally returned by + * GDALCreateApproxTransformer(). + */ + +void GDALDestroyApproxTransformer( void * pCBData ) + +{ + ApproxTransformInfo *psATInfo = (ApproxTransformInfo *) pCBData; + + if( psATInfo->bOwnSubtransformer ) + GDALDestroyTransformer( psATInfo->pBaseCBData ); + + CPLFree( pCBData ); +} + +/************************************************************************/ +/* GDALApproxTransform() */ +/************************************************************************/ + +/** + * Perform approximate transformation. + * + * Actually performs the approximate transformation described in + * GDALCreateApproxTransformer(). This function matches the + * GDALTransformerFunc() signature. Details of the arguments are described + * there. + */ + +int GDALApproxTransform( void *pCBData, int bDstToSrc, int nPoints, + double *x, double *y, double *z, int *panSuccess ) + +{ + ApproxTransformInfo *psATInfo = (ApproxTransformInfo *) pCBData; + double x2[3], y2[3], z2[3], dfDeltaX, dfDeltaY, dfError, dfDist, dfDeltaZ; + int nMiddle, anSuccess2[3], i, bSuccess; + + nMiddle = (nPoints-1)/2; + +/* -------------------------------------------------------------------- */ +/* Bail if our preconditions are not met, or if error is not */ +/* acceptable. */ +/* -------------------------------------------------------------------- */ + if( y[0] != y[nPoints-1] || y[0] != y[nMiddle] + || x[0] == x[nPoints-1] || x[0] == x[nMiddle] + || psATInfo->dfMaxError == 0.0 || nPoints <= 5 ) + { + return psATInfo->pfnBaseTransformer( psATInfo->pBaseCBData, bDstToSrc, + nPoints, x, y, z, panSuccess ); + } + +/* -------------------------------------------------------------------- */ +/* Transform first, last and middle point. */ +/* -------------------------------------------------------------------- */ + x2[0] = x[0]; + y2[0] = y[0]; + z2[0] = z[0]; + x2[1] = x[nMiddle]; + y2[1] = y[nMiddle]; + z2[1] = z[nMiddle]; + x2[2] = x[nPoints-1]; + y2[2] = y[nPoints-1]; + z2[2] = z[nPoints-1]; + + bSuccess = + psATInfo->pfnBaseTransformer( psATInfo->pBaseCBData, bDstToSrc, 3, + x2, y2, z2, anSuccess2 ); + if( !bSuccess || !anSuccess2[0] || !anSuccess2[1] || !anSuccess2[2] ) + return psATInfo->pfnBaseTransformer( psATInfo->pBaseCBData, bDstToSrc, + nPoints, x, y, z, panSuccess ); + +/* -------------------------------------------------------------------- */ +/* Is the error at the middle acceptable relative to an */ +/* interpolation of the middle position? */ +/* -------------------------------------------------------------------- */ + dfDeltaX = (x2[2] - x2[0]) / (x[nPoints-1] - x[0]); + dfDeltaY = (y2[2] - y2[0]) / (x[nPoints-1] - x[0]); + dfDeltaZ = (z2[2] - z2[0]) / (x[nPoints-1] - x[0]); + + dfError = fabs((x2[0] + dfDeltaX * (x[nMiddle] - x[0])) - x2[1]) + + fabs((y2[0] + dfDeltaY * (x[nMiddle] - x[0])) - y2[1]); + + if( dfError > psATInfo->dfMaxError ) + { +#ifdef notdef + CPLDebug( "GDAL", "ApproxTransformer - " + "error %g over threshold %g, subdivide %d points.", + dfError, psATInfo->dfMaxError, nPoints ); +#endif + + bSuccess = + GDALApproxTransform( psATInfo, bDstToSrc, nMiddle, + x, y, z, panSuccess ); + + if( !bSuccess ) + return FALSE; + + bSuccess = + GDALApproxTransform( psATInfo, bDstToSrc, nPoints - nMiddle, + x+nMiddle, y+nMiddle, z+nMiddle, + panSuccess+nMiddle ); + + if( !bSuccess ) + return FALSE; + + return TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Error is OK since this is just used to compute output bounds */ +/* of newly created file for gdalwarper. So just use affine */ +/* approximation of the reverse transform. Eventually we */ +/* should implement iterative searching to find a result within */ +/* our error threshold. */ +/* -------------------------------------------------------------------- */ + for( i = nPoints-1; i >= 0; i-- ) + { + dfDist = (x[i] - x[0]); + y[i] = y2[0] + dfDeltaY * dfDist; + x[i] = x2[0] + dfDeltaX * dfDist; + z[i] = z2[0] + dfDeltaZ * dfDist; + panSuccess[i] = TRUE; + } + + return TRUE; +} + +/************************************************************************/ +/* GDALDeserializeApproxTransformer() */ +/************************************************************************/ + +static void * +GDALDeserializeApproxTransformer( CPLXMLNode *psTree ) + +{ + double dfMaxError = atof(CPLGetXMLValue( psTree, "MaxError", "0.25" )); + CPLXMLNode *psContainer; + GDALTransformerFunc pfnBaseTransform = NULL; + void *pBaseCBData = NULL; + + psContainer = CPLGetXMLNode( psTree, "BaseTransformer" ); + + if( psContainer != NULL && psContainer->psChild != NULL ) + { + GDALDeserializeTransformer( psContainer->psChild, + &pfnBaseTransform, + &pBaseCBData ); + + } + + if( pfnBaseTransform == NULL ) + return NULL; + else + { + void *pApproxCBData = GDALCreateApproxTransformer( pfnBaseTransform, + pBaseCBData, + dfMaxError ); + GDALApproxTransformerOwnsSubtransformer( pApproxCBData, TRUE ); + + return pApproxCBData; + } +} + +/************************************************************************/ +/* GDALApplyGeoTransform() */ +/************************************************************************/ + +/** + * Apply GeoTransform to x/y coordinate. + * + * Applies the following computation, converting a (pixel,line) coordinate + * into a georeferenced (geo_x,geo_y) location. + * + * *pdfGeoX = padfGeoTransform[0] + dfPixel * padfGeoTransform[1] + * + dfLine * padfGeoTransform[2]; + * *pdfGeoY = padfGeoTransform[3] + dfPixel * padfGeoTransform[4] + * + dfLine * padfGeoTransform[5]; + * + * @param padfGeoTransform Six coefficient GeoTransform to apply. + * @param dfPixel Input pixel position. + * @param dfLine Input line position. + * @param *pdfGeoX output location where GeoX (easting/longitude) location is placed. + * @param *pdfGeoY output location where GeoX (northing/latitude) location is placed. + */ + +void CPL_STDCALL GDALApplyGeoTransform( double *padfGeoTransform, + double dfPixel, double dfLine, + double *pdfGeoX, double *pdfGeoY ) +{ + *pdfGeoX = padfGeoTransform[0] + dfPixel * padfGeoTransform[1] + + dfLine * padfGeoTransform[2]; + *pdfGeoY = padfGeoTransform[3] + dfPixel * padfGeoTransform[4] + + dfLine * padfGeoTransform[5]; +} + +/************************************************************************/ +/* GDALInvGeoTransform() */ +/************************************************************************/ + +/** + * Invert Geotransform. + * + * This function will invert a standard 3x2 set of GeoTransform coefficients. + * This converts the equation from being pixel to geo to being geo to pixel. + * + * @param gt_in Input geotransform (six doubles - unaltered). + * @param gt_out Output geotransform (six doubles - updated). + * + * @return TRUE on success or FALSE if the equation is uninvertable. + */ + +int CPL_STDCALL GDALInvGeoTransform( double *gt_in, double *gt_out ) + +{ + double det, inv_det; + + /* we assume a 3rd row that is [1 0 0] */ + + /* Compute determinate */ + + det = gt_in[1] * gt_in[5] - gt_in[2] * gt_in[4]; + + if( fabs(det) < 0.000000000000001 ) + return 0; + + inv_det = 1.0 / det; + + /* compute adjoint, and devide by determinate */ + + gt_out[1] = gt_in[5] * inv_det; + gt_out[4] = -gt_in[4] * inv_det; + + gt_out[2] = -gt_in[2] * inv_det; + gt_out[5] = gt_in[1] * inv_det; + + gt_out[0] = ( gt_in[2] * gt_in[3] - gt_in[0] * gt_in[5]) * inv_det; + gt_out[3] = (-gt_in[1] * gt_in[3] + gt_in[0] * gt_in[4]) * inv_det; + + return 1; +} + +/************************************************************************/ +/* GDALSerializeTransformer() */ +/************************************************************************/ + +CPLXMLNode *GDALSerializeTransformer( GDALTransformerFunc pfnFunc, + void *pTransformArg ) + +{ + GDALTransformerInfo *psInfo = (GDALTransformerInfo *) pTransformArg; + + if( psInfo == NULL || !EQUAL(psInfo->szSignature,"GTI") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to serialize non-GTI transformer." ); + return NULL; + } + else + return psInfo->pfnSerialize( pTransformArg ); +} + +/************************************************************************/ +/* GDALDeserializeTransformer() */ +/************************************************************************/ + +CPLErr GDALDeserializeTransformer( CPLXMLNode *psTree, + GDALTransformerFunc *ppfnFunc, + void **ppTransformArg ) + +{ + *ppfnFunc = NULL; + *ppTransformArg = NULL; + + CPLErrorReset(); + + if( psTree == NULL || psTree->eType != CXT_Element ) + CPLError( CE_Failure, CPLE_AppDefined, + "Malformed element in GDALDeserializeTransformer" ); + else if( EQUAL(psTree->pszValue,"GenImgProjTransformer") ) + { + *ppfnFunc = GDALGenImgProjTransform; + *ppTransformArg = GDALDeserializeGenImgProjTransformer( psTree ); + } + else if( EQUAL(psTree->pszValue,"ReprojectionTransformer") ) + { + *ppfnFunc = GDALReprojectionTransform; + *ppTransformArg = GDALDeserializeReprojectionTransformer( psTree ); + } + else if( EQUAL(psTree->pszValue,"GCPTransformer") ) + { + *ppfnFunc = GDALGCPTransform; + *ppTransformArg = GDALDeserializeGCPTransformer( psTree ); + } + else if( EQUAL(psTree->pszValue,"TPSTransformer") ) + { + *ppfnFunc = GDALTPSTransform; + *ppTransformArg = GDALDeserializeTPSTransformer( psTree ); + } + else if( EQUAL(psTree->pszValue,"ApproxTransformer") ) + { + *ppfnFunc = GDALApproxTransform; + *ppTransformArg = GDALDeserializeApproxTransformer( psTree ); + } + else + CPLError( CE_Failure, CPLE_AppDefined, + "Unrecognised element '%s' GDALDeserializeTransformer", + psTree->pszValue ); + + return CPLGetLastErrorType(); +} + +/************************************************************************/ +/* GDALDestroyTransformer() */ +/************************************************************************/ + +void GDALDestroyTransformer( void *pTransformArg ) + +{ + GDALTransformerInfo *psInfo = (GDALTransformerInfo *) pTransformArg; + + if( psInfo == NULL || !EQUAL(psInfo->szSignature,"GTI") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to destroy non-GTI transformer." ); + } + else + psInfo->pfnCleanup( pTransformArg ); +} + diff --git a/Utilities/GDAL/alg/gdalwarper.cpp b/Utilities/GDAL/alg/gdalwarper.cpp new file mode 100644 index 0000000000..25195df3fd --- /dev/null +++ b/Utilities/GDAL/alg/gdalwarper.cpp @@ -0,0 +1,1153 @@ +/****************************************************************************** + * $Id: gdalwarper.cpp,v 1.19 2005/04/11 17:20:40 fwarmerdam Exp $ + * + * Project: High Performance Image Reprojector + * Purpose: Implementation of high level convenience APIs for warper. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdalwarper.cpp,v $ + * Revision 1.19 2005/04/11 17:20:40 fwarmerdam + * ensure dstnodata is duplicate in clonewarpoptions: bug 821 + * + * Revision 1.18 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.17 2004/12/31 02:11:20 fwarmerdam + * Avoid warning. + * + * Revision 1.16 2004/10/07 15:50:18 fwarmerdam + * added preliminary alpha band support + * + * Revision 1.15 2004/08/11 21:20:47 warmerda + * avoid crash if transformer does not serialize + * + * Revision 1.14 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.13 2004/04/01 18:58:41 warmerda + * fixed GDALReprojectImage() -- pass on eResampleAlg + * + * Revision 1.12 2004/03/28 21:20:39 warmerda + * fixed initialization of nodata values + * + * Revision 1.11 2004/03/19 15:54:42 warmerda + * Fixed another place where "2" was used instead of 0 as the default + * polynomial order. + * + * Revision 1.10 2004/03/19 05:06:00 warmerda + * Pass 0 for order to GDALCreateGenImgProjTransformer() from + * GDALCreateAndReprojectImage() so that the default will be to figure + * out the best order instead of defaulting to 2nd order. + * + * Revision 1.9 2004/02/25 19:51:00 warmerda + * Fixed nodata check in GDT_Int16 case (from Manuel Massing). + * + * Revision 1.8 2003/07/26 17:32:16 warmerda + * Added info on new warp options. + * + * Revision 1.7 2003/05/06 18:31:35 warmerda + * added WRITE_FLUSH comment + * + * Revision 1.6 2003/04/22 19:41:24 dron + * Fixed problem in GDALWarpNoDataMasker(): missed breaks in switch. + * + * Revision 1.5 2003/03/02 05:25:26 warmerda + * added GDALWarpNoDataMasker + * + * Revision 1.4 2003/02/22 02:04:11 warmerda + * added dfMaxError to reproject function + * + * Revision 1.3 2003/02/21 15:41:55 warmerda + * rename data member + * + * Revision 1.2 2003/02/20 21:53:06 warmerda + * partial implementation + * + * Revision 1.1 2003/02/18 17:25:50 warmerda + * New + * + */ + +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + +CPL_CVSID("$Id: gdalwarper.cpp,v 1.19 2005/04/11 17:20:40 fwarmerdam Exp $"); + +/************************************************************************/ +/* GDALReprojectImage() */ +/************************************************************************/ + +/** + * Reproject image. + * + * This is a convenience function utilizing the GDALWarpOperation class to + * reproject an image from a source to a destination. In particular, this + * function takes care of establishing the transformation function to + * implement the reprojection, and will default a variety of other + * warp options. + * + * By default all bands are transferred, with no masking or nodata values + * in effect. No metadata, projection info, or color tables are transferred + * to the output file. + * + * @param hSrcDS the source image file. + * @param pszSrcWKT the source projection. If NULL the source projection + * is read from from hSrcDS. + * @param hDstDS the destination image file. + * @param pszDstWKT the destination projection. If NULL the destination + * projection will be read from hDstDS. + * @param eResampleAlg the type of resampling to use. + * @param dfWarpMemoryLimit the amount of memory (in bytes) that the warp + * API is allowed to use for caching. This is in addition to the memory + * already allocated to the GDAL caching (as per GDALSetCacheMax()). May be + * 0.0 to use default memory settings. + * @param dfMaxError maximum error measured in input pixels that is allowed + * in approximating the transformation (0.0 for exact calculations). + * @param pfnProgress a GDALProgressFunc() compatible callback function for + * reporting progress or NULL. + * @param pProgressArg argument to be passed to pfnProgress. May be NULL. + * @param psOptions warp options, normally NULL. + * + * @return CE_None on success or CE_Failure if something goes wrong. + */ + +CPLErr CPL_STDCALL +GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + GDALResampleAlg eResampleAlg, + double dfWarpMemoryLimit, + double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ) + +{ + GDALWarpOptions *psWOptions; + +/* -------------------------------------------------------------------- */ +/* Default a few parameters. */ +/* -------------------------------------------------------------------- */ + if( pszSrcWKT == NULL ) + pszSrcWKT = GDALGetProjectionRef( hSrcDS ); + + if( pszDstWKT == NULL ) + pszDstWKT = pszSrcWKT; + +/* -------------------------------------------------------------------- */ +/* Setup a reprojection based transformer. */ +/* -------------------------------------------------------------------- */ + void *hTransformArg; + + hTransformArg = + GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, hDstDS, pszDstWKT, + TRUE, 1000.0, 0 ); + + if( hTransformArg == NULL ) + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Create a copy of the user provided options, or a defaulted */ +/* options structure. */ +/* -------------------------------------------------------------------- */ + if( psOptions == NULL ) + psWOptions = GDALCreateWarpOptions(); + else + psWOptions = GDALCloneWarpOptions( psOptions ); + + psWOptions->eResampleAlg = eResampleAlg; + +/* -------------------------------------------------------------------- */ +/* Set transform. */ +/* -------------------------------------------------------------------- */ + if( dfMaxError > 0.0 ) + { + psWOptions->pTransformerArg = + GDALCreateApproxTransformer( GDALGenImgProjTransform, + hTransformArg, dfMaxError ); + + psWOptions->pfnTransformer = GDALApproxTransform; + } + else + { + psWOptions->pfnTransformer = GDALGenImgProjTransform; + psWOptions->pTransformerArg = hTransformArg; + } + +/* -------------------------------------------------------------------- */ +/* Set file and band mapping. */ +/* -------------------------------------------------------------------- */ + int iBand; + + psWOptions->hSrcDS = hSrcDS; + psWOptions->hDstDS = hDstDS; + + if( psWOptions->nBandCount == 0 ) + { + psWOptions->nBandCount = MIN(GDALGetRasterCount(hSrcDS), + GDALGetRasterCount(hDstDS)); + + psWOptions->panSrcBands = (int *) + CPLMalloc(sizeof(int) * psWOptions->nBandCount); + psWOptions->panDstBands = (int *) + CPLMalloc(sizeof(int) * psWOptions->nBandCount); + + for( iBand = 0; iBand < psWOptions->nBandCount; iBand++ ) + { + psWOptions->panSrcBands[iBand] = iBand+1; + psWOptions->panDstBands[iBand] = iBand+1; + } + } + +/* -------------------------------------------------------------------- */ +/* Set source nodata values if the source dataset seems to have */ +/* any. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < psWOptions->nBandCount; iBand++ ) + { + GDALRasterBandH hBand = GDALGetRasterBand( hSrcDS, iBand+1 ); + int bGotNoData = FALSE; + double dfNoDataValue; + + dfNoDataValue = GDALGetRasterNoDataValue( hBand, &bGotNoData ); + if( bGotNoData ) + { + if( psWOptions->padfSrcNoDataReal == NULL ) + { + int ii; + + psWOptions->padfSrcNoDataReal = (double *) + CPLMalloc(sizeof(double) * psWOptions->nBandCount); + psWOptions->padfSrcNoDataImag = (double *) + CPLMalloc(sizeof(double) * psWOptions->nBandCount); + + for( ii = 0; ii < psWOptions->nBandCount; ii++ ) + { + psWOptions->padfSrcNoDataReal[ii] = -1.1e20; + psWOptions->padfSrcNoDataImag[ii] = 0.0; + } + } + + psWOptions->padfSrcNoDataReal[iBand] = dfNoDataValue; + } + } + +/* -------------------------------------------------------------------- */ +/* Set the progress function. */ +/* -------------------------------------------------------------------- */ + if( pfnProgress != NULL ) + { + psWOptions->pfnProgress = pfnProgress; + psWOptions->pProgressArg = pProgressArg; + } + +/* -------------------------------------------------------------------- */ +/* Create a warp options based on the options. */ +/* -------------------------------------------------------------------- */ + GDALWarpOperation oWarper; + CPLErr eErr; + + eErr = oWarper.Initialize( psWOptions ); + + if( eErr == CE_None ) + eErr = oWarper.ChunkAndWarpImage( 0, 0, + GDALGetRasterXSize(hDstDS), + GDALGetRasterYSize(hDstDS) ); + +/* -------------------------------------------------------------------- */ +/* Cleanup. */ +/* -------------------------------------------------------------------- */ + GDALDestroyGenImgProjTransformer( hTransformArg ); + + if( dfMaxError > 0.0 ) + GDALDestroyApproxTransformer( psWOptions->pTransformerArg ); + + GDALDestroyWarpOptions( psWOptions ); + + return eErr; +} + +/************************************************************************/ +/* GDALCreateAndReprojectImage() */ +/* */ +/* This is a "quicky" reprojection API. */ +/************************************************************************/ + +CPLErr CPL_STDCALL GDALCreateAndReprojectImage( + GDALDatasetH hSrcDS, const char *pszSrcWKT, + const char *pszDstFilename, const char *pszDstWKT, + GDALDriverH hDstDriver, char **papszCreateOptions, + GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ) + +{ +/* -------------------------------------------------------------------- */ +/* Default a few parameters. */ +/* -------------------------------------------------------------------- */ + if( hDstDriver == NULL ) + hDstDriver = GDALGetDriverByName( "GTiff" ); + + if( pszSrcWKT == NULL ) + pszSrcWKT = GDALGetProjectionRef( hSrcDS ); + + if( pszDstWKT == NULL ) + pszDstWKT = pszSrcWKT; + +/* -------------------------------------------------------------------- */ +/* Create a transformation object from the source to */ +/* destination coordinate system. */ +/* -------------------------------------------------------------------- */ + void *hTransformArg; + + hTransformArg = + GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT, + TRUE, 1000.0, 0 ); + + if( hTransformArg == NULL ) + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Get approximate output definition. */ +/* -------------------------------------------------------------------- */ + double adfDstGeoTransform[6]; + int nPixels, nLines; + + if( GDALSuggestedWarpOutput( hSrcDS, + GDALGenImgProjTransform, hTransformArg, + adfDstGeoTransform, &nPixels, &nLines ) + != CE_None ) + return CE_Failure; + + GDALDestroyGenImgProjTransformer( hTransformArg ); + +/* -------------------------------------------------------------------- */ +/* Create the output file. */ +/* -------------------------------------------------------------------- */ + GDALDatasetH hDstDS; + + hDstDS = GDALCreate( hDstDriver, pszDstFilename, nPixels, nLines, + GDALGetRasterCount(hSrcDS), + GDALGetRasterDataType(GDALGetRasterBand(hSrcDS,1)), + papszCreateOptions ); + + if( hDstDS == NULL ) + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Write out the projection definition. */ +/* -------------------------------------------------------------------- */ + GDALSetProjection( hDstDS, pszDstWKT ); + GDALSetGeoTransform( hDstDS, adfDstGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Perform the reprojection. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr ; + + eErr = + GDALReprojectImage( hSrcDS, pszSrcWKT, hDstDS, pszDstWKT, + eResampleAlg, dfWarpMemoryLimit, dfMaxError, + pfnProgress, pProgressArg, psOptions ); + + GDALClose( hDstDS ); + + return eErr; +} + +/************************************************************************/ +/* GDALWarpNoDataMasker() */ +/* */ +/* GDALMaskFunc for establishing a validity mask for a source */ +/* band based on a provided NODATA value. */ +/************************************************************************/ + +CPLErr +GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int /* nXOff */, int /* nYOff */, int nXSize, int nYSize, + GByte **ppImageData, + int bMaskIsFloat, void *pValidityMask ) + +{ + double *padfNoData = (double *) pMaskFuncArg; + GUInt32 *panValidityMask = (GUInt32 *) pValidityMask; + + if( nBandCount != 1 || bMaskIsFloat ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Invalid nBandCount or bMaskIsFloat argument in SourceNoDataMask" ); + return CE_Failure; + } + + switch( eType ) + { + case GDT_Byte: + { + int nNoData = (int) padfNoData[0]; + GByte *pabyData = (GByte *) *ppImageData; + int iOffset; + + // nothing to do if value is out of range. + if( padfNoData[0] < 0.0 || padfNoData[0] > 255.000001 + || padfNoData[1] != 0.0 ) + return CE_None; + + for( iOffset = nXSize*nYSize-1; iOffset >= 0; iOffset-- ) + { + if( pabyData[iOffset] == nNoData ) + { + panValidityMask[iOffset>>5] &= ~(0x01 << (iOffset & 0x1f)); + } + } + } + break; + + case GDT_Int16: + { + int nNoData = (int) padfNoData[0]; + GInt16 *panData = (GInt16 *) *ppImageData; + int iOffset; + + // nothing to do if value is out of range. + if( padfNoData[0] < -32768 || padfNoData[0] > 32767 + || padfNoData[1] != 0.0 ) + return CE_None; + + for( iOffset = nXSize*nYSize-1; iOffset >= 0; iOffset-- ) + { + if( panData[iOffset] == nNoData ) + { + panValidityMask[iOffset>>5] &= ~(0x01 << (iOffset & 0x1f)); + } + } + } + break; + + case GDT_UInt16: + { + int nNoData = (int) padfNoData[0]; + GUInt16 *panData = (GUInt16 *) *ppImageData; + int iOffset; + + // nothing to do if value is out of range. + if( padfNoData[0] < 0 || padfNoData[0] > 65535 + || padfNoData[1] != 0.0 ) + return CE_None; + + for( iOffset = nXSize*nYSize-1; iOffset >= 0; iOffset-- ) + { + if( panData[iOffset] == nNoData ) + { + panValidityMask[iOffset>>5] &= ~(0x01 << (iOffset & 0x1f)); + } + } + } + break; + + case GDT_Float32: + { + float fNoData = (float) padfNoData[0]; + float *pafData = (float *) *ppImageData; + int iOffset; + + // nothing to do if value is out of range. + if( padfNoData[1] != 0.0 ) + return CE_None; + + for( iOffset = nXSize*nYSize-1; iOffset >= 0; iOffset-- ) + { + if( pafData[iOffset] == fNoData ) + { + panValidityMask[iOffset>>5] &= ~(0x01 << (iOffset & 0x1f)); + } + } + } + break; + + default: + { + double *padfWrk; + int iLine, iPixel; + int nWordSize = GDALGetDataTypeSize(eType)/8; + + padfWrk = (double *) CPLMalloc(nXSize * sizeof(double) * 2); + for( iLine = 0; iLine < nYSize; iLine++ ) + { + GDALCopyWords( ((GByte *) *ppImageData)+nWordSize*iLine*nXSize, + eType, nWordSize, + padfWrk, GDT_CFloat64, 16, nXSize ); + + for( iPixel = 0; iPixel < nXSize; iPixel++ ) + { + if( padfWrk[iPixel*2] == padfNoData[0] + && padfWrk[iPixel*2+1] == padfNoData[1] ) + { + int iOffset = iPixel + iLine * nXSize; + + panValidityMask[iOffset>>5] &= + ~(0x01 << (iOffset & 0x1f)); + } + } + + } + + CPLFree( padfWrk ); + } + break; + } + + return CE_None; +} + +/************************************************************************/ +/* GDALWarpSrcAlphaMasker() */ +/* */ +/* GDALMaskFunc for reading source simple 8bit alpha mask */ +/* information and building a floating point density mask from */ +/* it. */ +/************************************************************************/ + +CPLErr +GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ) + +{ + GDALWarpOptions *psWO = (GDALWarpOptions *) pMaskFuncArg; + float *pafMask = (float *) pValidityMask; + +/* -------------------------------------------------------------------- */ +/* Do some minimal checking. */ +/* -------------------------------------------------------------------- */ + if( !bMaskIsFloat ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + if( psWO == NULL || psWO->nSrcAlphaBand < 1 ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Read the alpha band. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr; + GDALRasterBandH hAlphaBand = GDALGetRasterBand( psWO->hSrcDS, + psWO->nSrcAlphaBand ); + + eErr = GDALRasterIO( hAlphaBand, GF_Read, nXOff, nYOff, nXSize, nYSize, + pafMask, nXSize, nYSize, GDT_Float32, 0, 0 ); + + if( eErr != CE_None ) + return eErr; + +/* -------------------------------------------------------------------- */ +/* Rescale from 0-255 to 0.0-1.0. */ +/* -------------------------------------------------------------------- */ + for( int iPixel = nXSize * nYSize - 1; iPixel >= 0; iPixel-- ) + { // (1/255) + pafMask[iPixel] = pafMask[iPixel] * 0.00392157; + pafMask[iPixel] = MIN(1.0,pafMask[iPixel]); + } + + return CE_None; +} + +/************************************************************************/ +/* GDALWarpDstAlphaMasker() */ +/* */ +/* GDALMaskFunc for reading or writing the destination simple */ +/* 8bit alpha mask information and building a floating point */ +/* density mask from it. Note, writing is distinguished */ +/* negative bandcount. */ +/************************************************************************/ + +CPLErr +GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ) + +{ + GDALWarpOptions *psWO = (GDALWarpOptions *) pMaskFuncArg; + float *pafMask = (float *) pValidityMask; + int iPixel; + CPLErr eErr; + +/* -------------------------------------------------------------------- */ +/* Do some minimal checking. */ +/* -------------------------------------------------------------------- */ + if( !bMaskIsFloat ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + if( psWO == NULL || psWO->nDstAlphaBand < 1 ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + GDALRasterBandH hAlphaBand = + GDALGetRasterBand( psWO->hDstDS, psWO->nDstAlphaBand ); + +/* -------------------------------------------------------------------- */ +/* Read alpha case. */ +/* -------------------------------------------------------------------- */ + if( nBandCount >= 0 ) + { + const char *pszInitDest = + CSLFetchNameValue( psWO->papszWarpOptions, "INIT_DEST" ); + + // Special logic for destinations being initialized on the fly. + if( pszInitDest != NULL ) + { + for( iPixel = nXSize * nYSize - 1; iPixel >= 0; iPixel-- ) + pafMask[iPixel] = 0.0; + return CE_None; + } + + // Read data. + eErr = GDALRasterIO( hAlphaBand, GF_Read, nXOff, nYOff, nXSize, nYSize, + pafMask, nXSize, nYSize, GDT_Float32, 0, 0 ); + + if( eErr != CE_None ) + return eErr; + + // rescale. + for( iPixel = nXSize * nYSize - 1; iPixel >= 0; iPixel-- ) + { + pafMask[iPixel] = pafMask[iPixel] * 0.00392157; + pafMask[iPixel] = MIN(1.0,pafMask[iPixel]); + } + + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Write alpha case. */ +/* -------------------------------------------------------------------- */ + else + { + for( iPixel = nXSize * nYSize - 1; iPixel >= 0; iPixel-- ) + pafMask[iPixel] = (int) (pafMask[iPixel] * 255.1); + + // Read data. + eErr = GDALRasterIO( hAlphaBand, GF_Write, + nXOff, nYOff, nXSize, nYSize, + pafMask, nXSize, nYSize, GDT_Float32, 0, 0 ); + return eErr; + } +} + +/************************************************************************/ +/* ==================================================================== */ +/* GDALWarpOptions */ +/* ==================================================================== */ +/************************************************************************/ + +/** + * \var char **GDALWarpOptions::papszWarpOptions; + * + * A string list of additional options controlling the warp operation in + * name=value format. A suitable string list can be prepared with + * CSLSetNameValue(). + * + * The following values are currently supported: + * + * - INIT_DEST=[value] or INIT_DEST=NO_DATA: This option forces the + * destination image to be initialized to the indicated value (for all bands) + * or indicates that it should be initialized to the NO_DATA value in + * padfDstNoDataReal/padfDstNoDataImag. If this value isn't set the + * destination image will be read and overlayed. + * + * - WRITE_FLUSH=YES/NO: This option forces a flush to disk of data after + * each chunk is processed. In some cases this helps ensure a serial + * writing of the output data otherwise a block of data may be written to disk + * each time a block of data is read for the input buffer resulting in alot + * of extra seeking around the disk, and reduced IO throughput. The default + * at this time is NO. + * + * Normally when computing the source raster data to + * load to generate a particular output area, the warper samples transforms + * 21 points along each edge of the destination region back onto the source + * file, and uses this to compute a bounding window on the source image that + * is sufficient. Depending on the transformation in effect, the source + * window may be a bit too small, or even missing large areas. Problem + * situations are those where the transformation is very non-linear or + * "inside out". Examples are transforming from WGS84 to Polar Steregraphic + * for areas around the pole, or transformations where some of the image is + * untransformable. The following options provide some additional control + * to deal with errors in computing the source window: + * + * - SAMPLE_GRID=YES/NO: Setting this option to YES will force the sampling to + * include internal points as well as edge points which can be important if + * the transformation is esoteric inside out, or if large sections of the + * destination image are not transformable into the source coordinate system. + * + * - SAMPLE_STEPS: Modifies the density of the sampling grid. The default + * number of steps is 21. Increasing this can increase the computational + * cost, but improves the accuracy with which the source region is computed. + * + * - SOURCE_EXTRA: This is a number of extra pixels added around the source + * window for a given request, and by default it is 1 to take care of rounding + * error. Setting this larger will incease the amount of data that needs to + * be read, but can avoid missing source data. + */ + +/************************************************************************/ +/* GDALCreateWarpOptions() */ +/************************************************************************/ + +GDALWarpOptions * CPL_STDCALL GDALCreateWarpOptions() + +{ + GDALWarpOptions *psOptions; + + psOptions = (GDALWarpOptions *) CPLCalloc(sizeof(GDALWarpOptions),1); + + psOptions->eResampleAlg = GRA_NearestNeighbour; + psOptions->pfnProgress = GDALDummyProgress; + psOptions->eWorkingDataType = GDT_Unknown; + + return psOptions; +} + +/************************************************************************/ +/* GDALDestroyWarpOptions() */ +/************************************************************************/ + +void CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions *psOptions ) + +{ + CSLDestroy( psOptions->papszWarpOptions ); + CPLFree( psOptions->panSrcBands ); + CPLFree( psOptions->panDstBands ); + CPLFree( psOptions->padfSrcNoDataReal ); + CPLFree( psOptions->padfSrcNoDataImag ); + CPLFree( psOptions->padfDstNoDataReal ); + CPLFree( psOptions->padfDstNoDataImag ); + CPLFree( psOptions->papfnSrcPerBandValidityMaskFunc ); + CPLFree( psOptions->papSrcPerBandValidityMaskFuncArg ); + + CPLFree( psOptions ); +} + + +#define COPY_MEM(target,type,count) \ + if( (psSrcOptions->target) != NULL && (count) != 0 ) \ + { \ + (psDstOptions->target) = (type *) CPLMalloc(sizeof(type)*count); \ + memcpy( (psDstOptions->target), (psSrcOptions->target), \ + sizeof(type) * count ); \ + } + +/************************************************************************/ +/* GDALCloneWarpOptions() */ +/************************************************************************/ + +GDALWarpOptions * CPL_STDCALL +GDALCloneWarpOptions( const GDALWarpOptions *psSrcOptions ) + +{ + GDALWarpOptions *psDstOptions = GDALCreateWarpOptions(); + + memcpy( psDstOptions, psSrcOptions, sizeof(GDALWarpOptions) ); + + if( psSrcOptions->papszWarpOptions != NULL ) + psDstOptions->papszWarpOptions = + CSLDuplicate( psSrcOptions->papszWarpOptions ); + + COPY_MEM( panSrcBands, int, psSrcOptions->nBandCount ); + COPY_MEM( panDstBands, int, psSrcOptions->nBandCount ); + COPY_MEM( padfSrcNoDataReal, double, psSrcOptions->nBandCount ); + COPY_MEM( padfSrcNoDataImag, double, psSrcOptions->nBandCount ); + COPY_MEM( padfDstNoDataReal, double, psSrcOptions->nBandCount ); + COPY_MEM( padfDstNoDataImag, double, psSrcOptions->nBandCount ); + COPY_MEM( papfnSrcPerBandValidityMaskFunc, GDALMaskFunc, + psSrcOptions->nBandCount ); + + return psDstOptions; +} + +/************************************************************************/ +/* GDALSerializeWarpOptions() */ +/************************************************************************/ + +CPLXMLNode * CPL_STDCALL +GDALSerializeWarpOptions( const GDALWarpOptions *psWO ) + +{ + CPLXMLNode *psTree; + +/* -------------------------------------------------------------------- */ +/* Create root. */ +/* -------------------------------------------------------------------- */ + psTree = CPLCreateXMLNode( NULL, CXT_Element, "GDALWarpOptions" ); + +/* -------------------------------------------------------------------- */ +/* WarpMemoryLimit */ +/* -------------------------------------------------------------------- */ + CPLCreateXMLElementAndValue( + psTree, "WarpMemoryLimit", + CPLSPrintf("%g", psWO->dfWarpMemoryLimit ) ); + +/* -------------------------------------------------------------------- */ +/* ResampleAlg */ +/* -------------------------------------------------------------------- */ + const char *pszAlgName; + + if( psWO->eResampleAlg == GRA_NearestNeighbour ) + pszAlgName = "NearestNeighbour"; + else if( psWO->eResampleAlg == GRA_Bilinear ) + pszAlgName = "Bilinear"; + else if( psWO->eResampleAlg == GRA_Cubic ) + pszAlgName = "Cubic"; + else if( psWO->eResampleAlg == GRA_CubicSpline ) + pszAlgName = "CubicSpline"; + else + pszAlgName = "Unknown"; + + CPLCreateXMLElementAndValue( + psTree, "ResampleAlg", pszAlgName ); + +/* -------------------------------------------------------------------- */ +/* Working Data Type */ +/* -------------------------------------------------------------------- */ + + CPLCreateXMLElementAndValue( + psTree, "WorkingDataType", + GDALGetDataTypeName( psWO->eWorkingDataType ) ); + +/* -------------------------------------------------------------------- */ +/* Source and Destination Data Source */ +/* -------------------------------------------------------------------- */ + if( psWO->hSrcDS != NULL ) + { + CPLCreateXMLElementAndValue( + psTree, "SourceDataset", + GDALGetDescription( psWO->hSrcDS ) ); + } + + if( psWO->hDstDS != NULL && strlen(GDALGetDescription(psWO->hDstDS)) != 0 ) + { + CPLCreateXMLElementAndValue( + psTree, "DestinationDataset", + GDALGetDescription( psWO->hDstDS ) ); + } + +/* -------------------------------------------------------------------- */ +/* Serialize transformer. */ +/* -------------------------------------------------------------------- */ + if( psWO->pfnTransformer != NULL ) + { + CPLXMLNode *psTransformerContainer; + CPLXMLNode *psTransformerTree; + + psTransformerContainer = + CPLCreateXMLNode( psTree, CXT_Element, "Transformer" ); + + psTransformerTree = + GDALSerializeTransformer( psWO->pfnTransformer, + psWO->pTransformerArg ); + + if( psTransformerTree != NULL ) + CPLAddXMLChild( psTransformerContainer, psTransformerTree ); + } + +/* -------------------------------------------------------------------- */ +/* Band count and lists. */ +/* -------------------------------------------------------------------- */ + CPLXMLNode *psBandList = NULL; + int i; + + if( psWO->nBandCount != 0 ) + psBandList = CPLCreateXMLNode( psTree, CXT_Element, "BandList" ); + + for( i = 0; i < psWO->nBandCount; i++ ) + { + CPLXMLNode *psBand; + + psBand = CPLCreateXMLNode( psBandList, CXT_Element, "BandMapping" ); + if( psWO->panSrcBands != NULL ) + CPLCreateXMLNode( + CPLCreateXMLNode( psBand, CXT_Attribute, "src" ), + CXT_Text, CPLSPrintf( "%d", psWO->panSrcBands[i] ) ); + if( psWO->panDstBands != NULL ) + CPLCreateXMLNode( + CPLCreateXMLNode( psBand, CXT_Attribute, "dst" ), + CXT_Text, CPLSPrintf( "%d", psWO->panDstBands[i] ) ); + + if( psWO->padfSrcNoDataReal != NULL ) + CPLCreateXMLElementAndValue( + psBand, "SrcNoDataReal", + CPLSPrintf( "%.16g", psWO->padfSrcNoDataReal[i] ) ); + + if( psWO->padfSrcNoDataImag != NULL ) + CPLCreateXMLElementAndValue( + psBand, "SrcNoDataImag", + CPLSPrintf( "%.16g", psWO->padfSrcNoDataImag[i] ) ); + + if( psWO->padfDstNoDataReal != NULL ) + CPLCreateXMLElementAndValue( + psBand, "DstNoDataReal", + CPLSPrintf( "%.16g", psWO->padfDstNoDataReal[i] ) ); + + if( psWO->padfDstNoDataImag != NULL ) + CPLCreateXMLElementAndValue( + psBand, "DstNoDataImag", + CPLSPrintf( "%.16g", psWO->padfDstNoDataImag[i] ) ); + } + +/* -------------------------------------------------------------------- */ +/* Alpha bands. */ +/* -------------------------------------------------------------------- */ + if( psWO->nSrcAlphaBand > 0 ) + CPLCreateXMLElementAndValue( + psTree, "SrcAlphaBand", + CPLSPrintf( "%d", psWO->nSrcAlphaBand ) ); + + if( psWO->nDstAlphaBand > 0 ) + CPLCreateXMLElementAndValue( + psTree, "DstAlphaBand", + CPLSPrintf( "%d", psWO->nDstAlphaBand ) ); + + return psTree; +} + +/************************************************************************/ +/* GDALDeserializeWarpOptions() */ +/************************************************************************/ + +GDALWarpOptions * CPL_STDCALL GDALDeserializeWarpOptions( CPLXMLNode *psTree ) + +{ + CPLErrorReset(); + +/* -------------------------------------------------------------------- */ +/* Verify this is the right kind of object. */ +/* -------------------------------------------------------------------- */ + if( psTree == NULL || psTree->eType != CXT_Element + || !EQUAL(psTree->pszValue,"GDALWarpOptions") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Wrong node, unable to deserialize GDALWarpOptions." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create pre-initialized warp options. */ +/* -------------------------------------------------------------------- */ + GDALWarpOptions *psWO = GDALCreateWarpOptions(); + +/* -------------------------------------------------------------------- */ +/* Warp memory limit. */ +/* -------------------------------------------------------------------- */ + psWO->dfWarpMemoryLimit = + atof(CPLGetXMLValue(psTree,"WarpMemoryLimit","0.0")); + +/* -------------------------------------------------------------------- */ +/* resample algorithm */ +/* -------------------------------------------------------------------- */ + const char *pszValue = + CPLGetXMLValue(psTree,"ResampleAlg","Default"); + + if( EQUAL(pszValue,"NearestNeighbour") ) + psWO->eResampleAlg = GRA_NearestNeighbour; + else if( EQUAL(pszValue,"Bilinear") ) + psWO->eResampleAlg = GRA_Bilinear; + else if( EQUAL(pszValue,"Cubic") ) + psWO->eResampleAlg = GRA_Cubic; + else if( EQUAL(pszValue,"CubicSpline") ) + psWO->eResampleAlg = GRA_CubicSpline; + else if( EQUAL(pszValue,"Default") ) + /* leave as is */; + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unrecognise ResampleAlg value '%s'.", + pszValue ); + } + +/* -------------------------------------------------------------------- */ +/* Working data type. */ +/* -------------------------------------------------------------------- */ + psWO->eWorkingDataType = + GDALGetDataTypeByName( + CPLGetXMLValue(psTree,"WorkingDataType","Unknown")); + +/* -------------------------------------------------------------------- */ +/* Source Dataset. */ +/* -------------------------------------------------------------------- */ + pszValue = CPLGetXMLValue(psTree,"SourceDataset",NULL); + + if( pszValue != NULL ) + psWO->hSrcDS = GDALOpenShared( pszValue, GA_ReadOnly ); + +/* -------------------------------------------------------------------- */ +/* Destination Dataset. */ +/* -------------------------------------------------------------------- */ + pszValue = CPLGetXMLValue(psTree,"DestinationDataset",NULL); + + if( pszValue != NULL ) + psWO->hDstDS = GDALOpenShared( pszValue, GA_Update ); + +/* -------------------------------------------------------------------- */ +/* First, count band mappings so we can establish the bandcount. */ +/* -------------------------------------------------------------------- */ + CPLXMLNode *psBandTree = CPLGetXMLNode( psTree, "BandList" ); + CPLXMLNode *psBand = NULL; + + psWO->nBandCount = 0; + + for( psBand=psBandTree->psChild; psBand != NULL; psBand = psBand->psNext ) + { + if( psBand->eType != CXT_Element + || !EQUAL(psBand->pszValue,"BandMapping") ) + continue; + + psWO->nBandCount++; + } + +/* ==================================================================== */ +/* Now actually process each bandmapping. */ +/* ==================================================================== */ + int iBand = 0; + + for( psBand=psBandTree->psChild; psBand != NULL; psBand = psBand->psNext ) + { + if( psBand->eType != CXT_Element + || !EQUAL(psBand->pszValue,"BandMapping") ) + continue; + +/* -------------------------------------------------------------------- */ +/* Source band */ +/* -------------------------------------------------------------------- */ + if( psWO->panSrcBands == NULL ) + psWO->panSrcBands = (int *)CPLMalloc(sizeof(int)*psWO->nBandCount); + + pszValue = CPLGetXMLValue(psBand,"src",NULL); + if( pszValue == NULL ) + psWO->panSrcBands[iBand] = iBand+1; + else + psWO->panSrcBands[iBand] = atoi(pszValue); + +/* -------------------------------------------------------------------- */ +/* Destination band. */ +/* -------------------------------------------------------------------- */ + pszValue = CPLGetXMLValue(psBand,"dst",NULL); + if( pszValue != NULL ) + { + if( psWO->panDstBands == NULL ) + psWO->panDstBands = + (int *) CPLMalloc(sizeof(int)*psWO->nBandCount); + + psWO->panDstBands[iBand] = atoi(pszValue); + } + +/* -------------------------------------------------------------------- */ +/* Source nodata. */ +/* -------------------------------------------------------------------- */ + pszValue = CPLGetXMLValue(psBand,"SrcNoDataReal",NULL); + if( pszValue != NULL ) + { + if( psWO->padfSrcNoDataReal == NULL ) + psWO->padfSrcNoDataReal = + (double *) CPLCalloc(sizeof(double),psWO->nBandCount); + + psWO->padfSrcNoDataReal[iBand] = atof(pszValue); + } + + pszValue = CPLGetXMLValue(psBand,"SrcNoDataImag",NULL); + if( pszValue != NULL ) + { + if( psWO->padfSrcNoDataImag == NULL ) + psWO->padfSrcNoDataImag = + (double *) CPLCalloc(sizeof(double),psWO->nBandCount); + + psWO->padfSrcNoDataReal[iBand] = atof(pszValue); + } + +/* -------------------------------------------------------------------- */ +/* Destination nodata. */ +/* -------------------------------------------------------------------- */ + pszValue = CPLGetXMLValue(psBand,"DstNoDataReal",NULL); + if( pszValue != NULL ) + { + if( psWO->padfDstNoDataReal == NULL ) + psWO->padfDstNoDataReal = + (double *) CPLCalloc(sizeof(double),psWO->nBandCount); + + psWO->padfDstNoDataReal[iBand] = atof(pszValue); + } + + pszValue = CPLGetXMLValue(psBand,"DstNoDataImag",NULL); + if( pszValue != NULL ) + { + if( psWO->padfDstNoDataImag == NULL ) + psWO->padfDstNoDataImag = + (double *) CPLCalloc(sizeof(double),psWO->nBandCount); + + psWO->padfDstNoDataReal[iBand] = atof(pszValue); + } + + iBand++; + } + +/* -------------------------------------------------------------------- */ +/* Alpha bands. */ +/* -------------------------------------------------------------------- */ + psWO->nSrcAlphaBand = + atoi( CPLGetXMLValue( psTree, "SrcAlphaBand", "0" ) ); + psWO->nDstAlphaBand = + atoi( CPLGetXMLValue( psTree, "DstAlphaBand", "0" ) ); + +/* -------------------------------------------------------------------- */ +/* Transformation. */ +/* -------------------------------------------------------------------- */ + CPLXMLNode *psTransformer = CPLGetXMLNode( psTree, "Transformer" ); + + if( psTransformer != NULL && psTransformer->psChild != NULL ) + { + GDALDeserializeTransformer( psTransformer->psChild, + &(psWO->pfnTransformer), + &(psWO->pTransformerArg) ); + } + +/* -------------------------------------------------------------------- */ +/* If any error has occured, cleanup else return success. */ +/* -------------------------------------------------------------------- */ + if( CPLGetLastErrorNo() != CE_None ) + { + GDALDestroyWarpOptions( psWO ); + return NULL; + } + else + return psWO; +} diff --git a/Utilities/GDAL/alg/gdalwarper.h b/Utilities/GDAL/alg/gdalwarper.h new file mode 100644 index 0000000000..ec21138d69 --- /dev/null +++ b/Utilities/GDAL/alg/gdalwarper.h @@ -0,0 +1,418 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL High Performance Warper + * Purpose: Prototypes, and definitions for warping related work. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, 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: gdalwarper.h,v $ + * Revision 1.17 2005/04/04 15:24:16 fwarmerdam + * added CPL_STDCALL to some functions + * + * Revision 1.16 2004/11/14 04:16:30 fwarmerdam + * fixup src alpha support + * + * Revision 1.15 2004/10/07 15:50:18 fwarmerdam + * added preliminary alpha band support + * + * Revision 1.14 2004/08/11 20:11:47 warmerda + * added GDALInitializeWarpedVRT + * + * Revision 1.13 2004/08/11 19:01:25 warmerda + * Added prototypes for GDALAutoCreateWarpedVRT and GDALCreateWarpedVRT + * + * Revision 1.12 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.11 2003/11/22 19:13:31 dron + * Added C bindings for GDALWarpOperation functions. + * + * Revision 1.10 2003/07/04 11:50:57 dron + * GRA_CubicSpline added to the list of resampling algorithms. + * + * Revision 1.9 2003/06/12 11:21:33 dron + * Few additional comments. + * + * Revision 1.8 2003/05/27 20:49:25 warmerda + * added REPORT_TIMINGS support + * + * Revision 1.7 2003/05/07 19:13:06 warmerda + * added pre and post warp chunk processor + * + * Revision 1.6 2003/04/23 05:18:57 warmerda + * added multithread support + * + * Revision 1.5 2003/03/02 05:25:59 warmerda + * added some source nodata support + * + * Revision 1.4 2003/02/22 02:04:11 warmerda + * added dfMaxError to reproject function + * + * Revision 1.3 2003/02/21 15:41:37 warmerda + * added progressbase/scale for operation + * + * Revision 1.2 2003/02/20 21:53:06 warmerda + * partial implementation + * + * Revision 1.1 2003/02/18 17:25:50 warmerda + * New + * + */ + +#ifndef GDALWARPER_H_INCLUDED +#define GDALWARPER_H_INCLUDED + +/** + * \file gdalwarper.h + * + * GDAL warper related entry points and definitions. Eventually it is + * expected that this file will be mostly private to the implementation, + * and the public C entry points will be available in gdal_alg.h. + */ + +#include "gdal_alg.h" +#include "cpl_minixml.h" + +CPL_C_START + +/*! Warp Resampling Algorithm */ +typedef enum { + /*! Nearest neighbour (select on one input pixel) */ GRA_NearestNeighbour=0, + /*! Bilinear (2x2 kernel) */ GRA_Bilinear=1, + /*! Cubic Convolution Approximation (4x4 kernel) */ GRA_Cubic=2, + /*! Cubic B-Spline Approximation (4x4 kernel) */ GRA_CubicSpline=3, +} GDALResampleAlg; + +typedef int +(*GDALMaskFunc)( void *pMaskFuncArg, + int nBandCount, GDALDataType eType, + int nXOff, int nYOff, + int nXSize, int nYSize, + GByte **papabyImageData, + int bMaskIsFloat, void *pMask ); + +CPLErr CPL_DLL +GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte **papabyImageData, int bMaskIsFloat, + void *pValidityMask ); + +CPLErr CPL_DLL +GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ); +CPLErr CPL_DLL +GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType, + int nXOff, int nYOff, int nXSize, int nYSize, + GByte ** /*ppImageData */, + int bMaskIsFloat, void *pValidityMask ); + +/************************************************************************/ +/* GDALWarpOptions */ +/************************************************************************/ + +/** Warp control options for use with GDALWarpOperation::Initialize() */ +typedef struct { + + char **papszWarpOptions; + + /*! In bytes, 0.0 for internal default */ + double dfWarpMemoryLimit; + + /*! Resampling algorithm to use */ + GDALResampleAlg eResampleAlg; + + /*! data type to use during warp operation, GDT_Unknown lets the algorithm + select the type */ + GDALDataType eWorkingDataType; + + /*! Source image dataset. */ + GDALDatasetH hSrcDS; + + /*! Destination image dataset - may be NULL if only using GDALWarpOperation::WarpRegionToBuffer(). */ + GDALDatasetH hDstDS; + + /*! Number of bands to process, may be 0 to select all bands. */ + int nBandCount; + + /*! The band numbers for the source bands to process (1 based) */ + int *panSrcBands; + + /*! The band numbers for the destination bands to process (1 based) */ + int *panDstBands; + + /*! The source band so use as an alpha (transparency) value, 0=disabled */ + int nSrcAlphaBand; + + /*! The dest. band so use as an alpha (transparency) value, 0=disabled */ + int nDstAlphaBand; + + /*! The "nodata" value real component for each input band, if NULL there isn't one */ + double *padfSrcNoDataReal; + /*! The "nodata" value imaginary component - may be NULL even if real + component is provided. */ + double *padfSrcNoDataImag; + + /*! The "nodata" value real component for each output band, if NULL there isn't one */ + double *padfDstNoDataReal; + /*! The "nodata" value imaginary component - may be NULL even if real + component is provided. */ + double *padfDstNoDataImag; + + /*! GDALProgressFunc() compatible progress reporting function, or NULL + if there isn't one. */ + GDALProgressFunc pfnProgress; + + /*! Callback argument to be passed to pfnProgress. */ + void *pProgressArg; + + /*! Type of spatial point transformer function */ + GDALTransformerFunc pfnTransformer; + + /*! Handle to image transformer setup structure */ + void *pTransformerArg; + + GDALMaskFunc *papfnSrcPerBandValidityMaskFunc; + void **papSrcPerBandValidityMaskFuncArg; + + GDALMaskFunc pfnSrcValidityMaskFunc; + void *pSrcValidityMaskFuncArg; + + GDALMaskFunc pfnSrcDensityMaskFunc; + void *pSrcDensityMaskFuncArg; + + GDALMaskFunc pfnDstDensityMaskFunc; + void *pDstDensityMaskFuncArg; + + GDALMaskFunc pfnDstValidityMaskFunc; + void *pDstValidityMaskFuncArg; + + CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg ); + void *pPreWarpProcessorArg; + + CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg); + void *pPostWarpProcessorArg; + +} GDALWarpOptions; + +GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(); +void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * ); +GDALWarpOptions CPL_DLL * CPL_STDCALL +GDALCloneWarpOptions( const GDALWarpOptions * ); + +CPLXMLNode CPL_DLL * CPL_STDCALL + GDALSerializeWarpOptions( const GDALWarpOptions * ); +GDALWarpOptions CPL_DLL * CPL_STDCALL + GDALDeserializeWarpOptions( CPLXMLNode * ); + +/************************************************************************/ +/* GDALReprojectImage() */ +/************************************************************************/ + +CPLErr CPL_DLL CPL_STDCALL +GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, + GDALDatasetH hDstDS, const char *pszDstWKT, + GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, + double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, + const char *pszDstFilename, const char *pszDstWKT, + GDALDriverH hDstDriver, char **papszCreateOptions, + GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, + double dfMaxError, + GDALProgressFunc pfnProgress, void *pProgressArg, + GDALWarpOptions *psOptions ); + +/************************************************************************/ +/* VRTWarpedDataset */ +/************************************************************************/ + +GDALDatasetH CPL_DLL CPL_STDCALL +GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS, + const char *pszSrcWKT, const char *pszDstWKT, + GDALResampleAlg eResampleAlg, + double dfMaxError, const GDALWarpOptions *psOptions ); + +GDALDatasetH CPL_DLL CPL_STDCALL +GDALCreateWarpedVRT( GDALDatasetH hSrcDS, + int nPixels, int nLines, double *padfGeoTransform, + GDALWarpOptions *psOptions ); + +CPLErr CPL_DLL CPL_STDCALL +GDALInitializeWarpedVRT( GDALDatasetH hDS, + GDALWarpOptions *psWO ); + +CPL_C_END + +#ifdef __cplusplus + +/************************************************************************/ +/* GDALWarpKernel */ +/* */ +/* This class represents the lowest level of abstraction. It */ +/* is holds the imagery for one "chunk" of a warp, and the */ +/* pre-prepared masks. All IO is done before and after it's */ +/* operation. This class is not normally used by the */ +/* application. */ +/************************************************************************/ + +class CPL_DLL GDALWarpKernel +{ +public: + GDALWarpKernel(); + virtual ~GDALWarpKernel(); + + char **papszWarpOptions; + + GDALResampleAlg eResample; + GDALDataType eWorkingDataType; + int nBands; + + int nSrcXSize; + int nSrcYSize; + GByte **papabySrcImage; + + GUInt32 **papanBandSrcValid; + GUInt32 *panUnifiedSrcValid; + float *pafUnifiedSrcDensity; + + int nDstXSize; + int nDstYSize; + GByte **papabyDstImage; + GUInt32 *panDstValid; + float *pafDstDensity; + + int nSrcXOff; + int nSrcYOff; + + int nDstXOff; + int nDstYOff; + + GDALTransformerFunc pfnTransformer; + void *pTransformerArg; + + GDALProgressFunc pfnProgress; + void *pProgress; + + double dfProgressBase; + double dfProgressScale; + + CPLErr Validate(); + CPLErr PerformWarp(); +}; + +/************************************************************************/ +/* GDALWarpOperation() */ +/* */ +/* This object is application created, or created by a higher */ +/* level convenience function. It is responsible for */ +/* subdividing the operation into chunks, loading and saving */ +/* imagery, and establishing the varios validity and density */ +/* masks. Actual resampling is done by the GDALWarpKernel. */ +/************************************************************************/ + +class CPL_DLL GDALWarpOperation { +private: + GDALWarpOptions *psOptions; + + double dfProgressBase; + double dfProgressScale; + + void WipeOptions(); + int ValidateOptions(); + + CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int *pnSrcXOff, int *pnSrcYOff, + int *pnSrcXSize, int *pnSrcYSize ); + + CPLErr CreateKernelMask( GDALWarpKernel *, int iBand, + const char *pszType ); + + void *hThread1Mutex; + void *hThread2Mutex; + void *hIOMutex; + void *hWarpMutex; + + int nChunkListCount; + int nChunkListMax; + int *panChunkList; + + int bReportTimings; + unsigned long nLastTimeReported; + + void WipeChunkList(); + CPLErr CollectChunkList( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + void ReportTiming( const char * ); + +public: + GDALWarpOperation(); + virtual ~GDALWarpOperation(); + + CPLErr Initialize( const GDALWarpOptions *psNewOptions ); + + const GDALWarpOptions *GetOptions(); + + CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize ); + CPLErr WarpRegion( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0 ); + + CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + void *pDataBuf, + GDALDataType eBufDataType, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0 ); +}; + +#endif /* def __cplusplus */ + +CPL_C_START + +typedef void * GDALWarpOperationH; + +GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* ); +void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH ); +CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int ); +CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int ); +CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH, + int, int, int, int, int, int, int, int ); +CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int, + void *, GDALDataType, + int, int, int, int ); + +CPL_C_END + +#endif /* ndef GDAL_ALG_H_INCLUDED */ diff --git a/Utilities/GDAL/alg/gdalwarpkernel.cpp b/Utilities/GDAL/alg/gdalwarpkernel.cpp new file mode 100644 index 0000000000..b0ebc61770 --- /dev/null +++ b/Utilities/GDAL/alg/gdalwarpkernel.cpp @@ -0,0 +1,3780 @@ +/****************************************************************************** + * $Id: gdalwarpkernel.cpp,v 1.23 2005/09/13 01:21:16 fwarmerdam Exp $ + * + * Project: High Performance Image Reprojector + * Purpose: Implementation of the GDALWarpKernel class. Implements the actual + * image warping for a "chunk" of input and output imagery already + * loaded into memory. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdalwarpkernel.cpp,v $ + * Revision 1.23 2005/09/13 01:21:16 fwarmerdam + * added support for unifiedsrcvalid flag + * + * Revision 1.22 2005/04/01 17:13:37 fwarmerdam + * GWKSetPixel() now rounds properly for integer outputs. + * Fixes in GWKGeneralCase() fixes for edges of bilinear/cubic resamples. + * + * Revision 1.21 2004/12/13 19:39:21 fwarmerdam + * dont use the bilinear and cubic short funcs for GUInt16 per bug 709 + * + * Revision 1.20 2004/11/14 04:54:52 fwarmerdam + * fixed some problems with density handlnig + * + * Revision 1.19 2004/11/14 04:16:30 fwarmerdam + * fixup src alpha support + * + * Revision 1.18 2004/10/07 15:50:18 fwarmerdam + * added preliminary alpha band support + * + * Revision 1.17 2004/03/28 21:21:23 warmerda + * fixed bug in setting values in Int32 working buffer + * + * Revision 1.16 2003/10/31 11:21:33 dron + * Bicubic resampler improved. + * + * Revision 1.15 2003/07/24 18:47:00 dron + * Add 0.5 to the double values before casting to integers in all resamplers. + * + * Revision 1.14 2003/07/08 19:46:30 dron + * Few typos fixed. + * + * Revision 1.13 2003/07/04 12:34:16 dron + * Fixed casting to byte in GWKCubicNoMasksByte(). + * + * Revision 1.12 2003/07/04 11:49:41 dron + * Bicubic interpolation implemented as GRA_Cubic; B-spline one renamed in + * GRA_CubicSpline. + * + * Revision 1.11 2003/06/05 15:27:07 dron + * Use bilinear interpolation instead of cubic near the image borders. + * + * Revision 1.10 2003/06/05 11:15:34 dron + * Added bilinear and bicubic interpolators for Byte and Short datatypes. + * + * Revision 1.9 2003/04/23 12:19:07 dron + * Added GWKNearestNoMasksShort() and GWKNearestShort(). + * + * Revision 1.8 2003/03/19 15:14:50 dron + * Bicubic interpolation implemented in GWKCubicResample(). + * + * Revision 1.7 2003/03/17 15:39:01 dron + * Added GWKNearestNoMasksFloat() and GWKNearestFloat() functions. + * + * Revision 1.6 2003/03/16 15:07:48 dron + * GWKNearestByte() added. + * + * Revision 1.5 2003/03/02 05:26:21 warmerda + * fixed bugs in source validity mask handling + * + * Revision 1.4 2003/02/24 17:31:27 warmerda + * added general bilinear resampling logic + * + * Revision 1.3 2003/02/22 02:04:44 warmerda + * fixed bug with progress reporting, added first special case function + * + * Revision 1.2 2003/02/20 21:53:06 warmerda + * partial implementation + * + * Revision 1.1 2003/02/18 17:25:50 warmerda + * New + * + */ + +#include "gdalwarper.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: gdalwarpkernel.cpp,v 1.23 2005/09/13 01:21:16 fwarmerdam Exp $"); + +static CPLErr GWKGeneralCase( GDALWarpKernel * ); +static CPLErr GWKNearestNoMasksByte( GDALWarpKernel *poWK ); +static CPLErr GWKBilinearNoMasksByte( GDALWarpKernel *poWK ); +static CPLErr GWKCubicNoMasksByte( GDALWarpKernel *poWK ); +static CPLErr GWKCubicSplineNoMasksByte( GDALWarpKernel *poWK ); +static CPLErr GWKNearestByte( GDALWarpKernel *poWK ); +static CPLErr GWKNearestNoMasksShort( GDALWarpKernel *poWK ); +static CPLErr GWKBilinearNoMasksShort( GDALWarpKernel *poWK ); +static CPLErr GWKCubicNoMasksShort( GDALWarpKernel *poWK ); +static CPLErr GWKCubicSplineNoMasksShort( GDALWarpKernel *poWK ); +static CPLErr GWKNearestShort( GDALWarpKernel *poWK ); +static CPLErr GWKNearestNoMasksFloat( GDALWarpKernel *poWK ); +static CPLErr GWKNearestFloat( GDALWarpKernel *poWK ); + +/************************************************************************/ +/* ==================================================================== */ +/* GDALWarpKernel */ +/* ==================================================================== */ +/************************************************************************/ + +/** + * \class GDALWarpKernel "gdalwarper.h" + * + * Low level image warping class. + * + * This class is responsible for low level image warping for one + * "chunk" of imagery. The class is essentially a structure with all + * data members public - primarily so that new special-case functions + * can be added without changing the class declaration. + * + * Applications are normally intended to interactive with warping facilities + * through the GDALWarpOperation class, though the GDALWarpKernel can in + * theory be used directly if great care is taken in setting up the + * control data. + * + * <h3>Design Issues</h3> + * + * My intention is that PerformWarp() would analyse the setup in terms + * of the datatype, resampling type, and validity/density mask usage and + * pick one of many specific implementations of the warping algorithm over + * a continuim of optimization vs. generality. At one end there will be a + * reference general purpose implementation of the algorithm that supports + * any data type (working internally in double precision complex), all three + * resampling types, and any or all of the validity/density masks. At the + * other end would be highly optimized algorithms for common cases like + * nearest neighbour resampling on GDT_Byte data with no masks. + * + * The full set of optimized versions have not been decided but we should + * expect to have at least: + * - One for each resampling algorithm for 8bit data with no masks. + * - One for each resampling algorithm for float data with no masks. + * - One for each resampling algorithm for float data with any/all masks + * (essentially the generic case for just float data). + * - One for each resampling algorithm for 8bit data with support for + * input validity masks (per band or per pixel). This handles the common + * case of nodata masking. + * - One for each resampling algorithm for float data with support for + * input validity masks (per band or per pixel). This handles the common + * case of nodata masking. + * + * Some of the specializations would operate on all bands in one pass + * (especially the ones without masking would do this), while others might + * process each band individually to reduce code complexity. + * + * <h3>Masking Semantics</h3> + * + * A detailed explanation of the semantics of the validity and density masks, + * and their effects on resampling kernels is needed here. + */ + +/************************************************************************/ +/* GDALWarpKernel Data Members */ +/************************************************************************/ + +/** + * \var GDALResampleAlg GDALWarpKernel::eResample; + * + * Resampling algorithm. + * + * The resampling algorithm to use. One of GRA_NearestNeighbour, + * GRA_Bilinear, or GRA_Cubic. + * + * This field is required. GDT_NearestNeighbour may be used as a default + * value. + */ + +/** + * \var GDALDataType GDALWarpKernel::eWorkingDataType; + * + * Working pixel data type. + * + * The datatype of pixels in the source image (papabySrcimage) and + * destination image (papabyDstImage) buffers. Note that operations on + * some data types (such as GDT_Byte) may be much better optimized than other + * less common cases. + * + * This field is required. It may not be GDT_Unknown. + */ + +/** + * \var int GDALWarpKernel::nBands; + * + * Number of bands. + * + * The number of bands (layers) of imagery being warped. Determines the + * number of entries in the papabySrcImage, papanBandSrcValid, + * and papabyDstImage arrays. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nSrcXSize; + * + * Source image width in pixels. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nSrcYSize; + * + * Source image height in pixels. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::papabySrcImage; + * + * Array of source image band data. + * + * This is an array of pointers (of size GDALWarpKernel::nBands) pointers + * to image data. Each individual band of image data is organized as a single + * block of image data in left to right, then bottom to top order. The actual + * type of the image data is determined by GDALWarpKernel::eWorkingDataType. + * + * To access the the pixel value for the (x=3,y=4) pixel (zero based) of + * the second band with eWorkingDataType set to GDT_Float32 use code like + * this: + * + * \code + * float dfPixelValue; + * int nBand = 1; // band indexes are zero based. + * int nPixel = 3; // zero based + * int nLine = 4; // zero based + * + * assert( nPixel >= 0 && nPixel < poKern->nSrcXSize ); + * assert( nLine >= 0 && nLine < poKern->nSrcYSize ); + * assert( nBand >= 0 && nBand < poKern->nBands ); + * dfPixelValue = ((float *) poKern->papabySrcImage[nBand-1]) + * [nPixel + nLine * poKern->nSrcXSize]; + * \endcode + * + * This field is required. + */ + +/** + * \var GUInt32 **GDALWarpKernel::papanBandSrcValid; + * + * Per band validity mask for source pixels. + * + * Array of pixel validity mask layers for each source band. Each of + * the mask layers is the same size (in pixels) as the source image with + * one bit per pixel. Note that it is legal (and common) for this to be + * NULL indicating that none of the pixels are invalidated, or for some + * band validity masks to be NULL in which case all pixels of the band are + * valid. The following code can be used to test the validity of a particular + * pixel. + * + * \code + * int bIsValid = TRUE; + * int nBand = 1; // band indexes are zero based. + * int nPixel = 3; // zero based + * int nLine = 4; // zero based + * + * assert( nPixel >= 0 && nPixel < poKern->nSrcXSize ); + * assert( nLine >= 0 && nLine < poKern->nSrcYSize ); + * assert( nBand >= 0 && nBand < poKern->nBands ); + * + * if( poKern->papanBandSrcValid != NULL + * && poKern->papanBandSrcValid[nBand] != NULL ) + * { + * GUInt32 *panBandMask = poKern->papanBandSrcValid[nBand]; + * int iPixelOffset = nPixel + nLine * poKern->nSrcXSize; + * + * bIsValid = panBandMask[iPixelOffset>>5] + * & (0x01 << (iPixelOffset & 0x1f)); + * } + * \endcode + */ + +/** + * \var GUInt32 *GDALWarpKernel::panUnifiedSrcValid; + * + * Per pixel validity mask for source pixels. + * + * A single validity mask layer that applies to the pixels of all source + * bands. It is accessed similarly to papanBandSrcValid, but without the + * extra level of band indirection. + * + * This pointer may be NULL indicating that all pixels are valid. + * + * Note that if both panUnifiedSrcValid, and papanBandSrcValid are available, + * the pixel isn't considered to be valid unless both arrays indicate it is + * valid. + */ + +/** + * \var float *GDALWarpKernel::pafUnifiedSrcDensity; + * + * Per pixel density mask for source pixels. + * + * A single density mask layer that applies to the pixels of all source + * bands. It contains values between 0.0 and 1.0 indicating the degree to + * which this pixel should be allowed to contribute to the output result. + * + * This pointer may be NULL indicating that all pixels have a density of 1.0. + * + * The density for a pixel may be accessed like this: + * + * \code + * float fDensity = 1.0; + * int nPixel = 3; // zero based + * int nLine = 4; // zero based + * + * assert( nPixel >= 0 && nPixel < poKern->nSrcXSize ); + * assert( nLine >= 0 && nLine < poKern->nSrcYSize ); + * if( poKern->pafUnifiedSrcDensity != NULL ) + * fDensity = poKern->pafUnifiedSrcDensity + * [nPixel + nLine * poKern->nSrcXSize]; + * \endcode + */ + +/** + * \var int GDALWarpKernel::nDstXSize; + * + * Width of destination image in pixels. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nDstYSize; + * + * Height of destination image in pixels. + * + * This field is required. + */ + +/** + * \var GByte **GDALWarpKernel::papabyDstImage; + * + * Array of destination image band data. + * + * This is an array of pointers (of size GDALWarpKernel::nBands) pointers + * to image data. Each individual band of image data is organized as a single + * block of image data in left to right, then bottom to top order. The actual + * type of the image data is determined by GDALWarpKernel::eWorkingDataType. + * + * To access the the pixel value for the (x=3,y=4) pixel (zero based) of + * the second band with eWorkingDataType set to GDT_Float32 use code like + * this: + * + * \code + * float dfPixelValue; + * int nBand = 1; // band indexes are zero based. + * int nPixel = 3; // zero based + * int nLine = 4; // zero based + * + * assert( nPixel >= 0 && nPixel < poKern->nDstXSize ); + * assert( nLine >= 0 && nLine < poKern->nDstYSize ); + * assert( nBand >= 0 && nBand < poKern->nBands ); + * dfPixelValue = ((float *) poKern->papabyDstImage[nBand-1]) + * [nPixel + nLine * poKern->nSrcYSize]; + * \endcode + * + * This field is required. + */ + +/** + * \var GUInt32 *GDALWarpKernel::panDstValid; + * + * Per pixel validity mask for destination pixels. + * + * A single validity mask layer that applies to the pixels of all destination + * bands. It is accessed similarly to papanUnitifiedSrcValid, but based + * on the size of the destination image. + * + * This pointer may be NULL indicating that all pixels are valid. + */ + +/** + * \var float *GDALWarpKernel::pafDstDensity; + * + * Per pixel density mask for destination pixels. + * + * A single density mask layer that applies to the pixels of all destination + * bands. It contains values between 0.0 and 1.0. + * + * This pointer may be NULL indicating that all pixels have a density of 1.0. + * + * The density for a pixel may be accessed like this: + * + * \code + * float fDensity = 1.0; + * int nPixel = 3; // zero based + * int nLine = 4; // zero based + * + * assert( nPixel >= 0 && nPixel < poKern->nDstXSize ); + * assert( nLine >= 0 && nLine < poKern->nDstYSize ); + * if( poKern->pafDstDensity != NULL ) + * fDensity = poKern->pafDstDensity[nPixel + nLine * poKern->nDstXSize]; + * \endcode + */ + +/** + * \var int GDALWarpKernel::nSrcXOff; + * + * X offset to source pixel coordinates for transformation. + * + * See pfnTransformer. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nSrcYOff; + * + * Y offset to source pixel coordinates for transformation. + * + * See pfnTransformer. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nDstXOff; + * + * X offset to destination pixel coordinates for transformation. + * + * See pfnTransformer. + * + * This field is required. + */ + +/** + * \var int GDALWarpKernel::nDstYOff; + * + * Y offset to destination pixel coordinates for transformation. + * + * See pfnTransformer. + * + * This field is required. + */ + +/** + * \var GDALTransformerFunc GDALWarpKernel::pfnTransformer; + * + * Source/destination location transformer. + * + * The function to call to transform coordinates between source image + * pixel/line coordinates and destination image pixel/line coordinates. + * See GDALTransformerFunc() for details of the semantics of this function. + * + * The GDALWarpKern algorithm will only ever use this transformer in + * "destination to source" mode (bDstToSrc=TRUE), and will always pass + * partial or complete scanlines of points in the destination image as + * input. This means, amoung other things, that it is safe to the the + * approximating transform GDALApproxTransform() as the transformation + * function. + * + * Source and destination images may be subsets of a larger overall image. + * The transformation algorithms will expect and return pixel/line coordinates + * in terms of this larger image, so coordinates need to be offset by + * the offsets specified in nSrcXOff, nSrcYOff, nDstXOff, and nDstYOff before + * passing to pfnTransformer, and after return from it. + * + * The GDALWarpKernel::pfnTransformerArg value will be passed as the callback + * data to this function when it is called. + * + * This field is required. + */ + +/** + * \var void *GDALWarpKernel::pTransformerArg; + * + * Callback data for pfnTransformer. + * + * This field may be NULL if not required for the pfnTransformer being used. + */ + +/** + * \var GDALProgressFunc GDALWarpKernel::pfnProgress; + * + * The function to call to report progress of the algorithm, and to check + * for a requested termination of the operation. It operates according to + * GDALProgressFunc() semantics. + * + * Generally speaking the progress function will be invoked for each + * scanline of the destination buffer that has been processed. + * + * This field may be NULL (internally set to GDALDummyProgress()). + */ + +/** + * \var void *GDALWarpKernel::pProgress; + * + * Callback data for pfnProgress. + * + * This field may be NULL if not required for the pfnProgress being used. + */ + + +/************************************************************************/ +/* GDALWarpKernel() */ +/************************************************************************/ + +GDALWarpKernel::GDALWarpKernel() + +{ + eResample = GRA_NearestNeighbour; + eWorkingDataType = GDT_Unknown; + nBands = 0; + nDstXOff = 0; + nDstYOff = 0; + nDstXSize = 0; + nDstYSize = 0; + nSrcXOff = 0; + nSrcYOff = 0; + nSrcXSize = 0; + nSrcYSize = 0; + pafDstDensity = NULL; + pafUnifiedSrcDensity = NULL; + panDstValid = NULL; + panUnifiedSrcValid = NULL; + papabyDstImage = NULL; + papabySrcImage = NULL; + papanBandSrcValid = NULL; + pfnProgress = GDALDummyProgress; + pProgress = NULL; + dfProgressBase = 0.0; + dfProgressScale = 1.0; + pfnTransformer = NULL; + pTransformerArg = NULL; + papszWarpOptions = NULL; +} + +/************************************************************************/ +/* ~GDALWarpKernel() */ +/************************************************************************/ + +GDALWarpKernel::~GDALWarpKernel() + +{ +} + +/************************************************************************/ +/* PerformWarp() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpKernel::PerformWarp(); + * + * This method performs the warp described in the GDALWarpKernel. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpKernel::PerformWarp() + +{ + CPLErr eErr; + + if( (eErr = Validate()) != CE_None ) + return eErr; + + if( CSLFetchBoolean( papszWarpOptions, "USE_GENERAL_CASE", FALSE ) ) + return GWKGeneralCase( this ); + + if( eWorkingDataType == GDT_Byte + && eResample == GRA_NearestNeighbour + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKNearestNoMasksByte( this ); + + if( eWorkingDataType == GDT_Byte + && eResample == GRA_Bilinear + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKBilinearNoMasksByte( this ); + + if( eWorkingDataType == GDT_Byte + && eResample == GRA_Cubic + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKCubicNoMasksByte( this ); + + if( eWorkingDataType == GDT_Byte + && eResample == GRA_CubicSpline + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKCubicSplineNoMasksByte( this ); + + if( eWorkingDataType == GDT_Byte + && eResample == GRA_NearestNeighbour ) + return GWKNearestByte( this ); + + if( (eWorkingDataType == GDT_Int16 || eWorkingDataType == GDT_UInt16) + && eResample == GRA_NearestNeighbour + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKNearestNoMasksShort( this ); + + if( (eWorkingDataType == GDT_Int16 ) + && eResample == GRA_Cubic + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKCubicNoMasksShort( this ); + + if( (eWorkingDataType == GDT_Int16 ) + && eResample == GRA_CubicSpline + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKCubicSplineNoMasksShort( this ); + + if( (eWorkingDataType == GDT_Int16 ) + && eResample == GRA_Bilinear + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKBilinearNoMasksShort( this ); + + if( (eWorkingDataType == GDT_Int16 || eWorkingDataType == GDT_UInt16) + && eResample == GRA_NearestNeighbour ) + return GWKNearestShort( this ); + + if( eWorkingDataType == GDT_Float32 + && eResample == GRA_NearestNeighbour + && papanBandSrcValid == NULL + && panUnifiedSrcValid == NULL + && pafUnifiedSrcDensity == NULL + && panDstValid == NULL + && pafDstDensity == NULL ) + return GWKNearestNoMasksFloat( this ); + + if( eWorkingDataType == GDT_Float32 + && eResample == GRA_NearestNeighbour ) + return GWKNearestFloat( this ); + + return GWKGeneralCase( this ); +} + +/************************************************************************/ +/* Validate() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpKernel::Validate() + * + * Check the settings in the GDALWarpKernel, and issue a CPLError() + * (and return CE_Failure) if the configuration is considered to be + * invalid for some reason. + * + * This method will also do some standard defaulting such as setting + * pfnProgress to GDALDummyProgress() if it is NULL. + * + * @return CE_None on success or CE_Failure if an error is detected. + */ + +CPLErr GDALWarpKernel::Validate() + +{ + return CE_None; +} + +/************************************************************************/ +/* GWKOverlayDensity() */ +/* */ +/* Compute the final density for the destination pixel. This */ +/* is a function of the overlay density (passed in) and the */ +/* original density. */ +/************************************************************************/ + +static void GWKOverlayDensity( GDALWarpKernel *poWK, int iDstOffset, + double dfDensity ) +{ + if( dfDensity < 0.0001 || poWK->pafDstDensity == NULL ) + return; + + poWK->pafDstDensity[iDstOffset] + = 1.0 - (1.0-dfDensity) * (1.0-poWK->pafDstDensity[iDstOffset]); +} + +/************************************************************************/ +/* GWKSetPixelValue() */ +/************************************************************************/ + +static int GWKSetPixelValue( GDALWarpKernel *poWK, int iBand, + int iDstOffset, double dfDensity, + double dfReal, double dfImag ) + +{ + GByte *pabyDst = poWK->papabyDstImage[iBand]; + +/* -------------------------------------------------------------------- */ +/* If the source density is less than 100% we need to fetch the */ +/* existing destination value, and mix it with the source to */ +/* get the new "to apply" value. Also compute composite density. */ +/* -------------------------------------------------------------------- */ + if( dfDensity < 1.0 ) + { + double dfDstReal, dfDstImag, dfDstDensity = 1.0; + + if( dfDensity < 0.0001 ) + return TRUE; + + if( poWK->pafDstDensity != NULL ) + dfDstDensity = poWK->pafDstDensity[iDstOffset]; + + switch( poWK->eWorkingDataType ) + { + case GDT_Byte: + dfDstReal = pabyDst[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_Int16: + dfDstReal = ((GInt16 *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_UInt16: + dfDstReal = ((GUInt16 *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_Int32: + dfDstReal = ((GInt32 *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_UInt32: + dfDstReal = ((GUInt32 *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_Float32: + dfDstReal = ((float *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_Float64: + dfDstReal = ((double *) pabyDst)[iDstOffset]; + dfDstImag = 0.0; + break; + + case GDT_CInt16: + dfDstReal = ((GInt16 *) pabyDst)[iDstOffset*2]; + dfDstImag = ((GInt16 *) pabyDst)[iDstOffset*2+1]; + break; + + case GDT_CInt32: + dfDstReal = ((GInt32 *) pabyDst)[iDstOffset*2]; + dfDstImag = ((GInt32 *) pabyDst)[iDstOffset*2+1]; + break; + + case GDT_CFloat32: + dfDstReal = ((float *) pabyDst)[iDstOffset*2]; + dfDstImag = ((float *) pabyDst)[iDstOffset*2+1]; + break; + + case GDT_CFloat64: + dfDstReal = ((double *) pabyDst)[iDstOffset*2]; + dfDstImag = ((double *) pabyDst)[iDstOffset*2+1]; + break; + + default: + CPLAssert( FALSE ); + dfDstDensity = 0.0; + return FALSE; + } + + // the destination density is really only relative to the portion + // not occluded by the overlay. + double dfDstInfluence = (1.0 - dfDensity) * dfDstDensity; + + dfReal = (dfReal * dfDensity + dfDstReal * dfDstInfluence) + / (dfDensity + dfDstInfluence); + + dfImag = (dfImag * dfDensity + dfDstImag * dfDstInfluence) + / (dfDensity + dfDstInfluence); + } + +/* -------------------------------------------------------------------- */ +/* Actually apply the destination value. */ +/* -------------------------------------------------------------------- */ + switch( poWK->eWorkingDataType ) + { + case GDT_Byte: + if( dfReal < 0.0 ) + pabyDst[iDstOffset] = 0; + else if( dfReal > 255.0 ) + pabyDst[iDstOffset] = 255; + else + pabyDst[iDstOffset] = (GByte) (dfReal+0.5); + break; + + case GDT_Int16: + if( dfReal < -32768 ) + ((GInt16 *) pabyDst)[iDstOffset] = -32768; + else if( dfReal > 32767 ) + ((GInt16 *) pabyDst)[iDstOffset] = 32767; + else + ((GInt16 *) pabyDst)[iDstOffset] = (GInt16) floor(dfReal+0.5); + break; + + case GDT_UInt16: + if( dfReal < 0 ) + ((GUInt16 *) pabyDst)[iDstOffset] = 0; + else if( dfReal > 65535 ) + ((GUInt16 *) pabyDst)[iDstOffset] = 65535; + else + ((GUInt16 *) pabyDst)[iDstOffset] = (GUInt16) (dfReal+0.5); + break; + + case GDT_UInt32: + if( dfReal < 0 ) + ((GUInt32 *) pabyDst)[iDstOffset] = 0; + else if( dfReal > 4294967295.0 ) + ((GUInt32 *) pabyDst)[iDstOffset] = (GUInt32) 4294967295.0; + else + ((GUInt32 *) pabyDst)[iDstOffset] = (GUInt32) (dfReal+0.5); + break; + + case GDT_Int32: + if( dfReal < -2147483648.0 ) + ((GInt32 *) pabyDst)[iDstOffset] = 0; + else if( dfReal > 2147483647.0 ) + ((GInt32 *) pabyDst)[iDstOffset] = 2147483647; + else + ((GInt32 *) pabyDst)[iDstOffset] = (GInt32) floor(dfReal+0.5); + break; + + case GDT_Float32: + ((float *) pabyDst)[iDstOffset] = (float) dfReal; + break; + + case GDT_Float64: + ((double *) pabyDst)[iDstOffset] = dfReal; + break; + + case GDT_CInt16: + if( dfReal < -32768 ) + ((GInt16 *) pabyDst)[iDstOffset*2] = -32768; + else if( dfReal > 32767 ) + ((GInt16 *) pabyDst)[iDstOffset*2] = 32767; + else + ((GInt16 *) pabyDst)[iDstOffset*2] = (GInt16) floor(dfReal+0.5); + if( dfImag < -32768 ) + ((GInt16 *) pabyDst)[iDstOffset*2+1] = -32768; + else if( dfImag > 32767 ) + ((GInt16 *) pabyDst)[iDstOffset*2+1] = 32767; + else + ((GInt16 *) pabyDst)[iDstOffset*2+1] = (GInt16) floor(dfImag+0.5); + break; + + case GDT_CInt32: + if( dfReal < -2147483648.0 ) + ((GInt32 *) pabyDst)[iDstOffset*2] = (GInt32) -2147483648.0; + else if( dfReal > 2147483647.0 ) + ((GInt32 *) pabyDst)[iDstOffset*2] = (GInt32) 2147483647.0; + else + ((GInt32 *) pabyDst)[iDstOffset*2] = (GInt32) floor(dfReal+0.5); + if( dfImag < -2147483648.0 ) + ((GInt32 *) pabyDst)[iDstOffset*2+1] = (GInt32) -2147483648.0; + else if( dfImag > 2147483647.0 ) + ((GInt32 *) pabyDst)[iDstOffset*2+1] = (GInt32) 2147483647.0; + else + ((GInt32 *) pabyDst)[iDstOffset*2+1] = (GInt32) floor(dfImag+0.5); + break; + + case GDT_CFloat32: + ((float *) pabyDst)[iDstOffset*2] = (float) dfReal; + ((float *) pabyDst)[iDstOffset*2+1] = (float) dfImag; + break; + + case GDT_CFloat64: + ((double *) pabyDst)[iDstOffset*2] = (double) dfReal; + ((double *) pabyDst)[iDstOffset*2+1] = (double) dfImag; + break; + + default: + return FALSE; + } + + return TRUE; +} + +/************************************************************************/ +/* GWKGetPixelValue() */ +/************************************************************************/ + +static int GWKGetPixelValue( GDALWarpKernel *poWK, int iBand, + int iSrcOffset, double *pdfDensity, + double *pdfReal, double *pdfImag ) + +{ + GByte *pabySrc = poWK->papabySrcImage[iBand]; + + if( poWK->panUnifiedSrcValid != NULL + && !((poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + if( poWK->papanBandSrcValid != NULL + && poWK->papanBandSrcValid[iBand] != NULL + && !((poWK->papanBandSrcValid[iBand][iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f)))) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + switch( poWK->eWorkingDataType ) + { + case GDT_Byte: + *pdfReal = pabySrc[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_Int16: + *pdfReal = ((GInt16 *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_UInt16: + *pdfReal = ((GUInt16 *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_Int32: + *pdfReal = ((GInt32 *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_UInt32: + *pdfReal = ((GUInt32 *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_Float32: + *pdfReal = ((float *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_Float64: + *pdfReal = ((double *) pabySrc)[iSrcOffset]; + *pdfImag = 0.0; + break; + + case GDT_CInt16: + *pdfReal = ((GInt16 *) pabySrc)[iSrcOffset*2]; + *pdfImag = ((GInt16 *) pabySrc)[iSrcOffset*2+1]; + break; + + case GDT_CInt32: + *pdfReal = ((GInt32 *) pabySrc)[iSrcOffset*2]; + *pdfImag = ((GInt32 *) pabySrc)[iSrcOffset*2+1]; + break; + + case GDT_CFloat32: + *pdfReal = ((float *) pabySrc)[iSrcOffset*2]; + *pdfImag = ((float *) pabySrc)[iSrcOffset*2+1]; + break; + + case GDT_CFloat64: + *pdfReal = ((double *) pabySrc)[iSrcOffset*2]; + *pdfImag = ((double *) pabySrc)[iSrcOffset*2+1]; + break; + + default: + *pdfDensity = 0.0; + return FALSE; + } + + if( poWK->pafUnifiedSrcDensity != NULL ) + *pdfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + else + *pdfDensity = 1.0; + + return *pdfDensity != 0.0; +} + +/************************************************************************/ +/* GWKGetPixelByte() */ +/************************************************************************/ + +static int GWKGetPixelByte( GDALWarpKernel *poWK, int iBand, + int iSrcOffset, double *pdfDensity, + GByte *pbValue ) + +{ + GByte *pabySrc = poWK->papabySrcImage[iBand]; + + if( poWK->panUnifiedSrcValid != NULL + && !((poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + if( poWK->papanBandSrcValid != NULL + && poWK->papanBandSrcValid[iBand] != NULL + && !((poWK->papanBandSrcValid[iBand][iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f)))) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + *pbValue = pabySrc[iSrcOffset]; + + if( poWK->pafUnifiedSrcDensity != NULL ) + *pdfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + else + *pdfDensity = 1.0; + + return *pdfDensity != 0.0; +} + +/************************************************************************/ +/* GWKGetPixelShort() */ +/************************************************************************/ + +static int GWKGetPixelShort( GDALWarpKernel *poWK, int iBand, + int iSrcOffset, double *pdfDensity, + GInt16 *piValue ) + +{ + GInt16 *pabySrc = (GInt16 *)poWK->papabySrcImage[iBand]; + + if( poWK->panUnifiedSrcValid != NULL + && !((poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + if( poWK->papanBandSrcValid != NULL + && poWK->papanBandSrcValid[iBand] != NULL + && !((poWK->papanBandSrcValid[iBand][iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f)))) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + *piValue = pabySrc[iSrcOffset]; + + if( poWK->pafUnifiedSrcDensity != NULL ) + *pdfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + else + *pdfDensity = 1.0; + + return *pdfDensity != 0.0; +} + +/************************************************************************/ +/* GWKGetPixelFloat() */ +/************************************************************************/ + +static int GWKGetPixelFloat( GDALWarpKernel *poWK, int iBand, + int iSrcOffset, double *pdfDensity, + float *pfValue ) + +{ + float *pabySrc = (float *)poWK->papabySrcImage[iBand]; + + if( poWK->panUnifiedSrcValid != NULL + && !((poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + if( poWK->papanBandSrcValid != NULL + && poWK->papanBandSrcValid[iBand] != NULL + && !((poWK->papanBandSrcValid[iBand][iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f)))) ) + { + *pdfDensity = 0.0; + return FALSE; + } + + *pfValue = pabySrc[iSrcOffset]; + + if( poWK->pafUnifiedSrcDensity != NULL ) + *pdfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + else + *pdfDensity = 1.0; + + return *pdfDensity != 0.0; +} + +/************************************************************************/ +/* GWKBilinearResample() */ +/* Set of bilinear interpolators */ +/************************************************************************/ + +static int GWKBilinearResample( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + double *pdfDensity, + double *pdfReal, double *pdfImag ) + +{ + double dfAccumulatorReal = 0.0, dfAccumulatorImag = 0.0; + double dfAccumulatorDensity = 0.0; + double dfAccumulatorDivisor = 0.0; + + int iSrcX = (int) floor(dfSrcX - 0.5); + int iSrcY = (int) floor(dfSrcY - 0.5); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfRatioX = 1.5 - (dfSrcX - iSrcX); + double dfRatioY = 1.5 - (dfSrcY - iSrcY); + + // Upper Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize + && GWKGetPixelValue( poWK, iBand, iSrcOffset, pdfDensity, + pdfReal, pdfImag ) + && *pdfDensity != 0.0 ) + { + double dfMult = dfRatioX * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulatorReal += *pdfReal * dfMult; + dfAccumulatorImag += *pdfImag * dfMult; + dfAccumulatorDensity += *pdfDensity * dfMult; + } + + // Upper Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize + && GWKGetPixelValue( poWK, iBand, iSrcOffset+1, pdfDensity, + pdfReal, pdfImag ) + && *pdfDensity != 0.0 ) + { + double dfMult = (1.0-dfRatioX) * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulatorReal += *pdfReal * dfMult; + dfAccumulatorImag += *pdfImag * dfMult; + dfAccumulatorDensity += *pdfDensity * dfMult; + } + + // Lower Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize + && GWKGetPixelValue( poWK, iBand, iSrcOffset+1+poWK->nSrcXSize, + pdfDensity, pdfReal, pdfImag ) + && *pdfDensity != 0.0 ) + { + double dfMult = (1.0-dfRatioX) * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulatorReal += *pdfReal * dfMult; + dfAccumulatorImag += *pdfImag * dfMult; + dfAccumulatorDensity += *pdfDensity * dfMult; + } + + // Lower Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize + && GWKGetPixelValue( poWK, iBand, iSrcOffset+poWK->nSrcXSize, + pdfDensity, pdfReal, pdfImag ) + && *pdfDensity != 0.0 ) + { + double dfMult = dfRatioX * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulatorReal += *pdfReal * dfMult; + dfAccumulatorImag += *pdfImag * dfMult; + dfAccumulatorDensity += *pdfDensity * dfMult; + } + +/* -------------------------------------------------------------------- */ +/* Return result. */ +/* -------------------------------------------------------------------- */ + if( dfAccumulatorDivisor == 1.0 ) + { + *pdfReal = dfAccumulatorReal; + *pdfImag = dfAccumulatorImag; + *pdfDensity = dfAccumulatorDensity; + return TRUE; + } + else if( dfAccumulatorDivisor < 0.00001 ) + { + *pdfReal = 0.0; + *pdfImag = 0.0; + *pdfDensity = 0.0; + return FALSE; + } + else + { + *pdfReal = dfAccumulatorReal / dfAccumulatorDivisor; + *pdfImag = dfAccumulatorImag / dfAccumulatorDivisor; + *pdfDensity = dfAccumulatorDensity / dfAccumulatorDivisor; + return TRUE; + } +} + +static int GWKBilinearResampleNoMasksByte( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GByte *pbValue ) + +{ + double dfAccumulator = 0.0; + double dfAccumulatorDivisor = 0.0; + + int iSrcX = (int) floor(dfSrcX - 0.5); + int iSrcY = (int) floor(dfSrcY - 0.5); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfRatioX = 1.5 - (dfSrcX - iSrcX); + double dfRatioY = 1.5 - (dfSrcY - iSrcY); + + // Upper Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize ) + { + double dfMult = dfRatioX * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)poWK->papabySrcImage[iBand][iSrcOffset] * dfMult; + } + + // Upper Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize ) + { + double dfMult = (1.0-dfRatioX) * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)poWK->papabySrcImage[iBand][iSrcOffset+1] * dfMult; + } + + // Lower Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize ) + { + double dfMult = (1.0-dfRatioX) * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)poWK->papabySrcImage[iBand][iSrcOffset+1+poWK->nSrcXSize] + * dfMult; + } + + // Lower Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize ) + { + double dfMult = dfRatioX * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)poWK->papabySrcImage[iBand][iSrcOffset+poWK->nSrcXSize] + * dfMult; + } + +/* -------------------------------------------------------------------- */ +/* Return result. */ +/* -------------------------------------------------------------------- */ + double dfValue; + + if( dfAccumulatorDivisor < 0.00001 ) + { + *pbValue = 0; + return FALSE; + } + else if( dfAccumulatorDivisor == 1.0 ) + { + dfValue = dfAccumulator; + } + else + { + dfValue = dfAccumulator / dfAccumulatorDivisor; + } + + if ( dfValue < 0.0 ) + *pbValue = 0; + else if ( dfValue > 255.0 ) + *pbValue = 255; + else + *pbValue = (GByte)(0.5 + dfValue); + + return TRUE; +} + +static int GWKBilinearResampleNoMasksShort( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GInt16 *piValue ) + +{ + double dfAccumulator = 0.0; + double dfAccumulatorDivisor = 0.0; + + int iSrcX = (int) floor(dfSrcX - 0.5); + int iSrcY = (int) floor(dfSrcY - 0.5); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfRatioX = 1.5 - (dfSrcX - iSrcX); + double dfRatioY = 1.5 - (dfSrcY - iSrcY); + + // Upper Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize ) + { + double dfMult = dfRatioX * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset] + * dfMult; + } + + // Upper Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY >= 0 && iSrcY < poWK->nSrcYSize ) + { + double dfMult = (1.0-dfRatioX) * dfRatioY; + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset+1] * dfMult; + } + + // Lower Right Pixel + if( iSrcX+1 >= 0 && iSrcX+1 < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize ) + { + double dfMult = (1.0-dfRatioX) * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset+1+poWK->nSrcXSize] + * dfMult; + } + + // Lower Left Pixel + if( iSrcX >= 0 && iSrcX < poWK->nSrcXSize + && iSrcY+1 >= 0 && iSrcY+1 < poWK->nSrcYSize ) + { + double dfMult = dfRatioX * (1.0-dfRatioY); + + dfAccumulatorDivisor += dfMult; + + dfAccumulator += + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset+poWK->nSrcXSize] + * dfMult; + } + +/* -------------------------------------------------------------------- */ +/* Return result. */ +/* -------------------------------------------------------------------- */ + if( dfAccumulatorDivisor == 1.0 ) + { + *piValue = (GInt16)(0.5 + dfAccumulator); + return TRUE; + } + else if( dfAccumulatorDivisor < 0.00001 ) + { + *piValue = 0; + return FALSE; + } + else + { + *piValue = (GInt16)(0.5 + dfAccumulator / dfAccumulatorDivisor); + return TRUE; + } +} + +/************************************************************************/ +/* GWKCubicResample() */ +/* Set of bicubic interpolators using cubic convolution. */ +/************************************************************************/ + +#define CubicConvolution(distance1,distance2,distance3,f0,f1,f2,f3) \ + ( ( -f0 + f1 - f2 + f3) * distance3 \ + + (2.0*(f0 - f1) + f2 - f3) * distance2 \ + + ( -f0 + f2 ) * distance1 \ + + f1 ) + +static int GWKCubicResample( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + double *pdfDensity, + double *pdfReal, double *pdfImag ) + +{ + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + double dfDeltaX2 = dfDeltaX * dfDeltaX; + double dfDeltaY2 = dfDeltaY * dfDeltaY; + double dfDeltaX3 = dfDeltaX2 * dfDeltaX; + double dfDeltaY3 = dfDeltaY2 * dfDeltaY; + double dfDensity0, dfDensity1, dfDensity2, dfDensity3; + double dfReal0, dfReal1, dfReal2, dfReal3; + double dfImag0, dfImag1, dfImag2, dfImag3; + double adfValueDens[4], adfValueReal[4], adfValueImag[4]; + int i; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResample( poWK, iBand, dfSrcX, dfSrcY, + pdfDensity, pdfReal, pdfImag ); + + for ( i = -1; i < 3; i++ ) + { + int iOffset = iSrcOffset + i * poWK->nSrcXSize; + + if ( !GWKGetPixelValue( poWK, iBand, iOffset - 1, + &dfDensity0, &dfReal0, &dfImag0 ) ) + return FALSE; + + if ( !GWKGetPixelValue( poWK, iBand, iOffset, + &dfDensity1, &dfReal1, &dfImag1 ) ) + return FALSE; + + if ( !GWKGetPixelValue( poWK, iBand, iOffset + 1, + &dfDensity2, &dfReal2, &dfImag2 ) ) + return FALSE; + + if ( !GWKGetPixelValue( poWK, iBand, iOffset + 2, + &dfDensity3, &dfReal3, &dfImag3 ) ) + return FALSE; + + adfValueDens[i + 1] = CubicConvolution(dfDeltaX, dfDeltaX2, dfDeltaX3, + dfDensity0, dfDensity1, dfDensity2, dfDensity3); + adfValueReal[i + 1] = CubicConvolution(dfDeltaX, dfDeltaX2, dfDeltaX3, + dfReal0, dfReal1, dfReal2, dfReal3); + adfValueImag[i + 1] = CubicConvolution(dfDeltaX, dfDeltaX2, dfDeltaX3, + dfImag0, dfImag1, dfImag2, dfImag3); + } + + *pdfDensity = CubicConvolution(dfDeltaY, dfDeltaY2, dfDeltaY3, + adfValueDens[0], adfValueDens[1], + adfValueDens[2], adfValueDens[3]); + *pdfReal = CubicConvolution(dfDeltaY, dfDeltaY2, dfDeltaY3, + adfValueReal[0], adfValueReal[1], + adfValueReal[2], adfValueReal[3]); + *pdfImag = CubicConvolution(dfDeltaY, dfDeltaY2, dfDeltaY3, + adfValueImag[0], adfValueImag[1], + adfValueImag[2], adfValueImag[3]); + + return TRUE; +} + +static int GWKCubicResampleNoMasksByte( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GByte *pbValue ) + +{ + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + double dfDeltaX2 = dfDeltaX * dfDeltaX; + double dfDeltaY2 = dfDeltaY * dfDeltaY; + double dfDeltaX3 = dfDeltaX2 * dfDeltaX; + double dfDeltaY3 = dfDeltaY2 * dfDeltaY; + double adfValue[4]; + int i; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResampleNoMasksByte( poWK, iBand, dfSrcX, dfSrcY, + pbValue); + + for ( i = -1; i < 3; i++ ) + { + int iOffset = iSrcOffset + i * poWK->nSrcXSize; + + adfValue[i + 1] = CubicConvolution(dfDeltaX, dfDeltaX2, dfDeltaX3, + (double)poWK->papabySrcImage[iBand][iOffset - 1], + (double)poWK->papabySrcImage[iBand][iOffset], + (double)poWK->papabySrcImage[iBand][iOffset + 1], + (double)poWK->papabySrcImage[iBand][iOffset + 2]); + } + + double dfValue = CubicConvolution(dfDeltaY, dfDeltaY2, dfDeltaY3, + adfValue[0], adfValue[1], adfValue[2], adfValue[3]); + + if ( dfValue < 0.0 ) + *pbValue = 0; + else if ( dfValue > 255.0 ) + *pbValue = 255; + else + *pbValue = (GByte)(0.5 + dfValue); + + return TRUE; +} + +static int GWKCubicResampleNoMasksShort( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GInt16 *piValue ) + +{ + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + double dfDeltaX2 = dfDeltaX * dfDeltaX; + double dfDeltaY2 = dfDeltaY * dfDeltaY; + double dfDeltaX3 = dfDeltaX2 * dfDeltaX; + double dfDeltaY3 = dfDeltaY2 * dfDeltaY; + double adfValue[4]; + int i; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResampleNoMasksShort( poWK, iBand, dfSrcX, dfSrcY, + piValue); + + for ( i = -1; i < 3; i++ ) + { + int iOffset = iSrcOffset + i * poWK->nSrcXSize; + + adfValue[i + 1] =CubicConvolution(dfDeltaX, dfDeltaX2, dfDeltaX3, + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iOffset - 1], + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iOffset], + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iOffset + 1], + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iOffset + 2]); + } + + *piValue = (GInt16)CubicConvolution(dfDeltaY, dfDeltaY2, dfDeltaY3, + adfValue[0], adfValue[1], adfValue[2], adfValue[3]); + + return TRUE; +} + +/************************************************************************/ +/* GWKCubicSplineResample() */ +/* Set of bicubic interpolators using B-splines. */ +/************************************************************************/ + +#define P(x) (((x) > 0)?(x)*(x)*(x):0) + +static double BSpline( double x ) +{ + return ( P(x + 2) - 4 * P(x + 1) + 6 * P(x) - 4 * P(x - 1) ) / 6; +} + +static int GWKCubicSplineResample( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + double *pdfDensity, + double *pdfReal, double *pdfImag ) + +{ + double dfAccumulatorReal = 0.0, dfAccumulatorImag = 0.0; + double dfAccumulatorDensity = 0.0; + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + int i, j; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResample( poWK, iBand, dfSrcX, dfSrcY, + pdfDensity, pdfReal, pdfImag ); + + for ( i = -1; i < 3; i++ ) + { + double dfWeight1 = BSpline((double)i - dfDeltaX); + + for ( j = -1; j < 3; j++ ) + { + if ( GWKGetPixelValue( poWK, iBand, + iSrcOffset + i + j * poWK->nSrcXSize, + pdfDensity, pdfReal, pdfImag ) ) + { + double dfWeight2 = dfWeight1 * BSpline(dfDeltaY - (double)j); + + dfAccumulatorReal += *pdfReal * dfWeight2; + dfAccumulatorImag += *pdfImag * dfWeight2; + dfAccumulatorDensity += *pdfDensity * dfWeight2; + } + } + } + + *pdfReal = dfAccumulatorReal; + *pdfImag = dfAccumulatorImag; + *pdfDensity = dfAccumulatorDensity; + + return TRUE; +} + +static int GWKCubicSplineResampleNoMasksByte( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GByte *pbValue ) + +{ + double dfAccumulator = 0.0; + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + int i, j; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResampleNoMasksByte( poWK, iBand, dfSrcX, dfSrcY, + pbValue); + + for ( i = -1; i < 3; i++ ) + { + double dfWeight1 = BSpline((double)i - dfDeltaX); + + for ( j = -1; j < 3; j++ ) + { + double dfWeight2 = dfWeight1 * BSpline(dfDeltaY - (double)j); + + dfAccumulator += + (double)poWK->papabySrcImage[iBand][iSrcOffset + i + j * poWK->nSrcXSize] + * dfWeight2; + } + } + + if ( dfAccumulator < 0.0 ) + *pbValue = 0; + else if ( dfAccumulator > 255.0 ) + *pbValue = 255; + else + *pbValue = (GByte)(0.5 + dfAccumulator); + + return TRUE; +} + +static int GWKCubicSplineResampleNoMasksShort( GDALWarpKernel *poWK, int iBand, + double dfSrcX, double dfSrcY, + GInt16 *piValue ) + +{ + double dfAccumulator = 0.0; + int iSrcX = (int) floor( dfSrcX - 0.5 ); + int iSrcY = (int) floor( dfSrcY - 0.5 ); + int iSrcOffset = iSrcX + iSrcY * poWK->nSrcXSize; + double dfDeltaX = dfSrcX - 0.5 - iSrcX; + double dfDeltaY = dfSrcY - 0.5 - iSrcY; + int i, j; + + // Get the bilinear interpolation at the image borders + if ( iSrcX - 1 < 0 || iSrcX + 2 >= poWK->nSrcXSize + || iSrcY - 1 < 0 || iSrcY + 2 >= poWK->nSrcYSize ) + return GWKBilinearResampleNoMasksShort( poWK, iBand, dfSrcX, dfSrcY, + piValue); + + for ( i = -1; i < 3; i++ ) + { + double dfWeight1 = BSpline((double)i - dfDeltaX); + + for ( j = -1; j < 3; j++ ) + { + double dfWeight2 = dfWeight1 * BSpline(dfDeltaY - (double)j); + + dfAccumulator += + (double)((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset + i + j * poWK->nSrcXSize] + * dfWeight2; + } + } + + *piValue = (GInt16)(0.5 + dfAccumulator); + + return TRUE; +} + +/************************************************************************/ +/* GWKGeneralCase() */ +/* */ +/* This is the most general case. It attempts to handle all */ +/* possible features with relatively little concern for */ +/* efficiency. */ +/************************************************************************/ + +static CPLErr GWKGeneralCase( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKGeneralCase()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* How much of a window around our source pixel might we need */ +/* to collect data from based on the resampling kernel? Even */ +/* if the requested central pixel falls off the source image, */ +/* we may need to collect data if some portion of the */ +/* resampling kernel could be on-image. */ +/* -------------------------------------------------------------------- */ + int nResWinSize = 0; + + if( poWK->eResample == GRA_Bilinear ) + nResWinSize = 1; + + if( poWK->eResample == GRA_Cubic ) + nResWinSize = 2; + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff - nResWinSize + || padfY[iDstX] < poWK->nSrcYOff - nResWinSize ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize + nResWinSize + || iSrcY >= nSrcYSize + nResWinSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* -------------------------------------------------------------------- */ +/* Don't generate output pixels for which the destination valid */ +/* mask exists and is already set. */ +/* -------------------------------------------------------------------- */ + iDstOffset = iDstX + iDstY * nDstXSize; + if( poWK->panDstValid != NULL + && (poWK->panDstValid[iDstOffset>>5] + & (0x01 << (iDstOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply transparent/invalid source pixels to the */ +/* destination. This currently ignores the multi-pixel input */ +/* of bilinear and cubic resamples. */ +/* -------------------------------------------------------------------- */ + double dfDensity = 1.0; + + if( poWK->pafUnifiedSrcDensity != NULL + && iSrcX >= 0 && iSrcY >= 0 + && iSrcX < nSrcXSize && iSrcY < nSrcYSize ) + { + dfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + if( dfDensity < 0.00001 ) + continue; + } + + if( poWK->panUnifiedSrcValid != NULL + && iSrcX >= 0 && iSrcY >= 0 + && iSrcX < nSrcXSize && iSrcY < nSrcYSize + && !(poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) + continue; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + double dfBandDensity = 0.0; + double dfValueReal = 0.0; + double dfValueImag = 0.0; + +/* -------------------------------------------------------------------- */ +/* Collect the source value. */ +/* -------------------------------------------------------------------- */ + if( poWK->eResample == GRA_NearestNeighbour ) + { + GWKGetPixelValue( poWK, iBand, iSrcOffset, &dfBandDensity, + &dfValueReal, &dfValueImag ); + } + else if( poWK->eResample == GRA_Bilinear ) + { + GWKBilinearResample( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &dfBandDensity, + &dfValueReal, &dfValueImag ); + } + else if( poWK->eResample == GRA_Cubic ) + { + GWKCubicResample( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &dfBandDensity, + &dfValueReal, &dfValueImag ); + } + else if( poWK->eResample == GRA_CubicSpline ) + { + GWKCubicSplineResample( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &dfBandDensity, + &dfValueReal, &dfValueImag ); + } + + + // If we didn't find any valid inputs skip to next band. + if( dfBandDensity == 0.0 ) + continue; + +/* -------------------------------------------------------------------- */ +/* We have a computed value from the source. Now apply it to */ +/* the destination pixel. */ +/* -------------------------------------------------------------------- */ + GWKSetPixelValue( poWK, iBand, iDstOffset, + dfBandDensity, dfValueReal, dfValueImag ); + + } + +/* -------------------------------------------------------------------- */ +/* Update destination density/validity masks. */ +/* -------------------------------------------------------------------- */ + GWKOverlayDensity( poWK, iDstOffset, dfDensity ); + + if( poWK->panDstValid != NULL ) + { + poWK->panDstValid[iDstOffset>>5] |= + 0x01 << (iDstOffset & 0x1f); + } + + } /* Next iDstX */ + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestNoMasksByte() */ +/* */ +/* Case for 8bit input data with nearest neighbour resampling */ +/* without concerning about masking. Should be as fast as */ +/* possible for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestNoMasksByte( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestNoMasksByte()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + poWK->papabyDstImage[iBand][iDstOffset] = + poWK->papabySrcImage[iBand][iSrcOffset]; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKBilinearNoMasksByte() */ +/* */ +/* Case for 8bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKBilinearNoMasksByte( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKBilinearNoMasksByte()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GWKBilinearResampleNoMasksByte( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &poWK->papabyDstImage[iBand][iDstOffset] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKCubicNoMasksByte() */ +/* */ +/* Case for 8bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKCubicNoMasksByte( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKCubicNoMasksByte()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GWKCubicResampleNoMasksByte( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &poWK->papabyDstImage[iBand][iDstOffset] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKCubicSplineNoMasksByte() */ +/* */ +/* Case for 8bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKCubicSplineNoMasksByte( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKCubicSplineNoMasksByte()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GWKCubicSplineResampleNoMasksByte( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &poWK->papabyDstImage[iBand][iDstOffset] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestByte() */ +/* */ +/* Case for 8bit input data with nearest neighbour resampling */ +/* using valid flags. Should be as fast as possible for this */ +/* particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestByte( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestByte()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* -------------------------------------------------------------------- */ +/* Don't generate output pixels for which the destination valid */ +/* mask exists and is already set. */ +/* */ +/* -- NFW -- FIXME: I think this test is in error. We should, */ +/* generally, be pasteing over existing valid data. */ +/* -------------------------------------------------------------------- */ + iDstOffset = iDstX + iDstY * nDstXSize; + if( poWK->panDstValid != NULL + && (poWK->panDstValid[iDstOffset>>5] + & (0x01 << (iDstOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply invalid source pixels to the dest. */ +/* -------------------------------------------------------------------- */ + if( poWK->panUnifiedSrcValid != NULL + && !(poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply transparent source pixels to the destination.*/ +/* -------------------------------------------------------------------- */ + double dfDensity = 1.0; + + if( poWK->pafUnifiedSrcDensity != NULL ) + { + dfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + if( dfDensity < 0.00001 ) + continue; + } + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GByte bValue = 0; + double dfBandDensity = 0.0; + +/* -------------------------------------------------------------------- */ +/* Collect the source value. */ +/* -------------------------------------------------------------------- */ + if ( GWKGetPixelByte( poWK, iBand, iSrcOffset, &dfBandDensity, + &bValue ) ) + { + if( dfBandDensity < 1.0 ) + { + if( dfBandDensity == 0.0 ) + /* do nothing */; + else + { + /* let the general code take care of mixing */ + GWKSetPixelValue( poWK, iBand, iDstOffset, + dfBandDensity, (double) bValue, + 0.0 ); + } + } + else + { + poWK->papabyDstImage[iBand][iDstOffset] = bValue; + } + } + } + +/* -------------------------------------------------------------------- */ +/* Mark this pixel valid/opaque in the output. */ +/* -------------------------------------------------------------------- */ + GWKOverlayDensity( poWK, iDstOffset, dfDensity ); + + if( poWK->panDstValid != NULL ) + { + poWK->panDstValid[iDstOffset>>5] |= + 0x01 << (iDstOffset & 0x1f); + } + } /* Next iDstX */ + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } /* Next iDstY */ + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestNoMasksShort() */ +/* */ +/* Case for 16bit signed and unsigned integer input data with */ +/* nearest neighbour resampling without concerning about masking. */ +/* Should be as fast as possible for this particular */ +/* transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestNoMasksShort( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestNoMasksShort()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + ((GInt16 *)poWK->papabyDstImage[iBand])[iDstOffset] = + ((GInt16 *)poWK->papabySrcImage[iBand])[iSrcOffset]; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKBilinearNoMasksShort() */ +/* */ +/* Case for 16bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKBilinearNoMasksShort( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKBilinearNoMasksShort()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GInt16 iValue = 0; + GWKBilinearResampleNoMasksShort( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &iValue ); + ((GInt16 *)poWK->papabyDstImage[iBand])[iDstOffset] = iValue; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKCubicNoMasksShort() */ +/* */ +/* Case for 16bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKCubicNoMasksShort( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKCubicNoMasksShort()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GInt16 iValue = 0; + GWKCubicResampleNoMasksShort( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &iValue ); + ((GInt16 *)poWK->papabyDstImage[iBand])[iDstOffset] = iValue; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKCubicSplineNoMasksShort() */ +/* */ +/* Case for 16bit input data with cubic resampling without */ +/* concerning about masking. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKCubicSplineNoMasksShort( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKCubicSplineNoMasksShort()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + int iDstOffset; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GInt16 iValue = 0; + GWKCubicSplineResampleNoMasksShort( poWK, iBand, + padfX[iDstX]-poWK->nSrcXOff, + padfY[iDstX]-poWK->nSrcYOff, + &iValue ); + ((GInt16 *)poWK->papabyDstImage[iBand])[iDstOffset] = iValue; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestShort() */ +/* */ +/* Case for 32bit float input data with nearest neighbour */ +/* resampling using valid flags. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestShort( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestShort()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* -------------------------------------------------------------------- */ +/* Don't generate output pixels for which the destination valid */ +/* mask exists and is already set. */ +/* -------------------------------------------------------------------- */ + iDstOffset = iDstX + iDstY * nDstXSize; + if( poWK->panDstValid != NULL + && (poWK->panDstValid[iDstOffset>>5] + & (0x01 << (iDstOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Don't generate output pixels for which the source valid */ +/* mask exists and is invalid. */ +/* -------------------------------------------------------------------- */ + if( poWK->panUnifiedSrcValid != NULL + && !(poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply transparent source pixels to the destination.*/ +/* -------------------------------------------------------------------- */ + double dfDensity = 1.0; + + if( poWK->pafUnifiedSrcDensity != NULL ) + { + dfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + if( dfDensity < 0.00001 ) + continue; + } + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + GInt16 iValue = 0; + double dfBandDensity = 0.0; + +/* -------------------------------------------------------------------- */ +/* Collect the source value. */ +/* -------------------------------------------------------------------- */ + if ( GWKGetPixelShort( poWK, iBand, iSrcOffset, &dfBandDensity, + &iValue ) ) + { + if( dfBandDensity < 1.0 ) + { + if( dfBandDensity == 0.0 ) + /* do nothing */; + else + { + /* let the general code take care of mixing */ + GWKSetPixelValue( poWK, iBand, iDstOffset, + dfBandDensity, (double) iValue, + 0.0 ); + } + } + else + { + ((GInt16 *)poWK->papabyDstImage[iBand])[iDstOffset] = iValue; + } + } + } + +/* -------------------------------------------------------------------- */ +/* Mark this pixel valid/opaque in the output. */ +/* -------------------------------------------------------------------- */ + GWKOverlayDensity( poWK, iDstOffset, dfDensity ); + + if( poWK->panDstValid != NULL ) + { + poWK->panDstValid[iDstOffset>>5] |= + 0x01 << (iDstOffset & 0x1f); + } + } /* Next iDstX */ + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } /* Next iDstY */ + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestNoMasksFloat() */ +/* */ +/* Case for 32bit float input data with nearest neighbour */ +/* resampling without concerning about masking. Should be as fast */ +/* as possible for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestNoMasksFloat( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestNoMasksFloat()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + iDstOffset = iDstX + iDstY * nDstXSize; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + ((float *)poWK->papabyDstImage[iBand])[iDstOffset] = + ((float *)poWK->papabySrcImage[iBand])[iSrcOffset]; + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + +/************************************************************************/ +/* GWKNearestFloat() */ +/* */ +/* Case for 32bit float input data with nearest neighbour */ +/* resampling using valid flags. Should be as fast as possible */ +/* for this particular transformation type. */ +/************************************************************************/ + +static CPLErr GWKNearestFloat( GDALWarpKernel *poWK ) + +{ + int iDstY; + int nDstXSize = poWK->nDstXSize, nDstYSize = poWK->nDstYSize; + int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize; + CPLErr eErr = CE_None; + + CPLDebug( "GDAL", "GDALWarpKernel()::GWKNearestFloat()\n" + "Src=%d,%d,%dx%d Dst=%d,%d,%dx%d", + poWK->nSrcXOff, poWK->nSrcYOff, + poWK->nSrcXSize, poWK->nSrcYSize, + poWK->nDstXOff, poWK->nDstYOff, + poWK->nDstXSize, poWK->nDstYSize ); + + if( !poWK->pfnProgress( poWK->dfProgressBase, "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate x,y,z coordinate arrays for transformation ... one */ +/* scanlines worth of positions. */ +/* -------------------------------------------------------------------- */ + double *padfX, *padfY, *padfZ; + int *pabSuccess; + + padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize); + padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize); + pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize); + +/* ==================================================================== */ +/* Loop over output lines. */ +/* ==================================================================== */ + for( iDstY = 0; iDstY < nDstYSize && eErr == CE_None; iDstY++ ) + { + int iDstX; + +/* -------------------------------------------------------------------- */ +/* Setup points to transform to source image space. */ +/* -------------------------------------------------------------------- */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff; + padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff; + padfZ[iDstX] = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Transform the points from destination pixel/line coordinates */ +/* to source pixel/line coordinates. */ +/* -------------------------------------------------------------------- */ + poWK->pfnTransformer( poWK->pTransformerArg, TRUE, nDstXSize, + padfX, padfY, padfZ, pabSuccess ); + +/* ==================================================================== */ +/* Loop over pixels in output scanline. */ +/* ==================================================================== */ + for( iDstX = 0; iDstX < nDstXSize; iDstX++ ) + { + int iDstOffset; + + if( !pabSuccess[iDstX] ) + continue; + +/* -------------------------------------------------------------------- */ +/* Figure out what pixel we want in our source raster, and skip */ +/* further processing if it is well off the source image. */ +/* -------------------------------------------------------------------- */ + // We test against the value before casting to avoid the + // problem of asymmetric truncation effects around zero. That is + // -0.5 will be 0 when cast to an int. + if( padfX[iDstX] < poWK->nSrcXOff + || padfY[iDstX] < poWK->nSrcYOff ) + continue; + + int iSrcX, iSrcY, iSrcOffset; + + iSrcX = ((int) padfX[iDstX]) - poWK->nSrcXOff; + iSrcY = ((int) padfY[iDstX]) - poWK->nSrcYOff; + + if( iSrcX >= nSrcXSize || iSrcY >= nSrcYSize ) + continue; + + iSrcOffset = iSrcX + iSrcY * nSrcXSize; + +/* -------------------------------------------------------------------- */ +/* Don't generate output pixels for which the destination valid */ +/* mask exists and is already set. */ +/* -------------------------------------------------------------------- */ + iDstOffset = iDstX + iDstY * nDstXSize; + if( poWK->panDstValid != NULL + && (poWK->panDstValid[iDstOffset>>5] + & (0x01 << (iDstOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply invalid source pixels to the dest. */ +/* -------------------------------------------------------------------- */ + if( poWK->panUnifiedSrcValid != NULL + && !(poWK->panUnifiedSrcValid[iSrcOffset>>5] + & (0x01 << (iSrcOffset & 0x1f))) ) + continue; + +/* -------------------------------------------------------------------- */ +/* Do not try to apply transparent source pixels to the destination.*/ +/* -------------------------------------------------------------------- */ + double dfDensity = 1.0; + + if( poWK->pafUnifiedSrcDensity != NULL ) + { + dfDensity = poWK->pafUnifiedSrcDensity[iSrcOffset]; + if( dfDensity < 0.00001 ) + continue; + } + +/* ==================================================================== */ +/* Loop processing each band. */ +/* ==================================================================== */ + int iBand; + + for( iBand = 0; iBand < poWK->nBands; iBand++ ) + { + float fValue = 0; + double dfBandDensity = 0.0; + +/* -------------------------------------------------------------------- */ +/* Collect the source value. */ +/* -------------------------------------------------------------------- */ + if ( GWKGetPixelFloat( poWK, iBand, iSrcOffset, &dfBandDensity, + &fValue ) ) + { + if( dfBandDensity < 1.0 ) + { + if( dfBandDensity == 0.0 ) + /* do nothing */; + else + { + /* let the general code take care of mixing */ + GWKSetPixelValue( poWK, iBand, iDstOffset, + dfBandDensity, (double) fValue, + 0.0 ); + } + } + else + { + ((float *)poWK->papabyDstImage[iBand])[iDstOffset] + = fValue; + } + } + } + +/* -------------------------------------------------------------------- */ +/* Mark this pixel valid/opaque in the output. */ +/* -------------------------------------------------------------------- */ + GWKOverlayDensity( poWK, iDstOffset, dfDensity ); + + if( poWK->panDstValid != NULL ) + { + poWK->panDstValid[iDstOffset>>5] |= + 0x01 << (iDstOffset & 0x1f); + } + } + +/* -------------------------------------------------------------------- */ +/* Report progress to the user, and optionally cancel out. */ +/* -------------------------------------------------------------------- */ + if( !poWK->pfnProgress( poWK->dfProgressBase + poWK->dfProgressScale * + ((iDstY+1) / (double) nDstYSize), + "", poWK->pProgress ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); + eErr = CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); + CPLFree( pabSuccess ); + + return eErr; +} + diff --git a/Utilities/GDAL/alg/gdalwarpoperation.cpp b/Utilities/GDAL/alg/gdalwarpoperation.cpp new file mode 100644 index 0000000000..9eb5b2cf97 --- /dev/null +++ b/Utilities/GDAL/alg/gdalwarpoperation.cpp @@ -0,0 +1,1959 @@ +/****************************************************************************** + * $Id: gdalwarpoperation.cpp,v 1.25 2005/12/23 18:16:04 fwarmerdam Exp $ + * + * Project: High Performance Image Reprojector + * Purpose: Implementation of the GDALWarpOperation class. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gdalwarpoperation.cpp,v $ + * Revision 1.25 2005/12/23 18:16:04 fwarmerdam + * added SKIP_NOSOURCE option + * + * Revision 1.24 2005/09/13 01:20:16 fwarmerdam + * added UNIFIED_SRC_NODATA mechanism + * + * Revision 1.23 2004/11/14 04:16:30 fwarmerdam + * fixup src alpha support + * + * Revision 1.22 2004/11/05 18:24:26 fwarmerdam + * In ComputeSourceWindow() fallback to using grid if any points along edges + * fail. Also add a buffer around the imagery read if any points fail. + * + * Revision 1.21 2004/10/07 15:50:18 fwarmerdam + * added preliminary alpha band support + * + * Revision 1.20 2004/08/09 14:38:27 warmerda + * added serialize/deserialize support for warpoptions and transformers + * + * Revision 1.19 2004/04/29 13:44:55 warmerda + * fixed some memory leaks + * + * Revision 1.18 2004/03/28 21:22:46 warmerda + * Substantial improvement in default selection of eWorkingDataType. In some + * cases we need to use a more refined data type to preserve nodata values. + * + * Revision 1.17 2003/11/22 19:13:31 dron + * Added C bindings for GDALWarpOperation functions. + * + * Revision 1.16 2003/07/26 17:43:15 warmerda + * Added various warp options in ComputeSourceWindow(). + * + * Revision 1.15 2003/07/24 16:48:40 warmerda + * fixed bug with window size, and origin in ComputeSourceWindow + * + * Revision 1.14 2003/07/04 11:52:22 dron + * GRA_CubicSpline added to the list of validated algorithms. + * + * Revision 1.13 2003/06/05 17:10:13 warmerda + * changed to report approximately correct completion amount in multi case + * + * Revision 1.12 2003/05/27 20:49:26 warmerda + * added REPORT_TIMINGS support + * + * Revision 1.11 2003/05/16 19:43:28 warmerda + * ensure that chunks dont get negative sizes + * + * Revision 1.10 2003/05/07 19:57:32 warmerda + * INIT_DEST now supports a list of band values + * + * Revision 1.9 2003/05/07 19:13:06 warmerda + * added pre and post warp chunk processor + * + * Revision 1.8 2003/05/06 18:32:48 warmerda + * Added WRITE_FLUSH option support. + * Fixed multi-threaded support so that mutexes are released after creation. + * + * Revision 1.7 2003/04/28 20:47:59 warmerda + * use dataset level RasterIO call + * + * Revision 1.6 2003/04/23 05:18:57 warmerda + * added multithread support + * + * Revision 1.5 2003/03/02 05:25:59 warmerda + * added some source nodata support + * + * Revision 1.4 2003/02/22 02:05:20 warmerda + * added defaulting of band mapping, added warp options + * + * Revision 1.3 2003/02/21 15:41:19 warmerda + * working minimally + * + * Revision 1.2 2003/02/20 21:53:06 warmerda + * partial implementation + * + * Revision 1.1 2003/02/18 17:25:50 warmerda + * New + * + */ + +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_multiproc.h" + +CPL_CVSID("$Id: gdalwarpoperation.cpp,v 1.25 2005/12/23 18:16:04 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* GDALWarpOperation */ +/* ==================================================================== */ +/************************************************************************/ + +/** + * \class GDALWarpOperation "gdalwarper.h" + * + * High level image warping class. + +<h2>Warper Design</h2> + +The overall GDAL high performance image warper is split into a few components. + + - The transformation between input and output file coordinates is handled +via GDALTransformerFunc() implementations such as the one returned by +GDALCreateGenImgProjTransformer(). The transformers are ultimately responsible +for translating pixel/line locations on the destination image to pixel/line +locations on the source image. + + - In order to handle images too large to hold in RAM, the warper needs to +segment large images. This is the responsibility of the GDALWarpOperation +class. The GDALWarpOperation::ChunkAndWarpImage() invokes +GDALWarpOperation::WarpRegion() on chunks of output and input image that +are small enough to hold in the amount of memory allowed by the application. +This process is described in greater detail in the <b>Image Chunking</b> +section. + + - The GDALWarpOperation::WarpRegion() function creates and loads an output +image buffer, and then calls WarpRegionToBuffer(). + + - GDALWarpOperation::WarpRegionToBuffer() is responsible for loading the +source imagery corresponding to a particular output region, and generating +masks and density masks from the source and destination imagery using +the generator functions found in the GDALWarpOptions structure. Binds this +all into an instance of GDALWarpKernel on which the +GDALWarpKernel::PerformWarp() method is called. + + - GDALWarpKernel does the actual image warping, but is given an input image +and an output image to operate on. The GDALWarpKernel does no IO, and in +fact knows nothing about GDAL. It invokes the transformation function to +get sample locations, builds output values based on the resampling algorithm +in use. It also takes any validity and density masks into account during +this operation. + +<h3>Chunk Size Selection</h3> + +The GDALWarpOptions ChunkAndWarpImage() method is responsible for invoking +the WarpRegion() method on appropriate sized output chunks such that the +memory required for the output image buffer, input image buffer and any +required density and validity buffers is less than or equal to the application +defined maximum memory available for use. + +It checks the memory requrired by walking the edges of the output region, +transforming the locations back into source pixel/line coordinates and +establishing a bounding rectangle of source imagery that would be required +for the output area. This is actually accomplished by the private +GDALWarpOperation::ComputeSourceWindow() method. + +Then memory requirements are used by totaling the memory required for all +output bands, input bands, validity masks and density masks. If this is +greater than the GDALWarpOptions::dfWarpMemoryLimit then the destination +region is divided in two (splitting the longest dimension), and +ChunkAndWarpImage() recursively invoked on each destination subregion. + +<h3>Validity and Density Masks Generation</h3> + +Fill in ways in which the validity and density masks may be generated here. +Note that detailed semantics of the masks should be found in +GDALWarpKernel. + +*/ + +/************************************************************************/ +/* GDALWarpOperation() */ +/************************************************************************/ + +GDALWarpOperation::GDALWarpOperation() + +{ + psOptions = NULL; + + dfProgressBase = 0.0; + dfProgressScale = 1.0; + + hThread1Mutex = NULL; + hThread2Mutex = NULL; + hIOMutex = NULL; + hWarpMutex = NULL; + + nChunkListCount = 0; + nChunkListMax = 0; + panChunkList = NULL; + + bReportTimings = FALSE; + nLastTimeReported = 0; +} + +/************************************************************************/ +/* ~GDALWarpOperation() */ +/************************************************************************/ + +GDALWarpOperation::~GDALWarpOperation() + +{ + WipeOptions(); + + if( hThread1Mutex != NULL ) + { + CPLDestroyMutex( hThread1Mutex ); + CPLDestroyMutex( hThread2Mutex ); + CPLDestroyMutex( hIOMutex ); + CPLDestroyMutex( hWarpMutex ); + } + + WipeChunkList(); +} + +/************************************************************************/ +/* GetOptions() */ +/************************************************************************/ + +const GDALWarpOptions *GDALWarpOperation::GetOptions() + +{ + return psOptions; +} + +/************************************************************************/ +/* WipeOptions() */ +/************************************************************************/ + +void GDALWarpOperation::WipeOptions() + +{ + if( psOptions != NULL ) + { + GDALDestroyWarpOptions( psOptions ); + psOptions = NULL; + } +} + +/************************************************************************/ +/* ValidateOptions() */ +/************************************************************************/ + +int GDALWarpOperation::ValidateOptions() + +{ + if( psOptions == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " no options currently initialized." ); + return FALSE; + } + + if( psOptions->dfWarpMemoryLimit < 100000.0 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " dfWarpMemoryLimit=%g is unreasonably small.", + psOptions->dfWarpMemoryLimit ); + return FALSE; + } + + if( psOptions->eResampleAlg != GRA_NearestNeighbour + && psOptions->eResampleAlg != GRA_Bilinear + && psOptions->eResampleAlg != GRA_Cubic + && psOptions->eResampleAlg != GRA_CubicSpline ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " eResampleArg=%d is not a supported value.", + psOptions->eResampleAlg ); + return FALSE; + } + + if( (int) psOptions->eWorkingDataType < 1 + && (int) psOptions->eWorkingDataType >= GDT_TypeCount ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " eWorkingDataType=%d is not a supported value.", + psOptions->eWorkingDataType ); + return FALSE; + } + + if( psOptions->hSrcDS == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " hSrcDS is not set." ); + return FALSE; + } + + if( psOptions->hDstDS == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " hDstDS is not set." ); + return FALSE; + } + + if( psOptions->nBandCount == 0 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " nBandCount=0, no bands configured!" ); + return FALSE; + } + + if( psOptions->panSrcBands == NULL || psOptions->panDstBands == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " Either panSrcBands or panDstBands is NULL." ); + return FALSE; + } + + for( int iBand = 0; iBand < psOptions->nBandCount; iBand++ ) + { + if( psOptions->panSrcBands[iBand] < 1 + || psOptions->panSrcBands[iBand] + > GDALGetRasterCount( psOptions->hSrcDS ) ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "panSrcBands[%d] = %d ... out of range for dataset.", + iBand, psOptions->panSrcBands[iBand] ); + return FALSE; + } + if( psOptions->panDstBands[iBand] < 1 + || psOptions->panDstBands[iBand] + > GDALGetRasterCount( psOptions->hDstDS ) ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "panDstBands[%d] = %d ... out of range for dataset.", + iBand, psOptions->panDstBands[iBand] ); + return FALSE; + } + + if( GDALGetRasterAccess( + GDALGetRasterBand(psOptions->hDstDS, + psOptions->panDstBands[iBand]) ) + == GA_ReadOnly ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "Destination band %d appears to be read-only.", + psOptions->panDstBands[iBand] ); + return FALSE; + } + } + + if( psOptions->nBandCount == 0 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " nBandCount=0, no bands configured!" ); + return FALSE; + } + + if( psOptions->padfSrcNoDataReal != NULL + && psOptions->padfSrcNoDataImag == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " padfSrcNoDataReal set, but padfSrcNoDataImag not set." ); + return FALSE; + } + + if( psOptions->pfnProgress == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " pfnProgress is NULL." ); + return FALSE; + } + + if( psOptions->pfnTransformer == NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " pfnTransformer is NULL." ); + return FALSE; + } + + if( CSLFetchNameValue( psOptions->papszWarpOptions, + "SAMPLE_STEPS" ) != NULL ) + { + if( atoi(CSLFetchNameValue( psOptions->papszWarpOptions, + "SAMPLE_STEPS" )) < 2 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " SAMPLE_STEPS warp option has illegal value." ); + return FALSE; + } + } + + if( psOptions->nSrcAlphaBand > 0 + && psOptions->pfnSrcDensityMaskFunc != NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " pfnSrcDensityMaskFunc provided as well as a SrcAlphaBand." ); + return FALSE; + } + + if( psOptions->nDstAlphaBand > 0 + && psOptions->pfnDstDensityMaskFunc != NULL ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "GDALWarpOptions.Validate()\n" + " pfnDstDensityMaskFunc provided as well as a DstAlphaBand." ); + return FALSE; + } + + return TRUE; +} + +/************************************************************************/ +/* Initialize() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpOperation::Initialize( const GDALWarpOptions * ); + * + * This method initializes the GDALWarpOperation's concept of the warp + * options in effect. It creates an internal copy of the GDALWarpOptions + * structure and defaults a variety of additional fields in the internal + * copy if not set in the provides warp options. + * + * Defaulting operations include: + * - If the nBandCount is 0, it will be set to the number of bands in the + * source image (which must match the output image) and the panSrcBands + * and panDstBands will be populated. + * + * @param psNewOptions input set of warp options. These are copied and may + * be destroyed after this call by the application. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpOperation::Initialize( const GDALWarpOptions *psNewOptions ) + +{ + CPLErr eErr = CE_None; + +/* -------------------------------------------------------------------- */ +/* Copy the passed in options. */ +/* -------------------------------------------------------------------- */ + if( psOptions != NULL ) + WipeOptions(); + + psOptions = GDALCloneWarpOptions( psNewOptions ); + +/* -------------------------------------------------------------------- */ +/* Default band mapping if missing. */ +/* -------------------------------------------------------------------- */ + if( psOptions->nBandCount == 0 + && psOptions->hSrcDS != NULL + && psOptions->hDstDS != NULL + && GDALGetRasterCount( psOptions->hSrcDS ) + == GDALGetRasterCount( psOptions->hDstDS ) ) + { + int i; + + psOptions->nBandCount = GDALGetRasterCount( psOptions->hSrcDS ); + + psOptions->panSrcBands = (int *) + CPLMalloc(sizeof(int) * psOptions->nBandCount ); + psOptions->panDstBands = (int *) + CPLMalloc(sizeof(int) * psOptions->nBandCount ); + + for( i = 0; i < psOptions->nBandCount; i++ ) + { + psOptions->panSrcBands[i] = i+1; + psOptions->panDstBands[i] = i+1; + } + } + +/* -------------------------------------------------------------------- */ +/* If no working data type was provided, set one now. */ +/* */ +/* Default to the highest resolution output band. But if the */ +/* input band is higher resolution and has a nodata value "out */ +/* of band" with the output type we may need to use the higher */ +/* resolution input type to ensure we can identify nodata values. */ +/* -------------------------------------------------------------------- */ + if( psOptions->eWorkingDataType == GDT_Unknown + && psOptions->hDstDS != NULL + && psOptions->nBandCount >= 1 ) + { + int iBand; + psOptions->eWorkingDataType = GDT_Byte; + + for( iBand = 0; iBand < psOptions->nBandCount; iBand++ ) + { + GDALRasterBandH hDstBand = GDALGetRasterBand( + psOptions->hDstDS, psOptions->panDstBands[iBand] ); + GDALRasterBandH hSrcBand = GDALGetRasterBand( + psOptions->hSrcDS, psOptions->panSrcBands[iBand] ); + + if( hDstBand != NULL ) + psOptions->eWorkingDataType = + GDALDataTypeUnion( psOptions->eWorkingDataType, + GDALGetRasterDataType( hDstBand ) ); + + if( hSrcBand != NULL + && psOptions->padfSrcNoDataReal != NULL ) + { + int bMergeSource = FALSE; + + if( psOptions->padfSrcNoDataImag[iBand] != 0.0 + && !GDALDataTypeIsComplex( psOptions->eWorkingDataType ) ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] < 0.0 + && (psOptions->eWorkingDataType == GDT_Byte + || psOptions->eWorkingDataType == GDT_UInt16 + || psOptions->eWorkingDataType == GDT_UInt32) ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] < -32768.0 + && psOptions->eWorkingDataType == GDT_Int16 ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] < -2147483648.0 + && psOptions->eWorkingDataType == GDT_Int32 ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] > 256 + && psOptions->eWorkingDataType == GDT_Byte ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] > 32767 + && psOptions->eWorkingDataType == GDT_Int16 ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] > 65535 + && psOptions->eWorkingDataType == GDT_UInt16 ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] > 2147483648.0 + && psOptions->eWorkingDataType == GDT_Int32 ) + bMergeSource = TRUE; + else if( psOptions->padfSrcNoDataReal[iBand] > 4294967295.0 + && psOptions->eWorkingDataType == GDT_UInt32 ) + bMergeSource = TRUE; + + if( bMergeSource ) + psOptions->eWorkingDataType = + GDALDataTypeUnion( psOptions->eWorkingDataType, + GDALGetRasterDataType( hSrcBand ) ); + } + } + } + +/* -------------------------------------------------------------------- */ +/* Default memory available. */ +/* */ +/* For now we default to 64MB of RAM, but eventually we should */ +/* try various schemes to query physical RAM. This can */ +/* certainly be done on Win32 and Linux. */ +/* -------------------------------------------------------------------- */ + if( psOptions->dfWarpMemoryLimit == 0.0 ) + { + psOptions->dfWarpMemoryLimit = 64.0 * 1024*1024; + } + +/* -------------------------------------------------------------------- */ +/* Are we doing timings? */ +/* -------------------------------------------------------------------- */ + bReportTimings = CSLFetchBoolean( psOptions->papszWarpOptions, + "REPORT_TIMINGS", FALSE ); + +/* -------------------------------------------------------------------- */ +/* If the options don't validate, then wipe them. */ +/* -------------------------------------------------------------------- */ + if( !ValidateOptions() ) + eErr = CE_Failure; + + if( eErr != CE_None ) + WipeOptions(); + + return eErr; +} + +/************************************************************************/ +/* GDALCreateWarpOperation() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::Initialize() + */ + +GDALWarpOperationH GDALCreateWarpOperation( + const GDALWarpOptions *psNewOptions ) +{ + GDALWarpOperation *poOperation; + + poOperation = new GDALWarpOperation; + if ( poOperation->Initialize( psNewOptions ) != CE_None ) + { + delete poOperation; + return NULL; + } + + return (GDALWarpOperationH)poOperation; +} + +/************************************************************************/ +/* GDALDestroyWarpOperation() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::~GDALWarpOperation() + */ + +void GDALDestroyWarpOperation( GDALWarpOperationH hOperation ) +{ + if ( hOperation ) + delete (GDALWarpOperation *)hOperation; +} + +/************************************************************************/ +/* ChunkAndWarpImage() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpOperation::ChunkAndWarpImage( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ); + * + * This method does a complete warp of the source image to the destination + * image for the indicated region with the current warp options in effect. + * Progress is reported to the installed progress monitor, if any. + * + * This function will subdivide the region and recursively call itself + * until the total memory required to process a region chunk will all fit + * in the memory pool defined by GDALWarpOptions::dfWarpMemoryLimit. + * + * Once an appropriate region is selected GDALWarpOperation::WarpRegion() + * is invoked to do the actual work. + * + * @param nDstXOff X offset to window of destination data to be produced. + * @param nDstYOff Y offset to window of destination data to be produced. + * @param nDstXSize Width of output window on destination file to be produced. + * @param nDstYSize Height of output window on destination file to be produced. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpOperation::ChunkAndWarpImage( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ) + +{ +/* -------------------------------------------------------------------- */ +/* Collect the list of chunks to operate on. */ +/* -------------------------------------------------------------------- */ + WipeChunkList(); + CollectChunkList( nDstXOff, nDstYOff, nDstXSize, nDstYSize ); + +/* -------------------------------------------------------------------- */ +/* Total up output pixels to process. */ +/* -------------------------------------------------------------------- */ + int iChunk; + double dfTotalPixels = 0; + + for( iChunk = 0; iChunk < nChunkListCount; iChunk++ ) + { + int *panThisChunk = panChunkList + iChunk*8; + double dfChunkPixels = panThisChunk[2] * (double) panThisChunk[3]; + + dfTotalPixels += dfChunkPixels; + } + +/* -------------------------------------------------------------------- */ +/* Process them one at a time, updating the progress */ +/* information for each region. */ +/* -------------------------------------------------------------------- */ + double dfPixelsProcessed=0.0; + + for( iChunk = 0; iChunk < nChunkListCount; iChunk++ ) + { + int *panThisChunk = panChunkList + iChunk*8; + double dfChunkPixels = panThisChunk[2] * (double) panThisChunk[3]; + CPLErr eErr; + + dfProgressBase = dfPixelsProcessed / dfTotalPixels; + dfProgressScale = dfChunkPixels / dfTotalPixels; + + eErr = WarpRegion( panThisChunk[0], panThisChunk[1], + panThisChunk[2], panThisChunk[3], + panThisChunk[4], panThisChunk[5], + panThisChunk[6], panThisChunk[7] ); + + if( eErr != CE_None ) + return eErr; + + dfPixelsProcessed += dfChunkPixels; + } + + WipeChunkList(); + + return CE_None; +} + +/************************************************************************/ +/* GDALChunkAndWarpImage() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::ChunkAndWarpImage() + */ + +CPLErr GDALChunkAndWarpImage( GDALWarpOperationH hOperation, + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ) +{ + return ( (GDALWarpOperation *)hOperation )-> + ChunkAndWarpImage( nDstXOff, nDstYOff, nDstXSize, nDstYSize ); +} + +/************************************************************************/ +/* ChunkThreadMain() */ +/************************************************************************/ + +static void ChunkThreadMain( void *pThreadData ) + +{ + void *hThreadMutex = ((void **) pThreadData)[0]; + GDALWarpOperation *poOperation = + (GDALWarpOperation *) (((void **) pThreadData)[1]); + int *panChunkInfo = (int *) (((void **) pThreadData)[2]); + + if( !CPLAcquireMutex( hThreadMutex, 2.0 ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to acquire thread mutex in ChunkThreadMain()." ); + return; + } + + CPLErr eErr; + + eErr = + poOperation->WarpRegion( panChunkInfo[0], panChunkInfo[1], + panChunkInfo[2], panChunkInfo[3], + panChunkInfo[4], panChunkInfo[5], + panChunkInfo[6], panChunkInfo[7] ); + + /* Return error. */ + ((void **) pThreadData)[2] = (void *) (long) eErr; + + /* Marks that we are done. */ + ((void **) pThreadData)[1] = NULL; + + /* Release mutex so parent knows we are done. */ + CPLReleaseMutex( hThreadMutex ); +} + +/************************************************************************/ +/* ChunkAndWarpMulti() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpOperation::ChunkAndWarpMulti( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ); + * + * This method does a complete warp of the source image to the destination + * image for the indicated region with the current warp options in effect. + * Progress is reported to the installed progress monitor, if any. + * + * Externally this method operates the same as ChunkAndWarpImage(), but + * internally this method uses multiple threads to interleave input/output + * for one region while the processing is being done for another. + * + * @param nDstXOff X offset to window of destination data to be produced. + * @param nDstYOff Y offset to window of destination data to be produced. + * @param nDstXSize Width of output window on destination file to be produced. + * @param nDstYSize Height of output window on destination file to be produced. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpOperation::ChunkAndWarpMulti( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ) + +{ + hThread1Mutex = CPLCreateMutex(); + hThread2Mutex = CPLCreateMutex(); + hIOMutex = CPLCreateMutex(); + hWarpMutex = CPLCreateMutex(); + + CPLReleaseMutex( hThread1Mutex ); + CPLReleaseMutex( hThread2Mutex ); + CPLReleaseMutex( hIOMutex ); + CPLReleaseMutex( hWarpMutex ); + +/* -------------------------------------------------------------------- */ +/* Collect the list of chunks to operate on. */ +/* -------------------------------------------------------------------- */ + WipeChunkList(); + CollectChunkList( nDstXOff, nDstYOff, nDstXSize, nDstYSize ); + +/* -------------------------------------------------------------------- */ +/* Process them one at a time, updating the progress */ +/* information for each region. */ +/* -------------------------------------------------------------------- */ + void * volatile papThreadDataList[6] = { hThread1Mutex, NULL, NULL, + hThread2Mutex, NULL, NULL }; + int iChunk; + double dfPixelsProcessed=0.0, dfTotalPixels = nDstXSize*(double)nDstYSize; + + for( iChunk = 0; iChunk < nChunkListCount+1; iChunk++ ) + { + int iThread = iChunk % 2; + +/* -------------------------------------------------------------------- */ +/* Launch thread for this chunk. */ +/* -------------------------------------------------------------------- */ + if( iChunk < nChunkListCount ) + { + int *panThisChunk = panChunkList + iChunk*8; + double dfChunkPixels = panThisChunk[2] * (double) panThisChunk[3]; + + dfProgressBase = dfPixelsProcessed / dfTotalPixels; + dfProgressScale = dfChunkPixels / dfTotalPixels; + + dfPixelsProcessed += dfChunkPixels; + + papThreadDataList[iThread*3+1] = (void *) this; + papThreadDataList[iThread*3+2] = (void *) panThisChunk; + + CPLDebug( "GDAL", "Start chunk %d.", iChunk ); + if( CPLCreateThread( ChunkThreadMain, + (void *) (papThreadDataList + iThread*3)) == -1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "CPLCreateThread() failed in ChunkAndWarpMulti()" ); + return CE_Failure; + } + + /* Eventually we need a mechanism to ensure we wait for this + thread to acquire the IO mutex before proceeding. */ + if( iChunk == 0 ) + CPLSleep( 0.25 ); + } + + +/* -------------------------------------------------------------------- */ +/* Wait for previous chunks thread to complete. */ +/* -------------------------------------------------------------------- */ + if( iChunk > 0 ) + { + iThread = (iChunk-1) % 2; + + /* Wait for thread to finish. */ + while( papThreadDataList[iThread*3+1] != NULL ) + { + if( CPLAcquireMutex( papThreadDataList[iThread*3+0], 1.0 ) ) + CPLReleaseMutex( papThreadDataList[iThread*3+0] ); + } + + CPLDebug( "GDAL", "Finished chunk %d.", iChunk-1 ); + + CPLErr eErr = (CPLErr) (long) papThreadDataList[iThread*3+2]; + + if( eErr != CE_None ) + return eErr; + } + } + + WipeChunkList(); + + return CE_None; +} + +/************************************************************************/ +/* GDALChunkAndWarpMulti() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::ChunkAndWarpMulti() + */ + +CPLErr GDALChunkAndWarpMulti( GDALWarpOperationH hOperation, + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ) +{ + return ( (GDALWarpOperation *)hOperation )-> + ChunkAndWarpMulti( nDstXOff, nDstYOff, nDstXSize, nDstYSize ); +} + +/************************************************************************/ +/* WipeChunkList() */ +/************************************************************************/ + +void GDALWarpOperation::WipeChunkList() + +{ + CPLFree( panChunkList ); + panChunkList = NULL; + nChunkListCount = 0; + nChunkListMax = 0; +} + +/************************************************************************/ +/* CollectChunkList() */ +/************************************************************************/ + +CPLErr GDALWarpOperation::CollectChunkList( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize ) + +{ +/* -------------------------------------------------------------------- */ +/* Compute the bounds of the input area corresponding to the */ +/* output area. */ +/* -------------------------------------------------------------------- */ + int nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize; + CPLErr eErr; + + eErr = ComputeSourceWindow( nDstXOff, nDstYOff, nDstXSize, nDstYSize, + &nSrcXOff, &nSrcYOff, &nSrcXSize, &nSrcYSize ); + + if( eErr != CE_None ) + return eErr; + +/* -------------------------------------------------------------------- */ +/* If we are allowed to drop no-source regons, do so now if */ +/* appropriate. */ +/* -------------------------------------------------------------------- */ + if( (nSrcXSize == 0 || nSrcYSize == 0) + && CSLFetchBoolean( psOptions->papszWarpOptions, "SKIP_NOSOURCE",0 )) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* Based on the types of masks in use, how many bits will each */ +/* source pixel cost us? */ +/* -------------------------------------------------------------------- */ + int nSrcPixelCostInBits; + + nSrcPixelCostInBits = + GDALGetDataTypeSize( psOptions->eWorkingDataType ) + * psOptions->nBandCount; + + if( psOptions->pfnSrcDensityMaskFunc != NULL ) + nSrcPixelCostInBits += 32; /* float mask */ + + if( psOptions->papfnSrcPerBandValidityMaskFunc != NULL + || psOptions->padfSrcNoDataReal != NULL ) + nSrcPixelCostInBits += psOptions->nBandCount; /* bit/band mask */ + + if( psOptions->pfnSrcValidityMaskFunc != NULL ) + nSrcPixelCostInBits += 1; /* bit mask */ + +/* -------------------------------------------------------------------- */ +/* What about the cost for the destination. */ +/* -------------------------------------------------------------------- */ + int nDstPixelCostInBits; + + nDstPixelCostInBits = + GDALGetDataTypeSize( psOptions->eWorkingDataType ) + * psOptions->nBandCount; + + if( psOptions->pfnDstDensityMaskFunc != NULL ) + nDstPixelCostInBits += 32; + + if( psOptions->padfDstNoDataReal != NULL + || psOptions->pfnDstValidityMaskFunc != NULL ) + nDstPixelCostInBits += psOptions->nBandCount; + +/* -------------------------------------------------------------------- */ +/* Does the cost of the current rectangle exceed our memory */ +/* limit? If so, split the destination along the longest */ +/* dimension and recurse. */ +/* -------------------------------------------------------------------- */ + double dfTotalMemoryUse; + + dfTotalMemoryUse = + (((double) nSrcPixelCostInBits) * nSrcXSize * nSrcYSize + + ((double) nDstPixelCostInBits) * nDstXSize * nDstYSize) / 8.0; + + if( dfTotalMemoryUse > psOptions->dfWarpMemoryLimit + && (nDstXSize > 2 || nDstYSize > 2) ) + { + if( nDstXSize > nDstYSize ) + { + int nChunk1 = nDstXSize / 2; + int nChunk2 = nDstXSize - nChunk1; + + eErr = CollectChunkList( nDstXOff, nDstYOff, + nChunk1, nDstYSize ); + + if( eErr == CE_None ) + { + eErr = CollectChunkList( nDstXOff+nChunk1, nDstYOff, + nChunk2, nDstYSize ); + } + } + else + { + int nChunk1 = nDstYSize / 2; + int nChunk2 = nDstYSize - nChunk1; + + eErr = CollectChunkList( nDstXOff, nDstYOff, + nDstXSize, nChunk1 ); + + if( eErr == CE_None ) + { + eErr = CollectChunkList( nDstXOff, nDstYOff+nChunk1, + nDstXSize, nChunk2 ); + } + } + + return eErr; + } + +/* -------------------------------------------------------------------- */ +/* OK, everything fits, so add to the chunk list. */ +/* -------------------------------------------------------------------- */ + if( nChunkListCount == nChunkListMax ) + { + nChunkListMax = nChunkListMax * 2 + 1; + panChunkList = (int *) + CPLRealloc(panChunkList,sizeof(int)*nChunkListMax*8 ); + } + + panChunkList[nChunkListCount*8+0] = nDstXOff; + panChunkList[nChunkListCount*8+1] = nDstYOff; + panChunkList[nChunkListCount*8+2] = nDstXSize; + panChunkList[nChunkListCount*8+3] = nDstYSize; + panChunkList[nChunkListCount*8+4] = nSrcXOff; + panChunkList[nChunkListCount*8+5] = nSrcYOff; + panChunkList[nChunkListCount*8+6] = nSrcXSize; + panChunkList[nChunkListCount*8+7] = nSrcYSize; + + nChunkListCount++; + + return CE_None; +} + + +/************************************************************************/ +/* WarpRegion() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpOperation::WarpRegion(int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0 ); + * + * This method requests the indicated region of the output file be generated. + * + * Note that WarpRegion() will produce the requested area in one low level warp + * operation without verifying that this does not exceed the stated memory + * limits for the warp operation. Applications should take care not to call + * WarpRegion() on too large a region! This function + * is normally called by ChunkAndWarpImage(), the normal entry point for + * applications. Use it instead if staying within memory constraints is + * desired. + * + * Progress is reported from 0.0 to 1.0 for the indicated region. + * + * @param nDstXOff X offset to window of destination data to be produced. + * @param nDstYOff Y offset to window of destination data to be produced. + * @param nDstXSize Width of output window on destination file to be produced. + * @param nDstYSize Height of output window on destination file to be produced. + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpOperation::WarpRegion( int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff, int nSrcYOff, + int nSrcXSize, int nSrcYSize ) + +{ + CPLErr eErr; + int iBand; + +/* -------------------------------------------------------------------- */ +/* Acquire IO mutex. */ +/* -------------------------------------------------------------------- */ + if( hIOMutex != NULL ) + { + if( !CPLAcquireMutex( hIOMutex, 600.0 ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to acquire IOMutex in WarpRegion()." ); + return CE_Failure; + } + } + + ReportTiming( NULL ); + +/* -------------------------------------------------------------------- */ +/* Allocate the output buffer. */ +/* -------------------------------------------------------------------- */ + void *pDstBuffer; + int nWordSize = GDALGetDataTypeSize(psOptions->eWorkingDataType)/8; + int nBandSize = nWordSize * nDstXSize * nDstYSize; + + pDstBuffer = VSIMalloc( nBandSize * psOptions->nBandCount ); + if( pDstBuffer == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Out of memory allocatint %d byte destination buffer.", + nBandSize * psOptions->nBandCount ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* If the INIT_DEST option is given the initialize the output */ +/* destination buffer to the indicated value without reading it */ +/* from the hDstDS. This is sometimes used to optimize */ +/* operation to a new output file ... it doesn't have to */ +/* written out and read back for nothing. */ +/* -------------------------------------------------------------------- */ + const char *pszInitDest = CSLFetchNameValue( psOptions->papszWarpOptions, + "INIT_DEST" ); + + if( pszInitDest != NULL ) + { + char **papszInitValues = + CSLTokenizeStringComplex( pszInitDest, ",", FALSE, FALSE ); + int nInitCount = CSLCount(papszInitValues); + + for( iBand = 0; iBand < psOptions->nBandCount; iBand++ ) + { + double adfInitRealImag[2]; + GByte *pBandData; + const char *pszBandInit = papszInitValues[MIN(iBand,nInitCount-1)]; + + if( EQUAL(pszBandInit,"NO_DATA") + && psOptions->padfDstNoDataReal != NULL ) + { + adfInitRealImag[0] = psOptions->padfDstNoDataReal[iBand]; + adfInitRealImag[1] = psOptions->padfDstNoDataImag[iBand]; + } + else + { + CPLStringToComplex( pszBandInit, + adfInitRealImag + 0, adfInitRealImag + 1); + } + + pBandData = ((GByte *) pDstBuffer) + iBand * nBandSize; + + if( psOptions->eWorkingDataType == GDT_Byte ) + memset( pBandData, + MAX(0,MIN(255,(int)adfInitRealImag[0])), + nBandSize); + else if( adfInitRealImag[0] == 0.0 && adfInitRealImag[1] == 0 ) + { + memset( pBandData, 0, nBandSize ); + } + else if( adfInitRealImag[1] == 0.0 ) + { + GDALCopyWords( &adfInitRealImag, GDT_Float64, 0, + pBandData,psOptions->eWorkingDataType,nWordSize, + nDstXSize * nDstYSize ); + } + else + { + GDALCopyWords( &adfInitRealImag, GDT_CFloat64, 0, + pBandData,psOptions->eWorkingDataType,nWordSize, + nDstXSize * nDstYSize ); + } + } + + CSLDestroy( papszInitValues ); + } + +/* -------------------------------------------------------------------- */ +/* If we aren't doing fixed initialization of the output buffer */ +/* then read it from disk so we can overlay on existing imagery. */ +/* -------------------------------------------------------------------- */ + if( pszInitDest == NULL ) + { + eErr = GDALDatasetRasterIO( psOptions->hDstDS, GF_Read, + nDstXOff, nDstYOff, nDstXSize, nDstYSize, + pDstBuffer, nDstXSize, nDstYSize, + psOptions->eWorkingDataType, + psOptions->nBandCount, + psOptions->panDstBands, + 0, 0, 0 ); + + if( eErr != CE_None ) + { + CPLFree( pDstBuffer ); + return eErr; + } + + ReportTiming( "Output buffer read" ); + } + +/* -------------------------------------------------------------------- */ +/* Perform the warp. */ +/* -------------------------------------------------------------------- */ + eErr = WarpRegionToBuffer( nDstXOff, nDstYOff, nDstXSize, nDstYSize, + pDstBuffer, psOptions->eWorkingDataType, + nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize ); + +/* -------------------------------------------------------------------- */ +/* Write the output data back to disk if all went well. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None ) + { + eErr = GDALDatasetRasterIO( psOptions->hDstDS, GF_Write, + nDstXOff, nDstYOff, nDstXSize, nDstYSize, + pDstBuffer, nDstXSize, nDstYSize, + psOptions->eWorkingDataType, + psOptions->nBandCount, + psOptions->panDstBands, + 0, 0, 0 ); + if( CSLFetchBoolean( psOptions->papszWarpOptions, "WRITE_FLUSH", + FALSE ) ) + { + GDALFlushCache( psOptions->hDstDS ); + } + ReportTiming( "Output buffer write" ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup and return. */ +/* -------------------------------------------------------------------- */ + VSIFree( pDstBuffer ); + + if( hIOMutex != NULL ) + CPLReleaseMutex( hIOMutex ); + + return eErr; +} + +/************************************************************************/ +/* GDALWarpRegion() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::WarpRegion() + */ + +CPLErr GDALWarpRegion( GDALWarpOperationH hOperation, + int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int nSrcXOff, int nSrcYOff, + int nSrcXSize, int nSrcYSize ) + +{ + return ( (GDALWarpOperation *)hOperation )-> + WarpRegion( nDstXOff, nDstYOff, nDstXSize, nDstYSize, + nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize); +} + +/************************************************************************/ +/* WarpRegionToBuffer() */ +/************************************************************************/ + +/** + * \fn CPLErr GDALWarpOperation::WarpRegionToBuffer( + int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + void *pDataBuf, + GDALDataType eBufDataType, + int nSrcXOff=0, int nSrcYOff=0, + int nSrcXSize=0, int nSrcYSize=0 ); + * + * This method requests that a particular window of the output dataset + * be warped and the result put into the provided data buffer. The output + * dataset doesn't even really have to exist to use this method as long as + * the transformation function in the GDALWarpOptions is setup to map to + * a virtual pixel/line space. + * + * This method will do the whole region in one chunk, so be wary of the + * amount of memory that might be used. + * + * @param nDstXOff X offset to window of destination data to be produced. + * @param nDstYOff Y offset to window of destination data to be produced. + * @param nDstXSize Width of output window on destination file to be produced. + * @param nDstYSize Height of output window on destination file to be produced. + * @param pDataBuf the data buffer to place result in, of type eBufDataType. + * @param eBufDataType the type of the output data buffer. For now this + * must match GDALWarpOptions::eWorkingDataType. + * @param nSrcXOff source window X offset (computed if window all zero) + * @param nSrcYOff source window Y offset (computed if window all zero) + * @param nSrcXSize source window X size (computed if window all zero) + * @param nSrcYSize source window Y size (computed if window all zero) + * + * @return CE_None on success or CE_Failure if an error occurs. + */ + +CPLErr GDALWarpOperation::WarpRegionToBuffer( + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize, + void *pDataBuf, GDALDataType eBufDataType, + int nSrcXOff, int nSrcYOff, int nSrcXSize, int nSrcYSize ) + +{ + CPLErr eErr = CE_None; + int i; + int nWordSize = GDALGetDataTypeSize(psOptions->eWorkingDataType)/8; + + (void) eBufDataType; + CPLAssert( eBufDataType == psOptions->eWorkingDataType ); + +/* -------------------------------------------------------------------- */ +/* If not given a corresponding source window compute one now. */ +/* -------------------------------------------------------------------- */ + if( nSrcXSize == 0 && nSrcYSize == 0 ) + { + eErr = ComputeSourceWindow( nDstXOff, nDstYOff, nDstXSize, nDstYSize, + &nSrcXOff, &nSrcYOff, + &nSrcXSize, &nSrcYSize ); + + if( eErr != CE_None ) + return eErr; + } + +/* -------------------------------------------------------------------- */ +/* Prepare a WarpKernel object to match this operation. */ +/* -------------------------------------------------------------------- */ + GDALWarpKernel oWK; + + oWK.eResample = psOptions->eResampleAlg; + oWK.nBands = psOptions->nBandCount; + oWK.eWorkingDataType = psOptions->eWorkingDataType; + + oWK.pfnTransformer = psOptions->pfnTransformer; + oWK.pTransformerArg = psOptions->pTransformerArg; + + oWK.pfnProgress = psOptions->pfnProgress; + oWK.pProgress = psOptions->pProgressArg; + oWK.dfProgressBase = dfProgressBase; + oWK.dfProgressScale = dfProgressScale; + + oWK.papszWarpOptions = psOptions->papszWarpOptions; + +/* -------------------------------------------------------------------- */ +/* Setup the source buffer. */ +/* */ +/* Eventually we may need to take advantage of pixel */ +/* interleaved reading here. */ +/* -------------------------------------------------------------------- */ + oWK.nSrcXOff = nSrcXOff; + oWK.nSrcYOff = nSrcYOff; + oWK.nSrcXSize = nSrcXSize; + oWK.nSrcYSize = nSrcYSize; + + oWK.papabySrcImage = (GByte **) + CPLCalloc(sizeof(GByte*),psOptions->nBandCount); + oWK.papabySrcImage[0] = (GByte *) + VSIMalloc( nWordSize * nSrcXSize * nSrcYSize * psOptions->nBandCount ); + + if( oWK.papabySrcImage[0] == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Failed to allocate %d byte source buffer.", + nWordSize * nSrcXSize * nSrcYSize * psOptions->nBandCount ); + eErr = CE_Failure; + } + + for( i = 0; i < psOptions->nBandCount && eErr == CE_None; i++ ) + oWK.papabySrcImage[i] = ((GByte *) oWK.papabySrcImage[0]) + + nWordSize * nSrcXSize * nSrcYSize * i; + + if( eErr == CE_None && nSrcXSize > 0 && nSrcYSize > 0 ) + eErr = + GDALDatasetRasterIO( psOptions->hSrcDS, GF_Read, + nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize, + oWK.papabySrcImage[0], nSrcXSize, nSrcYSize, + psOptions->eWorkingDataType, + psOptions->nBandCount, psOptions->panSrcBands, + 0, 0, 0 ); + + ReportTiming( "Input buffer read" ); + +/* -------------------------------------------------------------------- */ +/* Initialize destination buffer. */ +/* -------------------------------------------------------------------- */ + oWK.nDstXOff = nDstXOff; + oWK.nDstYOff = nDstYOff; + oWK.nDstXSize = nDstXSize; + oWK.nDstYSize = nDstYSize; + + oWK.papabyDstImage = (GByte **) + CPLCalloc(sizeof(GByte*),psOptions->nBandCount); + + for( i = 0; i < psOptions->nBandCount && eErr == CE_None; i++ ) + { + oWK.papabyDstImage[i] = ((GByte *) pDataBuf) + + i * nDstXSize * nDstYSize * nWordSize; + } + +/* -------------------------------------------------------------------- */ +/* Eventually we need handling for a whole bunch of the */ +/* validity and density masks here. */ +/* -------------------------------------------------------------------- */ + + /* TODO */ + +/* -------------------------------------------------------------------- */ +/* Generate a source density mask if we have a source alpha band */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->nSrcAlphaBand > 0 ) + { + CPLAssert( oWK.pafDstDensity == NULL ); + + eErr = CreateKernelMask( &oWK, i, "UnifiedSrcDensity" ); + + if( eErr == CE_None ) + eErr = + GDALWarpSrcAlphaMasker( psOptions, + psOptions->nBandCount, + psOptions->eWorkingDataType, + oWK.nSrcXOff, oWK.nSrcYOff, + oWK.nSrcXSize, oWK.nSrcYSize, + oWK.papabySrcImage, + TRUE, oWK.pafUnifiedSrcDensity ); + } + +/* -------------------------------------------------------------------- */ +/* Generate a destination density mask if we have a destination */ +/* alpha band. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->nDstAlphaBand > 0 ) + { + CPLAssert( oWK.pafDstDensity == NULL ); + + eErr = CreateKernelMask( &oWK, i, "DstDensity" ); + + if( eErr == CE_None ) + eErr = + GDALWarpDstAlphaMasker( psOptions, + psOptions->nBandCount, + psOptions->eWorkingDataType, + oWK.nDstXOff, oWK.nDstYOff, + oWK.nDstXSize, oWK.nDstYSize, + oWK.papabyDstImage, + TRUE, oWK.pafDstDensity ); + } + +/* -------------------------------------------------------------------- */ +/* If we have source nodata values create, or update the */ +/* validity mask. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->padfSrcNoDataReal != NULL ) + { + for( i = 0; i < psOptions->nBandCount && eErr == CE_None; i++ ) + { + eErr = CreateKernelMask( &oWK, i, "BandSrcValid" ); + if( eErr == CE_None ) + { + double adfNoData[2]; + + adfNoData[0] = psOptions->padfSrcNoDataReal[i]; + adfNoData[1] = psOptions->padfSrcNoDataImag[i]; + + eErr = + GDALWarpNoDataMasker( adfNoData, 1, + psOptions->eWorkingDataType, + oWK.nSrcXOff, oWK.nSrcYOff, + oWK.nSrcXSize, oWK.nSrcYSize, + &(oWK.papabySrcImage[i]), + FALSE, oWK.papanBandSrcValid[i] ); + } + } + +/* -------------------------------------------------------------------- */ +/* If UNIFIED_SRC_NODATA is set, then compute a unified input */ +/* pixel mask if and only if all bands nodata is true. That */ +/* is, we only treat a pixel as nodata if all bands match their */ +/* respective nodata values. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchBoolean( psOptions->papszWarpOptions, "UNIFIED_SRC_NODATA", + FALSE ) + && eErr == CE_None ) + { + int nBytesInMask = (oWK.nSrcXSize * oWK.nSrcYSize + 31) / 8; + int iWord; + + eErr = CreateKernelMask( &oWK, i, "UnifiedSrcValid" ); + + memset( oWK.panUnifiedSrcValid, 0, nBytesInMask ); + + for( i = 0; i < psOptions->nBandCount; i++ ) + { + for( iWord = nBytesInMask/4 - 1; iWord >= 0; iWord-- ) + oWK.panUnifiedSrcValid[iWord] |= + oWK.papanBandSrcValid[i][iWord]; + CPLFree( oWK.papanBandSrcValid[i] ); + oWK.papanBandSrcValid[i] = NULL; + } + + CPLFree( oWK.papanBandSrcValid ); + oWK.papanBandSrcValid = NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Release IO Mutex, and acquire warper mutex. */ +/* -------------------------------------------------------------------- */ + if( hIOMutex != NULL ) + { + CPLReleaseMutex( hIOMutex ); + if( !CPLAcquireMutex( hWarpMutex, 600.0 ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to acquire WarpMutex in WarpRegion()." ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Optional application provided prewarp chunk processor. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->pfnPreWarpChunkProcessor != NULL ) + eErr = psOptions->pfnPreWarpChunkProcessor( + (void *) &oWK, psOptions->pPreWarpProcessorArg ); + +/* -------------------------------------------------------------------- */ +/* Perform the warp. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None ) + { + eErr = oWK.PerformWarp(); + ReportTiming( "In memory warp operation" ); + } + +/* -------------------------------------------------------------------- */ +/* Optional application provided postwarp chunk processor. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->pfnPostWarpChunkProcessor != NULL ) + eErr = psOptions->pfnPostWarpChunkProcessor( + (void *) &oWK, psOptions->pPostWarpProcessorArg ); + +/* -------------------------------------------------------------------- */ +/* Release Warp Mutex, and acquire io mutex. */ +/* -------------------------------------------------------------------- */ + if( hIOMutex != NULL ) + { + CPLReleaseMutex( hWarpMutex ); + if( !CPLAcquireMutex( hIOMutex, 600.0 ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to acquire IOMutex in WarpRegion()." ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Write destination alpha if available. */ +/* -------------------------------------------------------------------- */ + if( eErr == CE_None && psOptions->nDstAlphaBand > 0 ) + { + eErr = + GDALWarpDstAlphaMasker( psOptions, + -psOptions->nBandCount, + psOptions->eWorkingDataType, + oWK.nDstXOff, oWK.nDstYOff, + oWK.nDstXSize, oWK.nDstYSize, + oWK.papabyDstImage, + TRUE, oWK.pafDstDensity ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup. */ +/* -------------------------------------------------------------------- */ + CPLFree( oWK.papabySrcImage[0] ); + CPLFree( oWK.papabySrcImage ); + CPLFree( oWK.papabyDstImage ); + + if( oWK.papanBandSrcValid != NULL ) + { + for( i = 0; i < oWK.nBands; i++ ) + CPLFree( oWK.papanBandSrcValid[i] ); + CPLFree( oWK.papanBandSrcValid ); + } + CPLFree( oWK.panUnifiedSrcValid ); + CPLFree( oWK.pafUnifiedSrcDensity ); + CPLFree( oWK.panDstValid ); + CPLFree( oWK.pafDstDensity ); + + return eErr; +} + +/************************************************************************/ +/* GDALWarpRegionToBuffer() */ +/************************************************************************/ + +/** + * @see GDALWarpOperation::WarpRegionToBuffer() + */ + +CPLErr GDALWarpRegionToBuffer( GDALWarpOperationH hOperation, + int nDstXOff, int nDstYOff, int nDstXSize, int nDstYSize, + void *pDataBuf, GDALDataType eBufDataType, + int nSrcXOff, int nSrcYOff, int nSrcXSize, int nSrcYSize ) + +{ + return ( (GDALWarpOperation *)hOperation )-> + WarpRegionToBuffer( nDstXOff, nDstYOff, nDstXSize, nDstYSize, + pDataBuf, eBufDataType, + nSrcXOff, nSrcYOff, nSrcXSize, nSrcYSize ); +} + +/************************************************************************/ +/* CreateKernelMask() */ +/* */ +/* If mask does not yet exist, create it. Supported types are */ +/* the name of the variable in question. That is */ +/* "BandSrcValid", "UnifiedSrcValid", "UnifiedSrcDensity", */ +/* "DstValid", and "DstDensity". */ +/************************************************************************/ + +CPLErr GDALWarpOperation::CreateKernelMask( GDALWarpKernel *poKernel, + int iBand, const char *pszType ) + +{ + void **ppMask; + int nXSize, nYSize, nBitsPerPixel, nDefault; + +/* -------------------------------------------------------------------- */ +/* Get particulars of mask to be updated. */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszType,"BandSrcValid") ) + { + if( poKernel->papanBandSrcValid == NULL ) + poKernel->papanBandSrcValid = (GUInt32 **) + CPLCalloc( sizeof(void*),poKernel->nBands); + + ppMask = (void **) &(poKernel->papanBandSrcValid[iBand]); + nXSize = poKernel->nSrcXSize; + nYSize = poKernel->nSrcYSize; + nBitsPerPixel = 1; + nDefault = 0xff; + } + else if( EQUAL(pszType,"UnifiedSrcValid") ) + { + ppMask = (void **) &(poKernel->panUnifiedSrcValid); + nXSize = poKernel->nSrcXSize; + nYSize = poKernel->nSrcYSize; + nBitsPerPixel = 1; + nDefault = 0xff; + } + else if( EQUAL(pszType,"UnifiedSrcDensity") ) + { + ppMask = (void **) &(poKernel->pafUnifiedSrcDensity); + nXSize = poKernel->nSrcXSize; + nYSize = poKernel->nSrcYSize; + nBitsPerPixel = 32; + nDefault = 0; + } + else if( EQUAL(pszType,"DstValid") ) + { + ppMask = (void **) &(poKernel->panDstValid); + nXSize = poKernel->nDstXSize; + nYSize = poKernel->nDstYSize; + nBitsPerPixel = 1; + nDefault = 0xff; + } + else if( EQUAL(pszType,"DstDensity") ) + { + ppMask = (void **) &(poKernel->pafDstDensity); + nXSize = poKernel->nDstXSize; + nYSize = poKernel->nDstYSize; + nBitsPerPixel = 32; + nDefault = 0; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Internal error in CreateKernelMask(%s).", + pszType ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate if needed. */ +/* -------------------------------------------------------------------- */ + if( *ppMask == NULL ) + { + int nBytes; + + if( nBitsPerPixel == 32 ) + nBytes = nXSize * nYSize * 4; + else + nBytes = (nXSize * nYSize + 31) / 8; + + *ppMask = VSIMalloc( nBytes ); + + if( *ppMask == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Out of memory allocating %d bytes for %s mask.", + nBytes, pszType ); + return CE_Failure; + } + + memset( *ppMask, nDefault, nBytes ); + } + + return CE_None; +} + + + +/************************************************************************/ +/* ComputeSourceWindow() */ +/************************************************************************/ + +CPLErr GDALWarpOperation::ComputeSourceWindow(int nDstXOff, int nDstYOff, + int nDstXSize, int nDstYSize, + int *pnSrcXOff, int *pnSrcYOff, + int *pnSrcXSize, int *pnSrcYSize) + +{ +/* -------------------------------------------------------------------- */ +/* Figure out whether we just want to do the usual "along the */ +/* edge" sampling, or using a grid. The grid usage is */ +/* important in some weird "inside out" cases like WGS84 to */ +/* polar stereographic around the pole. Also figure out the */ +/* sampling rate. */ +/* -------------------------------------------------------------------- */ + double dfStepSize; + int nSampleMax, nStepCount = 21, bUseGrid; + int *pabSuccess = NULL; + double *padfX, *padfY, *padfZ; + int nSamplePoints; + double dfRatio; + + if( CSLFetchNameValue( psOptions->papszWarpOptions, + "SAMPLE_STEPS" ) != NULL ) + { + nStepCount = + atoi(CSLFetchNameValue( psOptions->papszWarpOptions, + "SAMPLE_STEPS" )); + nStepCount = MAX(2,nStepCount); + } + + dfStepSize = 1.0 / (nStepCount-1); + + bUseGrid = CSLFetchBoolean( psOptions->papszWarpOptions, + "SAMPLE_GRID", FALSE ); + + TryAgainWithGrid: + nSamplePoints = 0; + if( bUseGrid ) + nSampleMax = nStepCount * nStepCount; + else + nSampleMax = nStepCount * 4; + + pabSuccess = (int *) CPLMalloc(sizeof(int) * nSampleMax); + padfX = (double *) CPLMalloc(sizeof(double) * 3 * nSampleMax); + padfY = padfX + nSampleMax; + padfZ = padfX + nSampleMax * 2; + +/* -------------------------------------------------------------------- */ +/* Setup sample points on a grid pattern throughout the area. */ +/* -------------------------------------------------------------------- */ + if( bUseGrid ) + { + double dfRatioY; + + for( dfRatioY = 0.0; + dfRatioY <= 1.0 + dfStepSize*0.5; + dfRatioY += dfStepSize ) + { + for( dfRatio = 0.0; + dfRatio <= 1.0 + dfStepSize*0.5; + dfRatio += dfStepSize ) + { + padfX[nSamplePoints] = dfRatio * nDstXSize + nDstXOff; + padfY[nSamplePoints] = dfRatioY * nDstYSize + nDstYOff; + padfZ[nSamplePoints++] = 0.0; + } + } + } + /* -------------------------------------------------------------------- */ + /* Setup sample points all around the edge of the input raster. */ + /* -------------------------------------------------------------------- */ + else + { + for( dfRatio = 0.0; dfRatio <= 1.0 + dfStepSize*0.5; dfRatio += dfStepSize ) + { + // Along top + padfX[nSamplePoints] = dfRatio * nDstXSize + nDstXOff; + padfY[nSamplePoints] = nDstYOff; + padfZ[nSamplePoints++] = 0.0; + + // Along bottom + padfX[nSamplePoints] = dfRatio * nDstXSize + nDstXOff; + padfY[nSamplePoints] = nDstYOff + nDstYSize; + padfZ[nSamplePoints++] = 0.0; + + // Along left + padfX[nSamplePoints] = nDstXOff; + padfY[nSamplePoints] = dfRatio * nDstYSize + nDstYOff; + padfZ[nSamplePoints++] = 0.0; + + // Along right + padfX[nSamplePoints] = nDstXSize + nDstXOff; + padfY[nSamplePoints] = dfRatio * nDstYSize + nDstYOff; + padfZ[nSamplePoints++] = 0.0; + } + } + + CPLAssert( nSamplePoints == nSampleMax ); + +/* -------------------------------------------------------------------- */ +/* Transform them to the output coordinate system. */ +/* -------------------------------------------------------------------- */ + if( !psOptions->pfnTransformer( psOptions->pTransformerArg, + TRUE, nSamplePoints, + padfX, padfY, padfZ, pabSuccess ) ) + { + CPLFree( padfX ); + CPLFree( pabSuccess ); + + CPLError( CE_Failure, CPLE_AppDefined, + "GDALWarperOperation::ComputeSourceWindow() failed because\n" + "the pfnTransformer failed." ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Collect the bounds, ignoring any failed points. */ +/* -------------------------------------------------------------------- */ + double dfMinXOut=0.0, dfMinYOut=0.0, dfMaxXOut=0.0, dfMaxYOut=0.0; + int bGotInitialPoint = FALSE; + int nFailedCount = 0, i; + + for( i = 0; i < nSamplePoints; i++ ) + { + if( !pabSuccess[i] ) + { + nFailedCount++; + continue; + } + + if( !bGotInitialPoint ) + { + bGotInitialPoint = TRUE; + dfMinXOut = dfMaxXOut = padfX[i]; + dfMinYOut = dfMaxYOut = padfY[i]; + } + else + { + dfMinXOut = MIN(dfMinXOut,padfX[i]); + dfMinYOut = MIN(dfMinYOut,padfY[i]); + dfMaxXOut = MAX(dfMaxXOut,padfX[i]); + dfMaxYOut = MAX(dfMaxYOut,padfY[i]); + } + } + + CPLFree( padfX ); + CPLFree( pabSuccess ); + +/* -------------------------------------------------------------------- */ +/* If we got any failures when not using a grid, we should */ +/* really go back and try again with the grid. Sorry for the */ +/* goto. */ +/* -------------------------------------------------------------------- */ + if( !bUseGrid && nFailedCount > 0 ) + { + bUseGrid = TRUE; + goto TryAgainWithGrid; + } + +/* -------------------------------------------------------------------- */ +/* If we get hardly any points (or none) transforming, we give */ +/* up. */ +/* -------------------------------------------------------------------- */ + if( nFailedCount > nSamplePoints - 5 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Too many points (%d out of %d) failed to transform,\n" + "unable to compute output bounds.", + nFailedCount, nSamplePoints ); + return CE_Failure; + } + + if( nFailedCount > 0 ) + CPLDebug( "GDAL", + "GDALWarpOperation::ComputeSourceWindow() %d out of %d points failed to transform.", + nFailedCount, nSamplePoints ); + +/* -------------------------------------------------------------------- */ +/* How much of a window around our source pixel might we need */ +/* to collect data from based on the resampling kernel? Even */ +/* if the requested central pixel falls off the source image, */ +/* we may need to collect data if some portion of the */ +/* resampling kernel could be on-image. */ +/* -------------------------------------------------------------------- */ + int nResWinSize = 0; + + if( psOptions->eResampleAlg == GRA_Bilinear ) + nResWinSize = 1; + + if( psOptions->eResampleAlg == GRA_Cubic ) + nResWinSize = 2; + +/* -------------------------------------------------------------------- */ +/* Allow addition of extra sample pixels to source window to */ +/* avoid missing pixels due to sampling error. In fact, */ +/* fallback to adding a bit to the window if any points failed */ +/* to transform. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( psOptions->papszWarpOptions, + "SOURCE_EXTRA" ) != NULL ) + { + nResWinSize += atoi( + CSLFetchNameValue( psOptions->papszWarpOptions, "SOURCE_EXTRA" )); + } + else if( nFailedCount > 0 ) + nResWinSize += 10; + +/* -------------------------------------------------------------------- */ +/* return bounds. */ +/* -------------------------------------------------------------------- */ + *pnSrcXOff = MAX(0,(int) floor( dfMinXOut ) - nResWinSize ); + *pnSrcYOff = MAX(0,(int) floor( dfMinYOut ) - nResWinSize ); + *pnSrcXSize = MIN( GDALGetRasterXSize(psOptions->hSrcDS) - *pnSrcXOff, + ((int) ceil( dfMaxXOut )) - *pnSrcXOff + nResWinSize ); + *pnSrcYSize = MIN( GDALGetRasterYSize(psOptions->hSrcDS) - *pnSrcYOff, + ((int) ceil( dfMaxYOut )) - *pnSrcYOff + nResWinSize ); + *pnSrcXSize = MAX(0,*pnSrcXSize); + *pnSrcYSize = MAX(0,*pnSrcYSize); + + return CE_None; +} + +/************************************************************************/ +/* ReportTiming() */ +/************************************************************************/ + +void GDALWarpOperation::ReportTiming( const char * pszMessage ) + +{ + if( !bReportTimings ) + return; + + unsigned long nNewTime = VSITime(NULL); + + if( pszMessage != NULL ) + { + CPLDebug( "WARP_TIMING", "%s: %ds", + pszMessage, nNewTime - nLastTimeReported ); + } + + nLastTimeReported = nNewTime; +} + diff --git a/Utilities/GDAL/alg/gvgcpfit.h b/Utilities/GDAL/alg/gvgcpfit.h new file mode 100644 index 0000000000..d289cc2712 --- /dev/null +++ b/Utilities/GDAL/alg/gvgcpfit.h @@ -0,0 +1,94 @@ +#ifndef _GVGCPFIT_H_INCLUDED +#define _GVGCPFIT_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_conv.h" +#include "cpl_error.h" + +#define EXTERNAL +#define LOCAL static + +#define SUCCESS 0 +#define ABORT -1 + + +/*------------------------ Start of file CURVEFIT.H -----------------------*/ + +/* +****************************************************************************** +* * +* CURVEFIT.H * +* ========= * +* * +* This file contains the function prototype for CURVEFIT.C. * +****************************************************************************** +*/ + + +#ifndef CURVEFIT_H +#define CURVEFIT_H + +/*- Function prototypes in CURVEFIT.C. -*/ + +EXTERNAL int svdfit(float x[], float y[], int ndata, + double a[], int ma, double **u, double **v, double w[], + double *chisq, void (*funcs)(double, double *, int)); + +EXTERNAL void svbksb(double **u, double w[], double **v, int m,int n, + double b[], double x[]); + +EXTERNAL void svdvar(double **v, int ma, double w[], double **cvm); + +EXTERNAL int svdcmp(double **a, int m, int n, double *w, double **v); + + +#endif + + +/*-------------------------- End of file CURVEFIT.H -----------------------*/ + + + + +/*----------------------------- FILE polyfit.h ----------------------------*/ +#ifndef __POLYFIT_H +#define __POLYFIT_H + +EXTERNAL int OneDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array ); + +EXTERNAL double OneDPolyEval( double *coeff, int order, double x ); + +EXTERNAL int TwoDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array, + double *y_array ); + +EXTERNAL double TwoDPolyEval( double *coeff, int order, double x, double y ); + +EXTERNAL int TwoDPolyGradFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *gradxy_array, + double *x_array, double *y_array ); + +EXTERNAL void TwoDPolyGradEval(double *fgradx, double *fgrady, + double *coeff, int order, double x, double y); + +EXTERNAL void GetPolyInX (double *xcoeffs, double *xycoeffs, int order, + double y); + +EXTERNAL void GetPolyInY(double *ycoeffs, double *xycoeffs, int order, + double x); + +EXTERNAL int ThreeDPolyFit( double *rms_err, double *coeffs_array, + int fit_order, int no_samples, double *f_array, double *x_array, + double *y_array, double *z_array ); + +EXTERNAL double ThreeDPolyEval( double *coeff, int order, double x, double y, double z ); + + + +#endif /* __POLYFIT_H */ + + +/*---------------------- End of FILE polyfit.h ----------------------------*/ + +#endif /* ndef _GVGCPFIT_INCLUDED */ diff --git a/Utilities/GDAL/alg/llrasterize.cpp b/Utilities/GDAL/alg/llrasterize.cpp new file mode 100644 index 0000000000..f5a78bc77e --- /dev/null +++ b/Utilities/GDAL/alg/llrasterize.cpp @@ -0,0 +1,252 @@ +/****************************************************************************** + * $Id: llrasterize.cpp,v 1.1 2005/10/28 17:46:08 fwarmerdam Exp $ + * + * Project: GDAL + * Purpose: Vector polygon rasterization code. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2000, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: llrasterize.cpp,v $ + * Revision 1.1 2005/10/28 17:46:08 fwarmerdam + * New + * + */ + +/* + * NOTE: This code was originally adapted from the gdImageFilledPolygon() + * function in libgd. + * + * http://www.boutell.com/gd/ + * + * It was later adapted for direct inclusion in GDAL and relicensed under + * the GDAL MIT/X license (pulled from the OpenEV distribution). + */ + +#include "gdal_alg.h" + +static int llCompareInt(const void *a, const void *b) +{ + return (*(const int *)a) - (*(const int *)b); +} + +/************************************************************************/ +/* dllImageFilledPolygon() */ +/* */ +/* Perform scanline conversion of the passed multi-ring */ +/* polygon. Note the polygon does not need to be explicitly */ +/* closed. The scanline function will be called with */ +/* horizontal scanline chunks which may not be entirely */ +/* contained within the valid raster area (in the X */ +/* direction). */ +/* */ +/* NEW: Nodes' coordinate are kept as double in order */ +/* to compute accurately the intersections with the lines */ +/* */ +/* Two methods for determining the border pixels: */ +/* */ +/* 1) method = 0 */ +/* Inherits algorithm from version above but with several bugs */ +/* fixed except for the cone facing down. */ +/* A pixel on which a line intersects a segment of a */ +/* polygon will always be considered as inside the shape. */ +/* Note that we only compute intersections with lines that */ +/* passes through the middle of a pixel (line coord = 0.5, */ +/* 1.5, 2.5, etc.) */ +/* */ +/* 2) method = 1: */ +/* A pixel is considered inside a polygon if its center */ +/* falls inside the polygon. This is somehow more robust unless */ +/* the nodes are placed in the center of the pixels in which */ +/* case, due to numerical inaccuracies, it's hard to predict */ +/* if the pixel will be considered inside or outside the shape. */ +/************************************************************************/ + +void GDALdllImageFilledPolygon(int nRasterXSize, int nRasterYSize, + int nPartCount, int *panPartSize, + double *padfX, double *padfY, + llScanlineFunc pfnScanlineFunc, void *pCBData ) +{ +/************************************************************************* +2nd Method (method=1): +===================== +No known bug +*************************************************************************/ + + int i; + int y; + int miny, maxy,minx,maxx; + double dminy, dmaxy; + double dx1, dy1; + double dx2, dy2; + double dy; + double intersect; + + + int ind1, ind2; + int ints, n, part; + int *polyInts, polyAllocated; + + + int horizontal_x1, horizontal_x2; + + + if (!nPartCount) { + return; + } + + n = 0; + for( part = 0; part < nPartCount; part++ ) + n += panPartSize[part]; + + polyInts = (int *) malloc(sizeof(int) * n); + polyAllocated = n; + + dminy = padfY[0]; + dmaxy = padfY[0]; + for (i=1; (i < n); i++) { + + if (padfY[i] < dminy) { + dminy = padfY[i]; + } + if (padfY[i] > dmaxy) { + dmaxy = padfY[i]; + } + } + miny = (int) dminy; + maxy = (int) dmaxy; + + + if( miny < 0 ) + miny = 0; + if( maxy >= nRasterYSize ) + maxy = nRasterYSize-1; + + + minx = 0; + maxx = nRasterXSize - 1; + + /* Fix in 1.3: count a vertex only once */ + for (y=miny; y <= maxy; y++) { + int partoffset = 0; + + dy = y +0.5; /* center height of line*/ + + + part = 0; + ints = 0; + + + /*Initialize polyInts, otherwise it can sometimes causes a seg fault */ + for (i=0; (i < n); i++) { + polyInts[i] = -1; + } + + + for (i=0; (i < n); i++) { + + + if( i == partoffset + panPartSize[part] ) { + partoffset += panPartSize[part]; + part++; + } + + if( i == partoffset ) { + ind1 = partoffset + panPartSize[part] - 1; + ind2 = partoffset; + } else { + ind1 = i-1; + ind2 = i; + } + + + dy1 = padfY[ind1]; + dy2 = padfY[ind2]; + + + if( (dy1 < dy && dy2 < dy) || (dy1 > dy && dy2 > dy) ) + continue; + + if (dy1 < dy2) { + dx1 = padfX[ind1]; + dx2 = padfX[ind2]; + } else if (dy1 > dy2) { + dy2 = padfY[ind1]; + dy1 = padfY[ind2]; + dx2 = padfX[ind1]; + dx1 = padfX[ind2]; + } else /* if (fabs(dy1-dy2)< 1.e-6) */ + { + + /*AE: DO NOT skip bottom horizontal segments + -Fill them separately- + They are not taken into account twice.*/ + if (padfX[ind1] > padfX[ind2]) + { + horizontal_x1 = (int) floor(padfX[ind2]+0.5); + horizontal_x2 = (int) floor(padfX[ind1]+0.5); + + if ( (horizontal_x1 > maxx) || (horizontal_x2 < minx) ) + continue; + + /*fill the horizontal segment (separately from the rest)*/ + pfnScanlineFunc( pCBData, y, horizontal_x1, horizontal_x2 - 1 ); + continue; + } + else /*skip top horizontal segments (they are already filled in the regular loop)*/ + continue; + + } + + if(( dy < dy2 ) && (dy >= dy1)) + { + + intersect = (dy-dy1) * (dx2-dx1) / (dy2-dy1) + dx1; + + polyInts[ints++] = (int) floor(intersect+0.5); + } + } + + /* + * It would be more efficient to do this inline, to avoid + * a function call for each comparison. + */ + qsort(polyInts, ints, sizeof(int), llCompareInt); + + + for (i=0; (i < (ints)); i+=2) { + + if( polyInts[i] <= maxx && polyInts[i+1] >= minx ) + { + pfnScanlineFunc( pCBData, y, polyInts[i], polyInts[i+1] - 1 ); + + } + + } + } + + free( polyInts ); +} + + + diff --git a/Utilities/GDAL/alg/makefile.vc b/Utilities/GDAL/alg/makefile.vc new file mode 100644 index 0000000000..1935532e2c --- /dev/null +++ b/Utilities/GDAL/alg/makefile.vc @@ -0,0 +1,23 @@ + +# +# Algorithms +# + +GDAL_ROOT = .. + +!INCLUDE ..\nmake.opt + +!IFDEF INCLUDE_OGR_FRMTS +OBJ_OGR_RELATED = contour.obj +!ENDIF + +OBJ = gdaldither.obj gdalmediancut.obj gdal_crs.obj gdaltransformer.obj \ + gdalsimplewarp.obj gdalwarper.obj gdalwarpkernel.obj \ + thinplatespline.obj gdal_tps.obj gdalrasterize.obj llrasterize.obj \ + gdalwarpoperation.obj gdalchecksum.obj gdal_rpc.obj $(OBJ_OGR_RELATED) + +default: $(OBJ) + +clean: + -del *.obj + diff --git a/Utilities/GDAL/alg/thinplatespline.cpp b/Utilities/GDAL/alg/thinplatespline.cpp new file mode 100644 index 0000000000..9614c3c95c --- /dev/null +++ b/Utilities/GDAL/alg/thinplatespline.cpp @@ -0,0 +1,588 @@ +/****************************************************************************** + * $Id: thinplatespline.cpp,v 1.5 2005/03/15 08:04:39 fwarmerdam Exp $ + * + * Project: GDAL Warp API + * Purpose: Implemenentation of 2D Thin Plate Spline transformer. + * Author: VIZRT Development Team. + * + * This code was provided by Gilad Ronnen (gro at visrt dot com) with + * permission to reuse under the following license. + * + ****************************************************************************** + * Copyright (c) 2004, VIZRT Inc. + * + * 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: thinplatespline.cpp,v $ + * Revision 1.5 2005/03/15 08:04:39 fwarmerdam + * Define FLT_MAX/MIN if not found elsewhere. + * + * Revision 1.4 2004/12/31 02:12:40 fwarmerdam + * Avoid warnings. + * + * Revision 1.3 2004/12/31 02:02:31 fwarmerdam + * added check of HAVE_FLOAT_H and HAVE_VALUES_H + * + * Revision 1.2 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.1 2004/11/14 04:16:44 fwarmerdam + * New + * + */ + +#include "thinplatespline.h" + +#ifdef HAVE_FLOAT_H +# include <float.h> +#elif defined(HAVE_VALUES_H) +# include <values.h> +#endif + +#ifndef FLT_MAX +# define FLT_MAX 1e+37 +# define FLT_MIN 1e-37 +#endif + +VizGeorefSpline2D* viz_xy2llz; +VizGeorefSpline2D* viz_llz2xy; + +///////////////////////////////////////////////////////////////////////////////////// +//// vizGeorefSpline2D +///////////////////////////////////////////////////////////////////////////////////// + +#define A(r,c) _AA[ _nof_eqs * (r) + (c) ] +#define Ainv(r,c) _Ainv[ _nof_eqs * (r) + (c) ] + + +#define VIZ_GEOREF_SPLINE_DEBUG 0 + +int matrixInvert( int N, double input[], double output[] ); + +void VizGeorefSpline2D::grow_points() + +{ + int new_max = _max_nof_points*2 + 2 + 3; + int i; + + if( _max_nof_points == 0 ) + { + x = (double *) VSIMalloc( sizeof(double) * new_max ); + y = (double *) VSIMalloc( sizeof(double) * new_max ); + u = (double *) VSIMalloc( sizeof(double) * new_max ); + unused = (int *) VSIMalloc( sizeof(int) * new_max ); + index = (int *) VSIMalloc( sizeof(int) * new_max ); + for( i = 0; i < VIZGEOREF_MAX_VARS; i++ ) + { + rhs[i] = (double *) VSIMalloc( sizeof(double) * new_max ); + coef[i] = (double *) VSIMalloc( sizeof(double) * new_max ); + } + } + else + { + x = (double *) VSIRealloc( x, sizeof(double) * new_max ); + y = (double *) VSIRealloc( y, sizeof(double) * new_max ); + u = (double *) VSIRealloc( u, sizeof(double) * new_max ); + unused = (int *) VSIRealloc( unused, sizeof(int) * new_max ); + index = (int *) VSIRealloc( index, sizeof(int) * new_max ); + for( i = 0; i < VIZGEOREF_MAX_VARS; i++ ) + { + rhs[i] = (double *) + VSIRealloc( rhs[i], sizeof(double) * new_max ); + coef[i] = (double *) + VSIRealloc( coef[i], sizeof(double) * new_max ); + } + } + + _max_nof_points = new_max - 3; +} + +int VizGeorefSpline2D::add_point( const double Px, const double Py, const double *Pvars ) +{ + type = VIZ_GEOREF_SPLINE_POINT_WAS_ADDED; + int i; + + if( _nof_points == _max_nof_points ) + grow_points(); + + i = _nof_points; + //A new point is added + x[i] = Px; + y[i] = Py; + for ( int j = 0; j < _nof_vars; j++ ) + rhs[j][i+3] = Pvars[j]; + _nof_points++; + return 1; +} + +bool VizGeorefSpline2D::change_point(int index, double Px, double Py, double* Pvars) +{ + if ( index < _nof_points ) + { + int i = index; + x[i] = Px; + y[i] = Py; + for ( int j = 0; j < _nof_vars; j++ ) + rhs[j][i+3] = Pvars[j]; + } + + return( true ); +} + +bool VizGeorefSpline2D::get_xy(int index, double& outX, double& outY) +{ + bool ok; + + if ( index < _nof_points ) + { + ok = true; + outX = x[index]; + outY = y[index]; + } + else + { + ok = false; + outX = outY = 0.0f; + } + + return(ok); +} + +int VizGeorefSpline2D::delete_point(const double Px, const double Py ) +{ + for ( int i = 0; i < _nof_points; i++ ) + { + if ( ( fabs(Px - x[i]) <= _tx ) && ( fabs(Py - y[i]) <= _ty ) ) + { + for ( int j = i; j < _nof_points - 1; j++ ) + { + x[j] = x[j+1]; + y[j] = y[j+1]; + for ( int k = 0; k < _nof_vars; k++ ) + rhs[k][j+3] = rhs[k][j+3+1]; + } + _nof_points--; + type = VIZ_GEOREF_SPLINE_POINT_WAS_DELETED; + return(1); + } + } + return(0); +} + +int VizGeorefSpline2D::solve(void) +{ + int r, c, v; + int p; + + // No points at all + if ( _nof_points < 1 ) + { + type = VIZ_GEOREF_SPLINE_ZERO_POINTS; + return(0); + } + + // Only one point + if ( _nof_points == 1 ) + { + type = VIZ_GEOREF_SPLINE_ONE_POINT; + return(1); + } + // Just 2 points - it is necessarily 1D case + if ( _nof_points == 2 ) + { + _dx = x[1] - x[0]; + _dy = y[1] - y[0]; + double fact = 1.0 / ( _dx * _dx + _dy * _dy ); + _dx *= fact; + _dy *= fact; + + type = VIZ_GEOREF_SPLINE_TWO_POINTS; + return(2); + } + + // More than 2 points - first we have to check if it is 1D or 2D case + + double xmax = FLT_MIN, xmin = FLT_MAX, ymax = FLT_MIN, ymin = FLT_MAX; + double delx, dely; + double xx, yy; + double sumx = 0.0f, sumy= 0.0f, sumx2 = 0.0f, sumy2 = 0.0f, sumxy = 0.0f; + double SSxx, SSyy, SSxy; + + for ( p = 0; p < _nof_points; p++ ) + { + xx = x[p]; + yy = y[p]; + + xmax = MAX( xmax, xx ); + xmin = MIN( xmin, xx ); + ymax = MAX( ymax, yy ); + ymin = MIN( ymin, yy ); + + sumx += xx; + sumx2 += xx * xx; + sumy += yy; + sumy2 += yy * yy; + sumxy += xx * yy; + } + delx = xmax - xmin; + dely = ymax - ymin; + + SSxx = sumx2 - sumx * sumx / _nof_points; + SSyy = sumy2 - sumy * sumy / _nof_points; + SSxy = sumxy - sumx * sumy / _nof_points; + + if ( delx < 0.001 * dely || dely < 0.001 * delx || + fabs ( SSxy * SSxy / ( SSxx * SSyy ) ) > 0.99 ) + { + int p1; + + type = VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL; + + _dx = _nof_points * sumx2 - sumx * sumx; + _dy = _nof_points * sumy2 - sumy * sumy; + double fact = 1.0 / sqrt( _dx * _dx + _dy * _dy ); + _dx *= fact; + _dy *= fact; + + for ( p = 0; p < _nof_points; p++ ) + { + double dxp = x[p] - x[0]; + double dyp = y[p] - y[0]; + u[p] = _dx * dxp + _dy * dyp; + unused[p] = 1; + } + + for ( p = 0; p < _nof_points; p++ ) + { + int min_index = -1; + double min_u = 0; + for ( p1 = 0; p1 < _nof_points; p1++ ) + { + if ( unused[p1] ) + { + if ( min_index < 0 || u[p1] < min_u ) + { + min_index = p1; + min_u = u[p1]; + } + } + } + index[p] = min_index; + unused[min_index] = 0; + } + + return(3); + } + + type = VIZ_GEOREF_SPLINE_FULL; + // Make the necessary memory allocations + if ( _AA ) + delete _AA; + if ( _Ainv ) + delete _Ainv; + + _nof_eqs = _nof_points + 3; + + _AA = ( double * )calloc( _nof_eqs * _nof_eqs, sizeof( double ) ); + _Ainv = ( double * )calloc( _nof_eqs * _nof_eqs, sizeof( double ) ); + + // Calc the values of the matrix A + for ( r = 0; r < 3; r++ ) + for ( c = 0; c < 3; c++ ) + A(r,c) = 0.0; + + for ( c = 0; c < _nof_points; c++ ) + { + A(0,c+3) = 1.0; + A(1,c+3) = x[c]; + A(2,c+3) = y[c]; + + A(c+3,0) = 1.0; + A(c+3,1) = x[c]; + A(c+3,2) = y[c]; + } + + for ( r = 0; r < _nof_points; r++ ) + for ( c = r; c < _nof_points; c++ ) + { + A(r+3,c+3) = base_func( x[r], y[r], x[c], y[c] ); + if ( r != c ) + A(c+3,r+3 ) = A(r+3,c+3); + } + +#if VIZ_GEOREF_SPLINE_DEBUG + + for ( r = 0; r < _nof_eqs; r++ ) + { + for ( c = 0; c < _nof_eqs; c++ ) + fprintf(stderr, "%f", A(r,c)); + fprintf(stderr, "\n"); + } + +#endif + + // Invert the matrix + int status = matrixInvert( _nof_eqs, _AA, _Ainv ); + + if ( !status ) + { + fprintf(stderr, " There is a problem to invert the interpolation matrix\n"); + return 0; + } + + // calc the coefs + for ( v = 0; v < _nof_vars; v++ ) + for ( r = 0; r < _nof_eqs; r++ ) + { + coef[v][r] = 0.0; + for ( c = 0; c < _nof_eqs; c++ ) + coef[v][r] += Ainv(r,c) * rhs[v][c]; + } + + return(4); +} + +int VizGeorefSpline2D::get_point( const double Px, const double Py, double *vars ) +{ + int v, r; + double tmp, Pu; + double fact; + int leftP=0, rightP=0, found = 0; + + switch ( type ) + { + case VIZ_GEOREF_SPLINE_ZERO_POINTS : + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = 0.0; + break; + case VIZ_GEOREF_SPLINE_ONE_POINT : + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = rhs[v][3]; + break; + case VIZ_GEOREF_SPLINE_TWO_POINTS : + fact = _dx * ( Px - x[0] ) + _dy * ( Py - y[0] ); + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = ( 1 - fact ) * rhs[v][3] + fact * rhs[v][4]; + break; + case VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL : + Pu = _dx * ( Px - x[0] ) + _dy * ( Py - y[0] ); + if ( Pu <= u[index[0]] ) + { + leftP = index[0]; + rightP = index[1]; + } + else if ( Pu >= u[index[_nof_points-1]] ) + { + leftP = index[_nof_points-2]; + rightP = index[_nof_points-1]; + } + else + { + for ( r = 1; !found && r < _nof_points; r++ ) + { + leftP = index[r-1]; + rightP = index[r]; + if ( Pu >= u[leftP] && Pu <= u[rightP] ) + found = 1; + } + } + + fact = ( Pu - u[leftP] ) / ( u[rightP] - u[leftP] ); + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = ( 1.0 - fact ) * rhs[v][leftP+3] + + fact * rhs[v][rightP+3]; + break; + case VIZ_GEOREF_SPLINE_FULL : + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = coef[v][0] + coef[v][1] * Px + coef[v][2] * Py; + + for ( r = 0; r < _nof_points; r++ ) + { + tmp = base_func( Px, Py, x[r], y[r] ); + for ( v= 0; v < _nof_vars; v++ ) + vars[v] += coef[v][r+3] * tmp; + } + break; + case VIZ_GEOREF_SPLINE_POINT_WAS_ADDED : + fprintf(stderr, " A point was added after the last solve\n"); + fprintf(stderr, " NO interpolation - return values are zero\n"); + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = 0.0; + return(0); + break; + case VIZ_GEOREF_SPLINE_POINT_WAS_DELETED : + fprintf(stderr, " A point was deleted after the last solve\n"); + fprintf(stderr, " NO interpolation - return values are zero\n"); + for ( v = 0; v < _nof_vars; v++ ) + vars[v] = 0.0; + return(0); + break; + default : + return(0); + break; + } + return(1); +} + +double VizGeorefSpline2D::base_func( const double x1, const double y1, + const double x2, const double y2 ) +{ + if ( ( x1 == x2 ) && (y1 == y2 ) ) + return 0.0; + + double dist = ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ); + + return dist * log( dist ); +} + +int matrixInvert( int N, double input[], double output[] ) +{ + // Receives an array of dimension NxN as input. This is passed as a one- + // dimensional array of N-squared size. It produces the inverse of the + // input matrix, returned as output, also of size N-squared. The Gauss- + // Jordan Elimination method is used. (Adapted from a BASIC routine in + // "Basic Scientific Subroutines Vol. 1", courtesy of Scott Edwards.) + + // Array elements 0...N-1 are for the first row, N...2N-1 are for the + // second row, etc. + + // We need to have a temporary array of size N x 2N. We'll refer to the + // "left" and "right" halves of this array. + + int row, col; + +#if 0 + fprintf(stderr, "Matrix Inversion input matrix (N=%d)\n", N); + for ( row=0; row<N; row++ ) + { + for ( col=0; col<N; col++ ) + { + fprintf(stderr, "%5.2f ", input[row*N + col ] ); + } + fprintf(stderr, "\n"); + } +#endif + + int tempSize = 2 * N * N; + double* temp = (double*) new double[ tempSize ]; + double ftemp; + + if (temp == 0) { + + fprintf(stderr, "matrixInvert(): ERROR - memory allocation failed.\n"); + return false; + } + + // First create a double-width matrix with the input array on the left + // and the identity matrix on the right. + + for ( row=0; row<N; row++ ) + { + for ( col=0; col<N; col++ ) + { + // Our index into the temp array is X2 because it's twice as wide + // as the input matrix. + + temp[ 2*row*N + col ] = input[ row*N+col ]; // left = input matrix + temp[ 2*row*N + col + N ] = 0.0f; // right = 0 + } + temp[ 2*row*N + row + N ] = 1.0f; // 1 on the diagonal of RHS + } + + // Now perform row-oriented operations to convert the left hand side + // of temp to the identity matrix. The inverse of input will then be + // on the right. + + int max; + int k=0; + for (k = 0; k < N; k++) + { + if (k+1 < N) // if not on the last row + { + max = k; + for (row = k+1; row < N; row++) // find the maximum element + { + if (fabs( temp[row*2*N + k] ) > fabs( temp[max*2*N + k] )) + { + max = row; + } + } + + if (max != k) // swap all the elements in the two rows + { + for (col=k; col<2*N; col++) + { + ftemp = temp[k*2*N + col]; + temp[k*2*N + col] = temp[max*2*N + col]; + temp[max*2*N + col] = ftemp; + } + } + } + + ftemp = temp[ k*2*N + k ]; + if ( ftemp == 0.0f ) // matrix cannot be inverted + { + delete temp; + return false; + } + + for ( col=k; col<2*N; col++ ) + { + temp[ k*2*N + col ] /= ftemp; + } + + for ( row=0; row<N; row++ ) + { + if ( row != k ) + { + ftemp = temp[ row*2*N + k ]; + for ( col=k; col<2*N; col++ ) + { + temp[ row*2*N + col ] -= ftemp * temp[ k*2*N + col ]; + } + } + } + } + + // Retrieve inverse from the right side of temp + + for (row = 0; row < N; row++) + { + for (col = 0; col < N; col++) + { + output[row*N + col] = temp[row*2*N + col + N ]; + } + } + +#if 0 + fprintf(stderr, "Matrix Inversion result matrix:\n"); + for ( row=0; row<N; row++ ) + { + for ( col=0; col<N; col++ ) + { + fprintf(stderr, "%5.2f ", output[row*N + col ] ); + } + fprintf(stderr, "\n"); + } +#endif + + delete [] temp; // free memory + return true; +} diff --git a/Utilities/GDAL/alg/thinplatespline.h b/Utilities/GDAL/alg/thinplatespline.h new file mode 100644 index 0000000000..e33ee962c6 --- /dev/null +++ b/Utilities/GDAL/alg/thinplatespline.h @@ -0,0 +1,190 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Warp API + * Purpose: Declarations for 2D Thin Plate Spline transformer. + * Author: VIZRT Development Team. + * + * This code was provided by Gilad Ronnen (gro at visrt dot com) with + * permission to reuse under the following license. + * + ****************************************************************************** + * Copyright (c) 2004, VIZRT Inc. + * + * 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: thinplatespline.h,v $ + * Revision 1.2 2004/12/26 16:12:21 fwarmerdam + * thin plate spline support now implemented + * + * Revision 1.1 2004/11/14 04:16:44 fwarmerdam + * New + * + */ + +#include "gdal_alg.h" +#include "cpl_conv.h" + +typedef enum +{ + VIZ_GEOREF_SPLINE_ZERO_POINTS, + VIZ_GEOREF_SPLINE_ONE_POINT, + VIZ_GEOREF_SPLINE_TWO_POINTS, + VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL, + VIZ_GEOREF_SPLINE_FULL, + + VIZ_GEOREF_SPLINE_POINT_WAS_ADDED, + VIZ_GEOREF_SPLINE_POINT_WAS_DELETED + +} vizGeorefInterType; + +//#define VIZ_GEOREF_SPLINE_MAX_POINTS 40 +#define VIZGEOREF_MAX_VARS 2 + +class VizGeorefSpline2D +{ + public: + + VizGeorefSpline2D(int nof_vars = 1){ + x = y = u = NULL; + unused = index = NULL; + for( int i = 0; i < nof_vars; i++ ) + { + rhs[i] = NULL; + coef[i] = NULL; + } + + _tx = _ty = 0.0; + _ta = 10.0; + _nof_points = 0; + _nof_vars = nof_vars; + _max_nof_points = 0; + _AA = NULL; + _Ainv = NULL; + grow_points(); + for ( int v = 0; v < _nof_vars; v++ ) + for ( int i = 0; i < 3; i++ ) + rhs[i][v] = 0.0; + type = VIZ_GEOREF_SPLINE_ZERO_POINTS; + } + + ~VizGeorefSpline2D(){ + if ( _AA ) + delete _AA; + if ( _Ainv ) + delete _Ainv; + + CPLFree( x ); + CPLFree( y ); + CPLFree( u ); + CPLFree( unused ); + CPLFree( index ); + for( int i = 0; i < _nof_vars; i++ ) + { + CPLFree( rhs[i] ); + CPLFree( coef[i] ); + } + } + + int get_nof_points(){ + return _nof_points; + } + + void set_toler( double tx, double ty ){ + _tx = tx; + _ty = ty; + } + + void get_toler( double& tx, double& ty) { + tx = _tx; + ty = _ty; + } + + vizGeorefInterType get_interpolation_type ( ){ + return type; + } + + void dump_data_points() + { + for ( int i = 0; i < _nof_points; i++ ) + { + fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]); + for ( int v = 0; v < _nof_vars; v++ ) + fprintf(stderr, "%f ", rhs[i+3][v]); + fprintf(stderr, "\n"); + } + } + int delete_list() + { + _nof_points = 0; + type = VIZ_GEOREF_SPLINE_ZERO_POINTS; + if ( _AA ) + { + delete _AA; + _AA = NULL; + } + if ( _Ainv ) + { + delete _Ainv; + _Ainv = NULL; + } + return _nof_points; + } + + void grow_points(); + int add_point( const double Px, const double Py, const double *Pvars ); + int delete_point(const double Px, const double Py ); + int get_point( const double Px, const double Py, double *Pvars ); + bool get_xy(int index, double& x, double& y); + bool change_point(int index, double x, double y, double* Pvars); + void reset(void) { _nof_points = 0; } + int solve(void); + + private: + double base_func( const double x1, const double y1, + const double x2, const double y2 ); + + vizGeorefInterType type; + + int _nof_vars; + int _nof_points; + int _max_nof_points; + int _nof_eqs; + + double _tx, _ty; + double _ta; + double _dx, _dy; + + double *x; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; + double *y; // [VIZ_GEOREF_SPLINE_MAX_POINTS+3]; + +// double rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; +// double coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS]; + double *rhs[VIZGEOREF_MAX_VARS]; + double *coef[VIZGEOREF_MAX_VARS]; + + double *u; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + int *unused; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + int *index; // [VIZ_GEOREF_SPLINE_MAX_POINTS]; + + double *_AA, *_Ainv; +}; + + diff --git a/Utilities/GDAL/bridge/.cvsignore b/Utilities/GDAL/bridge/.cvsignore new file mode 100644 index 0000000000..177f4f3525 --- /dev/null +++ b/Utilities/GDAL/bridge/.cvsignore @@ -0,0 +1 @@ +bridge_test diff --git a/Utilities/GDAL/bridge/Makefile b/Utilities/GDAL/bridge/Makefile new file mode 100644 index 0000000000..cf3247232c --- /dev/null +++ b/Utilities/GDAL/bridge/Makefile @@ -0,0 +1,11 @@ + +bridge_test: bridge_test.cpp gbgetsymbol.cpp gdalbridge.cpp + $(CXX) -Wall -g bridge_test.cpp gbgetsymbol.cpp gdalbridge.cpp -ldl \ + -o bridge_test + +clean: + rm *.o bridge_test + + + + diff --git a/Utilities/GDAL/bridge/bridge_test.cpp b/Utilities/GDAL/bridge/bridge_test.cpp new file mode 100644 index 0000000000..2152f293ac --- /dev/null +++ b/Utilities/GDAL/bridge/bridge_test.cpp @@ -0,0 +1,392 @@ +/****************************************************************************** + * $Id: bridge_test.cpp,v 1.5 2003/09/26 02:18:41 warmerda Exp $ + * + * Project: GDAL Bridge + * Purpose: Simple mainline for testing bridge. This is a slightly modified + * apps/gdalinfo.c. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: bridge_test.cpp,v $ + * Revision 1.5 2003/09/26 02:18:41 warmerda + * Added missing include files + * + * Revision 1.4 2001/11/18 00:48:24 warmerda + * substantial upgrade + * + * Revision 1.3 2001/09/06 14:03:21 warmerda + * upgrade bridge error reporting + * + * Revision 1.2 2000/08/25 20:03:40 warmerda + * added more entry points + * + * Revision 1.1 1999/04/21 23:01:31 warmerda + * New + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include "gdalbridge.h" + +static int +GDALInfoReportCorner( GDALDatasetH hDataset, + const char * corner_name, + double x, double y ); + +int main( int argc, char ** argv ) + +{ + GDALDatasetH hDataset; + GDALRasterBandH hBand; + int i, iBand; + double adfGeoTransform[6]; + GDALDriverH hDriver; + char **papszMetadata; + int bComputeMinMax = FALSE; + + if( !GDALBridgeInitialize( "..", stderr ) ) + { + fprintf( stderr, "Unable to intiailize GDAL bridge.\n" ); + exit( 10 ); + } + + if( argc > 1 && strcmp(argv[1],"-mm") == 0 ) + { + bComputeMinMax = TRUE; + argv++; + } + + GDALAllRegister(); + + hDataset = GDALOpen( argv[1], GA_ReadOnly ); + + if( hDataset == NULL ) + { + fprintf( stderr, + "GDALOpen failed - %d\n%s\n", + CPLGetLastErrorNo(), CPLGetLastErrorMsg() ); + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* Report general info. */ +/* -------------------------------------------------------------------- */ + hDriver = GDALGetDatasetDriver( hDataset ); + printf( "Driver: %s/%s\n", + GDALGetDriverShortName( hDriver ), + GDALGetDriverLongName( hDriver ) ); + + printf( "Size is %d, %d\n", + GDALGetRasterXSize( hDataset ), + GDALGetRasterYSize( hDataset ) ); + +/* -------------------------------------------------------------------- */ +/* Report projection. */ +/* -------------------------------------------------------------------- */ + if( GDALGetProjectionRef( hDataset ) != NULL ) + { + OGRSpatialReferenceH hSRS; + char *pszProjection; + + pszProjection = (char *) GDALGetProjectionRef( hDataset ); + + hSRS = OSRNewSpatialReference(NULL); + if( OSRImportFromWkt( hSRS, &pszProjection ) == CE_None ) + { + char *pszPrettyWkt = NULL; + + OSRExportToPrettyWkt( hSRS, &pszPrettyWkt, FALSE ); + printf( "Coordinate System is:\n%s\n", pszPrettyWkt ); + } + else + printf( "Coordinate System is `%s'\n", + GDALGetProjectionRef( hDataset ) ); + + OSRDestroySpatialReference( hSRS ); + } + +/* -------------------------------------------------------------------- */ +/* Report Geotransform. */ +/* -------------------------------------------------------------------- */ + if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None ) + { + printf( "Origin = (%.6f,%.6f)\n", + adfGeoTransform[0], adfGeoTransform[3] ); + + printf( "Pixel Size = (%.6f,%.6f)\n", + adfGeoTransform[1], adfGeoTransform[5] ); + } + +/* -------------------------------------------------------------------- */ +/* Report GCPs. */ +/* -------------------------------------------------------------------- */ + if( GDALGetGCPCount( hDataset ) > 0 ) + { + printf( "GCP Projection = %s\n", GDALGetGCPProjection(hDataset) ); + for( i = 0; i < GDALGetGCPCount(hDataset); i++ ) + { + const GDAL_GCP *psGCP; + + psGCP = GDALGetGCPs( hDataset ) + i; + + printf( "GCP[%3d]: Id=%s, Info=%s\n" + " (%g,%g) -> (%g,%g,%g)\n", + i, psGCP->pszId, psGCP->pszInfo, + psGCP->dfGCPPixel, psGCP->dfGCPLine, + psGCP->dfGCPX, psGCP->dfGCPY, psGCP->dfGCPZ ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report metadata. */ +/* -------------------------------------------------------------------- */ + papszMetadata = GDALGetMetadata( hDataset, NULL ); + if( papszMetadata != NULL ) + { + printf( "Metadata:\n" ); + for( i = 0; papszMetadata[i] != NULL; i++ ) + { + printf( " %s\n", papszMetadata[i] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report subdatasets. */ +/* -------------------------------------------------------------------- */ + papszMetadata = GDALGetMetadata( hDataset, "SUBDATASETS" ); + if( papszMetadata != NULL ) + { + printf( "Subdatasets:\n" ); + for( i = 0; papszMetadata[i] != NULL; i++ ) + { + printf( " %s\n", papszMetadata[i] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Report corners. */ +/* -------------------------------------------------------------------- */ + printf( "Corner Coordinates:\n" ); + GDALInfoReportCorner( hDataset, "Upper Left", + 0.0, 0.0 ); + GDALInfoReportCorner( hDataset, "Lower Left", + 0.0, GDALGetRasterYSize(hDataset)); + GDALInfoReportCorner( hDataset, "Upper Right", + GDALGetRasterXSize(hDataset), 0.0 ); + GDALInfoReportCorner( hDataset, "Lower Right", + GDALGetRasterXSize(hDataset), + GDALGetRasterYSize(hDataset) ); + GDALInfoReportCorner( hDataset, "Center", + GDALGetRasterXSize(hDataset)/2.0, + GDALGetRasterYSize(hDataset)/2.0 ); + +/* ==================================================================== */ +/* Loop over bands. */ +/* ==================================================================== */ + for( iBand = 0; iBand < GDALGetRasterCount( hDataset ); iBand++ ) + { + double dfMin, dfMax, adfCMinMax[2], dfNoData; + int bGotMin, bGotMax, bGotNodata; + int nBlockXSize, nBlockYSize; + + hBand = GDALGetRasterBand( hDataset, iBand+1 ); + GDALGetBlockSize( hBand, &nBlockXSize, &nBlockYSize ); + printf( "Band %d Block=%dx%d Type=%d, ColorInterp=%d\n", iBand+1, + nBlockXSize, nBlockYSize, + GDALGetRasterDataType(hBand), + GDALGetRasterColorInterpretation(hBand) ); + + dfMin = GDALGetRasterMinimum( hBand, &bGotMin ); + dfMax = GDALGetRasterMaximum( hBand, &bGotMax ); + printf( " Min=%.3f/%d, Max=%.3f/%d", dfMin, bGotMin, dfMax, bGotMax); + + if( bComputeMinMax ) + { + GDALComputeRasterMinMax( hBand, TRUE, adfCMinMax ); + printf( ", Computed Min/Max=%.3f,%.3f", + adfCMinMax[0], adfCMinMax[1] ); + } + printf( "\n" ); + + dfNoData = GDALGetRasterNoDataValue( hBand, &bGotNodata ); + if( bGotNodata ) + { + printf( " NoData Value=%g\n", dfNoData ); + } + + if( GDALGetOverviewCount(hBand) > 0 ) + { + int iOverview; + + printf( " Overviews: " ); + for( iOverview = 0; + iOverview < GDALGetOverviewCount(hBand); + iOverview++ ) + { + GDALRasterBandH hOverview; + + if( iOverview != 0 ) + printf( ", " ); + + hOverview = GDALGetOverview( hBand, iOverview ); + printf( "%dx%d", + GDALGetRasterBandXSize( hOverview ), + GDALGetRasterBandYSize( hOverview ) ); + } + printf( "\n" ); + } + + papszMetadata = GDALGetMetadata( hBand, NULL ); + if( papszMetadata != NULL ) + { + printf( "Metadata:\n" ); + for( i = 0; papszMetadata[i] != NULL; i++ ) + { + printf( " %s\n", papszMetadata[i] ); + } + } + + if( GDALGetRasterColorInterpretation(hBand) == GCI_PaletteIndex ) + { + GDALColorTableH hTable; + int i; + + hTable = GDALGetRasterColorTable( hBand ); + printf( " Color Table (%s with %d entries)\n", + GDALGetPaletteInterpretationName( + GDALGetPaletteInterpretation( hTable )), + GDALGetColorEntryCount( hTable ) ); + + for( i = 0; i < GDALGetColorEntryCount( hTable ); i++ ) + { + GDALColorEntry sEntry; + + GDALGetColorEntryAsRGB( hTable, i, &sEntry ); + printf( " %3d: %d,%d,%d,%d\n", + i, + sEntry.c1, + sEntry.c2, + sEntry.c3, + sEntry.c4 ); + } + } + } + + GDALClose( hDataset ); + + exit( 0 ); +} + +/************************************************************************/ +/* GDALInfoReportCorner() */ +/************************************************************************/ + +static int +GDALInfoReportCorner( GDALDatasetH hDataset, + const char * corner_name, + double x, double y ) + +{ + double dfGeoX, dfGeoY; + const char *pszProjection; + double adfGeoTransform[6]; + OGRCoordinateTransformationH hTransform = NULL; + + printf( "%-11s ", corner_name ); + +/* -------------------------------------------------------------------- */ +/* Transform the point into georeferenced coordinates. */ +/* -------------------------------------------------------------------- */ + if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None ) + { + pszProjection = GDALGetProjectionRef(hDataset); + + dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x + + adfGeoTransform[2] * y; + dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x + + adfGeoTransform[5] * y; + } + + else + { + printf( "(%7.1f,%7.1f)\n", x, y ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Report the georeferenced coordinates. */ +/* -------------------------------------------------------------------- */ + if( fabs(dfGeoX) < 181 && fabs(dfGeoY) < 91 ) + { + printf( "(%12.7f,%12.7f) ", dfGeoX, dfGeoY ); + + } + else + { + printf( "(%12.3f,%12.3f) ", dfGeoX, dfGeoY ); + } + +/* -------------------------------------------------------------------- */ +/* Setup transformation to lat/long. */ +/* -------------------------------------------------------------------- */ + if( pszProjection != NULL && strlen(pszProjection) > 0 ) + { + OGRSpatialReferenceH hProj, hLatLong = NULL; + + hProj = OSRNewSpatialReference( pszProjection ); + if( hProj != NULL ) + hLatLong = OSRCloneGeogCS( hProj ); + + if( hLatLong != NULL ) + { + hTransform = OCTNewCoordinateTransformation( hProj, hLatLong ); + OSRDestroySpatialReference( hLatLong ); + } + + if( hProj != NULL ) + OSRDestroySpatialReference( hProj ); + } + +/* -------------------------------------------------------------------- */ +/* Transform to latlong and report. */ +/* -------------------------------------------------------------------- */ + if( hTransform != NULL + && OCTTransform(hTransform,1,&dfGeoX,&dfGeoY,NULL) ) + { + + printf( "(%s,", GDALDecToDMS( dfGeoX, "Long", 2 ) ); + printf( "%s)", GDALDecToDMS( dfGeoY, "Lat", 2 ) ); + } + + if( hTransform != NULL ) + OCTDestroyCoordinateTransformation( hTransform ); + + printf( "\n" ); + + return TRUE; +} + diff --git a/Utilities/GDAL/bridge/gbgetsymbol.cpp b/Utilities/GDAL/bridge/gbgetsymbol.cpp new file mode 100644 index 0000000000..2c81f4b8e9 --- /dev/null +++ b/Utilities/GDAL/bridge/gbgetsymbol.cpp @@ -0,0 +1,138 @@ +/****************************************************************************** + * $Id: gbgetsymbol.cpp,v 1.3 2001/09/06 14:03:21 warmerda Exp $ + * + * Project: GDAL Bridge + * Purpose: Fetch a function pointer from a shared library / DLL. + * Author: Frank Warmerdam, warmerda@home.com + * + * Adapted from cplgetsymbol.cpp. + * + ****************************************************************************** + * Copyright (c) 1999, 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: gbgetsymbol.cpp,v $ + * Revision 1.3 2001/09/06 14:03:21 warmerda + * upgrade bridge error reporting + * + * Revision 1.2 2000/09/27 13:22:07 warmerda + * also allow for unix in check + * + * Revision 1.1 1999/04/21 23:01:31 warmerda + * New + * + */ + +#include <stdio.h> +#include "gdalbridge.h" + +/* ==================================================================== */ +/* Unix Implementation */ +/* ==================================================================== */ +#if defined(__unix__) || defined(unix) + +#include <dlfcn.h> + +/************************************************************************/ +/* GBGetSymbol() */ +/* */ +/* Note that this function doesn't: */ +/* o prevent the reference count on the library from going up */ +/* for every request, or given any opportunity to unload */ +/* the library. */ +/* o Attempt to look for the library in non-standard */ +/* locations. */ +/* o Attempt to try variations on the symbol name, like */ +/* pre-prending or post-pending an underscore. */ +/************************************************************************/ + +void *GBGetSymbol( const char * pszLibrary, const char * pszSymbolName ) + +{ + void *pLibrary; + void *pSymbol; + + pLibrary = dlopen(pszLibrary, RTLD_LAZY); + if( pLibrary == NULL ) + { + return NULL; + } + + pSymbol = dlsym( pLibrary, pszSymbolName ); + + if( pSymbol == NULL ) + { + fprintf( stderr, "GBGetSymbol(): %s\n", dlerror() ); + return NULL; + } + + return( pSymbol ); +} + +#endif /* def __unix__ && defined(HAVE_DLFCN_H) */ + +/* ==================================================================== */ +/* Windows Implementation */ +/* ==================================================================== */ +#ifdef _WIN32 + +#include <windows.h> + +/************************************************************************/ +/* GBGetSymbol() */ +/* */ +/* Note that this function doesn't: */ +/* o prevent the reference count on the library from going up */ +/* for every request, or given any opportunity to unload */ +/* the library. */ +/* o Attempt to look for the library in non-standard */ +/* locations. */ +/* o Attempt to try variations on the symbol name, like */ +/* pre-prending or post-pending an underscore. */ +/************************************************************************/ + +void *GBGetSymbol( const char * pszLibrary, const char * pszSymbolName ) + +{ + void *pLibrary; + void *pSymbol; + + pLibrary = LoadLibrary(pszLibrary); + if( pLibrary == NULL ) + { + return NULL; + } + + pSymbol = GetProcAddress( (HINSTANCE) pLibrary, pszSymbolName ); + + if( pSymbol == NULL ) + { + fprintf( stderr, + "GBGetSymbol(): Can't find requested entry point: %s\n", + pszSymbolName ); + return NULL; + } + + return( pSymbol ); +} + +#endif /* def _WIN32 */ + diff --git a/Utilities/GDAL/bridge/gdalbridge.cpp b/Utilities/GDAL/bridge/gdalbridge.cpp new file mode 100644 index 0000000000..c43e981164 --- /dev/null +++ b/Utilities/GDAL/bridge/gdalbridge.cpp @@ -0,0 +1,555 @@ +/****************************************************************************** + * $Id: gdalbridge.cpp,v 1.15 2003/07/17 03:33:15 sperkins Exp $ + * + * Project: GDAL Bridge + * Purpose: Implementation of GDALBridgeInitialize() + * Author: Frank Warmerdam, warmerda@home.com + * + * Adapted from cplgetsymbol.cpp. + * + ****************************************************************************** + * Copyright (c) 1999, 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: gdalbridge.cpp,v $ + * Revision 1.15 2003/07/17 03:33:15 sperkins + * added GDALFILLRaster() + * + * Revision 1.14 2001/11/18 00:48:24 warmerda + * substantial upgrade + * + * Revision 1.13 2001/09/06 14:03:21 warmerda + * upgrade bridge error reporting + * + * Revision 1.10 2000/09/26 15:20:32 warmerda + * added GDALGetRasterBand{X,Y}Size + * + * Revision 1.9 2000/09/01 19:12:09 warmerda + * fixed const mismatch + * + * Revision 1.8 2000/08/28 20:16:14 warmerda + * added lots of OGRSpatialReference stuff + * + * Revision 1.7 2000/08/25 20:03:40 warmerda + * added more entry points + * + * Revision 1.6 1999/09/17 03:18:08 warmerda + * change to search for a list of GDAL .so/.dll files + * + * Revision 1.5 1999/05/07 14:08:49 warmerda + * change .so name + * + * Revision 1.4 1999/04/22 13:35:11 warmerda + * Fixed copyright header. + * + */ + +/* ==================================================================== */ +/* We #define GDAL_ENTRY to nothing so that when the include */ +/* file is include the real definition of the function pointer */ +/* variables will occur in this files object file. */ +/* ==================================================================== */ + +#define GDAL_ENTRY +#define GDAL_NULL = NULL + +#include "gdalbridge.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef _WIN32 +#define PATH_SEP '\\' +static const char *papszSOFilenames[] = { + "gdal11.dll" + ,"gdal.1.0.dll" + , NULL }; +#else +#define PATH_SEP '/' +static const char *papszSOFilenames[] = { + "libgdal.1.1.so" + ,"gdal.1.0.so" + ,"gdal.so.1.0" + ,"libgdal.so.1" + , NULL }; +#endif + +#define MAX_SYMBOL 1024 + +/************************************************************************/ +/* GBGetSymbolCheck() */ +/* */ +/* Get a symbol, and on error add the missing entry point to a */ +/* list of missing entry points. */ +/************************************************************************/ + +static void *GBGetSymbolCheck( const char *pszLibrary, + const char *pszSymbolName, + char **papszErrorList ) + +{ + void *pReturn; + + pReturn = GBGetSymbol( pszLibrary, pszSymbolName ); + + if( pReturn == NULL && papszErrorList != NULL ) + { + int i; + + for( i = 0; papszErrorList[i] != NULL; i++ ) {} + + if( i < MAX_SYMBOL-1 ) + { + papszErrorList[i] = strdup( pszSymbolName ); + papszErrorList[i+1] = NULL; + } + } + + return pReturn; +} + +/************************************************************************/ +/* GDALBridgeInitialize() */ +/************************************************************************/ + +int GDALBridgeInitialize( const char * pszTargetDir, FILE *fpReportFailure ) + +{ + char szPath[2048]; + void *pfnTest = NULL; + int iSOFile; + char *apszFailed[MAX_SYMBOL]; + +/* -------------------------------------------------------------------- */ +/* Do we want to force reporting on? */ +/* -------------------------------------------------------------------- */ + if( fpReportFailure == NULL + && (getenv("CPL_DEBUG") != NULL || getenv("GB_DEBUG") != NULL) ) + { + fpReportFailure = stderr; + } + +/* -------------------------------------------------------------------- */ +/* The first phase is to try and find the shared library. */ +/* -------------------------------------------------------------------- */ + for( iSOFile = 0; + papszSOFilenames[iSOFile] != NULL && pfnTest == NULL; + iSOFile++ ) + { + if( pszTargetDir != NULL ) + { + sprintf( szPath, "%s%c%s", + pszTargetDir, PATH_SEP, papszSOFilenames[iSOFile] ); + pfnTest = GBGetSymbol( szPath, "GDALOpen" ); + } + + if( pfnTest == NULL && getenv( "GDAL_HOME" ) != NULL ) + { + sprintf( szPath, + "%s%c%s", getenv("GDAL_HOME"), + PATH_SEP, papszSOFilenames[iSOFile] ); + pfnTest = GBGetSymbol( szPath, "GDALOpen" ); + } + + if( pfnTest == NULL ) + { + sprintf( szPath, papszSOFilenames[iSOFile] ); + pfnTest = GBGetSymbol( szPath, "GDALOpen" ); + } + } + +/* -------------------------------------------------------------------- */ +/* Did we fail to even find the DLL/.so? */ +/* -------------------------------------------------------------------- */ + if( pfnTest == NULL ) + { + + if( fpReportFailure == NULL ) + return FALSE; + + + fprintf( fpReportFailure, + "GBBridgeInitialize() failed to find an suitable GDAL .DLL/.so file.\n" ); + fprintf( fpReportFailure, + "The following filenames were searched for:\n" ); + + for( iSOFile = 0; papszSOFilenames[iSOFile] != NULL; iSOFile++ ) + fprintf( fpReportFailure, " o %s\n", papszSOFilenames[iSOFile] ); + + fprintf( fpReportFailure, "\n" ); + fprintf( fpReportFailure, "The following locations were searched:\n" ); + + if( pszTargetDir != NULL ) + fprintf( fpReportFailure, " o %s\n", pszTargetDir ); + + if( getenv( "GDAL_HOME" ) != NULL ) + fprintf( fpReportFailure, " o %s\n", getenv( "GDAL_HOME" ) ); + + fprintf( fpReportFailure, " o System default locations.\n" ); + fprintf( fpReportFailure, "\n" ); + + fprintf( fpReportFailure, "\n" ); +#ifdef __unix__ + if( getenv("LD_LIBRARY_PATH") != NULL ) + { + fprintf( fpReportFailure, + "System default locations may be influenced by:\n" ); + fprintf( fpReportFailure, + "LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH") ); + } +#else + if( getenv("PATH") != NULL ) + { + fprintf( fpReportFailure, + "System default locations may be influenced by:\n" ); + fprintf( fpReportFailure, + "PATH = %s\n", getenv("PATH") ); + } +#endif + + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Start loading functions. */ +/* -------------------------------------------------------------------- */ + apszFailed[0] = NULL; + + GDALGetDataTypeSize = (int (*)(GDALDataType)) + GBGetSymbolCheck( szPath, "GDALGetDataTypeSize", apszFailed ); + + GDALAllRegister = (void (*)(void)) + GBGetSymbolCheck( szPath, "GDALAllRegister", apszFailed ); + + GDALCreate = (GDALDatasetH (*)(GDALDriverH, const char *, int, int, int, + GDALDataType, char ** )) + GBGetSymbolCheck( szPath, "GDALCreate", apszFailed ); + + GDALOpen = (GDALDatasetH (*)(const char *, GDALAccess)) + GBGetSymbolCheck( szPath, "GDALOpen", apszFailed ); + + GDALGetDriverByName = (GDALDriverH (*)(const char *)) + GBGetSymbolCheck( szPath, "GDALGetDriverByName", apszFailed ); + + GDALGetDriverShortName = (const char *(*)(GDALDriverH)) + GBGetSymbolCheck( szPath, "GDALGetDriverShortName", apszFailed ); + + GDALGetDriverLongName = (const char *(*)(GDALDriverH)) + GBGetSymbolCheck( szPath, "GDALGetDriverLongName", apszFailed ); + + GDALGetDatasetDriver = (GDALDriverH (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetDatasetDriver", apszFailed ); + + GDALClose = (void (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALClose", apszFailed ); + + GDALGetRasterXSize = (int (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetRasterXSize", apszFailed ); + + GDALGetRasterYSize = (int (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetRasterYSize", apszFailed ); + + GDALGetRasterCount = (int (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetRasterCount", apszFailed ); + + GDALGetRasterBand = (GDALRasterBandH (*)(GDALDatasetH, int)) + GBGetSymbolCheck( szPath, "GDALGetRasterBand", apszFailed ); + + GDALGetProjectionRef = (const char *(*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetProjectionRef", apszFailed ); + + GDALSetProjection = (CPLErr (*)(GDALDatasetH, const char *)) + GBGetSymbolCheck( szPath, "GDALSetProjection", apszFailed ); + + GDALGetGeoTransform = (CPLErr (*)(GDALDatasetH, double *)) + GBGetSymbolCheck( szPath, "GDALGetGeoTransform", apszFailed ); + + GDALSetGeoTransform = (CPLErr (*)(GDALDatasetH, double *)) + GBGetSymbolCheck( szPath, "GDALSetGeoTransform", apszFailed ); + + GDALGetInternalHandle = (void *(*)(GDALDatasetH, const char *)) + GBGetSymbolCheck( szPath, "GDALGetInternalHandle", apszFailed ); + + GDALGetGCPCount = (int (*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetGCPCount", apszFailed ); + + GDALGetGCPProjection = (const char *(*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetGCPProjection", apszFailed ); + + GDALGetGCPs = (const GDAL_GCP *(*)(GDALDatasetH)) + GBGetSymbolCheck( szPath, "GDALGetGCPs", apszFailed ); + + GDALGetRasterDataType = (GDALDataType (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetRasterDataType", apszFailed ); + + GDALGetRasterBandXSize = (int (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetRasterBandXSize", apszFailed ); + + GDALGetRasterBandYSize = (int (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetRasterBandYSize", apszFailed ); + + GDALGetBlockSize = (void (*)(GDALRasterBandH, int *, int *)) + GBGetSymbolCheck( szPath, "GDALGetBlockSize", apszFailed ); + + GDALRasterIO = (CPLErr (*)(GDALRasterBandH, GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, int, int )) + GBGetSymbolCheck( szPath, "GDALRasterIO", apszFailed ); + + GDALReadBlock = (CPLErr (*)(GDALRasterBandH, int, int, void *)) + GBGetSymbolCheck( szPath, "GDALReadBlock", apszFailed ); + + GDALWriteBlock = (CPLErr (*)(GDALRasterBandH, int, int, void *)) + GBGetSymbolCheck( szPath, "GDALWriteBlock", apszFailed ); + + GDALGetOverviewCount = (int (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetOverviewCount", apszFailed ); + + GDALGetOverview = (GDALRasterBandH (*)(GDALRasterBandH, int)) + GBGetSymbolCheck( szPath, "GDALGetOverview", apszFailed ); + + GDALGetRasterNoDataValue = (double (*)(GDALRasterBandH, int*)) + GBGetSymbolCheck( szPath, "GDALGetRasterNoDataValue", apszFailed ); + + GDALSetRasterNoDataValue = (CPLErr (*)(GDALRasterBandH, double)) + GBGetSymbolCheck( szPath, "GDALSetRasterNoDataValue", apszFailed ); + + GDALFillRaster = (CPLErr (*)(GDALRasterBandH, double, double)) + GBGetSymbolCheck( szPath, "GDALFillRaster", apszFailed ); + + GDALGetRasterMinimum = (double (*)(GDALRasterBandH, int *)) + GBGetSymbolCheck( szPath, "GDALGetRasterMinimum", apszFailed ); + + GDALGetRasterMaximum = (double (*)(GDALRasterBandH, int *)) + GBGetSymbolCheck( szPath, "GDALGetRasterMaximum", apszFailed ); + + GDALComputeRasterMinMax = (void (*)(GDALRasterBandH, int, double *)) + GBGetSymbolCheck( szPath, "GDALComputeRasterMinMax", apszFailed ); + + GDALGetRasterColorInterpretation = (GDALColorInterp (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetRasterColorInterpretation", apszFailed ); + + GDALGetColorInterpretationName = (const char *(*)(GDALColorInterp)) + GBGetSymbolCheck( szPath, "GDALGetColorInterpretationName", apszFailed ); + + GDALGetRasterColorTable = (GDALColorTableH (*)(GDALRasterBandH)) + GBGetSymbolCheck( szPath, "GDALGetRasterColorTable", apszFailed ); + + GDALDecToDMS = (const char *(*)(double, const char *, int )) + GBGetSymbolCheck( szPath, "GDALDecToDMS", apszFailed ); + + GDALGetPaletteInterpretation = (GDALPaletteInterp (*)(GDALColorTableH)) + GBGetSymbolCheck( szPath, "GDALGetPaletteInterpretation", apszFailed ); + + GDALGetPaletteInterpretationName = (const char *(*)(GDALPaletteInterp)) + GBGetSymbolCheck( szPath, "GDALGetPaletteInterpretationName", apszFailed ); + + GDALGetColorEntryCount = (int (*)(GDALColorTableH)) + GBGetSymbolCheck( szPath, "GDALGetColorEntryCount", apszFailed ); + + GDALGetColorEntry = (const GDALColorEntry *(*)(GDALColorTableH,int)) + GBGetSymbolCheck( szPath, "GDALGetColorEntry", apszFailed ); + + GDALGetColorEntryAsRGB = (int (*)(GDALColorTableH,int, + GDALColorEntry*)) + GBGetSymbolCheck( szPath, "GDALGetColorEntryAsRGB", apszFailed ); + + GDALSetColorEntry = (void (*)(GDALColorTableH, int, const GDALColorEntry*)) + GBGetSymbolCheck( szPath, "GDALSetColorEntry", apszFailed ); + +/* -------------------------------------------------------------------- */ +/* GDALMajorObject */ +/* -------------------------------------------------------------------- */ + GDALGetMetadata = (char **(*)(GDALMajorObjectH, const char *)) + GBGetSymbolCheck( szPath, "GDALGetMetadata", apszFailed ); + + GDALSetMetadata = (CPLErr(*)(GDALMajorObjectH, char **, const char *)) + GBGetSymbolCheck( szPath, "GDALSetMetadata", apszFailed ); + + GDALGetMetadataItem = (const char *(*)(GDALMajorObjectH, const char *, + const char *)) + GBGetSymbolCheck( szPath, "GDALGetMetadataItem", apszFailed ); + + GDALSetMetadataItem = (CPLErr (*)(GDALMajorObjectH, const char *, + const char *, const char *)) + GBGetSymbolCheck( szPath, "GDALSetMetadataItem", apszFailed ); + +/* -------------------------------------------------------------------- */ +/* CPL */ +/* -------------------------------------------------------------------- */ + CPLErrorReset = (void (*)()) + GBGetSymbolCheck( szPath, "CPLErrorReset", apszFailed ); + + CPLGetLastErrorNo = (int (*)()) + GBGetSymbolCheck( szPath, "CPLGetLastErrorNo", apszFailed ); + + CPLGetLastErrorType = (CPLErr (*)()) + GBGetSymbolCheck( szPath, "CPLGetLastErrorType", apszFailed ); + + CPLGetLastErrorMsg = (const char *(*)()) + GBGetSymbolCheck( szPath, "CPLGetLastErrorMsg", apszFailed ); + + CPLPushErrorHandler = (void (*)(CPLErrorHandler)) + GBGetSymbolCheck( szPath, "CPLPushErrorHandler", apszFailed ); + + CPLPopErrorHandler = (void (*)()) + GBGetSymbolCheck( szPath, "CPLPopErrorHandler", apszFailed ); + +/* -------------------------------------------------------------------- */ +/* OSR API */ +/* -------------------------------------------------------------------- */ + OSRNewSpatialReference = (OGRSpatialReferenceH (*)( const char * )) + GBGetSymbolCheck( szPath, "OSRNewSpatialReference", apszFailed ); + + OSRCloneGeogCS = (OGRSpatialReferenceH (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRCloneGeogCS", apszFailed ); + + OSRDestroySpatialReference = (void (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRDestroySpatialReference", apszFailed ); + + OSRReference = (int (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRReference", apszFailed ); + + OSRDereference = (int (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRDereference", apszFailed ); + + OSRImportFromEPSG = (OGRErr (*)(OGRSpatialReferenceH,int)) + GBGetSymbolCheck( szPath, "OSRImportFromEPSG", apszFailed ); + + OSRImportFromWkt = (OGRErr (*)(OGRSpatialReferenceH,char **)) + GBGetSymbolCheck( szPath, "OSRImportFromWkt", apszFailed ); + + OSRImportFromProj4 = (OGRErr (*)(OGRSpatialReferenceH,const char *)) + GBGetSymbolCheck( szPath, "OSRImportFromProj4", apszFailed ); + + OSRExportToWkt = (OGRErr (*)(OGRSpatialReferenceH, char **)) + GBGetSymbolCheck( szPath, "OSRExportToWkt", apszFailed ); + + OSRExportToPrettyWkt = (OGRErr (*)(OGRSpatialReferenceH, char **, int)) + GBGetSymbolCheck( szPath, "OSRExportToPrettyWkt", apszFailed ); + + OSRExportToProj4 = (OGRErr (*)(OGRSpatialReferenceH, char **)) + GBGetSymbolCheck( szPath, "OSRExportToProj4", apszFailed ); + + OSRSetAttrValue = (OGRErr (*)(OGRSpatialReferenceH, const char *, + const char *)) + GBGetSymbolCheck( szPath, "OSRSetAttrValue", apszFailed ); + + OSRGetAttrValue = (const char *(*)(OGRSpatialReferenceH, const char *,int)) + GBGetSymbolCheck( szPath, "OSRGetAttrValue", apszFailed ); + + OSRSetLinearUnits = (OGRErr (*)(OGRSpatialReferenceH, const char *,double)) + GBGetSymbolCheck( szPath, "OSRSetLinearUnits", apszFailed ); + + OSRGetLinearUnits = (double (*)(OGRSpatialReferenceH, char **)) + GBGetSymbolCheck( szPath, "OSRGetLinearUnits", apszFailed ); + + OSRIsGeographic = (int (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRIsGeographic", apszFailed ); + + OSRIsProjected = (int (*)(OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRIsProjected", apszFailed ); + + OSRIsSameGeogCS = (int (*)(OGRSpatialReferenceH,OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRIsSameGeogCS", apszFailed ); + + OSRIsSame = (int (*)(OGRSpatialReferenceH,OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OSRIsSame", apszFailed ); + + OSRSetProjCS = (OGRErr (*)(OGRSpatialReferenceH,const char*)) + GBGetSymbolCheck( szPath, "OSRSetProjCS", apszFailed ); + + OSRSetWellKnownGeogCS = (OGRErr (*)(OGRSpatialReferenceH, const char *)) + GBGetSymbolCheck( szPath, "OSRSetWellKnownGeogCS", apszFailed ); + + OSRSetGeogCS = (OGRErr (*)( OGRSpatialReferenceH hSRS, + const char * pszGeogName, + const char * pszDatumName, + const char * pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + const char * pszPMName /* = NULL */, + double dfPMOffset /* = 0.0 */, + const char * pszUnits /* = NULL */, + double dfConvertToRadians /* = 0.0 */ )) + GBGetSymbolCheck( szPath, "OSRSetGeogCS", apszFailed ); + + OSRGetSemiMajor = (double (*)(OGRSpatialReferenceH, OGRErr *)) + GBGetSymbolCheck( szPath, "OSRGetSemiMajor", apszFailed ); + + OSRGetSemiMinor = (double (*)(OGRSpatialReferenceH, OGRErr *)) + GBGetSymbolCheck( szPath, "OSRGetSemiMinor", apszFailed ); + + OSRGetInvFlattening = (double (*)(OGRSpatialReferenceH, OGRErr *)) + GBGetSymbolCheck( szPath, "OSRGetInvFlattening", apszFailed ); + + OSRSetAuthority = (OGRErr (*)(OGRSpatialReferenceH, const char *, + const char *, int)) + GBGetSymbolCheck( szPath, "OSRSetAuthority", apszFailed ); + + OSRSetProjParm = (OGRErr (*)(OGRSpatialReferenceH, const char *, double)) + GBGetSymbolCheck( szPath, "OSRSetProjParm", apszFailed ); + + OSRGetProjParm = (double (*)(OGRSpatialReferenceH, const char *, + double, OGRErr *)) + GBGetSymbolCheck( szPath, "OSRGetProjParm", apszFailed ); + + OSRSetUTM = (OGRErr (*)(OGRSpatialReferenceH, int, int)) + GBGetSymbolCheck( szPath, "OSRSetUTM", apszFailed ); + + OSRGetUTMZone = (int (*)(OGRSpatialReferenceH, int *)) + GBGetSymbolCheck( szPath, "OSRGetUTMZone", apszFailed ); + + OCTNewCoordinateTransformation = (OGRCoordinateTransformationH + (*)(OGRSpatialReferenceH, OGRSpatialReferenceH)) + GBGetSymbolCheck( szPath, "OCTNewCoordinateTransformation",apszFailed); + + OCTDestroyCoordinateTransformation = + (void (*)(OGRCoordinateTransformationH)) + GBGetSymbolCheck( szPath, "OCTDestroyCoordinateTransformation", + apszFailed ); + + OCTTransform = (int (*)(OGRCoordinateTransformationH, int, + double *, double *, double *)) + GBGetSymbolCheck( szPath, "OCTTransform", apszFailed ); + +/* -------------------------------------------------------------------- */ +/* Did we fail to find any entry points? */ +/* -------------------------------------------------------------------- */ + if( apszFailed[0] != NULL && fpReportFailure != NULL ) + { + int iError; + + fprintf( fpReportFailure, + "While a GDAL .DLL/.so was found at `%s'\n" + "it appears to be missing the following entry points.\n" + "Consider upgrading to a more recent GDAL library.\n", + szPath ); + + for( iError = 0; apszFailed[iError] != NULL; iError++ ) + { + fprintf( fpReportFailure, " o %s\n", apszFailed[iError] ); + free( apszFailed[iError] ); + } + } + + return apszFailed[0] == NULL; +} + + diff --git a/Utilities/GDAL/bridge/gdalbridge.h b/Utilities/GDAL/bridge/gdalbridge.h new file mode 100644 index 0000000000..7e01204a1a --- /dev/null +++ b/Utilities/GDAL/bridge/gdalbridge.h @@ -0,0 +1,750 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Bridge + * Purpose: Declarations for GDAL Bridge support. + * Author: Frank Warmerdam, warmerda@home.com + * + * This file needs to be kept up to date with the contents of gdal.h by hand. + * + ****************************************************************************** + * Copyright (c) 1999, 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: gdalbridge.h,v $ + * Revision 1.13 2003/07/17 03:33:15 sperkins + * added GDALFILLRaster() + * + * Revision 1.12 2001/11/18 00:48:24 warmerda + * substantial upgrade + * + * Revision 1.11 2001/09/06 14:03:21 warmerda + * upgrade bridge error reporting + * + * Revision 1.8 2000/11/09 16:25:30 warmerda + * added various srs defines + * + * Revision 1.7 2000/09/26 15:20:32 warmerda + * added GDALGetRasterBand{X,Y}Size + * + * Revision 1.6 2000/08/28 20:16:14 warmerda + * added lots of OGRSpatialReference stuff + * + * Revision 1.5 2000/08/25 20:03:40 warmerda + * added more entry points + * + * Revision 1.4 1999/09/17 03:18:37 warmerda + * added name indirection for function pointer names for libtool + * + * Revision 1.3 1999/04/22 13:36:43 warmerda + * Added copyright header. + * + */ + +#ifndef GDALBRIDGE_H_INCLUDED +#define GDALBRIDGE_H_INCLUDED + +/* -------------------------------------------------------------------- */ +/* Start C context. */ +/* -------------------------------------------------------------------- */ +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> + +/* ==================================================================== */ +/* Standard types and defines normally supplied by cpl_port.h. */ +/* ==================================================================== */ +#if UINT_MAX == 65535 +typedef long GInt32; +typedef unsigned long GUInt32; +#else +typedef int GInt32; +typedef unsigned int GUInt32; +#endif + +typedef short GInt16; +typedef unsigned short GUInt16; +typedef unsigned char GByte; +typedef int GBool; + +#ifndef FALSE +# define FALSE 0 +# define TRUE 1 +#endif + +#ifndef NULL +# define NULL 0 +#endif + +#ifndef GDAL_ENTRY +# define GDAL_ENTRY extern +# define GDAL_NULL +#endif + +/* -------------------------------------------------------------------- */ +/* Significant constants. */ +/* -------------------------------------------------------------------- */ + +/*! Pixel data types */ +typedef enum { + GDT_Unknown = 0, + /*! Eight bit unsigned integer */ GDT_Byte = 1, + /*! Sixteen bit unsigned integer */ GDT_UInt16 = 2, + /*! Sixteen bit signed integer */ GDT_Int16 = 3, + /*! Thirty two bit unsigned integer */ GDT_UInt32 = 4, + /*! Thirty two bit signed integer */ GDT_Int32 = 5, + /*! Thirty two bit floating point */ GDT_Float32 = 6, + /*! Sixty four bit floating point */ GDT_Float64 = 7, + /*! Complex Int16 */ GDT_CInt16 = 8, + /*! Complex Int32 */ GDT_CInt32 = 9, + /*! Complex Float32 */ GDT_CFloat32 = 10, + /*! Complex Float64 */ GDT_CFloat64 = 11, + GDT_TypeCount = 12 /* maximum type # + 1 */ +} GDALDataType; + +GDAL_ENTRY int (*pfnGDALGetDataTypeSize)( GDALDataType ) GDAL_NULL; +#define GDALGetDataTypeSize pfnGDALGetDataTypeSize + +typedef enum { + GA_ReadOnly = 0, + GA_Update = 1 +} GDALAccess; + +typedef enum { + GF_Read = 0, + GF_Write = 1 +} GDALRWFlag; + +/*! Types of color interpretation for raster bands. */ +typedef enum +{ + GCI_Undefined=0, + /*! Greyscale */ GCI_GrayIndex=1, + /*! Paletted (see associated color table) */ GCI_PaletteIndex=2, + /*! Red band of RGBA image */ GCI_RedBand=3, + /*! Green band of RGBA image */ GCI_GreenBand=4, + /*! Blue band of RGBA image */ GCI_BlueBand=5, + /*! Alpha (0=transparent, 255=opaque) */ GCI_AlphaBand=6, + /*! Hue band of HLS image */ GCI_HueBand=7, + /*! Saturation band of HLS image */ GCI_SaturationBand=8, + /*! Lightness band of HLS image */ GCI_LightnessBand=9, + /*! Cyan band of CMYK image */ GCI_CyanBand=10, + /*! Magenta band of CMYK image */ GCI_MagentaBand=11, + /*! Yellow band of CMYK image */ GCI_YellowBand=12, + /*! Black band of CMLY image */ GCI_BlackBand=13 +} GDALColorInterp; + +/*! Types of color interpretations for a GDALColorTable. */ +typedef enum +{ + /*! Grayscale (in GDALColorEntry.c1) */ GPI_Gray=0, + /*! Red, Green, Blue and Alpha in (in c1, c2, c3 and c4) */ GPI_RGB=1, + /*! Cyan, Magenta, Yellow and Black (in c1, c2, c3 and c4)*/ GPI_CMYK=2, + /*! Hue, Lightness and Saturation (in c1, c2, and c3) */ GPI_HLS=3 +} GDALPaletteInterp; + +/* -------------------------------------------------------------------- */ +/* GDAL Specific error codes. */ +/* */ +/* error codes 100 to 299 reserved for GDAL. */ +/* -------------------------------------------------------------------- */ +typedef enum +{ + CE_None = 0, + CE_Log = 1, + CE_Warning = 2, + CE_Failure = 3, + CE_Fatal = 4 + +} CPLErr; + +#define CPLE_AppDefined 1 +#define CPLE_OutOfMemory 2 +#define CPLE_FileIO 3 +#define CPLE_OpenFailed 4 +#define CPLE_IllegalArg 5 +#define CPLE_NotSupported 6 +#define CPLE_AssertionFailed 7 +#define CPLE_NoWriteAccess 8 + +#define CPLE_WrongFormat 200 + +typedef int OGRErr; + +#define OGRERR_NONE 0 +#define OGRERR_NOT_ENOUGH_DATA 1 /* not enough data to deserialize */ +#define OGRERR_NOT_ENOUGH_MEMORY 2 +#define OGRERR_UNSUPPORTED_GEOMETRY_TYPE 3 +#define OGRERR_UNSUPPORTED_OPERATION 4 +#define OGRERR_CORRUPT_DATA 5 +#define OGRERR_FAILURE 6 +#define OGRERR_UNSUPPORTED_SRS 7 + +/* -------------------------------------------------------------------- */ +/* Important CPL Functions. */ +/* -------------------------------------------------------------------- */ +typedef void (*CPLErrorHandler)(CPLErr, int, const char*); + +GDAL_ENTRY void (*pfnCPLErrorReset)() GDAL_NULL; +#define CPLErrorReset pfnCPLErrorReset + +GDAL_ENTRY int (*pfnCPLGetLastErrorNo)() GDAL_NULL; +#define CPLGetLastErrorNo pfnCPLGetLastErrorNo + +GDAL_ENTRY CPLErr (*pfnCPLGetLastErrorType)() GDAL_NULL; +#define CPLGetLastErrorType pfnCPLGetLastErrorType + +GDAL_ENTRY const char *(*pfnCPLGetLastErrorMsg)() GDAL_NULL; +#define CPLGetLastErrorMsg pfnCPLGetLastErrorMsg + +GDAL_ENTRY void (*pfnCPLPushErrorHandler)( CPLErrorHandler ) GDAL_NULL; +#define CPLPushErrorHandler pfnCPLPushErrorHandler + +GDAL_ENTRY void (*pfnCPLPopErrorHandler)() GDAL_NULL; +#define CPLPopErrorHandler pfnCPLPopErrorHandler + +/* -------------------------------------------------------------------- */ +/* Define handle types related to various internal classes. */ +/* -------------------------------------------------------------------- */ + +typedef void *GDALMajorObjectH; +typedef void *GDALDatasetH; +typedef void *GDALRasterBandH; +typedef void *GDALDriverH; +typedef void *GDALColorTableH; +typedef void *OGRSpatialReferenceH; +typedef void *OGRCoordinateTransformationH; + +/* ==================================================================== */ +/* GDAL_GCP */ +/* ==================================================================== */ + +/** Ground Control Point */ +typedef struct +{ + /** Unique identifier, often numeric */ + char *pszId; + + /** Informational message or "" */ + char *pszInfo; + + /** Pixel (x) location of GCP on raster */ + double dfGCPPixel; + /** Line (y) location of GCP on raster */ + double dfGCPLine; + + /** X position of GCP in georeferenced space */ + double dfGCPX; + + /** Y position of GCP in georeferenced space */ + double dfGCPY; + + /** Elevation of GCP, or zero if not known */ + double dfGCPZ; +} GDAL_GCP; + +/* ==================================================================== */ +/* Registration/driver related. */ +/* ==================================================================== */ + +GDAL_ENTRY void (*pfnGDALAllRegister)( void ) GDAL_NULL; +#define GDALAllRegister pfnGDALAllRegister + +GDAL_ENTRY GDALDatasetH (*pfnGDALCreate)( GDALDriverH hDriver, const char *, + int, int, int, GDALDataType, + char ** ) GDAL_NULL; +#define GDALCreate pfnGDALCreate + + +GDAL_ENTRY GDALDatasetH (*pfnGDALOpen)( const char *, GDALAccess ) GDAL_NULL; +#define GDALOpen pfnGDALOpen + +GDAL_ENTRY GDALDriverH (*pfnGDALGetDriverByName)( const char * ) GDAL_NULL; +#define GDALGetDriverByName pfnGDALGetDriverByName + +GDAL_ENTRY const char *(*pfnGDALGetDriverShortName)(GDALDriverH) GDAL_NULL; +#define GDALGetDriverShortName pfnGDALGetDriverShortName + +GDAL_ENTRY const char *(*pfnGDALGetDriverLongName)(GDALDriverH) GDAL_NULL; +#define GDALGetDriverLongName pfnGDALGetDriverLongName + +/* ==================================================================== */ +/* GDALMajorObject */ +/* ==================================================================== */ + +GDAL_ENTRY char **(*pfnGDALGetMetadata)( GDALMajorObjectH, + const char * ) GDAL_NULL; +#define GDALGetMetadata pfnGDALGetMetadata + +GDAL_ENTRY CPLErr (*pfnGDALSetMetadata)( GDALMajorObjectH, char **, + const char * ) GDAL_NULL; +#define GDALSetMetadata pfnGDALSetMetadata + +GDAL_ENTRY const char *(*pfnGDALGetMetadataItem)( GDALMajorObjectH, + const char *, const char * ) GDAL_NULL; +#define GDALGetMetadataItem pfnGDALGetMetadataItem + +GDAL_ENTRY CPLErr (*pfnGDALSetMetadataItem)( GDALMajorObjectH, + const char *, const char *, + const char * ) GDAL_NULL; +#define GDALSetMetadataItem pfnGDALSetMetadataItem + +GDAL_ENTRY const char *(*pfnGDALGetDescription)( GDALMajorObjectH ) GDAL_NULL; +#define GDALGetDescription pfnGDALGetDescription + +/* ==================================================================== */ +/* GDALDataset class ... normally this represents one file. */ +/* ==================================================================== */ + +GDAL_ENTRY void (*pfnGDALClose)( GDALDatasetH ) GDAL_NULL; +#define GDALClose pfnGDALClose + +GDAL_ENTRY GDALDriverH (*pfnGDALGetDatasetDriver)( GDALDatasetH ) GDAL_NULL; +#define GDALGetDatasetDriver pfnGDALGetDatasetDriver + +GDAL_ENTRY int (*pfnGDALGetRasterXSize)( GDALDatasetH ) GDAL_NULL; +#define GDALGetRasterXSize pfnGDALGetRasterXSize + +GDAL_ENTRY int (*pfnGDALGetRasterYSize)( GDALDatasetH ) GDAL_NULL; +#define GDALGetRasterYSize pfnGDALGetRasterYSize + +GDAL_ENTRY int (*pfnGDALGetRasterCount)( GDALDatasetH ) GDAL_NULL; +#define GDALGetRasterCount pfnGDALGetRasterCount + +GDAL_ENTRY GDALRasterBandH + (*pfnGDALGetRasterBand)( GDALDatasetH, int) GDAL_NULL; +#define GDALGetRasterBand pfnGDALGetRasterBand + +GDAL_ENTRY const char *(*pfnGDALGetProjectionRef)( GDALDatasetH ) GDAL_NULL; +#define GDALGetProjectionRef pfnGDALGetProjectionRef + +GDAL_ENTRY CPLErr (*pfnGDALSetProjection)( GDALDatasetH, + const char * ) GDAL_NULL; +#define GDALSetProjection pfnGDALSetProjection + +GDAL_ENTRY CPLErr (*pfnGDALGetGeoTransform)( GDALDatasetH, double* ) GDAL_NULL; +#define GDALGetGeoTransform pfnGDALGetGeoTransform + +GDAL_ENTRY CPLErr (*pfnGDALSetGeoTransform)( GDALDatasetH, double* ) GDAL_NULL; +#define GDALSetGeoTransform pfnGDALSetGeoTransform + +GDAL_ENTRY void *(*pfnGDALGetInternalHandle)( GDALDatasetH, + const char * ) GDAL_NULL; +#define GDALGetInternalHandle pfnGDALGetInternalHandle + +GDAL_ENTRY int (*pfnGDALGetGCPCount)( GDALDatasetH ) GDAL_NULL; +#define GDALGetGCPCount pfnGDALGetGCPCount + +GDAL_ENTRY const char *(*pfnGDALGetGCPProjection)( GDALDatasetH ) GDAL_NULL; +#define GDALGetGCPProjection pfnGDALGetGCPProjection + +GDAL_ENTRY const GDAL_GCP *(*pfnGDALGetGCPs)( GDALDatasetH ) GDAL_NULL; +#define GDALGetGCPs pfnGDALGetGCPs + +/* ==================================================================== */ +/* GDALRasterBand ... one band/channel in a dataset. */ +/* ==================================================================== */ + +GDAL_ENTRY GDALDataType (*pGDALGetRasterDataType)( GDALRasterBandH ) GDAL_NULL; +#define GDALGetRasterDataType pGDALGetRasterDataType + +GDAL_ENTRY void (*pGDALGetBlockSize)( GDALRasterBandH, + int * pnXSize, int * pnYSize ) GDAL_NULL; +#define GDALGetBlockSize pGDALGetBlockSize + +GDAL_ENTRY CPLErr (*pGDALRasterIO)( GDALRasterBandH hRBand, GDALRWFlag eRWFlag, + int nDSXOff, int nDSYOff, + int nDSXSize, int nDSYSize, + void * pBuffer, int nBXSize, int nBYSize, + GDALDataType eBDataType, + int nPixelSpace, int nLineSpace ) GDAL_NULL; +#define GDALRasterIO pGDALRasterIO + +GDAL_ENTRY CPLErr (*pGDALReadBlock)( GDALRasterBandH, + int, int, void * ) GDAL_NULL; +#define GDALReadBlock pGDALReadBlock + +GDAL_ENTRY CPLErr (*pGDALWriteBlock)( GDALRasterBandH, + int, int, void * ) GDAL_NULL; +#define GDALWriteBlock pGDALWriteBlock + +GDAL_ENTRY int (*pGDALGetOverviewCount)( GDALRasterBandH ) GDAL_NULL; +#define GDALGetOverviewCount pGDALGetOverviewCount + +GDAL_ENTRY GDALRasterBandH (*pGDALGetOverview)( GDALRasterBandH, int ) GDAL_NULL; +#define GDALGetOverview pGDALGetOverview + +GDAL_ENTRY double (*pGDALGetRasterNoDataValue)( GDALRasterBandH, int * ) + GDAL_NULL; +#define GDALGetRasterNoDataValue pGDALGetRasterNoDataValue + +GDAL_ENTRY CPLErr (*pGDALSetRasterNoDataValue)( GDALRasterBandH, double ) + GDAL_NULL; +#define GDALSetRasterNoDataValue pGDALSetRasterNoDataValue + +GDAL_ENTRY CPLErr (*pGDALFillRaster)( GDALRasterBandH, double, double ) + GDAL_NULL; +#define GDALFillRaster pGDALFillRaster + +GDAL_ENTRY double (*pGDALGetRasterMinimum)( GDALRasterBandH, int * ) GDAL_NULL; +#define GDALGetRasterMinimum pGDALGetRasterMinimum + +GDAL_ENTRY double (*pGDALGetRasterMaximum)( GDALRasterBandH, int * ) GDAL_NULL; +#define GDALGetRasterMaximum pGDALGetRasterMaximum + +GDAL_ENTRY void (*pGDALComputeRasterMinMax)( GDALRasterBandH, int, + double * ) GDAL_NULL; +#define GDALComputeRasterMinMax pGDALComputeRasterMinMax + +GDAL_ENTRY GDALColorInterp (*pGDALGetRasterColorInterpretation) + ( GDALRasterBandH ) GDAL_NULL; +#define GDALGetRasterColorInterpretation pGDALGetRasterColorInterpretation + +GDAL_ENTRY const char *(*pGDALGetColorInterpretationName)( GDALColorInterp ) GDAL_NULL; +#define GDALGetColorInterpretationName pGDALGetColorInterpretationName + +GDAL_ENTRY GDALColorTableH (*pGDALGetRasterColorTable)( GDALRasterBandH ) GDAL_NULL; +#define GDALGetRasterColorTable pGDALGetRasterColorTable + +GDAL_ENTRY int (*pfnGDALGetRasterBandXSize)( GDALRasterBandH ) GDAL_NULL; +#define GDALGetRasterBandXSize pfnGDALGetRasterBandXSize + +GDAL_ENTRY int (*pfnGDALGetRasterBandYSize)( GDALRasterBandH ) GDAL_NULL; +#define GDALGetRasterBandYSize pfnGDALGetRasterBandYSize + +/* ==================================================================== */ +/* Color tables. */ +/* ==================================================================== */ +/** Color tuple */ +typedef struct +{ + /*! gray, red, cyan or hue */ + short c1; + + /*! green, magenta, or lightness */ + short c2; + + /*! blue, yellow, or saturation */ + short c3; + + /*! alpha or blackband */ + short c4; +} GDALColorEntry; + +GDAL_ENTRY GDALPaletteInterp (*pGDALGetPaletteInterpretation)( GDALColorTableH ) GDAL_NULL; +#define GDALGetPaletteInterpretation pGDALGetPaletteInterpretation + +GDAL_ENTRY const char *(*pGDALGetPaletteInterpretationName)(GDALPaletteInterp) GDAL_NULL; +#define GDALGetPaletteInterpretationName pGDALGetPaletteInterpretationName + +GDAL_ENTRY int (*pGDALGetColorEntryCount)( GDALColorTableH ) GDAL_NULL; +#define GDALGetColorEntryCount pGDALGetColorEntryCount + +GDAL_ENTRY const GDALColorEntry *(*pGDALGetColorEntry)( GDALColorTableH, int ) GDAL_NULL; +#define GDALGetColorEntry pGDALGetColorEntry + +GDAL_ENTRY int (*pGDALGetColorEntryAsRGB)( GDALColorTableH, int, + GDALColorEntry *) GDAL_NULL; +#define GDALGetColorEntryAsRGB pGDALGetColorEntryAsRGB + +GDAL_ENTRY void (*pGDALSetColorEntry)( GDALColorTableH, int, + const GDALColorEntry * ) GDAL_NULL; +#define GDALSetColorEntry pGDALSetColorEntry + +/* ==================================================================== */ +/* Projections */ +/* ==================================================================== */ + +GDAL_ENTRY const char *(*pGDALDecToDMS)( double, const char *, int ) GDAL_NULL; +#define GDALDecToDMS pGDALDecToDMS + +/* -------------------------------------------------------------------- */ +/* ogr_srs_api.h services. */ +/* -------------------------------------------------------------------- */ + +GDAL_ENTRY OGRSpatialReferenceH + (*pOSRNewSpatialReference)( const char * ) GDAL_NULL; +#define OSRNewSpatialReference pOSRNewSpatialReference + +GDAL_ENTRY OGRSpatialReferenceH + (*pOSRCloneGeogCS)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRCloneGeogCS pOSRCloneGeogCS + +GDAL_ENTRY void + (*pOSRDestroySpatialReference)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRDestroySpatialReference pOSRDestroySpatialReference + +GDAL_ENTRY int (*pOSRReference)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRReference pOSRReference + +GDAL_ENTRY int (*pOSRDereference)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRDereference pOSRDereference + +GDAL_ENTRY OGRErr (*pOSRImportFromEPSG)( OGRSpatialReferenceH, int ) GDAL_NULL; +#define OSRImportFromEPSG pOSRImportFromEPSG + +GDAL_ENTRY OGRErr + (*pOSRImportFromWkt)( OGRSpatialReferenceH, char ** ) GDAL_NULL; +#define OSRImportFromWkt pOSRImportFromWkt + +GDAL_ENTRY OGRErr + (*pOSRImportFromProj4)( OGRSpatialReferenceH, const char *) GDAL_NULL; +#define OSRImportFromProj4 pOSRImportFromProj4 + +GDAL_ENTRY OGRErr + (*pOSRExportToWkt)( OGRSpatialReferenceH, char ** ) GDAL_NULL; +#define OSRExportToWkt pOSRExportToWkt + +GDAL_ENTRY OGRErr + (*pOSRExportToPrettyWkt)( OGRSpatialReferenceH, char **, int) GDAL_NULL; +#define OSRExportToPrettyWkt pOSRExportToPrettyWkt + +GDAL_ENTRY OGRErr + (*pOSRExportToProj4)( OGRSpatialReferenceH, char **) GDAL_NULL; +#define OSRExportToProj4 pOSRExportToProj4 + +GDAL_ENTRY OGRErr + (*pOSRSetAttrValue)( OGRSpatialReferenceH hSRS, + const char * pszNodePath, + const char * pszNewNodeValue ) GDAL_NULL; +#define OSRSetAttrValue pOSRSetAttrValue + +GDAL_ENTRY const char * (*pOSRGetAttrValue)( OGRSpatialReferenceH hSRS, + const char * pszName, int iChild ) GDAL_NULL; +#define OSRGetAttrValue pOSRGetAttrValue + +GDAL_ENTRY OGRErr (*pOSRSetLinearUnits)( OGRSpatialReferenceH, const char *, + double ) GDAL_NULL; +#define OSRSetLinearUnits pOSRSetLinearUnits + +GDAL_ENTRY double (*pOSRGetLinearUnits)( OGRSpatialReferenceH, + char ** ) GDAL_NULL; +#define OSRGetLinearUnits pOSRGetLinearUnits + +GDAL_ENTRY int (*pOSRIsGeographic)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRIsGeographic pOSRIsGeographic + +GDAL_ENTRY int (*pOSRIsProjected)( OGRSpatialReferenceH ) GDAL_NULL; +#define OSRIsProjected pOSRIsProjected + +GDAL_ENTRY int (*pOSRIsSameGeogCS)( OGRSpatialReferenceH, + OGRSpatialReferenceH ) GDAL_NULL; +#define OSRIsSameGeogCS pOSRIsSameGeogCS + +GDAL_ENTRY int (*pOSRIsSame)( OGRSpatialReferenceH, + OGRSpatialReferenceH ) GDAL_NULL; +#define OSRIsSame pOSRIsSame + +GDAL_ENTRY OGRErr (*pOSRSetProjCS)( OGRSpatialReferenceH hSRS, + const char * pszName ) GDAL_NULL; +#define OSRSetProjCS pOSRSetProjCS + +GDAL_ENTRY OGRErr (*pOSRSetWellKnownGeogCS)( OGRSpatialReferenceH hSRS, + const char * pszName ) GDAL_NULL; +#define OSRSetWellKnownGeogCS pOSRSetWellKnownGeogCS + +GDAL_ENTRY OGRErr (*pOSRSetGeogCS)( OGRSpatialReferenceH hSRS, + const char * pszGeogName, + const char * pszDatumName, + const char * pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + const char * pszPMName /* = NULL */, + double dfPMOffset /* = 0.0 */, + const char * pszUnits /* = NULL */, + double dfConvertToRadians /* = 0.0 */ ) GDAL_NULL; +#define OSRSetGeogCS pOSRSetGeogCS + +GDAL_ENTRY double (*pOSRGetSemiMajor)( OGRSpatialReferenceH, + OGRErr * /* = NULL */ ) GDAL_NULL; +#define OSRGetSemiMajor pOSRGetSemiMajor + +GDAL_ENTRY double (*pOSRGetSemiMinor)( OGRSpatialReferenceH, + OGRErr * /* = NULL */ ) GDAL_NULL; +#define OSRGetSemiMinor pOSRGetSemiMinor + +GDAL_ENTRY double (*pOSRGetInvFlattening)( OGRSpatialReferenceH, + OGRErr * /*=NULL*/) GDAL_NULL; +#define OSRGetInvFlattening pOSRGetInvFlattening + +GDAL_ENTRY OGRErr (*pOSRSetAuthority)( OGRSpatialReferenceH hSRS, + const char * pszTargetKey, + const char * pszAuthority, + int nCode ) GDAL_NULL; +#define OSRSetAuthority pOSRSetAuthority + +GDAL_ENTRY OGRErr (*pOSRSetProjParm)( OGRSpatialReferenceH, + const char *, double ) GDAL_NULL; +#define OSRSetProjParm pOSRSetProjParm + +GDAL_ENTRY double (*pOSRGetProjParm)( OGRSpatialReferenceH hSRS, + const char * pszParmName, + double dfDefault /* = 0.0 */, + OGRErr * /* = NULL */ ) GDAL_NULL; +#define OSRGetProjParm pOSRGetProjParm + +GDAL_ENTRY OGRErr (*pOSRSetUTM)( OGRSpatialReferenceH hSRS, + int nZone, int bNorth ) GDAL_NULL; +#define OSRSetUTM pOSRSetUTM + +GDAL_ENTRY int (*pOSRGetUTMZone)( OGRSpatialReferenceH hSRS, + int *pbNorth ) GDAL_NULL; +#define OSRGetUTMZone pOSRGetUTMZone + +GDAL_ENTRY OGRCoordinateTransformationH (*pOCTNewCoordinateTransformation) + ( OGRSpatialReferenceH hSourceSRS, + OGRSpatialReferenceH hTargetSRS ) GDAL_NULL; +#define OCTNewCoordinateTransformation pOCTNewCoordinateTransformation + +GDAL_ENTRY void (*pOCTDestroyCoordinateTransformation) + ( OGRCoordinateTransformationH ) GDAL_NULL; +#define OCTDestroyCoordinateTransformation pOCTDestroyCoordinateTransformation + +GDAL_ENTRY int (*pOCTTransform)( OGRCoordinateTransformationH hCT, + int nCount, double *x, double *y, + double *z ) GDAL_NULL; +#define OCTTransform pOCTTransform + +/* ==================================================================== */ +/* Some "standard" strings. */ +/* ==================================================================== */ +#ifndef SRS_PT_ALBERS_CONIC_EQUAL_AREA + +#define SRS_PT_ALBERS_CONIC_EQUAL_AREA \ + "Albers_Conic_Equal_Area" +#define SRS_PT_AZIMUTHAL_EQUIDISTANT "Azimuthal_Equidistant" +#define SRS_PT_CASSINI_SOLDNER "Cassini_Soldner" +#define SRS_PT_CYLINDRICAL_EQUAL_AREA "Cylindrical_Equal_Area" +#define SRS_PT_ECKERT_IV "Eckert_IV" +#define SRS_PT_ECKERT_VI "Eckert_VI" +#define SRS_PT_EQUIDISTANT_CONIC "Equidistant_Conic" +#define SRS_PT_EQUIRECTANGULAR "Equirectangular" +#define SRS_PT_GALL_STEREOGRAPHIC "Gall_Stereographic" +#define SRS_PT_GNOMONIC "Gnomonic" +#define SRS_PT_HOTINE_OBLIQUE_MERCATOR \ + "Hotine_Oblique_Mercator" +#define SRS_PT_LABORDE_OBLIQUE_MERCATOR \ + "Laborde_Oblique_Mercator" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP \ + "Lambert_Conformal_Conic_1SP" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP \ + "Lambert_Conformal_Conic_2SP" +#define SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM \ + "Lambert_Conformal_Conic_2SP_Belgium)" +#define SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA \ + "Lambert_Azimuthal_Equal_Area" +#define SRS_PT_MERCATOR_1SP "Mercator_1SP" +#define SRS_PT_MERCATOR_2SP "Mercator_2SP" +#define SRS_PT_MILLER_CYLINDRICAL "Miller_Cylindrical" +#define SRS_PT_MOLLWEIDE "Mollweide" +#define SRS_PT_NEW_ZEALAND_MAP_GRID \ + "New_Zealand_Map_Grid" +#define SRS_PT_OBLIQUE_STEREOGRAPHIC \ + "Oblique_Stereographic" +#define SRS_PT_ORTHOGRAPHIC "Orthographic" +#define SRS_PT_POLAR_STEREOGRAPHIC \ + "Polar_Stereographic" +#define SRS_PT_POLYCONIC "Polyconic" +#define SRS_PT_ROBINSON "Robinson" +#define SRS_PT_SINUSOIDAL "Sinusoidal" +#define SRS_PT_STEREOGRAPHIC "Stereographic" +#define SRS_PT_SWISS_OBLIQUE_CYLINDRICAL \ + "Swiss_Oblique_Cylindrical" +#define SRS_PT_TRANSVERSE_MERCATOR \ + "Transverse_Mercator" +#define SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED \ + "Transverse_Mercator_South_Orientated" +#define SRS_PT_TUNISIA_MINING_GRID \ + "Tunisia_Mining_Grid" +#define SRS_PT_VANDERGRINTEN "VanDerGrinten" + + + +#define SRS_PP_CENTRAL_MERIDIAN "central_meridian" +#define SRS_PP_SCALE_FACTOR "scale_factor" +#define SRS_PP_STANDARD_PARALLEL_1 "standard_parallel_1" +#define SRS_PP_STANDARD_PARALLEL_2 "standard_parallel_2" +#define SRS_PP_LONGITUDE_OF_CENTER "longitude_of_center" +#define SRS_PP_LATITUDE_OF_CENTER "latitude_of_center" +#define SRS_PP_LONGITUDE_OF_ORIGIN "longitude_of_origin" +#define SRS_PP_LATITUDE_OF_ORIGIN "latitude_of_origin" +#define SRS_PP_FALSE_EASTING "false_easting" +#define SRS_PP_FALSE_NORTHING "false_northing" +#define SRS_PP_AZIMUTH "azimuth" +#define SRS_PP_LONGITUDE_OF_POINT_1 "longitude_of_point_1" +#define SRS_PP_LATITUDE_OF_POINT_1 "latitude_of_point_1" +#define SRS_PP_LONGITUDE_OF_POINT_2 "longitude_of_point_2" +#define SRS_PP_LATITUDE_OF_POINT_2 "latitude_of_point_2" +#define SRS_PP_LONGITUDE_OF_POINT_3 "longitude_of_point_3" +#define SRS_PP_LATITUDE_OF_POINT_3 "latitude_of_point_3" +#define SRS_PP_RECTIFIED_GRID_ANGLE "rectified_grid_angle" +#define SRS_PP_LANDSAT_NUMBER "landsat_number" +#define SRS_PP_PATH_NUMBER "path_number" +#define SRS_PP_PERSPECTIVE_POINT_HEIGHT "perspective_point_height" +#define SRS_PP_FIPSZONE "fipszone" +#define SRS_PP_ZONE "zone" + +#define SRS_UL_METER "Meter" +#define SRS_UL_FOOT "Foot (International)" /* or just "FOOT"? */ +#define SRS_UL_FOOT_CONV "0.3048" +#define SRS_UL_US_FOOT "U.S. Foot" /* or "US survey foot" */ +#define SRS_UL_US_FOOT_CONV "0.3048006" +#define SRS_UL_NAUTICAL_MILE "Nautical Mile" +#define SRS_UL_NAUTICAL_MILE_CONV "1852.0" +#define SRS_UL_LINK "Link" /* Based on US Foot */ +#define SRS_UL_LINK_CONV "0.20116684023368047" +#define SRS_UL_CHAIN "Chain" /* based on US Foot */ +#define SRS_UL_CHAIN_CONV "2.0116684023368047" +#define SRS_UL_ROD "Rod" /* based on US Foot */ +#define SRS_UL_ROD_CONV "5.02921005842012" + +#define SRS_UA_DEGREE "degree" +#define SRS_UA_DEGREE_CONV "0.0174532925199433" +#define SRS_UA_RADIAN "radian" + +#define SRS_PM_GREENWICH "Greenwich" + +#define SRS_DN_NAD27 "North American Datum 1927" +#define SRS_DN_NAD83 "North American Datum 1983" +#define SRS_DN_WGS84 "World Geodetic System 1984" + +#define SRS_WGS84_SEMIMAJOR 6378137.0 +#define SRS_WGS84_INVFLATTENING 298.257223563 + +#endif + +/* -------------------------------------------------------------------- */ +/* This is the real entry point. It tries to load the shared */ +/* libraries (given a hint of a directory it might be in). It */ +/* returns TRUE if it succeeds, or FALSE otherwise. */ +/* -------------------------------------------------------------------- */ +int GDALBridgeInitialize( const char *, FILE * ); +void *GBGetSymbol( const char *, const char * ); + +/* -------------------------------------------------------------------- */ +/* Terminate C context. */ +/* -------------------------------------------------------------------- */ +#ifdef __cplusplus +} +#endif + +#endif /* ndef GDALBRIDGE_H_INCLUDED */ diff --git a/Utilities/GDAL/config.guess b/Utilities/GDAL/config.guess new file mode 100755 index 0000000000..c38553dc74 --- /dev/null +++ b/Utilities/GDAL/config.guess @@ -0,0 +1,1497 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2006-02-23' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner <per@bothner.com>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:MSYS_NT-*:*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[345]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[345]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/Utilities/GDAL/doc/ERMapperlogo_small.gif b/Utilities/GDAL/doc/ERMapperlogo_small.gif new file mode 100644 index 0000000000000000000000000000000000000000..e4aa251a317820098349eb9987e2bca3cf2e1f95 GIT binary patch literal 1106 zcmZ?wbhEHboW-EWu!sQ!{{R2)<mhzn{rjcIk7>^9sjjX5|Np<@PZmZ726hG=kP47m z2Il_~yYBomIOVx|uf^-LyZ<L>^rd97F)di9ldY3^n~N>+WWMu>Z!gOYCHd4uo~ao% zCSQN`cixPI!qO>zq31d-BtCH5FSatlM=w0wq&Z4=83#MBwgUG$>!#zJ|1QSvycogT z&{)=57?Rk*uT#ROr&Z~btX;yARLPZXHm!@Bc^2awEiZnS+Qq%u`iuChMc4IB@t9J_ zUCZX^$6U0D%ZDM$$#4HbXP)J{GcuTU*3PXuKkw{jEyk@}hKq`~g)<Z^Y(BK_Vcg8{ z%8a0MFH=)0H_UTfB6Rj9cim2|Ga)R?dLExF*r@QeyUW3ZA@Jwx)U_ve<$Vs|$+^DB z$<~8YRmf^;`~PGo2EmEBQWZU{G8J;7XI5PFP<CP4GpS}Vn}UOU(Ds;b220hvPc<2D zRAj2+cx=Mv9_#R$O-L=+$>d<@<sVA-h0MH`n&lRFom}7XtS9J|yP2jl#|M>;g&CjD zheU2#)22J=@oS-$BkvYf?OOXVWa~wxC0Du5<od3vYjt}1RBJuop2q!RdoDd*@!&v) z;b~);um+W*wG%7bJ{udQ^z?t13R(JU_R}*fG<mjl8mziD$I9_{NXqor7p`wPnzxnL z;@hP|F<F;)hn;)%`q=*^C$(mz#xGEC%w4y${H@XMvXl;q=Vo1-Pj&4&zj{XJnmpm! z6LwX~_M$h>oPEVFUauv$^Zlp)M>?;?^9LnNy_%vB`S2bOSCRRJ>Ypc%O|RShb=#fz zx4ath7TirCM{GFM4mOm!DO{D!`P0~T(p{UYh_^G{q18v>zsI!)Op_!JH<(?tTrpqK z;nS5MCziDnWAkk!C*1Au<l}rYSu#SRaY{f~Ci~Q-8tG4`#V4%1UJ%pvvU&Q-M$Kn4 zl_%_6JS}4z=b=e?W(?_bO6&|B7=Jxj**uR|<bet&>zT;o3<UxQp0nTop?Pp_!5zs1 z=Dl)UDGS1+q_~#;Dp{~%5x>Bx7mF+IMLMjg=(Ez2Y3y3HV&Sq!8LN0#31w-m+RQc~ zYwf;0R;zf|-@3JG{pxd4+4Jf)d1<bWRH%Nr;{WM$Sz61A?4n<(u~@u%K6lS4tA?f5 zqh_t%c2{cG$t^c-b>;57AElMIwQZhshW+$yr(bNHlh>WT`|Z73&5M6#-CnnL58J8C zEtO2(>vv9{^?JqD)=w|j9@yp9Ww3n}-<o%O1&qC4uHB_IVdGJW_^6M5=fiT=AK$a= zj^@&9c}m&`p5FUqw3qL+Oy2g(hja{f8^`X^*}Zhpt91t+Y_dMH+rxO*Tk}ufls_N7 zns@8ce(vpAZ`Xg>ms7NEchjji8_rkhXm7Sy*R*k?<LvAVUWxfuIqUr9uX)3?_g&PQ zc|TX(dCB7RIX3su{iq467Rc!A{IYyzUq{BHeyw+mTY|Y}zh-52PRxHQUh3vx!8tqq X-OuL>+Vy_DSTa5D*GmBv1_o;YT3;A( literal 0 HcmV?d00001 diff --git a/Utilities/GDAL/doc/api.dox b/Utilities/GDAL/doc/api.dox new file mode 100644 index 0000000000..0f4c6bb6e0 --- /dev/null +++ b/Utilities/GDAL/doc/api.dox @@ -0,0 +1,84 @@ +/*! + +\typedef int GDALProgressFunc + +GDALProcessFunc is a typedef defining the signature of functions to be +used with GDAL as callbacks to report the progress of long running processes. +Typically these are functions that would update a GUI progress bar showing how +much of a process is done. + +A number of GDAL functions and methods accept GDALProcessFunc arguments along +with an opaque application supplied data item (pProgressArg) which are then +used to implement progress reporting. The GDALDataset::BuildOverviews(), and +GDALDriver::CreateCopy() methods are examples of two methods that utilize +the progress semantics. + +\code + int (*GDALProgressFunc)(double dfComplete, const char *pszMessage, + void *pProgressArg); +\endcode + +@param dfComplete The ratio of completness of the process from 0.0 for just +started to 1.0 for completed. + +@param pszMessage An optional message string to display. This is usually NULL. + +@param pProgressArg Application supplied opaque data normally used by the +callback to display the result. + +@return TRUE if the operation should continue or FALSE if the user has +requested a cancel. + +For example, an application might implement the following simple +text progress reporting mechanism, using pData to pass a default message: + +\code + int MyTextProgress( double dfComplete, const char *pszMessage, void *pData) + { + if( pszMessage != NULL ) + printf( "%d%% complete: %s\n", (int) (dfComplete*100), pszMessage ); + else if( pData != NULL ) + printf( "%d%% complete:%s\n", (int) (dfComplete*100), + (char) pData ); + else + printf( "%d%% complete.\n", (int) (dfComplete*100) ); + + return TRUE; + } +\endcode + +This could be utilized with the GDALDataset::BuildOverviews() method like +this: + +\code + int anOverviewList[3] = {2, 4, 8}; + + poDataset->BuildOverviews( "NEAREST", 3, anOverviewList, 0, NULL, + MyTextProgress, "building overviews" ); +\endcode + +In addition to reporting progress to the user, the GDALProcessFunc mechanism +also provides a mechanism for a user interface to return a request from the +user to cancel the operation to the algorithm via the return value. If FALSE +is returned, the algorithm should terminate the operation and return as +quickly as possible. + +More often that implementing custom progress functions, applications +will just use existing progress functions like GDALDummyProgress(), +GDALTermProgress() and GDALScaledProgress(). Python scripts also can pass +progress functions. + +Application code implementing GDALProgressFunc semantics should remember +a few things: +<ol> +<li> Be wary of NULL progress functions being passed in. The pfnProgress +argument can be set to GDALDummyProgress() in this case for simplicity. + +<li> Always check the return value to watch for a FALSE indicating the +operation should be terminated. + +<li> The ratio of completeness should vary from 0.0 to 1.0. Please ensure the +exact value 1.0 is always returned at the end of the algorithm as some +gui display mechanisms use this as a clue to popdown the progress monitor. + +*/ diff --git a/Utilities/GDAL/doc/credits.dox b/Utilities/GDAL/doc/credits.dox new file mode 100644 index 0000000000..0076cb0566 --- /dev/null +++ b/Utilities/GDAL/doc/credits.dox @@ -0,0 +1,148 @@ +#ifndef DOXYGEN_SKIP +/* $Id: credits.dox,v 1.6 2006/01/05 14:03:54 fwarmerdam Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page credits Acknowledgements and Credits + +There are too many people who have helped since GDAL/OGR was launched in +late 1998 for me to thank them all. I have received moral support, +financial support, code contributions, sample datasets, and bug reports +from literally hundreds of people. However, below I would like to single +out a few people and organizations who have supported GDAL over the +years. Forgive me for all those I left out.<p> + +<i>Frank Warmerdam</i><p> + +\section credits_sponsorship Sponsorship + +<a href="http://www.ermapper.com/">ER Mapper</a> has generously provided +ongoing primary sponsorship for GDAL since February 2005 to support work on +GDAL improvement efforts not focused on any particular client project.<p> + +\section credits_personal Personal + +<ul> +<li> <b>Andrey Kiselev</b>: my right hand man on GDAL for several years. +He is primarily responsible for the HDF, MrSID, L1B, and PCIDSK drivers. +He has also relieved me of most libtiff maintenance work. <p> + +<li> <b>Daniel Morissette</b>: for his key contributions to CPL library, and +development of the Mapinfo TAB translator.<p> + +<li> <b>Howard Butler</b>: for substantial improvements to the python +bindings.<p> + +<li> <b>Ken Shih</b>: for the bulk of the implementation of the OLE DB +provider.<p> + +<li> <b>Markus Neteler</b>: for various contributions to GDAL documentation +and general supportiveness.<p> + +<li> <b>Silke Reimer</b>: for work on Debian, and RPM packaging as well +as the GDAL man pages.<p> + +<li> <b>Alessandro Amici</b>: for work on configuration and build system, +and for the initial Debian packaging.<p> + +<li> <b>Stephane Villeneuve</b>: for development of the Mapinfo MIF +translator.<p> + +</ul> + +\section credits_cooperate Corporate + +<ul> +<li> <b><a href="http://www.actgate.com/">Applied Coherent +Technologies</a></b>: Supported implementation of the GDAL contour generator, +as well as various improvements to HDF drivers. +<p> + +<li> <b><a href="http://www.atlantis-scientific.com/">Atlantis +Scientific</a></b>: Supported the development of the CEOS, +and a variety of other radar oriented format drivers as well as +development of OpenEV, my day-to-day GDAL image viewer.<p> + +<li> <b><a href="http://www.augsignals.com">A.U.G. Signals</a></b>: +Supported work on the HDF, NITF and ODBC drivers. +<p> + +<li> <b><a href="http://www.avenza.com">Avenza Systems</a></b>: +Supported development of <a href="http://dgnlib.maptools.org/">dgnlib</a>, +the basis of OGR dgn support, as well as preliminary work on image warping +in GDAL. +<p> + +<li> <b><a href="http://www.cadcorp.com">Cadcorp</a></b>: Supported +development of the Virtual Warped Raster capability. +<p> + +<li> <b><a href="http://www.dmsolutions.ca/">DM Solutions Group</a></b>: +Supported the development of the DGN driver, the OGR Arc/Info Binary +Coverage driver, OGR WCTS (Web Coordinate Transformation Server), +OGR VRT driver, ODBC driver, MySQL driver, SQLite driver, OGR JOIN and +OGR C API. +<p> + +<li> <b><a href="http://www.osgis.nl/">OSGIS</a></b> and the +<b>Geo-Information and ICT Department of the Ministry of Transport, Public +Works and Water Management</b>: +Funded the DWG/DXF writing driver in OGR.<p> + +<li> <b><a href="http://www.geosoft.com/">Geosoft</a></b>: Supported +improvements to libtiff (RGBA Strip/Tile access), and the Arc/Info Binary Grid +driver. +<p> + +<li> <b><a href="http://www.geotango.com/">GeoTango</a></b>: Supported +OGR Memory driver, Virtual Raster Filtering, and NITF RPC capabilities. +<p> + +<li> <b><a href="http://www.i3.com">i-cubed</a></b>: Supported the MrSID +driver. +<p> + +<li> <b><a href="http://www.intergraph.com">Intergraph</a></b>: Supported +development of the Erdas Imagine driver. +<p> + +<li> <b><a href="http://www.keyhole.com">Keyhole</a></b>: Supported development +of Erdas Imagine driver, and the GDAL Warp API. +<p> + +<li> <b><a href="http://www.opendap.org">OPeNDAP</a></b>: Supported development +of the OGR OPeNDAP Driver. +<p> + +<li> <b><a href="http://www.pcigeomatics.com/">PCI Geomatics</a></b>: Supported +development of the JPEG2000 (JP2KAK) driver. +<p> + +<li> <b><a href="http://www.pixia.com">Pixia</a></b>: Supported NITF/JPEG2000 +read support. +<p> + +<li> <b><a href="http://www.fao.org/">UN FAO</a></b>: Supported development +of the IDA (WinDisp) driver, and GDAL VB6 bindings.<p> + +<li> <b><a href="http://www.softmaptech.com">SoftMap</a></b>: Supported +initial development of OGR as well as the OGR MapInfo integration. +<p> + +<li> <b><a href="http://www.extendthereach.com/">SRC</a></b>: Supported +development of the OGR OCI (Oracle Spatial) driver. +<p> + +<li> <b><a href="http://www.safe.com/">Safe Software</a></b>: Supported +development of the OGR OLE DB provider, TIGER/Line driver, S-57 driver, +DTED driver, FMEObjects driver, SDTS driver and NTF driver. +<p> + +<li> <b><a href="http://www.environmentyukon.gov.yk.ca/main/index.shtml/"> +Yukon Department of the Environment</a></b>: Supported development of +CDED / USGS DEM Writer. +<p> + +</ul> + +*/ diff --git a/Utilities/GDAL/doc/download.dox b/Utilities/GDAL/doc/download.dox new file mode 100644 index 0000000000..49840b0958 --- /dev/null +++ b/Utilities/GDAL/doc/download.dox @@ -0,0 +1,91 @@ +#ifndef DOXYGEN_SKIP +/* $Id: download.dox,v 1.10 2005/10/27 13:17:49 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page download GDAL Downloads + +\section download_binaries Binary Packages + +\subsection download_binaries_fwtools FWTools + +The FWTools binary releases for Linux and Windows systems include the +full set of GDAL libraries, utilities, python support and documentation +along with lots of other stuff (including the OpenEV viewer). More +information is available at: + +<a href="http://fwtools.maptools.org/">http://fwtools.maptools.org/</a> + +The FWTools binaries for Linux should work on pretty much any modern +Intel Linux system.<p> + +\subsection download_binaries_other Other Binary Packages + +<ol> + +<li> RPMs suitable for Fedora Core are maintained by Schuyler Erle on +the <a href="http://mappinghacks.com">Mapping Hacks</a> site at +<a href="http://mappinghacks.com/rpm/">http://mappinghacks.com/rpm/</a>. +FC4 RPMs are also available from +<a href="http://www.gdal.org/dl/fc4-rpms">Intevation</a>.<p> + +<li> RPMs suitable for SuSe and Mandriva are maintained by GDF Hannover Germany site at +<a href="http://www.gdf-hannover.de/software">http://www.gdf-hannover.de/software</a>.<p> + +<li> Packages for Debian users are available in the official repository +<a href="http://packages.debian.org/libgdal1">http://packages.debian.org/libgdal1</a>.<p> + +<li> Packages for MacOS X are available via Fink from the <a href="http://fink.sourceforge.net/pdb/package.php/gdal">Fink repository</a>. + +<li> For the fink adverse, there is also a build of GDAL distributed as +part of the easy-to-install +<a href="http://wwwamb.bologna.enea.it/forgrass/download.htm">GRASS GIS ON MAC +OS X</a> package by Lorenzo Moretti, and a standalone <a href="http://www.gdal.org/dl/GDAL-1.2.6.dmg">GDAL 1.2.6 installer</a> which includes a Framework +version of the GDAL library.<p> + +<li> For the fink and framework adverse another option is William Kyngesburye's +GISLibs package, <a href="http://www.kyngchaos.com/macosx/downloads.php"> +binaries</a> and +<a href="http://www.kyngchaos.com/macosx/index.php">build instructions</a>.<p> + +</ol> + +\section download_sources Source + +GDAL source releases are available in tar.gz and zip from from the +GDAL primary ftp site, and http mirror site: + +<a href="http://www.gdal.org/dl">http://www.gdal.org/dl</a><p> +<a href="http://gdal.maptools.org/dl/">http://gdal.maptools.org/dl</a><p> + +The <a href="NEWS.html">NEWS</a> file describes features added up to the +most recent public release.<p> + +Late each night a development snapshot is captured from CVS and made available. +These snapshots are not stable releases, and might (on a bad night) not even +build. However, they do contain essentially the latest code. They can be +downloaded from: + +<a href="http://gdal.maptools.org/dl/daily">http://gdal.maptools.org/dl/daily</a><p> + +Refer to the <a href="gdal_building.html">build instructions</a> for how to +build GDAL from source.<p> + +\subsection download_sources_cvs CVS + +The GDAL source is available by anonymous CVS from the cvs.maptools.org +server: + +<pre> +% export CVSROOT=:pserver:cvsanon@cvs.maptools.org:/cvs/maptools/cvsroot +% cvs login +Password: *enter* +% cvs checkout gdal +</pre> + +Update access to the CVS repository can be obtained by arrangement +with the maintainer.<p> + +*/ + + diff --git a/Utilities/GDAL/doc/examples.dox b/Utilities/GDAL/doc/examples.dox new file mode 100644 index 0000000000..dcf8177e66 --- /dev/null +++ b/Utilities/GDAL/doc/examples.dox @@ -0,0 +1,28 @@ +#ifndef DOXYGEN_SKIP +/* $Id: examples.dox,v 1.2 2005/10/27 15:12:49 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdalinfo.c Simple C Example: gdalinfo.c + +\include gdalinfo.c +*/ + +/*! +\page gdalallregister.cpp Standard Driver Registration: gdalallregister.cpp + +\include gdalallregister.cpp +*/ + +/*! +\page jdemdataset.cpp Sample Driver: jdemdataset.cpp + +\include jdemdataset.cpp +*/ + +/*! +\page NEWS NEWS + +\include NEWS +*/ + diff --git a/Utilities/GDAL/doc/faq.dox b/Utilities/GDAL/doc/faq.dox new file mode 100644 index 0000000000..2b3609f941 --- /dev/null +++ b/Utilities/GDAL/doc/faq.dox @@ -0,0 +1,205 @@ +#ifndef DOXYGEN_SKIP +/* $Id: faq.dox,v 1.7 2006/01/05 16:01:52 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page faq GDAL FAQ + +<ol> +<!---------------------------------------------------------------------------> + +<li> <b>What's this OGR Stuff?</b><p> + +The gdal/ogr tree holds source for a vector IO library inspired by +OpenGIS Simple Features. In theory it is separate from GDAL, but currently +they reside in the same source tree and are somewhat entangled. More +information can be found at +<a href="http://ogr.maptools.org/">http://ogr.maptools.org</a>. It is +my plan to properly fold OGR into GDAL properly at some point +in the future. Then GDAL will be a raster and vector library. <p> + +<!---------------------------------------------------------------------------> +<li> <b>How do I add support for a new format?</b><p> + +To some extent this is now covered by the +<a href="gdal_drivertut.html">GDAL Driver Implementation Tutorial</a>.<p> + +<!---------------------------------------------------------------------------> +<li> <b>Can I get a MS Visual Studio Project file for GDAL?</b><p> + +The GDAL developers find it more convenient to build with makefiles +and the Visual Studio NMAKE utility. Maintaining a parallel set of project +files for GDAL is too much work, so there are no project files directly +available from the maintainers. Occasionally other users do prepare such +project files, and you may be able to get them by asking on the gdal-dev list. +However, I would strongly suggest you just use the NMAKE based build system. +With debugging enabled you can still debug into GDAL with Visual Studio.<p> + + +<!---------------------------------------------------------------------------> +<li> <b>Can I build GDAL with Cygwin or MingW?</b> + +GDAL should build with Cygwin using the unix style build methodology. +It is also possible to build with MingW though there are some complications. +The following might work:<p> + +<pre> +./configure --prefix=$PATH_TO_MINGW_ROOT --host=mingw32 \ + --without-libtool --without-python $YOUR_CONFIG_OPTIONS +</pre> + +Using external win32 libraries will often be problematic with either of +these environments - at the least requiring some manual hacking of the +GDALmake.opt file.<p> + +<!---------------------------------------------------------------------------> +<li> <b>Can I build GDAL with Borland C or other C compilers?</b> + +These are not supported compilers for GDAL; however, GDAL is mostly pretty +generic, so if you are willing to take on the onerous task of building an +appropriate makefile / project file it should be possible. You will find +most portability issues in the gdal/port/cpl_port.h file, and you will need +to prepare a gdal/port/cpl_config.h file appropriate to your platform. Using +cpl_config.h.vc as a guide may be useful. <p> + +<!---------------------------------------------------------------------------> + +<li> <a name="license"><b>What exactly was the license terms for GDAL?</b></a><p> + +The following terms are the same as X windows is released under, and is +generally known as the "MIT License". It is intended to give you permission +to do whatever you want with the GDAL source, including building proprietary +commercial software, without further permission from me, or requirement to +distribute your source code. A few portions of GDAL under under slightly +different terms. For instance the libpng, libjpeg, libtiff, and libgeotiff +license terms may vary slightly though I don't think any of them differ +in any significant way. Some external libraries which can be optionally +used by GDAL are under radically different licenses.<p> + +<pre> + Copyright (c) 2000, 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. +</pre> + +<!---------------------------------------------------------------------------> + +<li> <b>What are ``Well Known Text'' projections, and how do I use them?</b><p> + +OpenGIS's <i>Well Known Text</i> is a textual format for defining coordinate +systems. It is loosely based on the EPSG coordinate systems model. While +GDAL itself just passes these definitions around as text strings, there is +also an OGRSpatialReference class in gdal/ogr for manipulating them and +a linkage to <a href="http://www.remotesensing.org/proj">PROJ.4</a> for +transforming between coordinate systems. The +OGRSpatialReference, and PROJ.4 linkaged (but not PROJ.4 itself) is +linked into the GDAL shared library by default. More documentation on WKT +and OGRSpatialReference can be found in the +<a href="http://www.gdal.org/ogr/osr_tutorial.html"> +OGR Projections Tutorial</a>.<p> + + +<!---------------------------------------------------------------------------> + +<li> <b>Can I reproject rasters with GDAL?</b><p> + +Yes, you can use the <a href="gdal_utilities.html#gdalwarp">gdalwarp</a> +utility program or programmatically use the GDALWarpOperation class described +in the <a href="warptut.html">Warp API Tutorial</a>. + +<!---------------------------------------------------------------------------> + +<li> <b>Why won't gdalwarp or gdal_merge write to most formats?</b><p> + +GDAL supports many raster formats for reading, but significantly less formats +for writing. Of the ones supported for writing most are only supported in +<i>create copy</i> mode. Essentially this means they have to be written +sequentially from a provided input copy of the image to be written. +Programs like gdal_merge.py or gdalwarp that write chunks of imagery +non-sequentially cannot easily write to these sequential write formats. +Generally speaking formats that are compressed, such as PNG, JPEG and GIF +are sequential write. Also some formats require information such as the +coordinate system and color table to be known at creation time and so these +are also sequential write formats.<p> + +When you encounter this problem it is generally a good idea to first write +the result to GeoTIFF format, and then translate to the desired target +format.<p> + +To determine which formats support which capabilities, use the --formats +switch with pretty much any GDAL utility. Each driver will include either +<b>rw</b> (read-only), <b>rw</b> (read or sequential write) or <b>rw+</b> +(read, sequential write or random write).<p> + +<!---------------------------------------------------------------------------> + +<li> <b>Is the GDAL library thread-safe?</b><p> + +No, GDAL is not completely thread safe. + +However for GDAL 1.3.0 much work has been done on making some common +scenarios thread safe. In particular for the situation where many +threads are reading from GDAL datasets at once should work as long as +no two threads access the same GDALDataset object at the same time. +However, in this scenario, no threads can be writing to GDAL while others +are reading or chaos may ensue. + +Also, while the GDAL core infrastructure is now thread-safe for this specific +case, only a few drivers have been vetted to be thread safe. + +It is intended that work will continue on improving GDAL's thread safety +in future versions. + +<!--------------------------------------------------------------------------> + +<li> <b>Does GDAL work in different international numeric locales?</b><p> + +No. GDAL makes extensive use of sprintf() and atof() internally to translate +numeric values. If a locale is in effect that modifies formatting of +numbers, altering the role of commas and periods in numbers, then PROJ.4 +will not work. This problem is common in some European locales. + +On unix-like platforms, this problem can be avoided by forcing the use +of the default numeric locale by setting the LC_NUMERIC environment variable +to C. + +e.g. +<pre> +$ export LC_NUMERIC=C +$ gdalinfo abc.tif +</pre> + +<!--------------------------------------------------------------------------> + +<li> <b>How do I "debug" GDAL?</b><p> + +Various helpful debugging information will be produced by GDAL and OGR if +the CPL_DEBUG environment variable is set to the value ON. Review the +documentation for the CPLDebug() function for more information on built-in +debugging messages. + +On Unix operating systems GDAL can be built with the CFG environment variable +set to "debug" to enable debugger support with the -g compiler switch. On +Windows edit the nmake.opt and ensure /Zi appears in the OPTFLAGS variable. + + +</ol> + +*/ + diff --git a/Utilities/GDAL/doc/gdal_building.dox b/Utilities/GDAL/doc/gdal_building.dox new file mode 100644 index 0000000000..93fbe8a78e --- /dev/null +++ b/Utilities/GDAL/doc/gdal_building.dox @@ -0,0 +1,292 @@ +#ifndef DOXYGEN_SKIP +/* $Id: gdal_building.dox,v 1.5 2006/03/28 22:37:53 fwarmerdam Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdal_building Building GDAL From Source + +\section gdal_building_unix Building on Unix + +GDAL has been successfully built on Linux, IRIX, Solaris, BSD, and MacOS X. +On Unix platforms you might be able to build it as follows (assuming it is +unpacked or checked out of CVS as <b>gdal</b>): + +<pre> +% cd gdal +% ./configure +% make +% su +Password: ******** +# make install +# exit +</pre> + +In order to run GDAL after installing it is necessary for the shared +library to be findable. This can often be accomplished by setting +LD_LIBRARY_PATH to include /usr/local/lib.<p> + +Some caveats are:<p> +<ul> + +<li> I depend on GNUmake on Unix platforms. Just get and install it if +you don't already have it.<p> + +<li> GDAL shouldn't have many pre-requisite packages. It includes +built-in versions of libz, libtiff, libgeotiff, libpng, libgif, and libjpeg +if pre-installed versions are not available (or not desirable). + +<li> There are quite a few optional drivers that depend on +\ref gdal_building_libraries "external libraries". +Use <i>configure --help</i> to see the configure options. Some optional libraries +include those for GRASS, FITS, OGDI, HDF4, JPEG2000 and ECW. + +<li> The shared library building is pretty specific to the GNU tool chain. +If you are using something different than GNU C++, then you will likely +finding that the .so files isn't built successfully. You could just link +against the static libraries (normally gdal/gdal.a gdal/ogr/ogr.a +gdal/frmts/o/ *.a gdal/gdal.a gdal/port/cpl.a) or you could hack LD_SHARED +command in gdal/GDALmake.opt to work on your platform. For the SGI +a value of <i>c++ -shared -all</i> is often suitable.<p> + +<li> GDAL, and it's utilities should now build on Cygwin and other platforms +where shared libraries are not supported. However, to build your own +applications against it, you will need to link against a more extensive +set of libraries. The <i>gdal-config --libs</i> command can be used to +determine the library set.<p> + +<li> My "autoconf" logic that checks for libtiff, libpng and libjpeg isn't too +savvy about versions. If it is using pre-installed versions of these +libraries and this support isn't working, rerun <i>configure</i> with +``--with-png=internal'', ``--with-jpeg=internal'', ``--with-geotiff=internal'' +or ``--with-libtiff=internal'' instead. <p> + +<li> To build on IRIX it is generally necessary to hand modify the +GDALmake.opt file resulting from configure, and change "ld -shared" +to "ld -shared -all".<p> + +<li> If you find build problems with one of the format drivers that you +don't care about, just remove the format from the GDAL_FORMATS line +at the bottom of gdal/GDALmake.opt, do a <i>make clean</i>, and <i>make</i>. +This will drop it from the build and default runtime registration. <p> + +<li> If you are trying to install as other than root (to your own tree +set with --prefix) you will likely have problems with the python since it +always tries to install under the site-packages directory for the installed +python tree. If you don't need python support you can suppress it at +configure using --without-python, or override the python module output +directory at configure time with the --with-pymodir=<directory> + +</ul> + +\section gdal_building_win Building on Windows + +GDAL can be built on Win32 platforms using MS VC++ 6.x and MS Visual Studio +.NET (C++). +The source distribution includes NMAKE compatible makefiles for use from +the command shell. For those wanting Visual Studio 7.1 Solution files +(instead of the command line nmake files), Ben Discoe normally makes them +available on the <a href="http://vterrain.org/Distrib/gdal.html">VTerrain +site</a>. Only the nmake file approach is directly supported by the GDAL +maintainer.<p> + +Windows CE is also supported by an alternate set of build files. See +<a href="wince.html">GDAL for Windows CE</a> for details. + +For command line builds you will normally have to have run +the VCVAR32.BAT script that comes with the compiler. For VC 6.x this might be +found at: + +<pre> +C:\\Program Files\\Microsoft Visual Studio\\VC98\\bin\\VCVARS32.BAT +</pre> + +Once the environment is setup, you can cd to the GDAL root directory +and do the following:<p> + +<pre> +C:\\GDAL> nmake /f makefile.vc +</pre> + +Once the build has completed successfully, you can also install the required +GDAL files for using GDAL utilities using the install makefile target. +Ensure that BINDIR, and DATADIR are set appropriately in the nmake.opt file +before doing this. + +<pre> +C:\\GDAL> nmake /f makefile.vc install +</pre> + +If you wish to build your own applications using GDAL you can use the following +command to install all the required libraries, and include files as well. +Ensure that LIBDIR and INCDIR are properly set in the nmake.opt file. + +<pre> +C:\\GDAL> nmake /f makefile.vc devinstall +</pre> + +Projects linking against GDAL should include the directory specified in +INCDIR in the include path, and the directory specified in LIBDIR in their +/LIBPATH. To use gdal link against the gdal_i.lib stub library. + +\subsection gdal_building_win_basic Basic Options + +There are lots of options that can be tweaked by hand in the nmake.opt +file in the GDAL root directory. + +<ul> +<li> <b>BINDIR</b>: Directory in which to install executables, and DLLs if +you use the "nmake /f makefile.vc install" command. + +<li> <b>LIBDIR</b>: Directory in which to install stub library (gdal_i.lib). + +<li> <b>INCDIR</b>: Directory in which to install GDAL/OGR include files. + +<li> <b>DATADIR</b>: Directory in which to install GDAL required data files. + +<li> <b>OPTFLAGS</b>: Set this to contain the desired compiler flags for +compiling. The default is a debug build but there is usually a suitable +alternative for optimized builds commented out in the template file. Please, +note that if you will build GDAL against the third-party libraries +(installed from precompiled binaries or compiled by yourself) you should keep +the run-time linking options for that libraries and for GDAL the same. For +example, if you will use /MD option in <b>OPTFLAGS</b> string (link against +multithreaded dynamic library), the same should be used to build other +libraries, such as HDF4 or JasPer. If you don't have library sources then read +the documentation, supplied with library, to figure out how it was compiled +and set up the same linking option in <b>OPTFLAGS</b>. Mixing different +linking options or release/debug flags will result in build failures or in +crashes during run time. + +</ul> + +\subsection gdal_building_win_advanced Advanced Options + +<ul> + +<li> <b>PY_INST_DIR</b>: Directory to install python modules in. Only +required if Python support is being built. + +<li> <b>PYDIR</b>: The directory where your python tree is installed. +Used to find python include files. If this is set to a directory that +does not exist then python support will be omitted from the build. + +<li> <b>DLLBUILD</b>: Define this (to "1") to force all the OGR utilities +to link against the GDAL DLL instead of building built statically. + +<li> <b>INCLUDE_OGR_FRMTS</b>: Set to "YES" to build OGR formats into +the GDAL dll, or comment out to omit OGR formats from build. + +<li> <b>SETARGV</b>: Point this to the setargv.obj file distributed with +Visual Studio to get wildcard expansion for command line arguments or +leave commented out to omit this. + +<li> <b>ECWDIR/ECWLIB</b>: Uncomment these to enable building with ECW +support, correcting ECWDIR to point to the install location on your system. + +<li> <b>OGDIDIR/OGDIVER/OGDILIB</b>: Uncomment these to enable OGDI +support, correcting the OGDIDIR and OGDIVER values as needed. + +<li> <b>HDF4_DIR</b>: Uncomment, and correct path to enable support for +NCSA HDF Release 4. + +<li> <b>JASPER_DIR/JASPER_INCLUDE/JASPER_LIB</b>: This variables should be +pointed to appropriate directories where JasPer library was installed. JasPer +toolkit needed for JPEG2000 support. + +<li> <b>XERCES_DIR/XERCES_INCLUDE/XERCES_LIB</b>: Uncomment these and +correct XERCES_DIR to enable Xerces XML parser support for GML read support. + +<li> <b>FME_DIR</b>: Uncomment, and correct path to enable support for +FMEObject vector access. + +<li> <b>JPEG_EXTERNAL_LIB/JPEGDIR/JPEG_LIB</b>: Used to be able to link +gdal with an external JPEG library. Uncomment these lines and correct the +paths. + +<li> <b>PNG_EXTERNAL_LIB/PNGDIR/PNG_LIB</b>: Used to be able to link +gdal with an external PNG library. Uncomment these lines and correct the +paths. + +</ul> + +I frequently forget to update the Windows makefiles when I add new files, +so if something comes up missing consider comparing the file lists in the +appropriate makefile.vc against the GNUmakefile or just contact me. <p> + +\section gdal_building_libraries External Libraries + +Several drivers require additional libraries to be installed in your system. +These are: + +<ul> + <li> NCSA HDF library can be downloaded from the + <a href="http://hdf.ncsa.uiuc.edu/">The NCSA HDF Home Page</a> + at the <a href="http://www.ncsa.uiuc.edu/"> + National Center for Supercomputing Applications</a>.<p> + + If your OS distribution already contains prebuilt HDF library you can + use one from the distribution.<p> + + Please note, that NCSA HDF library compiled with several defaults which is + defined in <i>hlimits.h</i> file. For example, <i>hlimits.h</i> defines + the maximum number of opened files: + +<pre> +# define MAX_FILE 32 +</pre> + + If you need open more HDF4 files simultaneously you should change this value + and rebuild HDF4 library (there is no need to rebuild GDAL if it is already + compiled with HDF4 support). + + <li> JPEG2000 support based on JasPer toolkit which can be accessed + from the <a href="http://www.ece.uvic.ca/~mdadams/jasper/"> + The JasPer Project Home Page</a>.<p> + + JasPer itself is a bridge for working with several image file formats. + Only JP2 and JPC parts of JasPer used in GDAL.<p> + + You need modified JasPer library to build this driver with GeoJP2 + support enabled. Modified version can be downloaded from + <a href="ftp://ftp.remotesensing.org/gdal/jasper-1.701.0.uuid.tar.gz"> + ftp://ftp.remotesensing.org/gdal/jasper-1.701.0.uuid.tar.gz</a> + + <li> MrSID driver needs LizardTech decoding software development kit + (DSDK). It is not free software, but you can download it without + charge here: <a href="http://developer.lizardtech.com/"> + http://developer.lizardtech.com/</a>. To enable file creation + capability you need encoding SDK (ESDK). You should contact + <a href="http://www.lizardtech.com">LizardTech</a> to obtain it. + DSDK distributed in binary form and if you are using GCC, please, + ensure that you have the same compiler as was used for DSDK + compilation. It is C++ library, so you may get incompatibilities in + C++ name mangling among different GCC versions (2.95.x and 3.x). + +<li> NetCDF support requires the +<a href="http://www.unidata.ucar.edu/packages/netcdf/">netCDF library</a>. +Once it is built and installed, use the "--with-netcdf=<path to install tree>" +option to configure and build GDAL. Link conflicts have been observed with +the netCDF libraries, and the HDF libraries ... coexistence may not be +practical. NetCDF support has not been built or tested on Windows. <p> + +</ul> + +\section gdal_building_lfs Large File Support + +GDAL supports reading and writing large files (> 2GiB) if it is possible in your +operating system. Notes about large file support on Linux available here: <a +href="http://www.suse.de/~aj/linux_lfs.html">http://www.suse.de/~aj/linux_lfs.html</a>. +In short: if you have kernel 2.4.x and glibc 2.2.x you are in luck. Maximum +file size depends on cluster size. For ext2 filesystem with 1 KiB clusters it is 16448 +MiB, for ext2 with 4 KiB clusters it is 2048 GiB. Other filesystems can handle +even larger files.<p> + +Information about large file support in Windows could be obtained at <a +href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/supported_file_systems.asp"> +MSDN</a>. In short, maximum file size at NTFS is limited by (2^64 - 1) bytes, at +FAT32 and FAT16 it is (2^32 - 1) bytes. So don't try create files larger +than 4 GiB on FAT32. In some cases you will not get an error message during +jumping over 4GiB barrier, but all your data will be lost. This is not a GDAL +bug, this is Windows problem.<p> + +*/ diff --git a/Utilities/GDAL/doc/gdal_datamodel.dox b/Utilities/GDAL/doc/gdal_datamodel.dox new file mode 100644 index 0000000000..62641437fb --- /dev/null +++ b/Utilities/GDAL/doc/gdal_datamodel.dox @@ -0,0 +1,310 @@ +/* $Id: gdal_datamodel.dox,v 1.6 2006/01/11 02:49:55 fwarmerdam Exp $ */ + +/*! +\page gdal_datamodel GDAL Data Model + +This document attempts to describe the GDAL data model. That is the +types of information that a GDAL data store can contain, and their +semantics.<p> + +\section gdal_datamodel_dataset Dataset + +A dataset (represented by the GDALDataset class) is an assembly of +related raster bands and some information common to them all. In particular +the dataset has a concept of the raster size (in pixels and lines) that +applies to all the bands. The dataset is also responsible for the +georeferencing transform and coordinate system definition of all bands. The +dataset itself can also have associated metadata, a list of name/value +pairs in string form. + +Note that the GDAL dataset, and raster band data model is loosely +based on the OpenGIS Grid Coverages specification. + +\subsection gdal_datamodel_dataset_cs Coordinate System + +Dataset coordinate systems are represented as OpenGIS Well Known Text +strings. This can contain: + +<ul> +<li> An overall coordinate system name. +<li> A geographic coordinate system name. +<li> A datum identifier. +<li> An ellipsoid name, semi-major axis, and inverse flattening. +<li> A prime meridian name and offset from Greenwich. +<li> A projection method type (ie. Transverse Mercator). +<li> A list of projection parameters (ie. central_meridian). +<li> A units name, and conversion factor to meters or radians. +<li> Names and ordering for the axes. +<li> Codes for most of the above in terms of predefined coordinate systems +from authorities such as EPSG. +</ul> + +For more information on OpenGIS WKT coordinate system definitions, and +mechanisms to manipulate them, refer to the <a href="ogr/osr_tutorial.html"> +osr_tutorial</a> document and/or the OGRSpatialReference class documentation. + +The coordinate system returned by GDALDataset::GetProjectionRef() +describes the georeferenced coordinates implied by the affine georeferencing +transform returned by GDALDataset::GetGeoTransform(). The coordinate +system returned by GDALDataset::GetGCPProjection() describes the +georeferenced coordinates of the GCPs returned by GDALDataset::GetGCPs(). + +Note that a returned coordinate system strings of "" indicates nothing +is known about the georeferencing coordinate system. + +\subsection gdal_datamodel_dataset_gtm Affine GeoTransform + +GDAL datasets have two ways of describing the relationship between +raster positions (in pixel/line coordinates) and georeferenced coordinates. +The first, and most commonly used is the affine transform (the other is +GCPs). + +The affine transform consists of six coefficients returned by +GDALDataset::GetGeoTransform() which map pixel/line coordinates into +georeferenced space using the following relationship: + +<pre> + Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2) + Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5) +</pre> + +In case of north up images, the GT(2) and GT(4) coefficients are zero, and +the GT(1) is pixel width, and GT(5) is pixel height. The (GT(0),GT(3)) +position is the top left corner of the top left pixel of the raster. + +Note that the pixel/line coordinates in the above are from (0.0,0.0) at the +top left corner of the top left pixel to (width_in_pixels,height_in_pixels) +at the bottom right corner of the bottom right pixel. The pixel/line location +of the center of the top left pixel would therefore be (0.5,0.5). + +\subsection gdal_datamodel_dataset_gcp GCPs + +A dataset can have a set of control points relating one or more positions +on the raster to georeferenced coordinates. All GCPs share a georeferencing +coordinate system (returned by GDALDataset::GetGCPProjection()). Each GCP +(represented as the GDAL_GCP class) contains the following: + +<pre> +typedef struct +{ + char *pszId; + char *pszInfo; + double dfGCPPixel; + double dfGCPLine; + double dfGCPX; + double dfGCPY; + double dfGCPZ; +} GDAL_GCP; +</pre> + +The pszId string is intended to be a unique (and often, but not always +numerical) identifier for the GCP within the set of GCPs on this dataset. +The pszInfo is usually an empty string, but can contain any user defined +text associated with the GCP. Potentially this can also contain machine +parsable information on GCP status though that isn't done at this time. + +The (Pixel,Line) position is the GCP location on the raster. The (X,Y,Z) +position is the associated georeferenced location with the Z often being +zero. + +The GDAL data model does not imply a transformation mechanism that must +be generated from the GCPs ... this is left to the application. However +1st to 5th order polynomials are common. + +Normally a dataset will contain either an affine geotransform, GCPs or +neither. It is uncommon to have both, and it is undefined which is +authoritative. + +\subsection gdal_datamodel_dataset_metadata Metadata + +GDAL metadata is auxiliary format and application specific textual data +kept as a list of name/value pairs. The names are required to be well +behaved tokens (no spaces, or odd characters). The values can be of +any length, and contain anything except an embedded null (ASCII zero). + +The metadata handling system is not well tuned to handling very large bodies +of metadata. Handling of more than 100K of metadata for a dataset is likely +to lead to performance degradation. + +Over time there will be some well known names defined with established +semantics; however, that has not occurred at this time. + +Some formats will support generic (user defined) metadata, while other +format drivers will map specific format fields to metadata names. For +instance the TIFF driver returns a few information tags as metadata +including the date/time field which is returned as: + +<pre> +TIFFTAG_DATETIME=1999:05:11 11:29:56 +</pre> + +Metadata is split into named groups called domains, with the default +domain having no name (NULL or ""). Some specific domains exist for +special purposes. Note that currently there is no way to enumerate all +the domains available for a given object, but applications can "test" for +any domains they know how to interprete. + +\subsubsection gdal_datamodel_subdatasets SUBDATASETS Domain + +The SUBDATASETS domain holds a list of child datasets. Normally this is +used to provide pointers to a list of images stored within a single multi +image file (such as HDF or NITF). For instance, an NITF with four images +might have the following subdataset list. + +<pre> + SUBDATASET_1_NAME=NITF_IM:0:multi_1b.ntf + SUBDATASET_1_DESC=Image 1 of multi_1b.ntf + SUBDATASET_2_NAME=NITF_IM:1:multi_1b.ntf + SUBDATASET_2_DESC=Image 2 of multi_1b.ntf + SUBDATASET_3_NAME=NITF_IM:2:multi_1b.ntf + SUBDATASET_3_DESC=Image 3 of multi_1b.ntf + SUBDATASET_4_NAME=NITF_IM:3:multi_1b.ntf + SUBDATASET_4_DESC=Image 4 of multi_1b.ntf + SUBDATASET_5_NAME=NITF_IM:4:multi_1b.ntf + SUBDATASET_5_DESC=Image 5 of multi_1b.ntf +</pre> + +The value of the _NAME is the string that can be passed to GDALOpen() to +access the file. The _DESC value is intended to be a more user friendly +string that can be displayed to the user in a selector. + +\subsubsection gdal_datamodel_image_structure IMAGE_STRUCTURE Domain + +Metadata in the default domain is intended to be related to the +image, and not particularly related to the way the image is stored on +disk. That is, it is suitable for copying with the dataset when it is +copied to a new format. Some information of interest is closely tied +to a particular file format and storage mechanism. In order to prevent +this getting copied along with datasets it is placed in a special domain +called IMAGE_STRUCTURE that should not normally be copied to new formats. + +One item that appears in the IMAGE_STRUCTURE domain is the compression +scheme used for a fromat. The metadata item name is COMPRESSION but the +value can be format specific. + +\subsubsection gdal_datamodel_xml xml: Domains + +Any domain name prefixed with "xml:" is not normal name/value metadata. +It is a single XML document stored in one big string. + + +\section gdal_datamodel_rasterband Raster Band + +A raster band is represented in GDAL with the GDALRasterBand class. It +represents a single raster band/channel/layer. It does not necessarily +represent a whole image. For instance, a 24bit RGB image would normally +be represented as a dataset with three bands, one for red, one for green +and one for blue. + +A raster band has the following properties: + +<ul> + +<li> A width and height in pixels and lines. This is the same as that +defined for the dataset, if this is a full resolution band. + +<li> A datatype (GDALDataType). One of Byte, UInt16, Int16, UInt32, Int32, +Float32, Float64, and the complex types CInt16, CInt32, CFloat32, and CFloat64. + +<li> A block size. This is a preferred (efficient) access chunk size. For +tiled images this will be one tile. For scanline oriented images this will +normally be one scanline. + +<li> A list of name/value pair metadata in the same format as the dataset, +but of information that is potentially specific to this band. + +<li> An optional description string. + +<li> An optional list of category names (effectively class names in a +thematic image). + +<li> An optional minimum and maximum value. + +<li> An optional offset and scale for transforming raster values into meaning +full values (ie translate height to meters) + +<li> An optional raster unit name. For instance, this might indicate linear +units for elevation data. + +<li> A color interpretation for the band. This is one of: + + <ul> + <li> GCI_Undefined: the default, nothing is known. + <li> GCI_GrayIndex: this is an independent grayscale image + <li> GCI_PaletteIndex: this raster acts as an index into a color table + <li> GCI_RedBand: this raster is the red portion of an RGB or RGBA image + <li> GCI_GreenBand: this raster is the green portion of an RGB or RGBA image + <li> GCI_BlueBand: this raster is the blue portion of an RGB or RGBA image + <li> GCI_AlphaBand: this raster is the alpha portion of an RGBA image + <li> GCI_HueBand: this raster is the hue of an HLS image + <li> GCI_SaturationBand: this raster is the saturation of an HLS image + <li> GCI_LightnessBand: this raster is the hue of an HLS image + <li> GCI_CyanBand: this band is the cyan portion of a CMY or CMYK image + <li> GCI_MagentaBand: this band is the magenta portion of a CMY or CMYK image + <li> GCI_YellowBand: this band is the yellow portion of a CMY or CMYK image + <li> GCI_BlackBand: this band is the black portion of a CMYK image. + </ul> + +<li> A color table, described in more detail later. + +<li> Knowledge of reduced resolution overviews (pyramids) if available. + +</ul> + +\section gdal_datamodel_rasterband_ct Color Table + +A color table consists of zero or more color entries described in C by the +following structure: + +<pre> +typedef struct +{ + /- gray, red, cyan or hue -/ + short c1; + + /- green, magenta, or lightness -/ + short c2; + + /- blue, yellow, or saturation -/ + short c3; + + /- alpha or blackband -/ + short c4; +} GDALColorEntry; +</pre> + +The color table also has a palette interpretation value (GDALPaletteInterp) +which is one of the following values, and indicates how the c1/c2/c3/c4 values +of a color entry should be interpreted. + +<ul> +<li> GPI_Gray: Use c1 as grayscale value. +<li> GPI_RGB: Use c1 as red, c2 as green, c3 as blue and c4 as alpha. +<li> GPI_CMYK: Use c1 as cyan, c2 as magenta, c3 as yellow and c4 as black. +<li> GPI_HLS: Use c1 as hue, c2 as lightness, and c3 as saturation. +</ul> + +To associate a color with a raster pixel, the pixel value is used as a +subscript into the color table. That means that the colors are always +applied starting at zero and ascending. There is no provision for indicating +a prescaling mechanism before looking up in the color table. + +\section gdal_datamodel_rasterband_overviews Overviews + +A band may have zero or more overviews. Each overview is represented as +a "free standing" GDALRasterBand. The size (in pixels and lines) of the +overview will be different than the underlying raster, but the geographic +region covered by overviews is the same as the full resolution band. + +The overviews are used to display reduced resolution overviews more quickly +than could be done by reading all the full resolution data and downsampling. + +Bands also have a HasArbitraryOverviews property which is TRUE if the +raster can be read at any resolution efficiently but with no distinct +overview levels. This applies to some FFT encoded images, or images pulled +through gateways (like OGDI) where downsampling can be done efficiently +at the remote point. + +*/ + + diff --git a/Utilities/GDAL/doc/gdal_drivertut.dox b/Utilities/GDAL/doc/gdal_drivertut.dox new file mode 100644 index 0000000000..39ddaece2d --- /dev/null +++ b/Utilities/GDAL/doc/gdal_drivertut.dox @@ -0,0 +1,1023 @@ +#ifndef DOXYGEN_SKIP +/* $Id: gdal_drivertut.dox,v 1.3 2005/10/27 13:54:32 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdal_drivertut GDAL Driver Implementation Tutorial + +\section gdal_drivertut_overall Overall Approach + +In general new formats are added to GDAL by implementing format specific +drivers as subclasses of GDALDataset, and band accessors as subclasses +of GDALRasterBand. As well, a GDALDriver instance is created for the +format, and registered with the GDALDriverManager, to ensure that the system +<i>knows</i> about the format. + +This tutorial will start with implementing a simple read-only driver +(based on the JDEM driver), and then proceed to utilizing the RawRasterBand +helper class, implementing creatable and updatable formats, and some +esoteric issues. + +It is strongly advised that the <a href="gdal_datamodel.html">GDAL Data Model +</a> description be reviewed and understood before attempting to implement a +GDAL driver. + +\section gdal_drivertut_toc Contents + +<ol> +<li> \ref gdal_drivertut_dataset +<li> \ref gdal_drivertut_rasterband +<li> \ref gdal_drivertut_driver +<li> \ref gdal_drivertut_addingdriver +<li> \ref gdal_drivertut_georef +<li> \ref gdal_drivertut_overviews +<li> \ref gdal_drivertut_creation +<li> \ref gdal_drivertut_raw +<li> \ref gdal_drivertut_metadata +</ol> + +\section gdal_drivertut_dataset Implementing the Dataset + +We will start showing minimal implementation of a read-only driver for +the Japanese DEM format (<a href="jdemdataset.cpp.html">jdemdataset.cpp</a>). +First we declare a format +specific dataset class, JDEMDataset in this case. + +\code +class JDEMDataset : public GDALDataset +{ + FILE *fp; + GByte abyHeader[1012]; + + public: + ~JDEMDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); +}; +\endcode + +In general we provide capabilities for a driver, by overriding the various +virtual methods on the GDALDataset base class. However, the Open() method +is special. This is not a virtual method on the base class, and we will +need a freestanding function for this operation, so we declare it static. +Implementing it as a method in the JDEMDataset class is convenient because +we have privileged access to modify the contents of the database object. + +The open method itself may look something like this: + +\verbatim +GDALDataset *JDEMDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +// -------------------------------------------------------------------- +// Before trying JDEMOpen() we first verify that there is at +// least one "\n#keyword" type signature in the first chunk of +// the file. +// -------------------------------------------------------------------- + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 50 ) + return NULL; + + // check if century values seem reasonable + if( (!EQUALN((char *)poOpenInfo->pabyHeader+11,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+11,"20",2)) + || (!EQUALN((char *)poOpenInfo->pabyHeader+15,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+15,"20",2)) + || (!EQUALN((char *)poOpenInfo->pabyHeader+19,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+19,"20",2)) ) + { + return NULL; + } + +// -------------------------------------------------------------------- +// Create a corresponding GDALDataset. +// -------------------------------------------------------------------- + JDEMDataset *poDS; + + poDS = new JDEMDataset(); + + poDS->fp = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +// -------------------------------------------------------------------- +// Read the header. +// -------------------------------------------------------------------- + VSIFSeek( poDS->fp, 0, SEEK_SET ); + VSIFRead( poDS->abyHeader, 1, 1012, poDS->fp ); + + poDS->nRasterXSize = JDEMGetField( (char *) poDS->abyHeader + 23, 3 ); + poDS->nRasterYSize = JDEMGetField( (char *) poDS->abyHeader + 26, 3 ); + +// -------------------------------------------------------------------- +// Create band information objects. +// -------------------------------------------------------------------- + poDS->nBands = 1; + poDS->SetBand( 1, new JDEMRasterBand( poDS, 1 )); + + return( poDS ); +} +\endverbatim + +The first step in any database Open function is to verify that the file +being passed is in fact of the type this driver is for. It is important +to realize that each driver's Open function is called in turn till one +succeeds. Drivers must quietly return NULL if the passed file is not of +their format. They should only produce an error if the file does appear to +be of their supported format, but is for some reason unsupported or corrupt. + +The information on the file to be opened is passed in contained in a +GDALOpenInfo object. The GDALOpenInfo includes the following public +data members: + +\code + char *pszFilename; + + GDALAccess eAccess; // GA_ReadOnly or GA_Update + + GBool bStatOK; + VSIStatBuf sStat; + + FILE *fp; + + int nHeaderBytes; + GByte *pabyHeader; +\endcode + +The driver can inspect these to establish if the file is supported. If the +pszFilename refers to an object in the file system, the <b>bStatOK</b> flag +will be set, and the <b>sStat</b> structure will contain normal stat() +information about the object (be it directory, file, device). If the object +is a regular readable file, the <b>fp</b> will be non-NULL, and can be used +for reads on the file (please use the VSI stdio functions from +cpl_vsi.h). As well, if the file was successfully opened, the first kilobyte +or so is read in, and put in <b>pabyHeader</b>, with the exact size in +<b>nHeaderBytes</b>. + +In this typical testing example it is verified that the file was successfully +opened, that we have at least enough header information to perform our test, +and that various parts of the header are as expected for this format. In +this case, there are no <i>magic</i> numbers for JDEM format so we check +various date fields to ensure they have reasonable century values. If the +test fails, we quietly return NULL indicating this file isn't of our supported +format. + +\code + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 50 ) + return NULL; + + // check if century values seem reasonable + if( (!EQUALN((char *)poOpenInfo->pabyHeader+11,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+11,"20",2)) + || (!EQUALN((char *)poOpenInfo->pabyHeader+15,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+15,"20",2)) + || (!EQUALN((char *)poOpenInfo->pabyHeader+19,"19",2) + && !EQUALN((char *)poOpenInfo->pabyHeader+19,"20",2)) ) + { + return NULL; + } +\endcode + +It is important to make the <i>is this my format</i> test as stringent as +possible. In this particular case the test is weak, and a file that happened +to have 19s or 20s at a few locations could be erroneously recognized as +JDEM format, causing it to not be handled properly. + +Once we are satisfied that the file is of our format, we need to create +an instance of the database class in which we will set various information +of interest. + +\code + JDEMDataset *poDS; + + poDS = new JDEMDataset(); + + poDS->fp = poOpenInfo->fp; + poOpenInfo->fp = NULL; +\endcode + +Generally at this point we would open the file, to acquire a file handle +for the dataset; however, if read-only access is sufficient it is permitted +to <b>assume ownership</b> of the FILE * from the GDALOpenInfo object. +Just ensure that it is set to NULL in the GDALOpenInfo to avoid having it +get closed twice. It is also important to note that the state of the +FILE * adopted is indeterminate. Ensure that the current location is reset +with VSIFSeek() before assuming you can read from it. This is accomplished +in the following statements which reset the file and read the header. + +\code + VSIFSeek( poDS->fp, 0, SEEK_SET ); + VSIFRead( poDS->abyHeader, 1, 1012, poDS->fp ); +\endcode + +Next the X and Y size are extracted from the header. The nRasterXSize and +nRasterYSize are data fields inherited from the GDALDataset base class, and +must be set by the Open() method. + +\code + poDS->nRasterXSize = JDEMGetField( (char *) poDS->abyHeader + 23, 3 ); + poDS->nRasterYSize = JDEMGetField( (char *) poDS->abyHeader + 26, 3 ); +\endcode + +Finally, all the bands related to this dataset must be attached using +the SetBand() method. We will explore the JDEMRasterBand() class shortly. + +\code + poDS->SetBand( 1, new JDEMRasterBand( poDS, 1 )); + + return( poDS ); +\endcode + +\section gdal_drivertut_rasterband Implementing the RasterBand + +Similar to the customized JDEMDataset class subclassed from GDALDataset, +we also need to declare and implement a customized JDEMRasterBand derived +from GDALRasterBand for access to the band(s) of the JDEM file. For +JDEMRasterBand the declaration looks like this: + +\code +class JDEMRasterBand : public GDALRasterBand +{ + public: + JDEMRasterBand( JDEMDataset *, int ); + virtual CPLErr IReadBlock( int, int, void * ); +}; +\endcode + +The constructor may have any signature, and is only called from the Open() +method. Other virtual methods, such as IReadBlock() must be exactly +matched to the method signature in gdal_priv.h. + +The constructor implementation looks like this: + +\code +JDEMRasterBand::JDEMRasterBand( JDEMDataset *poDS, int nBand ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + eDataType = GDT_Float32; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; +} +\endcode + +The following data members are inherited from GDALRasterBand, and should +generally be set in the band constructor. + +<ul> +<li> <b>poDS</b>: Pointer to the parent GDALDataset. +<li> <b>nBand</b>: The band number within the dataset. +<li> <b>eDataType</b>: The data type of pixels in this band. +<li> <b>nBlockXSize</b>: The width of one block in this band. +<li> <b>nBlockYSize</b>: The height of one block in this band. +</ul> + +The full set of possible GDALDataType values are declared in gdal.h, and +include GDT_Byte, GDT_UInt16, GDT_Int16, and GDT_Float32. The block size is +used to establish a <i>natural</i> or efficient block size to access the data +with. For tiled datasets this will be the size of a tile, while for most +other datasets it will be one scanline, as in this case. + +Next we see the implementation of the code that actually reads the image +data, IReadBlock(). + +\code +CPLErr JDEMRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + JDEMDataset *poGDS = (JDEMDataset *) poDS; + char *pszRecord; + int nRecordSize = nBlockXSize*5 + 9 + 2; + int i; + + VSIFSeek( poGDS->fp, 1011 + nRecordSize*nBlockYOff, SEEK_SET ); + + pszRecord = (char *) CPLMalloc(nRecordSize); + VSIFRead( pszRecord, 1, nRecordSize, poGDS->fp ); + + if( !EQUALN((char *) poGDS->abyHeader,pszRecord,6) ) + { + CPLFree( pszRecord ); + + CPLError( CE_Failure, CPLE_AppDefined, + "JDEM Scanline corrupt. Perhaps file was not transferred\n" + "in binary mode?" ); + return CE_Failure; + } + + if( JDEMGetField( pszRecord + 6, 3 ) != nBlockYOff + 1 ) + { + CPLFree( pszRecord ); + + CPLError( CE_Failure, CPLE_AppDefined, + "JDEM scanline out of order, JDEM driver does not\n" + "currently support partial datasets." ); + return CE_Failure; + } + + for( i = 0; i < nBlockXSize; i++ ) + ((float *) pImage)[i] = JDEMGetField( pszRecord + 9 + 5 * i, 5) * 0.1; + + return CE_None; +} +\endcode + +Key items to note are: + +<ul> +<li> It is typical to cast the GDALRasterBand::poDS member to the derived +type of the owning dataset. If your RasterBand class will need privileged +access to the owning dataset object, ensure it is declared as a friend (omitted +above for brevity). + +<li> If an error occurs, report it with CPLError(), and return CE_Failure. +Otherwise return CE_None. + +<li> The pImage buffer should be filled with one block of data. The block +is the size declared in nBlockXSize and nBlockYSize for the raster band. The +type of the data within pImage should match the type declared in +eDataType in the raster band object. + +<li> The nBlockXOff and nBlockYOff are block offsets, so with 128x128 tiled +datasets values of 1 and 1 would indicate the block going from (128,128) to +(255,255) should be loaded. + +</ul> + +\section gdal_drivertut_driver The Driver + +While the JDEMDataset and JDEMRasterBand are now ready to use to read image +data, it still isn't clear how the GDAL system knows about the new driver. +This is accomplished via the GDALDriverManager. To register our format we +implement a registration function: + +\code +CPL_C_START +void GDALRegister_JDEM(void); +CPL_C_END + +... + +void GDALRegister_JDEM() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "JDEM" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "JDEM" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Japanese DEM (.mem)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#JDEM" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "mem" ); + + poDriver->pfnOpen = JDEMDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} +\endcode + +The registration function will create an instance of a GDALDriver object +when first called, and register it with the GDALDriverManager. The +following fields can be set in the driver before +registering it with the GDALDriverManager(). + +<ul> +<li> The description is the short name for the format. This is a unique +name for this format, often used to identity the driver in scripts and +commandline programs. Normally 3-5 characters in length, and matching the +prefix of the format classes. (mandatory) + +<li> GDAL_DMD_LONGNAME: A longer descriptive name for the file format, +but still no longer than 50-60 characters. (mandatory) + +<li> GDAL_DMD_HELPTOPIC: The name of a help topic to display for this driver, +if any. In this case JDEM format is contained within the various format +web page held in gdal/html. (optional) + +<li> GDAL_DMD_EXTENSION: The extension used for files of this type. If more +than one pick the primary extension, or none at all. (optional) + +<li> GDAL_DMD_MIMETYPE: The standard mime type for this file format, such as +"image/png". (optional) + +<li> GDAL_DMD_CREATIONOPTIONLIST: There is evolving work on mechanisms +to describe creation options. See the geotiff driver for an example of +this. (optional) + +<li> GDAL_DMD_CREATIONDATATYPES: A list of space separated data types +supported by this create when creating new datasets. If a Create() method +exists, these will be will supported. If a CreateCopy() method exists, this +will be a list of types that can be losslessly exported but it may include +weaker data types than the type eventually written. For instance, a format +with a CreateCopy() method, and that always writes Float32 might also list +Byte, Int16, and UInt16 since they can losslessly translated to Float32. An +example value might be "Byte Int16 UInt16". (required - if creation supported) + +<li> pfnOpen: The function to call to try opening files of this format. +(optional) + +<li> pfnCreate: The function to call to create new updatable datasets of this +format. (optional) + +<li> pfnCreateCopy: The function to call to create a new dataset of this format +copied from another source, but not necessary updatable. (optional) + +<li> pfnDelete: The function to call to delete a dataset of this format. +(optional) + +<li> pfnUnloadDriver: A function called only when the driver is destroyed. +Could be used to cleanup data at the driver level. Rarely used. (optional) + +</ul> + +\section gdal_drivertut_addingdriver Adding Driver to GDAL Tree + +Note that the GDALRegister_JDEM() method must be called by the higher +level program in order to have access to the JDEM driver. Normal practice +when writing new drivers is to: + +<ol> +<li> Add a driver directory under gdal/frmts, with the directory name the same +as the short name. + +<li> Add a GNUmakefile and makefile.vc in that directory modelled on those +from other similar directories (ie. the jdem directory). + +<li> Add the module with the dataset, and rasterband implementation. +Generally this is called <short_name>dataset.cpp, with all the GDAL specific +code in one file, though that is not required. + +<li> Add the registration entry point declaration (ie. GDALRegister_JDEM()) to +gdal/gcore/gdal_frmts.h. + +<li> Add a call to the registration function to frmts/gdalallregister.c, +protected by an appropriate #ifdef. + +<li> Add the format short name to the GDAL_FORMATS macro in +GDALmake.opt.in (and to GDALmake.opt). + +<li> Add a format specific item to the EXTRAFLAGS macro in frmts/makefile.vc. +</ol> + +Once this is all done, it should be possible to rebuild GDAL, and have +the new format available in all the utilities. The gdalinfo utility can be +used to test that opening and reporting on the format is working, and the +gdal_translate utility can be used to test image reading. + +\section gdal_drivertut_georef Adding Georeferencing + +Now we will take the example a step forward, adding georeferencing support. +We add the following two virtual method overrides to JDEMDataset, taking +care to exactly match the signature of the method on the GDALRasterDataset +base class. + +\code + CPLErr GetGeoTransform( double * padfTransform ); + const char *GetProjectionRef(); +\endcode + +The implementation of GetGeoTransform() just copies the usual geotransform +matrix into the supplied buffer. Note that GetGeoTransform() may be called +a lot, so it isn't generally wise to do a lot of computation in it. In many +cases the Open() will collect the geotransform, and this method will just +copy it over. Also note that the geotransform return is based on an +anchor point at the top left corner of the top left pixel, not the center +of pixel approach used in some packages. + +\code +CPLErr JDEMDataset::GetGeoTransform( double * padfTransform ) + +{ + double dfLLLat, dfLLLong, dfURLat, dfURLong; + + dfLLLat = JDEMGetAngle( (char *) abyHeader + 29 ); + dfLLLong = JDEMGetAngle( (char *) abyHeader + 36 ); + dfURLat = JDEMGetAngle( (char *) abyHeader + 43 ); + dfURLong = JDEMGetAngle( (char *) abyHeader + 50 ); + + padfTransform[0] = dfLLLong; + padfTransform[3] = dfURLat; + padfTransform[1] = (dfURLong - dfLLLong) / GetRasterXSize(); + padfTransform[2] = 0.0; + + padfTransform[4] = 0.0; + padfTransform[5] = -1 * (dfURLat - dfLLLat) / GetRasterYSize(); + + + return CE_None; +} +\endcode + +The GetProjectionRef() method returns a pointer to an internal string +containing a coordinate system definition in OGC WKT format. In this case +the coordinate system is fixed for all files of this format, but in more +complex cases a definition may need to be composed on the fly, in which case +it may be helpful to use the OGRSpatialReference class to help build the +definition. + +\code +const char *JDEMDataset::GetProjectionRef() + +{ + return( "GEOGCS[\"Tokyo\",DATUM[\"Tokyo\",SPHEROID[\"Bessel 1841\"," + "6377397.155,299.1528128,AUTHORITY[\"EPSG\",7004]],TOWGS84[-148," + "507,685,0,0,0,0],AUTHORITY[\"EPSG\",6301]],PRIMEM[\"Greenwich\"," + "0,AUTHORITY[\"EPSG\",8901]],UNIT[\"DMSH\",0.0174532925199433," + "AUTHORITY[\"EPSG\",9108]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," + "AUTHORITY[\"EPSG\",4301]]" ); +} +\endcode + +This completes explanation of the features of the JDEM driver. The full +source for <a href="jdemdataset.cpp.html">jdemdataset.cpp</a> can be reviewed +as needed. + +\section gdal_drivertut_overviews Overviews + +GDAL allows file formats to make pre-built overviews available to applications +via the GDALRasterBand::GetOverview() and related methods. However, +implementing this is pretty involved, and goes beyond the scope of this +document for now. The GeoTIFF driver (gdal/frmts/gtiff/geotiff.cpp) and +related source can be reviewed for an example of a file format implementing +overview reporting and creation support. + +Formats can also report that they have arbitrary overviews, by overriding +the HasArbitraryOverviews() method on the GDALRasterBand, returning TRUE. +In this case the raster band object is expected to override the RasterIO() +method itself, to implement efficient access to imagery with resampling. +This is also involved, and there are a lot of requirements for correct +implementation of the RasterIO() method. An example of this can be found +in the OGDI and ECW formats. + +However, by far the most common approach to implementing overviews is to +use the default support in GDAL for external overviews stored in TIFF files +with the same name as the dataset, but the extension .ovr appended. In +order to enable reading and creation of this style of overviews it is necessary +for the GDALDataset to initialize the oOvManager object within itself. This +is typically accomplished with a call like the following near the end of the +Open() method. + +\code + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); +\endcode + +This will enable default implementations for reading and creating overviews for +the format. It is advised that this be enabled for all simple file system +based formats unless there is a custom overview mechanism to be tied into. + +\section gdal_drivertut_creation File Creation + +There are two approaches to file creation. The first method is called the +CreateCopy() method, and involves implementing a function that can write a +file in the output format, pulling all imagery and other information needed +from a source GDALDataset. The second method, the dynamic creation method, +involves implementing a Create method to create the shell of the file, and +then the application writes various information by calls to set methods. + +The benefits of the first method are that that all the information is available +at the point the output file is being created. This can be especially +important when implementing file formats using external libraries which +require information like colormaps, and georeferencing information at the +point the file is created. The other advantage of this method is that the +CreateCopy() method can read some kinds of information, such as min/max, +scaling, description and GCPs for which there are no equivalent set methods. + +The benefits of the second method are that applications can create an +empty new file, and write results to it as they become available. A complete +image of the desired data does not have to be available in advance. + +For very important formats both methods may be implemented, otherwise do +whichever is simpler, or provides the required capabilities. + +\subsection gdal_drivertut_creation_createcopy CreateCopy + +The GDALDriver::CreateCopy() method call is passed through directly, so +that method should be consulted for details of arguments. However, some +things to keep in mind are: + +<ul> +<li> If the bStrict flag is FALSE the driver should try to do something +reasonable when it cannot exactly represent the source dataset, transforming +data types on the fly, dropping georeferencing and so forth. + +<li> Implementing progress reporting correctly is somewhat involved. The +return result of the progress function needs always to be checked for +cancellation, and progress should be reported at reasonable intervals. The +JPEGCreateCopy() method demonstrates good handling of the progress function. + +<li> Special creation options should be documented in the online help. +If the options take the format "NAME=VALUE" the papszOptions list can be +manipulated with CPLFetchNameValue() as demonstrated in the handling of +the QUALITY and PROGRESSIVE flags for JPEGCreateCopy(). + +<li> The returned GDALDataset handle can be in ReadOnly or Update mode. +Return it in Update mode if practical, otherwise in ReadOnly mode is fine. + +</ul> + +The full implementation of the CreateCopy function for JPEG (which is +assigned to pfnCreateCopy in the GDALDriver object) is here. + +\verbatim +static GDALDataset * +JPEGCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + int nBands = poSrcDS->GetRasterCount(); + int nXSize = poSrcDS->GetRasterXSize(); + int nYSize = poSrcDS->GetRasterYSize(); + int nQuality = 75; + int bProgressive = FALSE; + +// -------------------------------------------------------------------- +// Some some rudimentary checks +// -------------------------------------------------------------------- + if( nBands != 1 && nBands != 3 ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "JPEG driver doesn't support %d bands. Must be 1 (grey) " + "or 3 (RGB) bands.\n", nBands ); + + return NULL; + } + + if( poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && bStrict ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "JPEG driver doesn't support data type %s. " + "Only eight bit byte bands supported.\n", + GDALGetDataTypeName( + poSrcDS->GetRasterBand(1)->GetRasterDataType()) ); + + return NULL; + } + +// -------------------------------------------------------------------- +// What options has the user selected? +// -------------------------------------------------------------------- + if( CSLFetchNameValue(papszOptions,"QUALITY") != NULL ) + { + nQuality = atoi(CSLFetchNameValue(papszOptions,"QUALITY")); + if( nQuality < 10 || nQuality > 100 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "QUALITY=%s is not a legal value in the range 10-100.", + CSLFetchNameValue(papszOptions,"QUALITY") ); + return NULL; + } + } + + if( CSLFetchNameValue(papszOptions,"PROGRESSIVE") != NULL ) + { + bProgressive = TRUE; + } + +// -------------------------------------------------------------------- +// Create the dataset. +// -------------------------------------------------------------------- + FILE *fpImage; + + fpImage = VSIFOpen( pszFilename, "wb" ); + if( fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to create jpeg file %s.\n", + pszFilename ); + return NULL; + } + +// -------------------------------------------------------------------- +// Initialize JPG access to the file. +// -------------------------------------------------------------------- + struct jpeg_compress_struct sCInfo; + struct jpeg_error_mgr sJErr; + + sCInfo.err = jpeg_std_error( &sJErr ); + jpeg_create_compress( &sCInfo ); + + jpeg_stdio_dest( &sCInfo, fpImage ); + + sCInfo.image_width = nXSize; + sCInfo.image_height = nYSize; + sCInfo.input_components = nBands; + + if( nBands == 1 ) + { + sCInfo.in_color_space = JCS_GRAYSCALE; + } + else + { + sCInfo.in_color_space = JCS_RGB; + } + + jpeg_set_defaults( &sCInfo ); + + jpeg_set_quality( &sCInfo, nQuality, TRUE ); + + if( bProgressive ) + jpeg_simple_progression( &sCInfo ); + + jpeg_start_compress( &sCInfo, TRUE ); + +// -------------------------------------------------------------------- +// Loop over image, copying image data. +// -------------------------------------------------------------------- + GByte *pabyScanline; + CPLErr eErr; + + pabyScanline = (GByte *) CPLMalloc( nBands * nXSize ); + + for( int iLine = 0; iLine < nYSize; iLine++ ) + { + JSAMPLE *ppSamples; + + for( int iBand = 0; iBand < nBands; iBand++ ) + { + GDALRasterBand * poBand = poSrcDS->GetRasterBand( iBand+1 ); + eErr = poBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + pabyScanline + iBand, nXSize, 1, GDT_Byte, + nBands, nBands * nXSize ); + } + + ppSamples = pabyScanline; + jpeg_write_scanlines( &sCInfo, &ppSamples, 1 ); + } + + CPLFree( pabyScanline ); + + jpeg_finish_compress( &sCInfo ); + jpeg_destroy_compress( &sCInfo ); + + VSIFClose( fpImage ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly ); +} +\endverbatim + +\subsection gdal_drivertut_creation_create Dynamic Creation + +In the case of dynamic creation, there is no source dataset. Instead the +size, number of bands, and pixel data type of the desired file is provided +but other information (such as georeferencing, and imagery data) would be +supplied later via other method calls on the resulting GDALDataset. + +The following sample implement PCI .aux labelled raw raster creation. It +follows a common approach of creating a blank, but valid file using non-GDAL +calls, and then calling GDALOpen(,GA_Update) at the end to return a writable +file handle. This avoids having to duplicate the various setup actions in +the Open() function. + +\verbatim +GDALDataset *PAuxDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** // papszParmList ) + +{ + char *pszAuxFilename; + +// -------------------------------------------------------------------- +// Verify input options. +// -------------------------------------------------------------------- + if( eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 + && eType != GDT_Int16 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create PCI .Aux labelled dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + +// -------------------------------------------------------------------- +// Try to create the file. +// -------------------------------------------------------------------- + FILE *fp; + + fp = VSIFOpen( pszFilename, "w" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +// -------------------------------------------------------------------- +// Just write out a couple of bytes to establish the binary +// file, and then close it. +// -------------------------------------------------------------------- + VSIFWrite( (void *) "\0\0", 2, 1, fp ); + VSIFClose( fp ); + +// -------------------------------------------------------------------- +// Create the aux filename. +// -------------------------------------------------------------------- + pszAuxFilename = (char *) CPLMalloc(strlen(pszFilename)+5); + strcpy( pszAuxFilename, pszFilename );; + + for( int i = strlen(pszAuxFilename)-1; i > 0; i-- ) + { + if( pszAuxFilename[i] == '.' ) + { + pszAuxFilename[i] = '\0'; + break; + } + } + + strcat( pszAuxFilename, ".aux" ); + +// -------------------------------------------------------------------- +// Open the file. +// -------------------------------------------------------------------- + fp = VSIFOpen( pszAuxFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszAuxFilename ); + return NULL; + } + +// -------------------------------------------------------------------- +// We need to write out the original filename but without any +// path components in the AuxilaryTarget line. Do so now. +// -------------------------------------------------------------------- + int iStart; + + iStart = strlen(pszFilename)-1; + while( iStart > 0 && pszFilename[iStart-1] != '/' + && pszFilename[iStart-1] != '\\' ) + iStart--; + + VSIFPrintf( fp, "AuxilaryTarget: %s\n", pszFilename + iStart ); + +// -------------------------------------------------------------------- +// Write out the raw definition for the dataset as a whole. +// -------------------------------------------------------------------- + VSIFPrintf( fp, "RawDefinition: %d %d %d\n", + nXSize, nYSize, nBands ); + +// -------------------------------------------------------------------- +// Write out a definition for each band. We always write band +// sequential files for now as these are pretty efficiently +// handled by GDAL. +// -------------------------------------------------------------------- + int nImgOffset = 0; + + for( int iBand = 0; iBand < nBands; iBand++ ) + { + const char * pszTypeName; + int nPixelOffset; + int nLineOffset; + + nPixelOffset = GDALGetDataTypeSize(eType)/8; + nLineOffset = nXSize * nPixelOffset; + + if( eType == GDT_Float32 ) + pszTypeName = "32R"; + else if( eType == GDT_Int16 ) + pszTypeName = "16S"; + else if( eType == GDT_UInt16 ) + pszTypeName = "16U"; + else + pszTypeName = "8U"; + + VSIFPrintf( fp, "ChanDefinition-%d: %s %d %d %d %s\n", + iBand+1, pszTypeName, + nImgOffset, nPixelOffset, nLineOffset, +#ifdef CPL_LSB + "Swapped" +#else + "Unswapped" +#endif + ); + + nImgOffset += nYSize * nLineOffset; + } + +// -------------------------------------------------------------------- +// Cleanup +// -------------------------------------------------------------------- + VSIFClose( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} +\endverbatim + +File formats supporting dynamic creation, or even just update-in-place +access also need to implement an IWriteBlock() method +on the raster band class. It has semantics similar to IReadBlock(). +As well, for various esoteric reasons, it is critical that a FlushCache() +method be implemented in the raster band destructor. This is to ensure that +any write cache blocks for the band be flushed out before the destructor +is called. + +\section gdal_drivertut_raw RawDataset/RawRasterBand Helper Classes + +Many file formats have the actual imagery data stored in a regular, +binary, scanline oriented format. Rather than re-implement the access +semantics for this for each formats, there are provided RawDataset and +RawRasterBand classes declared in gdal/frmts/raw that can be utilized to +implement efficient and convenient access. + +In these cases the format specific band class may not be required, or if +required it can be derived from RawRasterBand. The dataset class should +be derived from RawDataset. + +The Open() method for the dataset then instantiates raster bands passing +all the layout information to the constructor. For instance, the PNM driver +uses the following calls to create it's raster bands. + +\code + if( poOpenInfo->pabyHeader[1] == '5' ) + { + poDS->SetBand( + 1, new RawRasterBand( poDS, 1, poDS->fpImage, + iIn, 1, nWidth, GDT_Byte, TRUE )); + } + else + { + poDS->SetBand( + 1, new RawRasterBand( poDS, 1, poDS->fpImage, + iIn, 3, nWidth*3, GDT_Byte, TRUE )); + poDS->SetBand( + 2, new RawRasterBand( poDS, 2, poDS->fpImage, + iIn+1, 3, nWidth*3, GDT_Byte, TRUE )); + poDS->SetBand( + 3, new RawRasterBand( poDS, 3, poDS->fpImage, + iIn+2, 3, nWidth*3, GDT_Byte, TRUE )); + } +\endcode + +The RawRasterBand takes the following arguments. + +<ul> +<li> <b>poDS</b>: The GDALDataset this band will be a child of. This +dataset must be of a class derived from RawRasterDataset. +<li> <b>nBand</b>: The band it is on that dataset, 1 based. +<li> <b>fpRaw</b>: The FILE * handle to the file containing the raster data. +<li> <b>nImgOffset</b>: The byte offset to the first pixel of raster data for +the first scanline. +<li> <b>nPixelOffset</b>: The byte offset from the start of one pixel to the +start of the next within the scanline. +<li> <b>nLineOffset</b>: The byte offset from the start of one scanline to +the start of the next. +<li> <b>eDataType</b>: The GDALDataType code for the type of the data on disk. +<li> <b>bNativeOrder</b>: FALSE if the data is not in the same endianness as +the machine GDAL is running on. The data will be automatically byte swapped. +</ul> + +Simple file formats utilizing the Raw services are normally placed all within +one file in the gdal/frmts/raw directory. There are numerous examples there +of format implementation.<p> + +\section gdal_drivertut_metadata Metadata, and Other Exotic Extensions + +There are various other items in the GDAL data model, for which virtual +methods exist on the GDALDataset and GDALRasterBand. They include: + +<ul> +<li> <b>Metadata</b>: Name/value text values about a dataset or band. The +GDALMajorObject (base class for GDALRasterBand and GDALDataset) has built-in +support for holding metadata, so for read access it only needs to be +set with calls to SetMetadataItem() during the Open(). The SAR_CEOS +(frmts/ceos2/sar_ceosdataset.cpp) and GeoTIFF drivers are examples of drivers +implementing readable metadata. + +<li> <b>ColorTables</b>: GDT_Byte raster bands can have color tables associated +with them. The frmts/png/pngdataset.cpp driver contains an example of a +format that supports colortables. + +<li> <b>ColorInterpretation</b>: The PNG driver contains an example of a +driver that returns an indication of whether a band should be treated as +a Red, Green, Blue, Alpha or Greyscale band. + +<li> <b>GCPs</b>: GDALDatasets can have a set of ground control points +associated with them (as opposed to an explicit affine transform returned by +GetGeotransform()) relating the raster to georeferenced coordinates. The +MFF2 (gdal/frmts/raw/hkvdataset.cpp) format is a simple example of a format +supporting GCPs. + +<li> <b>NoDataValue</b>: Bands with known "nodata" values can implement +the GetNoDataValue() method. See the PAux (frmts/raw/pauxdataset.cpp) for +an example of this. + +<li> <b>Category Names</b>: Classified images with names for each class can +return them using the GetCategoryNames() method though no formats currently +implement this. + +</ul> + +*/ diff --git a/Utilities/GDAL/doc/gdal_footer.html b/Utilities/GDAL/doc/gdal_footer.html new file mode 100644 index 0000000000..682dedc214 --- /dev/null +++ b/Utilities/GDAL/doc/gdal_footer.html @@ -0,0 +1,6 @@ +<hr> + +Generated for GDAL by +<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> $doxygenversion. +</body> +</html> diff --git a/Utilities/GDAL/doc/gdal_tutorial.dox b/Utilities/GDAL/doc/gdal_tutorial.dox new file mode 100644 index 0000000000..9d3f4d9bbe --- /dev/null +++ b/Utilities/GDAL/doc/gdal_tutorial.dox @@ -0,0 +1,611 @@ +/* $Id: gdal_tutorial.dox,v 1.9 2006/03/27 15:16:01 fwarmerdam Exp $ */ + +/*! +\page gdal_tutorial GDAL API Tutorial + +\section gdal_tutorial_open Opening the File + +Before opening a GDAL supported raster datastore it is necessary to +register drivers. There is a driver for each supported format. Normally +this is accomplished with the GDALAllRegister() function which attempts +to register all known drivers, including those auto-loaded from .so files +using GDALDriverManager::AutoLoadDrivers(). If for some applications it +is necessary to limit the set of drivers it may be helpful to review +the code from <a href="gdalallregister.cpp.html">gdalallregister.cpp</a>. + +Once the drivers are registered, the application should call the free +standing GDALOpen() function to open a dataset, passing the name of the +dataset and the access desired (GA_ReadOnly or GA_Update). + +In C++: +\code +#include "gdal_priv.h" + +int main() +{ + GDALDataset *poDataset; + + GDALAllRegister(); + + poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly ); + if( poDataset == NULL ) + { + ...; + } +\endcode + +In C: +\code +#include "gdal.h" + +int main() +{ + GDALDatasetH hDataset; + + GDALAllRegister(); + + hDataset = GDALOpen( pszFilename, GA_ReadOnly ); + if( hDataset == NULL ) + { + ...; + } +\endcode + +In Python: +\code + import gdal + from gdalconst import * + + dataset = gdal.Open( filename, GA_ReadOnly ) + if dataset is None: + ... +\endcode + +Note that if GDALOpen() returns NULL it means the open failed, and that +an error messages will already have been emitted via CPLError(). If you want +to control how errors are reported to the user review the CPLError() +documentation. Generally speaking all of GDAL uses CPLError() for error +reporting. Also, note that pszFilename need not actually be the name +of a physical file (though it usually is). It's interpretation is driver +dependent, and it might be an URL, a filename with additional parameters +added at the end controlling the open or almost anything. Please try not +to limit GDAL file selection dialogs to only selecting physical files. + +\section gdal_tutorial_dataset Getting Dataset Information + +As described in the <a href="gdal_datamodel.html">GDAL Data Model</a>, a +GDALDataset contains a list of raster bands, all pertaining to the same +area, and having the same resolution. It also has metadata, a coordinate +system, a georeferencing transform, size of raster and various other +information. + +\code + adfGeoTransform[0] /* top left x */ + adfGeoTransform[1] /* w-e pixel resolution */ + adfGeoTransform[2] /* rotation, 0 if image is "north up" */ + adfGeoTransform[3] /* top left y */ + adfGeoTransform[4] /* rotation, 0 if image is "north up" */ + adfGeoTransform[5] /* n-s pixel resolution */ +\endcode + +If we wanted to print some general information about the +dataset we might do the following: + +In C++: +\code + double adfGeoTransform[6]; + + printf( "Driver: %s/%s\n", + poDataset->GetDriver()->GetDescription(), + poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) ); + + printf( "Size is %dx%dx%d\n", + poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), + poDataset->GetRasterCount() ); + + if( poDataset->GetProjectionRef() != NULL ) + printf( "Projection is `%s'\n", poDataset->GetProjectionRef() ); + + if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None ) + { + printf( "Origin = (%.6f,%.6f)\n", + adfGeoTransform[0], adfGeoTransform[3] ); + + printf( "Pixel Size = (%.6f,%.6f)\n", + adfGeoTransform[1], adfGeoTransform[5] ); + } +\endcode + +In C: +\code + GDALDriverH hDriver; + double adfGeoTransform[6]; + + hDriver = GDALGetDatasetDriver( hDataset ); + printf( "Driver: %s/%s\n", + GDALGetDriverShortName( hDriver ), + GDALGetDriverLongName( hDriver ) ); + + printf( "Size is %dx%dx%d\n", + GDALGetRasterXSize( hDataset ), + GDALGetRasterYSize( hDataset ), + GDALGetRasterCount( hDataset ) ); + + if( GDALGetProjectionRef( hDataset ) != NULL ) + printf( "Projection is `%s'\n", GDALGetProjectionRef( hDataset ) ); + + if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None ) + { + printf( "Origin = (%.6f,%.6f)\n", + adfGeoTransform[0], adfGeoTransform[3] ); + + printf( "Pixel Size = (%.6f,%.6f)\n", + adfGeoTransform[1], adfGeoTransform[5] ); + } +\endcode + +In Python: +\code + print 'Driver: ', dataset.GetDriver().ShortName,'/', \ + dataset.GetDriver().LongName + print 'Size is ',dataset.RasterXSize,'x',dataset.RasterYSize, \ + 'x',dataset.RasterCount + print 'Projection is ',dataset.GetProjection() + + geotransform = dataset.GetGeoTransform() + if not geotransform is None: + print 'Origin = (',geotransform[0], ',',geotransform[3],')' + print 'Pixel Size = (',geotransform[1], ',',geotransform[5],')' +\endcode + +\section gdal_tutorial_band Fetching a Raster Band + +At this time access to raster data via GDAL is done one band at a time. +Also, there is metadata, blocksizes, color tables, and various other +information available on a band by band basis. The following codes fetches +a GDALRasterBand object from the dataset (numbered 1 through GetRasterCount()) +and displays a little information about it. + +In C++: +\code + GDALRasterBand *poBand; + int nBlockXSize, nBlockYSize; + int bGotMin, bGotMax; + double adfMinMax[2]; + + poBand = poDataset->GetRasterBand( 1 ); + poBand->GetBlockSize( &nBlockXSize, &nBlockYSize ); + printf( "Block=%dx%d Type=%s, ColorInterp=%s\n", + nBlockXSize, nBlockYSize, + GDALGetDataTypeName(poBand->GetRasterDataType()), + GDALGetColorInterpretationName( + poBand->GetColorInterpretation()) ); + + adfMinMax[0] = poBand->GetMinimum( &bGotMin ); + adfMinMax[1] = poBand->GetMaximum( &bGotMax ); + if( ! (bGotMin && bGotMax) ) + GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax); + + printf( "Min=%.3fd, Max=%.3f\n", adfMinMax[0], adfMinMax[1] ); + + if( poBand->GetOverviewCount() > 0 ) + printf( "Band has %d overviews.\n", poBand->GetOverviewCount() ); + + if( poBand->GetColorTable() != NULL ) + printf( "Band has a color table with %d entries.\n", + poBand->GetColorTable()->GetColorEntryCount() ); +\endcode + +In C: +\code + GDALRasterBandH hBand; + int nBlockXSize, nBlockYSize; + int bGotMin, bGotMax; + double adfMinMax[2]; + + hBand = GDALGetRasterBand( hDataset, 1 ); + GDALGetBlockSize( hBand, &nBlockXSize, &nBlockYSize ); + printf( "Block=%dx%d Type=%s, ColorInterp=%s\n", + nBlockXSize, nBlockYSize, + GDALGetDataTypeName(GDALGetRasterDataType(hBand)), + GDALGetColorInterpretationName( + GDALGetRasterColorInterpretation(hBand)) ); + + adfMinMax[0] = GDALGetRasterMinimum( hBand, &bGotMin ); + adfMinMax[1] = GDALGetRasterMaximum( hBand, &bGotMax ); + if( ! (bGotMin && bGotMax) ) + GDALComputeRasterMinMax( hBand, TRUE, adfMinMax ); + + printf( "Min=%.3fd, Max=%.3f\n", adfMinMax[0], adfMinMax[1] ); + + if( GDALGetOverviewCount(hBand) > 0 ) + printf( "Band has %d overviews.\n", GDALGetOverviewCount(hBand)); + + if( GDALGetRasterColorTable( hBand ) != NULL ) + printf( "Band has a color table with %d entries.\n", + GDALGetColorEntryCount( + GDALGetRasterColorTable( hBand ) ) ); +\endcode + +In Python (note several bindings are missing): +\code + band = dataset.GetRasterBand(1) + + print 'Band Type=',gdal.GetDataTypeName(band.DataType) + + min = band.GetMinimum() + max = band.GetMaximum() + if min is not None and max is not None: + (min,max) = ComputeRasterMinMax(1) + print 'Min=%.3f, Max=%.3f' % (min,max) + + if band.GetOverviewCount() > 0: + print 'Band has ', band.GetOverviewCount(), ' overviews.' + + if not band.GetRasterColorTable() is None: + print 'Band has a color table with ', \ + band.GetRasterColorTable().GetCount(), ' entries.' +\endcode + +\section gdal_tutorial_read Reading Raster Data + +There are a few ways to read raster data, but the most common is via +the GDALRasterBand::RasterIO() method. This method will automatically take +care of data type conversion, up/down sampling and windowing. The following +code will read the first scanline of data into a similarly sized buffer, +converting it to floating point as part of the operation. + +In C++: +\code + float *pafScanline; + int nXSize = poBand->GetXSize(); + + pafScanline = (float *) CPLMalloc(sizeof(float)*nXSize); + poBand->RasterIO( GF_Read, 0, 0, nXSize, 1, + pafScanline, nXSize, 1, GDT_Float32, + 0, 0 ); +\endcode + +In C: +\code + float *pafScanline; + int nXSize = GDALGetRasterBandXSize( hBand ); + + pafScanline = (float *) CPLMalloc(sizeof(float)*nXSize); + GDALRasterIO( hBand, GF_Read, 0, 0, nXSize, 1, + pafScanline, nXSize, 1, GDT_Float32, + 0, 0 ); +\endcode + +In Python: + +\code + scanline = band.ReadRaster( 0, 0, band.XSize, 1, \ + band.XSize, 1, GDT_Float32 ) +\endcode + +Note that the returned scanline is of type string, and contains +xsize*4 bytes of raw binary floating point data. This can be converted +to Python values using the <b>struct</b> module from the standard +library: + +\code + import struct + + tuple_of_floats = struct.unpack('f' * b2.XSize, scanline) +\endcode + +The RasterIO call takes the following arguments. +\code +CPLErr GDALRasterBand::RasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nPixelSpace, + int nLineSpace ) +\endcode + +Note that the same RasterIO() call is used to read, or write based on +the setting of eRWFlag (either GF_Read or GF_Write). The nXOff, nYOff, +nXSize, nYSize argument describe the window of raster data on disk to +read (or write). It doesn't have to fall on tile boundaries though access +may be more efficient if it does. + +The pData is the memory buffer the data is read into, or written from. It's +real type must be whatever is passed as eBufType, such as GDT_Float32, or +GDT_Byte. The RasterIO() call will take care of converting between the +buffer's data type and the data type of the band. Note that when converting +floating point data to integer RasterIO() rounds down, and when converting +source values outside the legal range of the output the nearest legal value +is used. This implies, for instance, that 16bit data read into a GDT_Byte +buffer will map all values greater than 255 to 255, <b>the data is not +scaled!</b> + +The nBufXSize and nBufYSize +values describe the size of the buffer. When loading data at full resolution +this would be the same as the window size. However, to load a reduced +resolution overview this could be set to smaller than the window on disk. In +this case the RasterIO() will utilize overviews to do the IO more efficiently +if the overviews are suitable. + +The nPixelSpace, and nLineSpace are normally zero indicating that default +values should be used. However, they can be used to control access to +the memory data buffer, allowing reading into a buffer containing other +pixel interleaved data for instance. + +\section gdal_tutorial_close Closing the Dataset + +Please keep in mind that GDALRasterBand objects are <i>owned</i> by their +dataset, and they should never be destroyed with the C++ delete operator. +GDALDataset's can be closed either by calling GDALClose() or using the +delete operator on the GDALDataset. Either will result in proper cleanup, +and flushing of any pending writes. + +\section gdal_tutorial_creation Techniques for Creating Files + +New files in GDAL supported formats may be created if the format driver +supports creation. There are two general techniques for creating files, +using CreateCopy() and Create(). +The CreateCopy method involves calling the CreateCopy() method on the +format driver, and passing in a source dataset that should be copied. The +Create method involves calling the Create() method on the driver, and then +explicitly writing all the metadata, and raster data with separate calls. +All drivers that support creating new files support the CreateCopy() method, +but only a few support the Create() method. + +To determine if a particular format supports Create or CreateCopy +it is possible to check the DCAP_CREATE and DCAP_CREATECOPY metadata on the +format driver object. Ensure that GDALAllRegister() has been called before +calling GetDriverByName(). In this example we + +In C++: +\code +#include "cpl_string.h" +... + const char *pszFormat = "GTiff"; + GDALDriver *poDriver; + char **papszMetadata; + + poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); + + if( poDriver == NULL ) + exit( 1 ); + + papszMetadata = poDriver->GetMetadata(); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) ) + printf( "Driver %s supports Create() method.\n", pszFormat ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) ) + printf( "Driver %s supports CreateCopy() method.\n", pszFormat ); +\endcode + +In C: +\code +#include "cpl_string.h" +... + const char *pszFormat = "GTiff"; + GDALDriver hDriver = GDALGetDriverByName( pszFormat ); + char **papszMetadata; + + if( hDriver == NULL ) + exit( 1 ); + + papszMetadata = GDALGetMetadata( hDriver, NULL ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) ) + printf( "Driver %s supports Create() method.\n", pszFormat ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) ) + printf( "Driver %s supports CreateCopy() method.\n", pszFormat ); +\endcode + +In Python: + +\code + format = "GTiff" + driver = gdal.GetDriverByName( format ) + metadata = driver.GetMetadata() + if metadata.has_key(gdal.DCAP_CREATE) \ + and metadata[gdal.DCAP_CREATE] == 'YES': + print 'Driver %s supports Create() method.' % format + if metadata.has_key(gdal.DCAP_CREATECOPY) \ + and metadata[gdal.DCAP_CREATECOPY] == 'YES': + print 'Driver %s supports CreateCopy() method.' % format +\endcode + +Note that a number of drivers are read-only and won't support Create() +or CreateCopy(). + +\section gdal_tutorial_createcopy Using CreateCopy() + +The GDALDriver::CreateCopy() method can be used fairly simply as most +information is collected from the source dataset. However, it includes +options for passing format specific creation options, and for reporting +progress to the user as a long dataset copy takes place. A simple copy +from the a file named pszSrcFilename, to a new file named pszDstFilename +using default options on a format whose driver was previously fetched might +look like this: + +In C++: +\code + GDALDataset *poSrcDS = + (GDALDataset *) GDALOpen( pszSrcFilename, GA_ReadOnly ); + GDALDataset *poDstDS; + + poDstDS = poDriver->CreateCopy( pszDstFilename, poSrcDS, FALSE, + NULL, NULL, NULL ); + if( poDstDS != NULL ) + delete poDstDS; +\endcode + +In C: +\code + GDALDatasetH hSrcDS = GDALOpen( pszSrcFilename, GA_ReadOnly ); + GDALDatasetH hDstDS; + + hDstDS = GDALCreateCopy( hDriver, pszDstFilename, hSrcDS, FALSE, + NULL, NULL, NULL ); + if( hDstDS != NULL ) + GDALClose( hDstDS ); +\endcode + +In Python: + +\code + src_ds = gdal.Open( src_filename ) + dst_ds = driver.CreateCopy( dst_filename, src_ds, 0 ) +\endcode + +Note that the CreateCopy() method returns a writeable dataset, and that it +must be closed properly to complete writing and flushing the dataset to disk. +In the Python case this occurs automatically when "dst_ds" goes out of scope. +The FALSE (or 0) value used for the bStrict option just after the destination +filename in the CreateCopy() call indicates that the CreateCopy() call +should proceed without a fatal error even if the destination dataset cannot +be created to exactly match the input dataset. This might be because the +output format does not support the pixel datatype of the input dataset, or +because the destination cannot support writing georeferencing for instance. + +A more complex case might involve passing creation options, and using a +predefined progress monitor like this: + +In C++: +\code +#include "cpl_string.h" +... + char **papszOptions = NULL; + + papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" ); + papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" ); + poDstDS = poDriver->CreateCopy( pszDstFilename, poSrcDS, FALSE, + papszOptions, GDALTermProgress, NULL ); + if( poDstDS != NULL ) + delete poDstDS; +\endcode + +In C: +\code +#include "cpl_string.h" +... + char **papszOptions = NULL; + + papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" ); + papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" ); + hDstDS = GDALCreateCopy( hDriver, pszDstFilename, hSrcDS, FALSE, + papszOptions, GDALTermProgres, NULL ); + if( hDstDS != NULL ) + GDALClose( hDstDS ); +\endcode + +In Python: + +\code + src_ds = gdal.Open( src_filename ) + dst_ds = driver.CreateCopy( dst_filename, src_ds, 0, + [ 'TILED=YES', 'COMPRESS=PACKBITS' ] ) +\endcode + +\section gdal_tutorial_create Using Create() + +For situations in which you are not just exporting an existing file to a new +file, it is generally necessary to use the GDALDriver::Create() method (though +some interesting options are possible through use of virtual files or in-memory +files). The Create() method takes an options list much like CreateCopy(), +but the image size, number of bands and band type must be provided explicitly. +<p> + +In C++: +\code + GDALDataset *poDstDS; + char **papszOptions = NULL; + + poDstDS = poDriver->Create( pszDstFilename, 512, 512, 1, GDT_Byte, + papszOptions ); +\endcode + +In C: +\code + GDALDatasetH hDstDS; + char **papszOptions = NULL; + + hDstDS = GDALCreate( hDriver, pszDstFilename, 512, 512, 1, GDT_Byte, + papszOptions ); +\endcode + +In Python: + +\code + dst_ds = driver.Create( dst_filename, 512, 512, 1, gdal.GDT_Byte ) +\endcode + +Once the dataset is successfully created, all appropriate metadata and raster +data must be written to the file. What this is will vary according to usage, +but a simple case with a projection, geotransform and raster data is covered +here.<p> + +In C++: +\code + double adfGeoTransform[6] = { 444720, 30, 0, 3751320, 0, -30 }; + OGRSpatialReference oSRS; + char *pszSRS_WKT = NULL; + GDALRasterBand *poBand; + GByte abyRaster[512*512]; + + poDstDS->SetGeoTransform( adfGeoTransform ); + + oSRS.SetUTM( 11, TRUE ); + oSRS.SetWellKnownGeogCS( "NAD27" ); + oSRS.exportToWkt( &pszSRS_WKT ); + poDstDS->SetProjection( pszSRS_WKT ); + CPLFree( pszSRS_WKT ); + + poBand = poDstDS->GetRasterBand(1); + poBand->RasterIO( GF_Write, 0, 0, 512, 512, + abyRaster, 512, 512, GDT_Byte, 0, 0 ); + + delete poDstDS; +\endcode + +In C: +\code + double adfGeoTransform[6] = { 444720, 30, 0, 3751320, 0, -30 }; + OGRSpatialReferenceH hSRS; + char *pszSRS_WKT = NULL; + GDALRasterBandH hBand; + GByte abyRaster[512*512]; + + GDALSetGeoTransform( hDstDS, adfGeoTransform ); + + hSRS = OSRNewSpatialReference( NULL ); + OSRSetUTM( hSRS, 11, TRUE ); + OSRSetWellKnownGeogCS( hSRS, "NAD27" ); + OSRExportToWkt( hSRS, &pszSRS_WKT ); + OSRDestroySpatialReference( hSRS ); + + GDALSetProjection( hDstDS, pszSRS_WKT ); + CPLFree( pszSRS_WKT ); + + hBand = GDALGetRasterBand( hDstDS, 1 ); + GDALRasterIO( hBand, GF_Write, 0, 0, 512, 512, + abyRaster, 512, 512, GDT_Byte, 0, 0 ); + + GDALClose( hDstDS ); +\endcode + +In Python: + +\code + import Numeric, osr + + dst_ds.SetGeoTransform( [ 444720, 30, 0, 3751320, 0, -30 ] ) + + srs = osr.SpatialReference() + srs.SetUTM( 11, 1 ) + srs.SetWellKnownGeogCS( 'NAD27' ) + dst_ds.SetProjection( srs.ExportToWkt() ) + + raster = Numeric.zeros( (512, 512) ) + dst_ds.GetRasterBand(1).WriteArray( raster ) +\endcode + +*/ + + + diff --git a/Utilities/GDAL/doc/gdal_utilities.dox b/Utilities/GDAL/doc/gdal_utilities.dox new file mode 100644 index 0000000000..8db2082403 --- /dev/null +++ b/Utilities/GDAL/doc/gdal_utilities.dox @@ -0,0 +1,1081 @@ +#ifndef DOXYGEN_SKIP +/* $Id: gdal_utilities.dox,v 1.14 2006/04/22 14:26:49 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdal_utilities GDAL Utilities + +The following utility programs are distributed with GDAL. + +<ul> +<li> \ref gdalinfo - report information about a file. +<li> \ref gdal_translate - Copy a raster file, with control of output format. +<li> \ref gdaladdo - Add overviews to a file. +<li> \ref gdalwarp - Warp an image into a new coordinate system. +<li> \ref gdaltindex - Build a MapServer raster tileindex. +<li> \ref gdal_contour - Contours from DEM. +<li> \ref rgb2pct - Convert a 24bit RGB image to 8bit paletted. +<li> \ref pct2rgb - Convert an 8bit paletted image to 24bit RGB. +<li> \ref gdal_merge - Build a quick mosaic from a set of images. +<li> \ref gdal_rasterize - Rasterize vectors into raster file. +<li> \ref gdal-config - Get options required to build software using GDAL. +</ul> + +\section gdal_utilities_creating Creating New Files + +Access an existing file to read it is generally quite simple. Just +indicate the name of the file or dataset on the commandline. However, +creating a file is more complicated. It may be necessary to indicate the +the format to create, various creation options affecting how it will +be created and perhaps a coordinate system to be assigned. Many of +these options are handled similarly by different GDAL utilities, and are +introduced here. <p> + +<dl> +<dt> <b>-of</b> <i>format</i></dt><dd> +Select the format to create the new file as. The formats are assigned short +names such as GTiff (for GeoTIFF) or HFA (for Erdas Imagine). The list of +all format codes can be listed with the <b>--formats</b> switch. Only +formats list as "(rw)" (read-write) can be written.<p> +Many utilities default +to creating GeoTIFF files if a format is not specified. File extensions +are not used to guess output format, nor are extensions generally added +by GDAL if not indicated in the filename by the user. +</dd> + +<dt> <b>-co</b> <i>NAME=VALUE</i></dt><dd> +Many formats have one or more optional creation options that can be used +to control particulars about the file created. For instance, the GeoTIFF +driver supports creation options to control compression, and whether the file +should be tiled.<p> +The creation options available vary by format driver, and some simple +formats have no creation options at all. A list of options supported +for a format can be listed with the "--format <format>" commandline +option but the web page for the format is the definitive source of +information on driver creation options.<p> +</dd> + +<dt> <b>-a_srs</b> <i>SRS</i></dt><dd> +Several utilities, (gdal_translate and gdalwarp) include the ability +to specify coordinate systems with commandline options like +<b>-a_srs</b> (assign SRS to output), <b>-s_srs</b> (source SRS) and +<b>-t_srs</b> (target SRS).<p> +These utilities allow the coordinate system (SRS = spatial reference system) +to be assigned in a variety of formats.<p> + +<ul> +<li> <b>NAD27</b>/<b>NAD83</b>/<b>WGS84</b>/<b>WGS72</b>: +These common geographic (lat/long) coordinate +systems can be used directly by these names. + +<li> <b>EPSG:</b><i>n</i>: Coordinate systems (projected or geographic) can +be selected based on their EPSG codes, for instance EPSG:27700 is the British +National Grid. A list of EPSG coordinate systems can be found in the GDAL +data files gcs.csv and pcs.csv. + +<li> <i>PROJ.4 Definitions</i>: A PROJ.4 definition string can be used +as a coordinate system. For instance "+proj=utm +zone=11 +datum=WGS84". +Take care to keep the proj.4 string together as a single argument to the +command (usually by double quoting). <p> + +<li> <i>OpenGIS Well Known Text</i>: The Open GIS Consortium has defined +a textual format for describing coordinate systems as part of the Simple +Features specifications. This format is the internal working format +for coordinate systems used in GDAL. The name of a file containing a +WKT coordinate system definition may be used a coordinate system argument, +or the entire coordinate system itself may be used as a commandline +option (though escaping all the quotes in WKT is quite challenging). <p> + +<li> <i>ESRI Well Known Text</i>: ESRI uses a slight variation on OGC WKT +format in their ArcGIS product (ArcGIS .prj files), and these may be used +in a similar manner to WKT files, but the filename should be prefixed with +<b>ESRI::</b>. For example <b>"ESRI::NAD 1927 StatePlane Wyoming West FIPS 4904.prj"</b>. <p> +</ul> +</dd> +</dl> + +\section gdal_utilities_switches General Command Line Switches +All GDAL command line utility programs support the following +"general" options.<p> + +<dl> +<dt> <b>--version</b></dt><dd> Report the version of GDAL and exit.</dd> + +<dt> <b>--formats</b></dt><dd> List all raster formats supported by this +GDAL build (read-only and read-write) and exit.</dd> + +<dt> <b>--format</b> <i>format</i></dt><dd> +List detailed information about a single format driver. The <i>format</i> +should be the short name reported in the <b>--formats</b> list, such as +GTiff.</dd> + +<dt> <b>--optfile</b> <i>file</i></dt><dd> +Read the named file and substitute the contents into the commandline +options list. Lines beginning with # will be ignored. Multi-word arguments +may be kept together with double quotes. +</dd> + +<dt> <b>--config</b> <i>key value</i></dt><dd> +Sets the named configuration keyword to the given value, as opposed to +setting them as environment variables. Some common configuration keywords +are GDAL_CACHEMAX (memory used internally for caching in megabytes) +and GDAL_DATA (path of the GDAL "data" directory). Individual drivers may +be influenced by other configuration options. +</dd> + +<dt> <b>--debug</b> <i>value</i></dt><dd> +Control what debugging messages are emitted. A value of <i>ON</i> will +enable all debug messages. A value of <i>OFF</i> will disable all debug +messages. Another value will select only debug messages containing that +string in the debug prefix code. +</dd> + +<dt> <b>--help-general</b></dt><dd> +Gives a brief usage message for the generic GDAL commandline options +and exit. +</dd> + +</dl> + +*/ + +******************************************************************************* +/*! \page gdalinfo gdalinfo + +lists information about a raster dataset + +\if man +\section synopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdalinfo [-mm] [-nogcp] [-nomd] datasetname +\endverbatim + +\if man +\section description DESCRIPTION +\endif + +The gdalinfo program lists various information about a GDAL supported +raster dataset. +<dl> +<dt> <b>-mm</b></dt><dd> Force computation of the actual min/max values for each +band in the dataset.</dd> +<dt> <b>-nogcp</b></dt><dd> Suppress ground control points list printing. It may be +useful for datasets with huge amount of GCPs, such as L1B AVHRR or HDF4 MODIS +which contain thousands of the ones.</dd> +<dt> <b>-nomd</b></dt><dd> Suppress metadata printing. Some datasets may contain a lot +of metadata strings.</dd> +</dl> + +The gdalinfo will report all of the following (if known): + +<ul> +<li> The format driver used to access the file. +<li> Raster size (in pixels and lines). +<li> The coordinate system for the file (in OGC WKT). +<li> The geotransform associated with the file (rotational coefficients are +currently not reported). +<li> Corner coordinates in georeferenced, and if possible lat/long based on +the full geotransform (but not GCPs). +<li> Ground control points. +<li> File wide (including subdatasets) metadata. +<li> Band data types. +<li> Band color interpretations. +<li> Band block size. +<li> Band descriptions. +<li> Band min/max values (internally known and possibly computed). +<li> Band NODATA value. +<li> Band overview resolutions available. +<li> Band unit type (i.e.. "meters" or "feet" for elevation bands). +<li> Band pseudo-color tables. +</ul> + +\if man +\section example EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +\verbatim +gdalinfo ~/openev/utm.tif +Driver: GTiff/GeoTIFF +Size is 512, 512 +Coordinate System is: +PROJCS["NAD27 / UTM zone 11N", + GEOGCS["NAD27", + DATUM["North_American_Datum_1927", + SPHEROID["Clarke 1866",6378206.4,294.978698213901]], + PRIMEM["Greenwich",0], + UNIT["degree",0.0174532925199433]], + PROJECTION["Transverse_Mercator"], + PARAMETER["latitude_of_origin",0], + PARAMETER["central_meridian",-117], + PARAMETER["scale_factor",0.9996], + PARAMETER["false_easting",500000], + PARAMETER["false_northing",0], + UNIT["metre",1]] +Origin = (440720.000000,3751320.000000) +Pixel Size = (60.000000,-60.000000) +Corner Coordinates: +Upper Left ( 440720.000, 3751320.000) (117d38'28.21"W, 33d54'8.47"N) +Lower Left ( 440720.000, 3720600.000) (117d38'20.79"W, 33d37'31.04"N) +Upper Right ( 471440.000, 3751320.000) (117d18'32.07"W, 33d54'13.08"N) +Lower Right ( 471440.000, 3720600.000) (117d18'28.50"W, 33d37'35.61"N) +Center ( 456080.000, 3735960.000) (117d28'27.39"W, 33d45'52.46"N) +Band 1 Block=512x16 Type=Byte, ColorInterp=Gray +\endverbatim + +\if man +\section author AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdal_translate gdal_translate + +converts raster data between different formats + +\if man +\section tsynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdal_translate [--help-general] + [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/ + CInt16/CInt32/CFloat32/CFloat64}] [-not_strict] + [-of format] [-b band] [-outsize xsize[%] ysize[%]] + [-scale [src_min src_max [dst_min dst_max]]] + [-srcwin xoff yoff xsize ysize] [-projwin ulx uly lrx lry] + [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value] + [-gcp pixel line easting northing]* + [-mo "META-TAG=VALUE"]* [-quiet] [-sds] + [-co "NAME=VALUE"]* + src_dataset dst_dataset +\endverbatim + +\if man +\section tdescription DESCRIPTION +\endif + +The gdal_translate utility can be used to convert raster data between +different formats, potentially performing some operations like subsettings, +resampling, and rescaling pixels in the process. + +<dl> +<dt> <b>-ot</b>: <i>type</i></dt><dd> For the output bands to be of the +indicated data type.</dd> +<dt> <b>-not_strict</b>:</dt><dd> Be forgiving of mismatches and lost data +when +translating to the output format.</dd> +<dt> <b>-of</b> <i>format</i>:</dt><dd> Select the output format. The default is +GeoTIFF (GTiff). Use the short format name.</dd> +<dt> <b>-b</b> <i>band</i>:</dt><dd> Select an input band <i>band</i> for +output. Bands are numbered from 1 Multiple <b>-b</b> switches may be used +to select a set of input bands to write to the output file, or to reorder +bands.</dd> +<dt> <b>-outsize</b> <i>xsize[%] ysize[%]</i>:</dt><dd> Set the size of the output +file. Outsize is in pixels and lines unless '%' is attached in which case it +is as a fraction of the input image size.</dd> +<dt> <b>-scale</b> <i>[src_min src_max [dst_min dst_max]]</i>:</dt><dd> Rescale the +input pixels values from the range <i>src_min</i> to <i>src_max</i> to +the range <i>dst_min</i> to <i>dst_max</i>. If omitted the output range is +0 to 255. If omitted the input range is automatically computed from the +source data.</dd> +<dt> <b>-srcwin</b> <i>xoff yoff xsize ysize</i>:</dt><dd> Selects a subwindow +from the source image for copying based on pixel/line location. </dd> +<dt> <b>-projwin</b> <i>ulx uly lrx lry</i>:</dt><dd> Selects a subwindow from +the source image for copying (like <b>-srcwin</b>) but with the corners given +in georeferenced coordinates. </dd> +<dt> <b>-a_srs</b> <i>srs_def</i>:</dt><dd> Override the projection for the +output file. The <i>srs_def</i> may be any of the usual GDAL/OGR forms, +complete WKT, PROJ.4, EPSG:n or a file containing the WKT. </dd> +<dt> <b>-a_ullr</b> <i>ulx uly lrx lry</i>:</dt><dd> +Assign/override the georeferenced bounds of the output file. This assigns +georeferenced bounds to the output file, ignoring what would have been derived +from the source file.</dd> +<dt> <b>-a_nodata</b> <i>value</i>:</dt><dd> +Assign a specified nodata value to output bands.</dd> +<dt> <b>-mo</b> <i>"META-TAG=VALUE"</i>:</dt><dd> Passes a metadata key and +value to set on the output dataset if possible.</dd> +<dt> <b>-co</b> <i>"NAME=VALUE"</i>:</dt><dd> Passes a creation option to the +output format driver. Multiple <b>-co</b> options may be listed. See format +specific documentation for legal creation options for each format.</dd> +<dt> <b>-gcp</b> <i>pixel line easting northing</i>:</dt><dd> +Add the indicated ground control point to the output dataset. This option +may be provided multiple times to provide a set of GCPs. +</dd> +<dt> <b>-quiet</b>:</dt><dd> Suppress progress monitor and other non-error +output.</dd> +<dt> <b>-sds</b>:</dt><dd> Copy all subdatasets of this file to individual +output files. Use with formats like HDF or OGDI that have subdatasets.</dd> +<dt> <i>src_dataset</i>:</dt><dd> The source file name.</dd> +<dt> <i>dst_dataset</i>:</dt><dd> The destination file name.</dd> +</dl> + +\if man +\section texample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +\verbatim +gdal_translate -of GTiff -co "TILED=YES" utm.tif utm_tiled.tif +\endverbatim + +\if man +\section tauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdaladdo gdaladdo + +builds or rebuilds overview images + +\if man +\section asynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdaladdo [-r {nearest,average,average_mp,average_magphase,mode}] + filename levels +\endverbatim + +\if man +\section adescription DESCRIPTION +\endif + +The gdaladdo utility can be used to build or rebuild overview images for +most supported file formats with one over several downsampling algorithms. + +<dl> +<dt> <b>-r</b> +<i>{nearest,average,average_mp,average_magphase,mode}</i>:</dt><dd> +Select a resampling algorithm.</dd> +<dt> <i>filename</i>:</dt><dd> The file to build overviews for. </dd> +<dt> <i>levels</i>:</dt><dd> A list of integral overview levels to build. </dd> +</dl> + +<i>Mode</i> is not actually implemented, and <i>average_mp</i> is unsuitable +for use. <i>Average_magphase</i> averages complex data in mag/phase space. +<i>Nearest</i> and <i>average</i> are applicable to normal image data. +<i>Nearest</i> applies a nearest neighbour (simple sampling) resampler, while +<i>average</i> computes the average of all non-NODATA contributing pixels. + +Selecting a level value like <i>2</i> causes an overview level that is 1/2 +the resolution (in each dimension) of the base layer to be computed. If +the file has existing overview levels at a level selected, those levels will +be recomputed and rewritten in place. + +Some format drivers do not support overviews at all. Many format drivers +store overviews in a secondary file with the extension .ovr that is actually +in TIFF format. The GeoTIFF driver stores overviews internally to the file +operated on. + +Overviews created in TIFF format may be compressed using the COMPRESS_OVERVIEW +configuration option. All compression methods, supported by the GeoTIFF +driver, available here. (eg --config COMPRESS_OVERVIEW DEFLATE) + +Most drivers also support an alternate overview format using Erdas Imagine +format. To trigger this use the USE_RRD=YES configuration option. This will +place the overviews in an associated .aux file suitable for direct use with +Imagine or ArcGIS as well as GDAL applications. (eg --config USE_RRD YES) + +\if man +\section aexample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +Create overviews, embedded in the supplied TIFF file: + +\verbatim +gdaladdo -r average abc.tif 2 4 8 16 +\endverbatim + +Create an external compressed GeoTIFF overview file from the ERDAS .IMG file: + +\verbatim +gdaladdo --config COMPRESS_OVERVIEW DEFLATE erdas.img 2 4 8 16 +\endverbatim + +Create an Erdas Imagine format overviews for the indicated JPEG file: + +\verbatim +gdaladdo --config USE_RRD YES airphoto.jpg 3 9 27 81 +\endverbatim + +\if man +\section aauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdalwarp gdalwarp + +simple image reprojection and warping utility + +\if man +\section wsynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdalwarp + [-s_srs srs_def] [-t_srs srs_def] [-order n] [-et err_threshold] + [-te xmin ymin xmax ymax] [-tr xres yres] [-ts width height] + [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt Byte/Int16] + [-srcnodata "value [value...]"] [-dstnodata "value [value...]"] + [-rn] [-rb] [-rc] [-rcs] [-wm memory_in_mb] [-multi] [-q] + [-of format] [-co "NAME=VALUE"]* srcfile dstfile +\endverbatim + +\if man +\section wdescription DESCRIPTION +\endif + +<p> +The gdalwarp utility is a simple image reprojection and warping +utility. The program can reproject to any support projection, +and can also apply GCPs stored with the image if the image is "raw" +with control information. + +<p> +<dl> +<dt> <b>-s_srs</b> <em>srs def</em>:</dt><dd> source spatial reference + set. The coordinate systems that can be passed are anything supported + by the OGRSpatialReference.SetFromUserInput() call, which includes + EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), + or the name of a .prf file containing well known text.</dd> +<dt> <b>-t_srs</b> <em>srs_def</em>:</dt><dd> target spatial reference set. The +coordinate systems that can be passed are anything supported by the +OGRSpatialReference.SetFromUserInput() call, which includes EPSG PCS +and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), or the name +of a .prf file containing well known text.</dd> +<dt> <b>-order</b> <em>n</em>:</dt><dd> order of polynomial used for warping (1 to 3). The default is to select a polynomial order based on the number of GCPs.</dd> +<dt> <b>-tps</b></dt><dd>Enable use of thin plate spline transformer +based on available GCPs. Use this <em>instead</em> of the -order switch.</dd> +<dt> <b>-et</b> <em>err_threshold</em>:</dt><dd> error threshold for transformation approximation (in pixel units - defaults to 0.125).</dd> +<dt> <b>-te</b> <em>xmin ymin xmax ymax</em>:</dt><dd> set georeferenced extents of output file to be created.</dd> +<dt> <b>-tr</b> <em>xres yres</em>:</dt><dd> set output file resolution (in target georeferenced units)</dd> +<dt> <b>-ts</b> <em>width height</em>:</dt><dd> set output file size in +pixels and lines</dd> +<dt> <b>-wo</b> <em>"NAME=VALUE"</em>:</dt><dd> Set a warp options. There is a + <a href="warptut.html#warpoptions">list</a> of available ones. Multiple + <b>-wo</b> options may be listed.</dd> +<dt> <b>-ot</b> <em>type</em>:</dt><dd> For the output bands to be of the indicated + data type.</dd> +<dt> <b>-wt</b> <em>type</em>:</dt><dd> Working pixel data type. The data type of + pixels in the source image and destination image buffers.</dd> +<dt> <b>-rn</b>:</dt><dd> Use nearest neighbour resampling (default, fastest algorithm, worst + interpolation quality).</dd> +<dt> <b>-rb</b>:</dt><dd> Use bilinear resampling.</dd> +<dt> <b>-rc</b>:</dt><dd> Use cubic resampling.</dd> +<dt> <b>-rcs</b>:</dt><dd> Use cubic spline resampling (slowest +algorithm).</dd> +<dt> <b>-srcnodata</b> <em>value [value...]</em>:</dt><dd> Set nodata masking +values for input bands (different values can be supplied for each band). If +more than one value is supplied all values should be quoted to keep them +together as a single operating system argument. Masked values will not be +used in interpolation.</dd> +<dt> <b>-dstnodata</b> <em>value [value...]</em>:</dt><dd> Set nodata values for output bands (different values can be supplied for each band). If +more than one value is supplied all values should be quoted to keep them +together as a single operating system argument. New files +will be initialized to this value and if possible the nodata value will be +recorded in the output file.</dd> +<dt> <b>-wm</b> <em>memory_in_mb</em>:</dt><dd> Set the amount of memory (in megabytes) that the warp API is allowed to use for caching.</dd> +<dt> <b>-multi</b>:</dt><dd> Use multithreaded warping implementation. + Multiple threads will be used to process chunks of image and perform + input/output operation simultaneously.</dd> +<dt> <b>-q</b>:</dt><dd> Be quiet.</dd> +<dt> <b>-of</b> <em>format</em>:</dt><dd> Select the output format. The default is GeoTIFF (GTiff). Use the short format name. </dd> +<dt> <b>-co</b> <em>"NAME=VALUE"</em>:</dt><dd> passes a creation + option to the output format driver. Multiple <b>-co</b> options may be + listed. See format specific documentation for legal creation options + for each format. </dd> +<dt> <em>srcfile</em>:</dt><dd> The source file name. </dd> +<dt> <em>dstfile</em>:</dt><dd> The destination file name. </dd> +</dl> + +Mosaicing into an existing output file is supported if the output file +already exists. + +<p> +\if man +\section wexample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +For instance, an eight bit spot scene stored in GeoTIFF with +control points mapping the corners to lat/long could be warped to a UTM +projection with a command like this:<p> + +\verbatim +gdalwarp -t_srs '+proj=utm +zone=11 +datum=WGS84' raw_spot.tif utm11.tif +\endverbatim + +For instance, the second channel of an ASTER image stored in HDF with +control points mapping the corners to lat/long could be warped to a UTM +projection with a command like this:<p> + +\verbatim +gdalwarp HDF4_SDS:ASTER_L1B:"pg-PR1B0000-2002031402_100_001":2 pg-PR1B0000-2002031402_100_001_2.tif +\endverbatim + +\if man +\section wauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdaltindex gdaltindex + +builds a shapefile as a raster tileindex + +\if man +\section isynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdaltindex [-tileindex field_name] index_file [gdal_file]* +\endverbatim + + +\if man +\section idescription DESCRIPTION +\endif + +This program builds a shapefile with a record for each input raster file, +an attribute containing the filename, and a polygon geometry outlining the +raster. This output is suitable for use with UMN MapServer as a raster +tileindex. + +<ul> +<li> The shapefile (index_file) will be created if it doesn't already exist. +<li> The default tile index field is 'location'. +<li> Raster filenames will be put in the file exactly as they are specified +on the commandline. +<li> Simple rectangular polygons are generated in the same +coordinate system as the rasters. +</ul> + +\if man +\section iexample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +\verbatim +gdaltindex doq_index.shp doq/*.tif +\endverbatim + +\if man +\section wauthor AUTHOR +Frank Warmerdam <warmerdam@pobox.com> +\endif +*/ + +******************************************************************************* +/*! \page gdal_contour gdal_contour + +builds vector contour lines from a raster elevation model + +\if man +\section isynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +Usage: gdal_contour [-b <band>] [-a <attribute_name>] [-3d] [-inodata] + [-snodata n] [-f <formatname>] [-i <interval>] + [-off <offset>] [-fl <level> <level>...] + <src_filename> <dst_filename> +\endverbatim + + +\if man +\section idescription DESCRIPTION +\endif + +This program generates a vector contour file from the input raster elevation +model (DEM). + +<dl> +<dt> <b>-s_srs</b> <em>srs def</em>:</dt><dd> source spatial reference + set. The coordinate systems that can be passed are anything supported + by the OGRSpatialReference.SetFromUserInput() call, which includes + EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), + or the name of a .prf file containing well known text.</dd> +</dl + +<dt> <b>-b</b> <em>band</em>:</dt><dd> picks a particular band to get the DEM from. Defaults to band 1.</dd> + +<dt> <b>-a</b> <em>name</em>:</dt><dd>provides a name for the attribute in which to put the elevation. If not provided no elevation attribute is attached. </dd> +<dt> <b>-3d</b>:</dt> <dd> + Force production of 3D vectors instead of 2D. Includes elevation at + every vertex.</dd> + +<dt> <b>-inodata</b>:</dt> <dd> Ignore any nodata value implied in the dataset - treat all values as valid.</dd> + +<dt> <b>-snodata</b> <em>value</em>:</dt><dd> + Input pixel value to treat as "nodata". </dd> + +<dt> <b>-f</b> <em>format</em>:</dt> <dd> +create output in a particular format, default is shapefiles.</dd> + +<dt> <b>-i</b> <em>interval</em>:</dt><dd> + elevation interval between contours.</dd> + +<dt> <b>-off</b> <em>offset</em>:</dt><dd> + Offset from zero relative to which to interpret intervals.</dd> + +<dt> <b>-fl</b> <em>level</em>:</dt> +<dd> Name one or more "fixed levels" to extract.</dd> +</dl> + +\if man +\section iexample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +This would create 10meter contours from the DEM data in dem.tif and produce +a shapefile in contour.shp/shx/dbf with the contour elevations in the "elev" +attribute. + +\verbatim +gdal_contour -a elev dem.tif contour.shp 10.0 +\endverbatim + +\if man +\section iauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdal_rasterize gdal_rasterize + +burns vector polygons into a raster + +\if man +\section isynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +Usage: gdal_rasterize [-b band] + [-burn value] | [-a attribute_name] | [-3d] + [-l layername]* [-where expression] [-sql select_statement] + <src_datasource> <dst_filename> +\endverbatim + +\if man +\section idescription DESCRIPTION +\endif + +This program burns vector polygons into the raster band(s) of a raster +image. Vectors are read from OGR supported vector formats. + +<dl> +<dt> <b>-b</b> <em>band</em>: </dt><dd> +The band(s) to burn values into. Multiple -b arguments may be used to burn +into a list of bands. The default is to burn into band 1.</dd> + +<dt> <b>-burn</b> <em>value</em>: </dt><dd> +A fixed value to burn into a band for all objects. A list of -burn options +can be supplied, one per band being written to.</dd> + +<dt> <b>-a</b> <em>attribute_name</em>: </dt><dd> +Identifies an attribute field on the features to be used for a burn in value. +The value will be burned into all output bands.</dd> + +<dt> <b>-3d</b>: </dt><dd> +Indicates that a burn value should be extracted from the "Z" values of the +feature (not yet implemented).</dd> + +<dt> <b>-l</b> <em>layername</em>: </dt><dd> +Indicates the layer(s) from the datasource that will be used for input +features. May be specified multiple times, but at least one layer name or a -sql option must be specified.</dd> + +<dt> <b>-where</b> <em>expression</em>: </dt><dd> +An optional SQL WHERE style query expression to be applied to select features +to burn in from the input layer(s). </dd> + +<dt> <b>-sql</b> <em>select_statement</em>: </dt><dd> +An SQL statement to be evaluated against the datasource to produce a +virtual layer of features to be burned in.</dd> + +<dt> <em>src_datasource</em>: </dt><dd> +Any OGR supported readable datasource.</dd> + +<dt> <em>dst_filename</em>: </dt><dd> +The GDAL supported output file. Must support update mode access. Currently +gdal_rasterize cannot create new output files though that may be added eventually.</dd> + +</dl> + +\if man +\section iexample EXAMPLE +\endif + +\htmlonly +Example: +\endhtmlonly + +The following would burn all polygons from mask.shp into the RGB TIFF +file work.tif with the color red (RGB = 255,0,0). + +\verbatim +gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l mask mask.shp work.tif +\endverbatim + +The following would burn all "class A" buildings into the output elevation +file, pulling the top elevation from the ROOF_H attribute. + +\verbatim +gdal_rasterize -a ROOF_H -where 'class="A"' -l footprints footprints.shp city_dem.tif +\endverbatim + +\if man +\section iauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com> +\endif +*/ + +******************************************************************************* +/*! \page rgb2pct rgb2pct.py + +converts an image into a pseudo-colored image + +\if man +\section rsynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +rgb2pct.py [-n colors] [-of format] source_file dest_file +\endverbatim + +\if man +\section rdescription DESCRIPTION +\endif + +This utility will compute an optimal pseudo-color table for a given RGB image +using a median cut algorithm on a downsampled RGB histogram. Then it +converts the image into a pseudo-colored image using the color table. +This conversion utilizes Floyd-Steinberg dithering (error diffusion) to +maximize output image visual quality. + +<dl> +<dt> <b>-n</b> <i>colors</i>:</dt><dd> Select the number of colors in the generated +color table. Defaults to 256. Must be between 2 and 256. </dd> +<dt> <b>-of</b> <i>format</i>:</dt><dd> Format to generated (defaults to GeoTIFF). Same +semantics as the <b>-of</b> flag for gdal_translate. Only output formats +supporting pseudocolor tables should be used. </dd> +<dt> <i>source_file</i>:</dt><dd> The input RGB file. </dd> +<dt> <i>dest_file</i>:</dt><dd> The output pseudo-colored file that will be +created.</dd> +</dl> + +NOTE: rgb2pct.py is a Python script, and will only work if GDAL was built +with Python support. + +\if man +\section iauthor AUTHOR +Frank Warmerdam <warmerdam@pobox.com> +\endif +*/ + +******************************************************************************* +/*! \page pct2rgb pct2rgb.py + +converts an image into a pseudo-colored image + +\if man +\section rsynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +pct2rgb.py [-of format] [-b band] source_file dest_file +\endverbatim + +\if man +\section rdescription DESCRIPTION +\endif + +This utility will convert a pseudocolor band on the input file into an output +RGB file of the desired format. + +<dl> +<dt> <b>-of</b> <i>format</i>:</dt><dd> Format to generated (defaults to GeoTIFF).</dd> +<dt> <b>-b</b> <i>band</i>:</dt><dd> +Band to convert to RGB, defaults to 1.</dd> +<dt> <i>source_file</i>:</dt><dd> The input file. </dd> +<dt> <i>dest_file</i>:</dt><dd> The output RGB file that will be +created.</dd> +</dl> + +NOTE: rgb2pct.py is a Python script, and will only work if GDAL was built +with Python support. + +\if man +\section rauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdal_merge gdal_merge.py + +mosaics a set of images + +\if man +\section msynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdal_merge.py [-o out_filename] [-of out_format] [-co NAME=VALUE]* + [-ps pixelsize_x pixelsize_y] [-separate] [-v] [-pct] + [-ul_lr ulx uly lrx lry] [-n nodata_value] [-init value] + [-ot datatype] [-createonly] input_files +\endverbatim +\if man +\section mdescription DESCRIPTION +\endif + +This utility will automatically mosaic a set of images. All the images must +be in the same coordinate system and have a matching number of bands, but +they may be overlapping, and at different resolutions. + +<dl> +<dt> <b>-o</b> <i>out_filename</i>:</dt><dd> The name of the output file to be +created.</dd> +<dt> <b>-of</b> <i>format</i>:</dt><dd> +Output format, defaults to GeoTIFF (GTiff). +</dd> +<dt> <b>-co</b> <i>NAME=VALUE</i>:</dt><dd> +Creation option for output file. Multiple options can be specified. +</dd> +<dt> <b>-ot</b> <i>datatype</i>:</dt><dd> +Force the output image bands to have a specific type. Use type names (ie. Byte, Int16,...) +</dd> +<dt> <b>-ps</b> <i>pixelsize_x pixelsize_y</i>:</dt><dd> Pixel size to be used for the +output file. If not specified the resolution of the first input file will +be used.</dd> +<dt> <b>-ul_lr</b> <i>ulx uly lrx lry</i>:</dt><dd> The extents of the output file. +If not specified the aggregate extents of all input files will be +used.</dd> +<dt> +<dt> <b>-v</b>:</dt><dd> Generate verbose output of mosaicing operations as they are done.</dd> +<dt> <b>-separate</b>:</dt><dd> +Place each input file into a separate <i>stacked</i> band. +</dd> +<dt> <b>-pct</b>:</dt><dd> +Grab a pseudocolor table from the first input image, and use it for the output. +Merging pseudocolored images this way assumes that all input files use the same +color table. +</dd> +<dt> <b>-n</b> <i>nodata_value</i>:</dt><dd> +Ignore pixels from files being merged in with this pixel value. +</dd> +<dt> <b>-init</b> <i>value</i>:</dt><dd> +Pre-initialize the output file with this value. However, it is not marked +as the nodata value in the output file. +</dd> +<dt> <b>-createonly</b>:</dt><dd> +The output file is created (and potentially pre-initialized) but no input +image data is copied into it. +</dd> +</dl> + +NOTE: gdal_merge.py is a Python script, and will only work if GDAL was built +with Python support. + +\if man +\section mauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ + +******************************************************************************* +/*! \page gdal_merge gdal_merge.py + +mosaics a set of images + +\if man +\section msynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdal_merge.py [-o out_filename] [-of out_format] [-co NAME=VALUE]* + [-ps pixelsize_x pixelsize_y] [-separate] [-v] [-pct] + [-ul_lr ulx uly lrx lry] [-n nodata_value] [-init value] + [-ot datatype] [-createonly] input_files +\endverbatim +\if man +\section mdescription DESCRIPTION +\endif + +This utility will automatically mosaic a set of images. All the images must +be in the same coordinate system and have a matching number of bands, but +they may be overlapping, and at different resolutions. + +<dl> +<dt> <b>-o</b> <i>out_filename</i>:</dt><dd> The name of the output file to be +created.</dd> +<dt> <b>-of</b> <i>format</i>:</dt><dd> +Output format, defaults to GeoTIFF (GTiff). +</dd> +<dt> <b>-co</b> <i>NAME=VALUE</i>:</dt><dd> +Creation option for output file. Multiple options can be specified. +</dd> +<dt> <b>-ot</b> <i>datatype</i>:</dt><dd> +Force the output image bands to have a specific type. Use type names (ie. Byte, Int16,...) +</dd> +<dt> <b>-ps</b> <i>pixelsize_x pixelsize_y</i>:</dt><dd> Pixel size to be used for the +output file. If not specified the resolution of the first input file will +be used.</dd> +<dt> <b>-ul_lr</b> <i>ulx uly lrx lry</i>:</dt><dd> The extents of the output file. +If not specified the aggregate extents of all input files will be +used.</dd> +<dt> +<dt> <b>-v</b>:</dt><dd> Generate verbose output of mosaicing operations as they are done.</dd> +<dt> <b>-separate</b>:</dt><dd> +Place each input file into a separate <i>stacked</i> band. +</dd> +<dt> <b>-pct</b>:</dt><dd> +Grab a pseudocolor table from the first input image, and use it for the output. +Merging pseudocolored images this way assumes that all input files use the same +color table. +</dd> +<dt> <b>-n</b> <i>nodata_value</i>:</dt><dd> +Ignore pixels from files being merged in with this pixel value. +</dd> +<dt> <b>-init</b> <i>value</i>:</dt><dd> +Pre-initialize the output file with this value. However, it is not marked +as the nodata value in the output file. +</dd> +<dt> <b>-createonly</b>:</dt><dd> +The output file is created (and potentially pre-initialized) but no input +image data is copied into it. +</dd> +</dl> + +NOTE: gdal_merge.py is a Python script, and will only work if GDAL was built +with Python support. + +\if man +\section mauthor AUTHORS +Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de> +\endif +*/ +******************************************************************************* +/*! \page gdal-config gdal-config + +determines various information about a GDAL installation + +\if man +\section csynopsis SYNOPSIS +\endif + +\htmlonly +Usage: +\endhtmlonly + +\verbatim +gdal-config [OPTIONS] +Options: + [--prefix[=DIR]] + [--libs] + [--cflags] + [--version] + [--ogr-enabled] + [--formats] +\endverbatim + +\if man +\section cdescription DESCRIPTION +\endif + +This utility script (available on Unix systems) can be used to determine +various information about a GDAL installation. It is normally just used +by configure scripts for applications using GDAL but can be queried by an +end user. + +<dl> +<dt> <b>--prefix</b>:</dt><dd> the top level directory for the GDAL +installation.</dd> +<dt> <b>--libs</b>:</dt><dd> The libraries and link directives required to +use GDAL.</dd> +<dt> <b>--cflags</b>:</dt><dd> The include and macro definition required to compiled +modules using GDAL.</dd> +<dt> <b>--version</b>:</dt><dd> Reports the GDAL version.</dd> +<dt> <b>--ogr-enabled</b>:</dt><dd> Reports "yes" or "no" to standard output depending +on whether OGR is built into GDAL.</dd> +<dt> <b>--formats</b>:</dt><dd> Reports which formats are configured into GDAL to +stdout.</dd> +</dl> + +*/ + + + diff --git a/Utilities/GDAL/doc/governance.dox b/Utilities/GDAL/doc/governance.dox new file mode 100644 index 0000000000..6de9d914ba --- /dev/null +++ b/Utilities/GDAL/doc/governance.dox @@ -0,0 +1,44 @@ +#ifndef DOXYGEN_SKIP +/* $Id: governance.dox,v 1.2 2006/04/12 19:16:52 fwarmerdam Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page governance Governance and Community Participation + +\section osgeo OSGeo Project Membership + +Traditionally GDAL has been lead by Frank Warmerdam, the original author of +much of GDAL/OGR, though with contributions and input from a variety of people. +As of February 2006 GDAL/OGR became a founding project of the +<a href="http://www.osgeo.org/">Open Source Geospatial Foundation (OSGeo)</a> +and began a transition to a more community oriented governance model - in keeping +with OSGeo expectations. + +Membership as an OSGeo project provides assurances that a variety of best practices +are being employed by the GDAL/OGR project, and that users and contributors can +be assured of responsible project operation and continuity of the project. In +particular: + +<ul> + +<li> A consensus oriented Project Management Committee will be in charge of the project. +<li> Project source code and contributions will be vetted to ensure code is properly +made available, protecting contributors and users of GDAL/OGR. + +<li> Systems infrastructure is provided by the foundation, with responsible backup and +redundancy to minimize disruptions. + +</ul> + +\section pmc Project Management Committee + +As of April 2006 (following the GDAL/OGR 1.3.2 release) the project has been +placed in the hands of a Project Steering Committee consisting of Frank Warmerdam, +Andrey Kiselev, Daniel Morissette and Howard Butler. This project steering +committee operates under the rules of \link rfc1_pmc.html GDAL/OGR RFC 1\endlink. + +Note that discussion of proposals to the PMC take place on gdal-dev, and input +from all subscribers is welcome. A \link rfc_list list of past RFCs\endlink is +available for review. + +*/ diff --git a/Utilities/GDAL/doc/index.dox b/Utilities/GDAL/doc/index.dox new file mode 100644 index 0000000000..15c138b6bd --- /dev/null +++ b/Utilities/GDAL/doc/index.dox @@ -0,0 +1,158 @@ +#ifndef DOXYGEN_SKIP +/* $Id: index.dox,v 1.19 2006/04/18 14:31:42 fwarmerdam Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! \mainpage GDAL - Geospatial Data Abstraction Library + +<center><b>Select language</b>: [English]<a href="index_ru.html">[Russian]</a></center> + +\htmlonly<img src="gdalicon.png" alt="GDAL">\endhtmlonly \latexonly GDAL \endlatexonly +is a translator library for raster geospatial data formats +that is released under an <a href="faq.html#license">X/MIT</a> style +<a href="http://www.opensource.org/"> +Open Source</a> license by the <a href="http://www.osgeo.org/">Open Source +Geospatial Foundation</a>. As a library, it presents a +\link gdal_datamodel.html single abstract data model\endlink +to the calling application for all supported formats. It also comes with a variety +of useful \link gdal_utilities.html commandline utilties\endlink +for data translation and processing. The \link NEWS.html NEWS\endlink +page describes the October 2005 GDAL 1.3.1 release. + +The related <a href="ogr">OGR</a> library (which lives within the GDAL source tree) +provides a similar capability for simple features vector data. + +Master: http://www.gdal.org<br> +Mirrors: http://gdal.osgeo.org, http://gdal.maptools.org<br> +Download: + <a href="http://www.gdal.org/dl">http at gdal.org</a>, + <a href="ftp://ftp.remotesensing.org/gdal">ftp at remotesensing.org</a>, + <a href="https://gdal.osgeo.org/servlets/ProjectDocumentList?folderID=40&expandFolder=40&folderID=0">http at osgeo.org</a> + +\section index_primary_sponsor Primary Sponsor + +<!-- XXX: we are using this small hack to workaround Doxygen deficiency +when processing HTML tags with arguments. --> +\htmlonly +<center><a href="http://www.ermapper.com/"><img src="ERMapperlogo_small.gif" alt="ER Mapper" border="0" width="154" height="46"></a></center> +\endhtmlonly +\latexonly +\image latex ERMapperlogo_small.gif +\endlatexonly + +<a href="http://www.ermapper.com/">ER Mapper</a> has generously provided +ongoing primary sponsorship for GDAL since February 2005 to support work +on GDAL improvement efforts not focused on any particular client project.<p> + +\section index_userdocs User Oriented Documentation + +<ul> +<li> \link download.html Downloads\endlink - Source and Binaries +<li> <a href="formats_list.html">Supported Formats</a> +<li> \link gdal_utilities.html GDAL Utility Programs\endlink +<li> \link faq.html GDAL FAQ\endlink +<li> \link gdal_datamodel.html GDAL Data Model\endlink +<li> \link governance.html GDAL/OGR Governance and Community Participation\endlink +<li> \link credits.html Acknowledgements and Credits\endlink +</ul> + +\section index_devdocs Developer Oriented Documentation + +<ul> +<li> \link gdal_building.html Building GDAL From Source\endlink +<li> \link hierarchy.html API Reference Documentation\endlink +<li> \link gdal_tutorial.html GDAL API Tutorial\endlink +<li> \link gdal_drivertut.html GDAL Driver Implementation Tutorial\endlink +<li> \link warptut.html GDAL Warp API Tutorial\endlink +<li> \link ogr/osr_tutorial.html OGRSpatialReference Tutorial\endlink +<li> \link gdal.h gdal.h the GDAL C API\endlink +<li> \link GDALDataset\endlink +<li> \link GDALRasterBand\endlink +<li> \link wince.html GDAL for Windows CE\endlink +</ul> + +\section index_maillist Mailing List + +The <a href="mailto:gdal-dev@lists.maptools.org">gdal-dev@lists.maptools.org</a> +mailing list can be used for discussion of development and user issues related +to GDAL and related technologies. Subscriptions can be done, and archives +reviewed <a href="http://lists.maptools.org/mailman/listinfo/gdal-dev/">on +the web</a>. The mailing list is also available in read-only format by NNTP at +<a href="news://news.gmane.org/gmane.comp.gis.gdal.devel">news://news.gmane.org/gmane.comp.gis.gdal.devel</a> +and by HTTP at +<a href="http://news.gmane.org/gmane.comp.gis.gdal.devel">http://news.gmane.org/gmane.comp.gis.gdal.devel</a>.<p> + +Some GDAL/OGR users and developers can also often be found in the +<a href="irc://irc.freenode.net/#gdal">#gdal</a> IRC channel on irc.freenode.net.<p> + +\section index_bugs Bug Reporting + +GDAL bugs +<a href="http://bugzilla.remotesensing.org/enter_bug.cgi?product=GDAL">can +be reported</a>, and +<a href="http://bugzilla.remotesensing.org/buglist.cgi?product=GDAL">can be +listed</a> using BugZilla.<p> + +\section index_bindings GDAL In Other Languages + +The following bindings of GDAL in other languages are available: + +<ul> +<li> <a href="http://map.hut.fi/gdal-perl/">Perl</a> +<li> <a href="gdal_tutorial.html">Python</a> (examples in standard tutorial) +<li> <a href="vb6_tutorial.html">VB6 Bindings</a> (not using SWIG) +<li> <a href="http://rgdal.sourceforge.net/">GDAL Bindings into R</a> +by Timothy H. Keitt. +<li> Ruby (no docs, but see gdalautotest/ruby for examples) +<li> Java (no docs ...) +<li> C# (not really working fully yet) +</ul> + +\section index_projects Projects Using GDAL + +<ul> +<li> <a href="http://grass.itc.it/index.html">GRASS</a>: A raster/vector +open source GIS uses GDAL for raster import (via r.in.gdal). +<li> <a href="http://openev.sourceforge.net">OpenEV</a>: An OpenGL/GTK/Python +based graphical viewer which exclusively uses GDAL for raster access. +<li> <a href="http://www.ossim.org">OSSIM</a>: +Another geospatial viewing and analysis environment which uses GDAL as one +of several plugins. +<li> <a href="http://mapserver.gis.umn.edu/index.html">UMN MapServer</a>: +A popular web mapping application with GDAL support. +<li> <a href="http://www.vterrain.org">Virtual Terrain Project</a>: +The VTP libraries now use GDAL. +<li> <a href="http://thuban.intevation.org">Thuban</a>: +A multi-platform interactive geographic data viewer. +<li> <a href="http://qgis.sourceforge.net">Quantum GIS (QGIS)</a>: +A Geographic Information System (GIS) built for Linux/Unix. +QGIS supports vector, raster, and database formats. +<li> <a href="http://www.terrainengine.com">Demeter</a>: +A another OpenGL based terrain engine somewhat similar to VTP. +<li> <a href="http://www.cadcorp.com/">Cadcorp SIS</a>: A Windows GIS with +a GDAL plugin. +<li> <a href="http://www.safe.com/">FME</a>: A GIS translator package +includes a GDAL plugin. +<li> <a href="http://www.scanex.ru/software/scanmagic/">ScanMagic</a>: +Commercial Win32 application for visualization, analysis and processing of +remote sensing data (lite version for free). +<li> <a href="http://www.msmacrosystem.nl/Ilwis/index.html">MS MacroSystem</a>: 3D DEM Viewer. +<li> <a href="http://www.gstat.org/">gstat</a>: a geostatistical modelling +package. +<li> <a href="http://flighttrack.sourceforge.net/">flighttrack</a>: +GPS track viewing and downloading software for Mac. +<li> <a href="http://starspan.casil.ucdavis.edu/?StarSpan">StarSpan</a>: raster/vector analysis. +<li> <a href="http://www.gvsig.gva.es/">gvSIG</a>: Desktop GIS Client. +<li> <a href="http://libral.sourceforge.net/">libral</a>: A raster algebra +implementation and an experimental GUI+CLI GIS with Perl and GTK+. +<li> <a href="http://earth.google.com/">Google Earth</a>: A 3D world viewer. +<li> <a href="http://www.vrco.com/vGeo/OverviewvGeo.html">vGeo</a>: +Interactive data fusion and visual analysis tool. +<li> <a href="http://www.itc.nl/ilwis/">ILWIS</a>: Remote Sensing and GIS +Desktop Package. +<li> <a href="http://www.spaceyes.com/">SpaceEyes3D</a>: Commercial +3D visualization software for cartographic data. +<li> <a href="http://www.mapwindow.org/">MapWindow</a>: open source +ActiveX control with GIS functionality. +</ul> + +*/ diff --git a/Utilities/GDAL/doc/ogr/style_pen1.gif b/Utilities/GDAL/doc/ogr/style_pen1.gif new file mode 100644 index 0000000000000000000000000000000000000000..35b66ac796c0aebddaae229247354547f8b815f3 GIT binary patch literal 132 zcmZ?wbhEHb^k(2^XkcLY|NsAg1_s5SEQ|~c3=BFT0wlx06y4Il^7LE&#dEgY>fU^B z&u{)VVZrtUcb7SVGEK6Ag>Ho$WiCe~k1E~}6igSfN9G`_GJKf)s_6G&4fVC(9<4Ed O|F3zWMVkvFgEatYsxVpr literal 0 HcmV?d00001 diff --git a/Utilities/GDAL/doc/ogr/style_pen2.gif b/Utilities/GDAL/doc/ogr/style_pen2.gif new file mode 100644 index 0000000000000000000000000000000000000000..0640e22dc270ed2b79c5686d6a949b8c1e2888b0 GIT binary patch literal 117 zcmZ?wbhEHb^k(2^XkcLY|NsAg1_s5SEQ|~c3=BFT0wlx0<kQl>^7LE&#dEgY>fU^B l&u{)VVL^FLv!m`!z8@zh1lOqC5W&ht*Y(Il%7u}^8UREOEhYc} literal 0 HcmV?d00001 diff --git a/Utilities/GDAL/doc/ogr/style_pen3.gif b/Utilities/GDAL/doc/ogr/style_pen3.gif new file mode 100644 index 0000000000000000000000000000000000000000..cb62da2a042708e1abca8575d592d51c19a36168 GIT binary patch literal 122 zcmZ?wbhEHb^k(2^XkcLY|NsAg1_s5SEQ|~c3=BFT0wlx06xh<g^7LE&#dEgY>fU^B z&u{)VVL^G$GM6KgN8Oub1q<CiPE2rjnG;xJgThm}At;zGB5b!zZ@Ya@(WNZ?b5)<; N*-LaKdx$Vt0|3&5EA;>X literal 0 HcmV?d00001 diff --git a/Utilities/GDAL/doc/ogr/style_textanchor.gif b/Utilities/GDAL/doc/ogr/style_textanchor.gif new file mode 100644 index 0000000000000000000000000000000000000000..8b99a0bd23bacad67ff60c90ffd9987dff489830 GIT binary patch literal 1538 zcmZ?wbh9u|Y-Z?Y_|Cxa9|X?)|3CBp|Fr-AjsO2=_<!dA|1)R)pPBjpOxpi5#{bVS zfFx(0`9E{!|Cwq3XBz*X$pBKDcIJQD%>QX=|I>{Br!j!E8lU-ZJoCSC+J9r?|Hcge z8UFugIP;%j=6{B?{|v_e85lqYgN&Ye=6~9m|HfzjGl1+lbLPyMnP<+VojGHC<_rVK z+L>q0%$#{<X4;vV#%E?SfLxJw=1khmGihmO(u~ifF@PLpeCCYt%rnMmXN--{7&Dw< z_<x4s%o&E6XBg7XFc_a<V3-N=(wUhcN2kpMIg0`01CUKKXM)T!o_U4=<e`~oW`aQ4 z%$deBXEK2Nmv&}m+RT}0X*1J|XQnZLylZ?0Bx#&B)7W^XF~dxT|1%lR%w(83lOb&; zgYirThBQ#vok;_QPFfns{|un80eNX=8pzScX=fNfK?SmSW*W$7<FuI!ppXMe&rAaW z<FqseP(T`=0a<IDmS$|6X3UVr@IQ^=Od7+?G={V^2IDja24hepoiPSQLz*!tpcz1+ z4hp-OAg!R_U;stJ%rnLyFQplS9L)fVle9A+AEc!jgN$YXMUn9tkcU8gV`F0mV}}36 z3}=iPW*Rf388a9gGk_8YC|tqu4Uz;$At;!^u>w*H4roxQgToG_6&xI(NC5i~WD?lX zpg1v}3GxBhCI$wOSquyy)eH>A?-&^FGBE6BU|7Y#(80h^&cG1Lz~I8bpv1r+$iTor zf%Lm~@9y5cyL<QURjXEYbaa%LmxqRiy12L~DJcmGg3MO@$-)2vIv@g+Cm1;XF)(t- zcx+g3u$e<xE9S(8g@@Y(l)dJ7Y+Q7-Tf#W&&WVkSkM}D$cgc8eT5@u-M)0bblbe>F zo^FtQYL4gTXUFRQM?AVSGg$TfJlVo^e|8G1UR)$q`Aft~Ak%Z1@4_IPS(h?H7AP%s z+v{;vBdjUPv5nPWThh%5spswfo|>BLy;b?4*Ocr_S+Tn%Ursu*JM5+J_PDQ$MDI)} z2-t7Hs~s|D%KPX8!jjvk_896u**X1a&^n%qV#o6{jF0oaw%GLIaOcu#X0cy29_@|& zzpac{N-1#mj&P&fvBl=bv-ipVx_5Trj*pLz+bZeX&AIuh|MX&G`Fk67et9mtINF`> zuhpk#S6BW!&0;^<=I{fPi_4$S-M#ns_YaRx&-dTI@9*y)pI_fUzkmP#{|syz4;om+ zG9EN?sI7R=#AEj2L9>9H#={nou#AVTX>-3#&-PwBZDCt)p~MaU_Qo00J7*<^-VW8+ z_EjiTn``SLXJfyoVY#kXPfX|&{P-i%-%d^CarOpIm!#zAxh}IOSsoP=tny>+3<%s; zxnp6M)5`4u#nzR_9n0_Ywg(s8l)SE5WZk)a>5TssKbIDrF0@Q5ED$q)USzRyrNDGH z&z<U}b!s=C+gJTN$&(va#gf{+Ms|vN^)|&*8fn3Px02JRg`HA~ZfrW5xolS6E6o)X zlRRH7*ettq<tmv{D~*W{SI_HuxMs_>tk-LIJX`g8-JWl+UavpEru}Ba5wYwy8&9aM zezWO}+3Po(FQhGbT6=lflDh>rwuZcQyuFk2S>au&?`x+&Qx#cPt~OPA((Gd^Pv<T) z$bCI&_j@_5%vGD>vZn8Gx>tQYSNTxall_aks;0Vk^1acVykgs{RSN{tTUQ=lYZ|j; z@lUlq4-b{MRy_*v>wC7bTY>q`_0?SLVFm|v>h36>`mfcRyl-M3k95$2OdrEzdS};M zJ|h1A#i!Hum+t7FQJKEyQ<Qh~mxBFj-;b`k>^58N!&!g#)nBj0l)wFYJ)wPVyaR(Z E0MeE08~^|S literal 0 HcmV?d00001 diff --git a/Utilities/GDAL/doc/ru/gdal_building_ru.dox b/Utilities/GDAL/doc/ru/gdal_building_ru.dox new file mode 100644 index 0000000000..b2342da3bc --- /dev/null +++ b/Utilities/GDAL/doc/ru/gdal_building_ru.dox @@ -0,0 +1,312 @@ +#ifndef DOXYGEN_SKIP +/* +$Id: gdal_building_ru.dox,v 1.1 2005/11/09 14:57:08 dron Exp $ +Translation corresponds to gdal_building.dox,v 1.3 2005/11/08 22:34:07 +Translator Andrey Kiselev <dron@remotesensing.org> +*/ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdal_building_ru ������ GDAL �� �������� ������� + +\section gdal_building_unix_ru ������ � ����� Unix + +���������� GDAL ������� ���������� � �������� Linux, IRIX, Solaris, BSD, � +MacOS X. �� Unix-���������� �� ������ �������������� ţ ��������� �������� +(��������������, ��� �������� ������ ����������� ��� ����� �� CVS ������ +<b>gdal</b>): + +<pre> +% cd gdal +% ./configure +% make +% su +Password: ******** +# make install +# exit +</pre> + +��� ����, ����� ��������� GDAL ����� ���������, ���������� ������� ����������� +���������� ��������� ������������� ����������. ������ ����� ����� �������, +������� � �������� ���������� ��������� LD_LIBRARY_PATH ���� +/usr/local/lib.<p> + +�������� �������� �� ��������� �����������:<p> +<ul> + +<li> ��� ������ �� ��������� Unix ���������� ������� GNU make. �������� � +���������� ţ, ���� ��� ����������� � ����� �������.<p> + +<li> GDAL �� ������� �������� ����� �������������� �������. ��� �������� � ���� +�������� ������ ��������� libz, libtiff, libgeotiff, libpng, libgif, � +libjpeg, ������� ����� ���� ������������, ���� ����������� �� ����������������� +������ (���� �� ������������� ������������). + +<li> ��������� �������� ������� �� +\ref gdal_building_libraries_ru "������� ���������". +������� <i>configure --help</i> ������� ������ ���������� ������, � ��� ����� +��������� ��� �������� ����� � ������� �����������, ����������� ��� ������ � +��������� GRASS, FITS, OGDI, HDF4, JPEG2000, ECW � �.�. + +<li> ������� ������ ����������� ���������� � ������� ������� ������������ +������� ������������ GNU. ���� �� ����������� ���-�� ����, ��� GNU C++, �� +������ ����� ��������, ��� ����� .so �� ����� ��������� �������. � ���� ������ +����� ����������� ��������� ���������� �� ������������ ������������ (������ +gdal/gdal.a gdal/ogr/ogr.a gdal/frmts/o/ *.a gdal/gdal.a gdal/port/cpl.a), +���� �������� ������� LD_SHARED � ����� gdal/GDALmake.opt ���, ����� ��� +�������� �� ����� ���������. ��������, ��� �������� SGI ������ �������� +������� <i>c++ -shared -all</i>.<p> + +<li> � GDAL, � ����ޣ���� � �������� ������� ������ ��������� ���������� � +����� Cygwin � �� ����������, ��� ����������� ���������� �� ��������������. +������ ��� ������ ����� ����������� ���������� ��������� ���������� � ����� +������� ������� ���������. ������� <i>gdal-config --libs</i> ������� ��������� +������ ���������. + +<li> ������ "autoconf", ����������� ������� libtiff, libpng � libjpeg +������������ ������ ��������� ������ ���� ���������. ���� �� ����������� +����������������� ���������� � ��� �� ��������, ������������� ������ +<i>configure</i> � ����������� "--with-png=internal", "--with-jpeg=internal", +"--with-geotiff=internal" ��� "--with-libtiff=internal". <p> + +<li> ��� ������ �� IRIX ������ ����� ����������� ������� ��������� ���� +GDALmake.opt, ������������ � ���������� ������� <i>configure</i> � �������� +"ld -shared" �� "ld -shared -all".<p> + +<li> ���� ��� ������ �� ���������� �������� � ����� �� ��������� ��� �������, +������� ��� �� �����, �� ������ ������� ��� �� ������ GDAL_FORMATS � ����� +����� gdal/GDALmake.opt, �������� <i>make clean</i> � ����� <i>make</i>. ��� +�������� ��� �� �������� ���������� � ������������� ����� �������.<p> + +<li> ��� ����������� ��� ���� ����������������� (� ���� ����������� �������, +��������� ���������� --prefix), �� �� ������ ����� �������� �������� � +�������� ��� ����� Python, ��������� ��� ������ �������� ������������ � +������� site-packages � ������ Python. ���� ��������� Python ��� �� �����, �� +�� ������ ��������� ţ �� ����� ���������������� � ������� ��������� +--without-python, ���� ������� ��������� ��� ������ ������� � ������� +��������� --with-pymodir=<directory>. ������ Python ����� ����������� +����. + +</ul> + +\section gdal_building_win_ru ������ � ����� Windows + +� ����� Windows GDAL ����� ������� � ������� ������������ MS VC++ 6.x ��� MS +Visual Studio .NET (C++) �� ��������� ������. ��� ����� ��� ������ ������� +��������� ������ VCVAR32.BAT, ������� ��������������� ������ � ������������. +��� MSVC 6.x �� ����� ���� ���������� � + +<pre> +C:\\Program Files\\Microsoft Visual Studio\\VC98\\bin\\VCVARS32.BAT +</pre> + +��� ������ ��� ���������� ��������� ����� �����������, ����� ���������� � �������� ������� GDAL � ��������� ��������� �������:<p> + +<pre> +C:\\GDAL> nmake /f makefile.vc +</pre> + +����� ��������� ���������� ������ ����� ���������� ��� ����������� ��� +���������������� GDAL �����, ��������� ���� install ���������. ����� +���� ���������, ��� ���������� BINDIR � DATADIR � ����� <i>nmake.opt</i> +����������� � ���������� ��� ��� ��������:<p> + +<pre> +C:\\GDAL> nmake /f makefile.vc install +</pre> + +���� �� ����������� ��������� GDAL � ����� ����������� �����������, �� ����� +������������ ��������� ������� ��� ��������� ���� ����������� ��������� � +������������ ������. ���������, ��� � ����� <i>nmake.opt</i> ���������� LIBDIR +� INCDIR ����������� � ���������� ��� ��� ��������. + +<pre> +C:\\GDAL> nmake /f makefile.vc devinstall +</pre> + +�������, ���������� � GDAL, ������ �������� �������, �������� � ���������� +INCDIR, � ������ ����� ��� ������ ������������ ������, � �������, �������� � +LIBDIR � ������ /LIBPATH. ����������� ������� � ����������� ������� +<i>gdal_i.lib</i>. + +\subsection gdal_building_win_basic �������� ��������� + +���� <i>nmake.opt</i>, ������������� � �������� �������� GDAL, �������� +������� ���������� ����������, ������� ����� ���� ��������� �������:<p> + +<ul> +<li> <b>BINDIR</b>: �������, � ������� ����� ����������� ����������� ����� � +����������� ���������� ��� ���������� ������� "nmake /f makefile.vc install". + +<li> <b>LIBDIR</b>: �������, � ������� ����� ����������� ���������� ������� +gdal_i.lib. + +<li> <b>INCDIR</b>: �������, � ������� ����� ����������� ������������ ����� +GDAL/OGR. + +<li> <b>DATADIR</b>: �������, � ������� ����� ����������� ����������� ����� +������. + +<li> <b>OPTFLAGS</b>: ��� ���������� ������ ��������� ����� �����������, +������� ������� ��������� ��� ������ GDAL. �� ��������� ������������ ������ � +���������� �����������, � ����� ��� ���������������� ������������� ������ +����������������. ����������, �������� �������� �� ��, ��� ���� �� ������ +�������� GDAL � �������������� �������������� ��������� (������������� �� +�������� �������, ���� ��������� ���� �����), ��� ���������� ������������ +���������� ��������� ������ ��� ���� ��������� � ��� GDAL. ��������, ���� �� +����������� ���� /MD � ������ <b>OPTFLAGS</b> (���������� � ������������� +����������� ����������� �����������), �� ��� �� ����� ���� ������ ���� +����������� ��� ���������� ������ ���������, �����, ��� HDF4 � JasPer. ���� � +��� ��� �������� ������� �������������� ���������, �� ���������� +������������, ������������ ������ � ����, ��� ����, ����� ��������, ��� ��� +���� �������������� � ����� ����� ��� ������� ��������� � ������ +<b>OPTFLAGS</b>. ���������� ��������� ���������� ���������� ��� ������ +�����������/������� �����ģ� � ������� ��� ������ ��� � �������� ����� ������� +�� ����������. + +</ul> + +\subsection gdal_building_win_advanced_ru �������������� ��������� + +<ul> + +<li> <b>PY_INST_DIR</b>: �������, � ������� ����� ��������������� ������ +��������� ����� Python. ��������� ������ � ������, ���� ��� ��������� +��������. + +<li> <b>PYDIR</b>: �������, � ������� ����������� ������ Python. ������������ +��� ��� ������ ������������ ������ Python. ���� ��� ���������� ��������� �� +�������������� �������, �� ����� ��������� Python ����� ���������. + +<li> <b>DLLBUILD</b>: ���������� ��� ���������� � �������� "1", ����� +��������� ������� OGR ����������� � ����������� ����������� GDAL, � �� +��������������� ����������. + +<li> <b>INCLUDE_OGR_FRMTS</b>: ���������� ��� ���������� � �������� "YES", +����� �������� ������ ���������� OGR, ���� ��������������� ţ, ��� ���������� +OGR �� ������. + +<li> <b>SETARGV</b>: ���� � ����� <i>setargv.obj</i> �� �������� Visual +Studio. �������� ��� ����������, ���� �� ������ �������� ��������� +������������ � ���������� ��������� ������. ���� ��� ��� �� ���������, +�������� �������� ������������������. + +<li> <b>ECWDIR/ECWLIB</b>: ���������������� ��� ��������� ��� ��������� +��������� ECW. ECWDIR ������ ��������� �� �������, � ������� ����������� +���������� ECW. + +<li> <b>OGDIDIR/OGDIVER/OGDILIB</b>: ���������������� ��� ��������� ��� +��������� ��������� OGDI, �������������� OGDIDIR � OGDIVER � ������������ � +����� ��������. + +<li> <b>HDF4_DIR</b>: ���������������� � �������������� ��� ���������� ��� +��������� ��������� NCSA HDF Release 4. + +<li> <b>JASPER_DIR/JASPER_INCLUDE/JASPER_LIB</b>: ��� ���������� ��������� �� +��������, � ������� ����������� ���������� ���������� JasPer. ��� ���������� +���������� ��� ��������� ������� JPEG2000. + +<li> <b>XERCES_DIR/XERCES_INCLUDE/XERCES_LIB</b>: ���������������� � +�������������� ���������� XERCES_DIR ��� ��������� ��������� XML-����������� +Xerces ��� ������ ������ � ������� GML. + +<li> <b>FME_DIR</b>: ���������������� � �������������� ��� ���������� ��� +��������� ��������� ���������� ������� FMEObject. + +<li> <b>JPEG_EXTERNAL_LIB/JPEGDIR/JPEG_LIB</b>: ��� ���������� ������������ +��� ���������� GDAL � ������� ����������� JPEG (�� ��������� ����� +�������������� ���������� ����������). ���������������� �� � �������������� +����. + +<li> <b>PNG_EXTERNAL_LIB/PNGDIR/PNG_LIB</b>: ��� ���������� ������������ +��� ���������� GDAL � ������� ����������� PNG (�� ��������� ����� +�������������� ���������� ����������). ���������������� �� � �������������� +����. + +</ul> + +��� ���������� ����� ����������� � ����� ������� �������� ��������� ��� +Windows, ������� ���� ��� ������ ���-�� �� �������, ���������� �������� ������ +������ � ��������������� makefile.vc �� �������� � GNUmakefile, ���� ������ +�������� �� ���� ���.<p> + +\section gdal_building_libraries_ru ������� ���������� + +��������� �������� ������� ��������� �� ���� ������� ��������� �������������� +���������: + +<ul> +<li> ���������� NCSA HDF. ����� ���� ������� � +<a href="http://hdf.ncsa.uiuc.edu/">�������� �������� NCSA HDF</a> � +<a href="http://www.ncsa.uiuc.edu/"> ������������ ������ ����������������� +����������</a>.<p> + +���� � �������� ����� ������������ ������� ��� ������ ���������� HDF, �� �� +������ ������������ ţ.<p> + +�������� �������� �� ��, ��� ���������� NCSA HDF ������� � ����� ����� +����������, ������̣���� � ����� <i>hlimits.h</i>. � +���������,<i>hlimits.h</i> ���������� ������������ ����� �������� ������: + +<pre> +# define MAX_FILE 32 +</pre> + +���� ��� ����� ��������� ������������ ������� ����� ������ � ������� HDF4, �� +��� �������� ������� �������� � ����������������� ���������� HDF4 (��� ���� +��� ������������� � ���������� GDAL, ���� ��� ��� ������� � ���������� +����������� ���������� HDF4). + +<li> ��������� JPEG2000 ������������ �� ���������� JasPer, ��������� �� ����� +<a href="http://www.ece.uvic.ca/~mdadams/jasper/"> �������� ��������</a>.<p> + +���� �� ���� ���������� JasPer �������� ������������ ����� ����������� +���������� ��������� ������. GDAL ���������� ������ ������� JP2 � JPC.<p> + +���� �� ������ �������� ��������� ���������� GeoJP2, �� ��� ����������� +���������������� ���������� JasPer, ������� ����� ���� ������� ������: +<a href="ftp://ftp.remotesensing.org/gdal/jasper-1.701.0.uuid.tar.gz"> +ftp://ftp.remotesensing.org/gdal/jasper-1.701.0.uuid.tar.gz</a> + +<li> ������� ������� MrSID ������� ������������ ���������� LizardTech (DSDK). +��� �� ��������� ����������� �����������, ������ ��� ��������� �������� �� +����� <a href="http://developer.lizardtech.com/"> +http://developer.lizardtech.com/</a>. ���� �� ������ ��������� ����� � ������� +MrSID, ��� ����������� ���������� ���������� (ESDK). ��������� � +��������������� �������� <a href="http://www.lizardtech.com">LizardTech</a> +��� ��������� ������� ţ ���������. ���������� MrSID ���������������� � +�������� ���� �, ���� �� ����������� GCC, ���������, ��� ����������� ��� �� +����� ����������, ������� ��� ����������� ��� ������ SDK. ������ ���������� +�������� �� C++, ������� �� ������ �������� ��������������� � ����� ���������� +�������� ��� ������������� ��������� ������ GCC (2.95.x and 3.x). + +<li> ��������� ������� NetCDF ������� +<a href="http://www.unidata.ucar.edu/packages/netcdf/">���������� netCDF</a>. +����� ������ � ��������� ���� ���������� ����������� �������� +"--with-netcdf=<path to install tree>" ��� ���������������� GDAL. ��� +������������� ������������� ��������� netCDF � HDF ����� ���������� ��������� +����������, ������� ����� ������������� ����� ��������� �����������. ��������� +NetCDF �� ���������� � �� ������������� � ����� Windows.<p> + +</ul> + +\section gdal_building_lfs_ru ��������� ������� ������ + +GDAL ������������ ������ � ������ ������� ������ (> 2GiB), ���� ��� �������� � +����� ������������ �������. ���������� � ��������� ������� ������ � ������� +Linux ����� �������� �����: <a href="http://www.suse.de/~aj/linux_lfs.html"> +http://www.suse.de/~aj/linux_lfs.html</a>. �������: ���� �� ��������� � ����� +2.4.x � glibc 2.2.x, �� ������� ���� �� ������. ������������ ������ ����� +������� �� ������� �������� �������� �������. ��� �������� ������� ext2 � +��������� � 1 KiB ��� 16448 MiB, ��� ext2 � ��������� 4 KiB ��� 2048 GiB. +������ �������� ������� ����� �������� � ������� ���� �������� �������.<p> + +���������� � ��������� ������� ������ � Windows ����� ����� �� ��������� +<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/supported_file_systems.asp">MSDN</a>. +�������: ������������ ������ ����� �� NTFS ��������� (2^64 - 1) �������, �� +FAT32 � FAT16 ��� (2^32 - 1) ����. ������� �� ��������� ��������� �����, +�������, ��� 4 GiB �� FAT32. � ��������� ������� �� ���� �� �������� ��������� +�� ������ ��� �������� �� ������ � 4GiB, � ���� ������ ����� ��������. ��� �� +������ � GDAL, ��� �������� Windows.<p> + +*/ diff --git a/Utilities/GDAL/doc/ru/gdal_datamodel_ru.dox b/Utilities/GDAL/doc/ru/gdal_datamodel_ru.dox new file mode 100644 index 0000000000..c11fb21a57 --- /dev/null +++ b/Utilities/GDAL/doc/ru/gdal_datamodel_ru.dox @@ -0,0 +1,252 @@ +#ifndef DOXYGEN_SKIP +/* +$Id: gdal_datamodel_ru.dox,v 1.2 2005/11/08 22:36:08 dron Exp $ +Translation corresponds to gdal_datamodel.dox,v 1.4 2005/10/26 +Translator Andrey Kiselev <dron@remotesensing.org> +*/ +#endif /* DOXYGEN_SKIP */ + +/*! +\page gdal_datamodel_ru ������ ������ GDAL + +��������� �������� ��������� ������ ������, ����������� ����������� GDAL: +������������� ����������, ������� ����� ����������� � ���������� ������ GDAL, +� ����� �� ���������.<p> + +\section gdal_datamodel_ru_dataset ����� ������ + +����� ������ (�������������� ������� GDALDataset) ������� �� ��������� +��������� �������, � ����� ��������� �������������� ����������, ����� ��� +����� ������. � ���������, ����� ������ ����� ������� ������� (������ � +������), ����� ��� ���� �������. ����� ������ ����� �������� �� �������������� +�������� � �������� ������������ �������, ����� ������ ��� ���� �������. ��� +����� ������ ����� ����� ��������������� �������� ����������: ������ ��� +����/�������� � ����� ASCIIZ ����� + +�������, ��� ����� ������ GDAL � ������ ��������� ������� ���������� +���������� �� ������������ ���������� �������� ����������� OpenGIS. + +\subsection gdal_datamodel_ru_dataset_cs ������� ��������� + +�������������� ������������ ������� �������������� � ���� ����� OpenGIS WKT +(Well Known Text). ����� ������ ����� ���������: + +<ul> +<li> ����� �������� ������������ �������. +<li> �������� �������������� ������������ �������. +<li> ������������� ������� ���������. +<li> �������� ����������, ������� �������, ������. +<li> �������� ���������� ��������� � ��� �������� ������������ ������������. +<li> �������� �������� (��������, Transverse Mercator). +<li> ������ ���������� �������� (��������, ��������� ������� ���������). +<li> �������� ������ ��������� � ��������� ��� �������� � ������ ��� ��������. +<li> �������� � ������� ���������� ������������ ����. +<li> ���� ��� ����������������� ���������� �� ����������̣���� ��������, +�����, ��� ������� EPSG. +</ul> + +�������������� �������� �� ������������ ������������ ������ � ������� ����� +OpenGIS WKT � �������� ������ � ���� ����� ����� � ������� +<a href="ogr/osr_tutorial.html">osr_tutorial</a>, � ����� � ������������ �� ����� +OGRSpatialReference. + +������������ �������, ������������ ������� GDALDataset::GetProjectionRef() +��������� ������������� ����������, ������������ � ������� ������� ��������� +��������������, ������������ �������� GDALDataset::GetGeoTransform(). +������������ �������, ������������ ������� GDALDataset::GetGCPProjection() +��������� ������������� ���������� �������� ����������� �����, ������ ������� +���� ����� GDALDataset::GetGCPs(). + +�������, ��� ������ ������ (""), ������������ � �������� ����������� ������������ �������, �������� ���������� ���������� � ������������ �������. + +\subsection gdal_datamodel_ru_dataset_gtm �������� �������������� ������������� ��������� + +���������� ��� ������� ������ ����� ����� ������� ������ (� �������� +������/�������) � �������������� ������������. ������ � �������� ����� +������������ --- ��� �������� ��������������. ������ ������������ +������������� �������� ����������� �����. + +������� ��������� �������������� ������� �� ����� �������������, ������������ ������� GDALDataset::GetGeoTransform(), ������� ���������� ������/������� � ������������ ������������� ��������� �� ���������� �����������: + +<pre> + Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2) + Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5) +</pre> + +� ������ �����������, ������� ����� ������� ������������� �� �����, +������������ GT(2) � GT(4) ����� ����, GT(1) ����� ������ �������, � GT(5) --- +��� ������. ���������� (GT(0),GT(3)) ������ ��������� �������� ������ ���� +�������� ������ ������� ������. + +�������, ��� ���������� ������/������� ����� ��������� �������� �� (0.0,0.0) � ������� ����� ���� �������� ������ ������� �� (������_� ��������,������_�_��������) � ������ ������ ���� ������� ������� �������. ��������� ������ �������� ������ ������� � �������� ������/������� �����, ����� �������, (0.5,0.5). + +\subsection gdal_datamodel_ru_dataset_gcp �������� ����������� ����� (Ground Control Points, GCPs) + +����� ������ ����� ����� ������ ����������� �����, ����������� ���� ��� +��������� ����� ������ � �� �������������� ������������. ��� ����������� ����� +������ � ����� � ��� �� ������������ �������, ������������ ������� +GDALDataset::GetGCPProjection(). ������ ����������� ����� (����������� ������� +GDAL_GCP) �������� ���������: + +<pre> +typedef struct +{ + char *pszId; + char *pszInfo; + double dfGCPPixel; + double dfGCPLine; + double dfGCPX; + double dfGCPY; + double dfGCPZ; +} GDAL_GCP; +</pre> + +������ pszId ������ ���� ���������� (�, �����, �� �� ������, ��������) +��������������� ��� ����������� ����� � ������ ����� ������� ������. pszInfo +--- ��� ������ ������ ������, �� ��� ����� ����� ��������� ����� +��������������� �����, ����������� � ������ �����. ������������ ��� ���� ����� +����� ��������� ������� �������� ���������� � ������� ������ �����, ������ � +��������� ������ ��� ����������� �� �����������. + +���������� (dfGCPPixel, dfGCPLine) ������ ��������� ����� �� ������. +���������� (dfGCPX, dfGCPY, dfGCPZ) ������ ��������������� �������� ����� � +������������� ����������� (���������� Z ����� ������ ��̣�). + +������ ������ GDAL �� �������� ��������� ��������������, ����������� �� +����������� �����, --- ��� ��������� ��� ���������� ����� �������� ������. +������ ��� ����� ����������� �������� �� 1-�� �� 5-�� �������. + +������ ����� ������ �������� ���� �������� ��������������, ���� ����������� �����, ���� ������. � ������ ������� ����� �������������� � ��, � ������, ����� �� ����������, ����� �� �������� ����� ������������. + +\subsection gdal_datamodel_ru_dataset_metadata ���������� + +���������� --- ��� ��������������� ������, ���������� � ���� ��� ����/��������. +�� ������ ������������ �������� �������� ������ � �����������. ����� ������ +���� "��������" ��������� (��� ���������� � ����������� ��������). �������� +����� ����� ����� ����� � ��������� ����� �������, �� ����������� �������� +������� ASCII. + +�������� ���������� ����������� ������ ������������� ��� ������ � ����� +�������� ������� ������. ������ ������ � �����������, ������������ � ������� +100KiB ������ ����� �����ģ� � �������� ������������������. + +� ������� �������������� �������� ���������� ����������� ������ � ����������̣���� ����������, ������ � ��������� ������ ������� ���. + +��������� ������� ������ �������� ����������� ����������, � �� ����� ��� �������� ��� ������ �������� ����� ���������� ����, ����������� ��� ������� �������, � ������ ����������. ��������, ������� TIFF ���������� ���������� ��������� �������������� ����� � ���� ����������, ������� ���� ����/�����, ������� ����� ��������� ���: + +<pre> +TIFFTAG_DATETIME=1999:05:11 11:29:56 +</pre> + +\section gdal_datamodel_ru_rasterband ��������� ����� + +��������� ����� ����������� � GDAL � ������� ������ GDALRasterBand. �� �� +����������� ������ ������������ �ӣ �����������. ��������, 24-������ +RGB-����������� ������ ���� ������������ ��� ����� ������ � ����� ��������, �� +������ ��� �������, ��̣��� � ����� ����������. + +��������� ����� ����� ��������� ��������: + +<ul> + +<li> ������ � ������ � �������� � �������. ��� ����� ���� �� ������, ��� � ��� ����� ������ ������, ���� ��� ����� � ������ ����������. + +<li> ��� ������ (GDALDataType). ���� �� ������������ (Byte, UInt16, Int16, +UInt32, Int32, Float32, Float64), ��� ����������� ����� CInt16, CInt32, +CFloat32, and CFloat64. + +<li> ������ �����. ���������������� (�������� �����������) ������ ����� ������ ��� ����������. ��� �����������, ���������� ���������, ��� � ����������� ������� ����� ���� ������. + +<li> ������ ���������� � ���� ��� ����/�������� � ��� �� �������, ��� � ��� ����� ������ ������, �� ���������� ����������, ����������� ��� ������� ������. + +<li> �������������� ������ ��������. + +<li> �������������� ������ ��������� (��������, �������� ������� �� +������������ �����). + +<li> �������������� ����������� � ������������ ��������. + +<li> �������������� ������������� ������������ ��� �����ޣ�� �������� ������ � +���������� �������� (��������, ������� ���ޣ��� ������ � �����). + +<li> �������������� �������� ������ ���������. ��������, ��� ���� ����� +��������� ������� ��������� ������ ��� ������ �������. + +<li> �������� ������������� ������. ���� ��: + + <ul> + <li> GCI_Undefined: �� ���������, �� ����������. + <li> GCI_GrayIndex: ��������� ����������� � �������� ������. + <li> GCI_PaletteIndex: ����������� � �������� ��������. + <li> GCI_RedBand: ������� ���������� RGB- ��� RGBA-�����������. + <li> GCI_GreenBand: ��̣��� ���������� RGB- ��� RGBA-�����������. + <li> GCI_BlueBand: ����� ���������� RGB- ��� RGBA-�����������. + <li> GCI_AlphaBand: �����-����� RGBA-�����������. + <li> GCI_HueBand: ���������� ����� HLS-�����������. + <li> GCI_SaturationBand: ���������� ������������ HLS-�����������. + <li> GCI_LightnessBand: ���������� ������� HLS-�����������. + <li> GCI_CyanBand: ������� ���������� CMY- ��� CMYK-�����������. + <li> GCI_MagentaBand: ��������� ���������� CMY- ��� CMYK-�����������. + <li> GCI_YellowBand: ֣���� ���������� CMY- ��� CMYK-�����������. + <li> GCI_BlackBand: ޣ���� ���������� CMY- ��� CMYK-�����������. + </ul> + +<li> ������� ������ (�������), ������� ����� �������� ������� ����. + +<li> ���������� �� ����������� �������� ������������ (���������). + +</ul> + +\section gdal_datamodel_ru_rasterband_ct ������� ������ + +������� ������ ������� �� ���� ��� ���������� �������, ����������� �� ����� C +� ���� ��������� ���������: + +<pre> +typedef struct +{ + /- �����, �������, ������� ��� ���� -/ + short c1; + + /- ��̣���, ��������� ��� ������� -/ + short c2; + + /- �����, ֣���� ��� ������������ -/ + short c3; + + /- �����-����� ��� ޣ���� -/ + short c4; +} GDALColorEntry; +</pre> + +������� ������ ����� ����� ��������� ������������� (GDALPaletteInterp), +������� ��������� �� ��, ��� ��������� c1/c2/c3/c4 ������ ���� +������������������� �����������. ���� ��������� ����� ��������� ��������� +��������: + +<ul> +<li> GPI_Gray: ������� c1 ��������� � ��������� ������. +<li> GPI_RGB: ������� c1 �������, c2 ��̣���, c3 �����, � c4 --- �����-�������. +<li> GPI_CMYK: ������� c1 �������, c2 ���������, c3 ֣����, c4 ޣ����. +<li> GPI_HLS: ������� c1 ������, c2 ��������, c3 �������������. +</ul> + +��� ���������� ����� � �������� �������� ����� ������� ������������ � �������� ������� � ������� ������. ��� ������, ��� ����� ������ ������������� � ������� ������� � �������� ������� � ����� �� �����������. �� ���������� ��������� ��� ���������������� ��������������� ��������, ������, ��� ����� ��������� ������� ������. + +\section gdal_datamodel_ru_rasterband_overviews �������� ����������� + +����� ����� ��������� �������� �����������. ������ �������� ����������� +������������ � ���� ���������� ������ GDALRasterBand. ������ ��������� +����������� (� �������� ����� � ��������) ����� ���������� �� �������� +��������������� ������, ������ ������������� ��� ����� ��������� ���� � ��� �� +������. + +�������� ����������� ����������� ��� �������� ����������� ����������� ����� +������, ������ ����, ����� ������ �������������� ����������� � ����������� +����������������. + +����� ����� �������� ��������� HasArbitraryOverviews, ������� ����� TRUE, ���� ����� ����� ���� ���������� �������� � ����� ����������, �� �� ����� ޣ���� ������������� ��ϣ�. ������ ���������� �������� ��������� ��������� ����������� ����������� � ������� ��� � ���������, � ����� �����������, ���������� �� ������� ���������� (�����, ��� OGDI), ����� ��������������� ������������ �� ���̣���� �������. + +*/ + + diff --git a/Utilities/GDAL/doc/ru/gdal_tutorial_ru.dox b/Utilities/GDAL/doc/ru/gdal_tutorial_ru.dox new file mode 100644 index 0000000000..8a637ea4a6 --- /dev/null +++ b/Utilities/GDAL/doc/ru/gdal_tutorial_ru.dox @@ -0,0 +1,616 @@ +/* +$Id: gdal_tutorial_ru.dox,v 1.1 2005/10/26 17:22:57 dron Exp $ +������� ������������� gdal_tutorial_ru.dox,v 1.8 2005/10/26 13:54:24 +����ף� ������ ����̣� <dron@remotesensing.org> +*/ + +/*! +\page gdal_tutorial_ru ����������� �� ������������� GDAL + +\section gdal_tutorial_ru_open �������� ����� + +����� ���, ��� ������� ����� ������, �������������� GDAL, ���������� +���������������� ��������. ��� ������� ��������������� ������� ���������� +��������� �������. � ����������� ������� ��� ����� ������� � ������� ������� +GDALAllRegister(), ������� �������� ���������������� ��� ��������� ��������, +������� ��, ��� ��������� �� ����������� ������������ ������� .so, ��������� +GDALDriverManager::AutoLoadDrivers(). ������� ����������� ���������� ����� +���������, ��������� � ����������; �������� ����� ������� ��� ������ <a +href="gdalallregister.cpp.html">gdalallregister.cpp</a>. + +��� ������ �������� ����������������, ���������� ������ ������� ������� +GDALOpen() ��� �������� ������ ������. � �������� ���������� ������� ��������� +�������� ������ ������ � ����� ������� (GA_ReadOnly ��� GA_Update). + +�� ����� C++: +\code +#include "gdal_priv.h" + +int main() +{ + GDALDataset *poDataset; + + GDALAllRegister(); + + poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly ); + if( poDataset == NULL ) + { + ...; + } +\endcode + +�� ����� C: +\code +#include "gdal.h" + +int main() +{ + GDALDatasetH hDataset; + + GDALAllRegister(); + + hDataset = GDALOpen( pszFilename, GA_ReadOnly ); + if( hDataset == NULL ) + { + ...; + } +\endcode + +�� ����� Python: +\code + import gdal + from gdalconst import * + + dataset = gdal.Open( filename, GA_ReadOnly ) + if dataset is None: + ... +\endcode + +���� GDALOpen() ���������� NULL, ��� ��������, ��� �������� �� ������� � ��� +��������� �� ������ ���� ������� � ������� ������� CPLError(). ���� �� ������ +��������� ��������� ������ ������������ ��������� �� �������, �� ���������� � +������������ �� ������� CPLError(). ������ ������, CPLError() ����������� �� +���� ����������� GDAL ��� ������ ��������� �� �������. ������� �����, ��� +pszFilename �� ������ ����������� ���� ������ ����� �� ���������� �������� +(���� ������ ��� ���). ������������� ����� ��������� ������� �� ��������, ��� +����� ���� URL ��� ��� ����� � ��������������� �����������, ������������ +��������� ������, ���� ���-�� ����. ����������, �� ������������� ������� +������ ������ ������ ��� �������� ������ ���� ������� �� ���������� ���������. + +\section gdal_tutorial_ru_dataset ������ ���������� � ������ ������ + +��� ���� ������� � ������� <a href="gdal_datamodel.html">������ ������ +GDAL</a>, ����� ������ GDALDataset �������� ������ ��������� �������, +����������� ���� � �� �� ���������� � ������� ���������� ����������. �� ����� +�������� ����������, ������������ �������, �������������� ��������, ������ +������ � ��������� �������������� ����������. + +\code + adfGeoTransform[0] /* ���������� x �������� ������ ���� */ + adfGeoTransform[1] /* ������ ������� */ + adfGeoTransform[2] /* �������, 0, ���� ����������� ������������� �� ����� */ + adfGeoTransform[3] /* ���������� y �������� ������ ���� */ + adfGeoTransform[4] /* �������, 0, ���� ����������� ������������� �� ����� */ + adfGeoTransform[5] /* ������ ������� */ +\endcode + +���� �� ����� ������� ��������� ����� ���������� � ������ ������, �� ����� +������� ���������: + +�� ����� C++: +\code + double adfGeoTransform[6]; + + printf( "�������: %s/%s\n", + poDataset->GetDriver()->GetDescription(), + poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) ); + + printf( "������ %dx%dx%d\n", + poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), + poDataset->GetRasterCount() ); + + if( poDataset->GetProjectionRef() != NULL ) + printf( "�������� \"%s\"\n", poDataset->GetProjectionRef() ); + + if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None ) + { + printf( "������ ��������� (%.6f,%.6f)\n", + adfGeoTransform[0], adfGeoTransform[3] ); + + printf( "������ ������� (%.6f,%.6f)\n", + adfGeoTransform[1], adfGeoTransform[5] ); + } +\endcode + +�� ����� C: +\code + GDALDriverH hDriver; + double adfGeoTransform[6]; + + hDriver = GDALGetDatasetDriver( hDataset ); + printf( "�������: %s/%s\n", + GDALGetDriverShortName( hDriver ), + GDALGetDriverLongName( hDriver ) ); + + printf( "������ %dx%dx%d\n", + GDALGetRasterXSize( hDataset ), + GDALGetRasterYSize( hDataset ), + GDALGetRasterCount( hDataset ) ); + + if( GDALGetProjectionRef( hDataset ) != NULL ) + printf( "�������� \"%s\"\n", GDALGetProjectionRef( hDataset ) ); + + if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None ) + { + printf( "������ ��������� (%.6f,%.6f)\n", + adfGeoTransform[0], adfGeoTransform[3] ); + + printf( "������ ������� (%.6f,%.6f)\n", + adfGeoTransform[1], adfGeoTransform[5] ); + } +\endcode + +�� ����� Python: +\code + print '�������: ', dataset.GetDriver().ShortName,'/', \ + dataset.GetDriver().LongName + print '������ ',dataset.RasterXSize,'x',dataset.RasterYSize, \ + 'x',dataset.RasterCount + print '�������� ',dataset.GetProjection() + + geotransform = dataset.GetGeoTransform() + if not geotransform is None: + print '������ ��������� (',geotransform[0], ',',geotransform[3],')' + print '������ ������� = (',geotransform[1], ',',geotransform[5],')' +\endcode + +\section gdal_tutorial_ru_band ������ ���������� ������ + +����� �� �������� ������ ��������� ������ � ������� GDAL �������� ����������� +������. ��� ���� ��� ���������������� ������ ������� �������� ����������, +��������� ������, � ����� ��������� ������ ����������. ����� ��������� ������� +����, ������������ ������ GDALRasterBand �� ������ ������ (������ ���������� +�� 1 � �� GetRasterCount()) � ���������� ��������� ���������� � ������. + +�� ����� C++: +\code + GDALRasterBand *poBand; + int nBlockXSize, nBlockYSize; + int bGotMin, bGotMax; + double adfMinMax[2]; + + poBand = poDataset->GetRasterBand( 1 ); + poBand->GetBlockSize( &nBlockXSize, &nBlockYSize ); + printf( "������ ����� %dx%d, ��� ������ %s, ColorInterp=%s\n", + nBlockXSize, nBlockYSize, + GDALGetDataTypeName(poBand->GetRasterDataType()), + GDALGetColorInterpretationName( + poBand->GetColorInterpretation()) ); + + adfMinMax[0] = poBand->GetMinimum( &bGotMin ); + adfMinMax[1] = poBand->GetMaximum( &bGotMax ); + if( ! (bGotMin && bGotMax) ) + GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax); + + printf( "Min=%.3fd, Max=%.3f\n", adfMinMax[0], adfMinMax[1] ); + + if( poBand->GetOverviewCount() > 0 ) + printf( "����� �������� %d �������� �����������.\n", + poBand->GetOverviewCount() ); + + if( poBand->GetColorTable() != NULL ) + printf( "����� �������� ������� ������ � %d ��������.\n", + poBand->GetColorTable()->GetColorEntryCount() ); +\endcode + +In C: +\code + GDALRasterBandH hBand; + int nBlockXSize, nBlockYSize; + int bGotMin, bGotMax; + double adfMinMax[2]; + + hBand = GDALGetRasterBand( hDataset, 1 ); + GDALGetBlockSize( hBand, &nBlockXSize, &nBlockYSize ); + printf( "������ ����� %dx%d, ��� ������ %s, ColorInterp=%s\n", + nBlockXSize, nBlockYSize, + GDALGetDataTypeName(GDALGetRasterDataType(hBand)), + GDALGetColorInterpretationName( + GDALGetRasterColorInterpretation(hBand)) ); + + adfMinMax[0] = GDALGetRasterMinimum( hBand, &bGotMin ); + adfMinMax[1] = GDALGetRasterMaximum( hBand, &bGotMax ); + if( ! (bGotMin && bGotMax) ) + GDALComputeRasterMinMax( hBand, TRUE, adfMinMax ); + + printf( "Min=%.3fd, Max=%.3f\n", adfMinMax[0], adfMinMax[1] ); + + if( GDALGetOverviewCount(hBand) > 0 ) + printf( "����� �������� %d �������� �����������.\n", + GDALGetOverviewCount(hBand)); + + if( GDALGetRasterColorTable( hBand ) != NULL ) + printf( "����� �������� ������� ������ � %d ��������.\n", + GDALGetColorEntryCount( + GDALGetRasterColorTable( hBand ) ) ); +\endcode + +�� ����� Python: +\code + band = dataset.GetRasterBand(1) + + print '��� ������',gdal.GetDataTypeName(band.DataType) + + min = band.GetMinimum() + max = band.GetMaximum() + if min is not None and max is not None: + (min,max) = ComputeRasterMinMax(1) + print 'Min=%.3f, Max=%.3f' % (min,max) + + if band.GetOverviewCount() > 0: + print '����� �������� ', band.GetOverviewCount(), \ + ' �������� �����������.' + + if not band.GetRasterColorTable() is None: + print '����� �������� ������� ������ � ', \ + band.GetRasterColorTable().GetCount(), ' ��������.' +\endcode + +\section gdal_tutorial_ru_read ������ ��������� ������ + +���������� ��������� �������� ������ ��������� ������, ������ �������� ����� �������� ������������� ����� GDALRasterBand::RasterIO(). ���� ����� ������������� ���������� ����������� ����� ������, ��������������� � ������� ������� ��������. ��������� ��� ������ ������ ������ ������ � ����� ���������������� �������, �������������� �� ��� ���� � ������������ ��� ��������� ��������. + +�� ����� C++: +\code + float *pafScanline; + int nXSize = poBand->GetXSize(); + + pafScanline = (float *) CPLMalloc(sizeof(float)*nXSize); + poBand->RasterIO( GF_Read, 0, 0, nXSize, 1, + pafScanline, nXSize, 1, GDT_Float32, + 0, 0 ); +\endcode + +�� ����� C: +\code + float *pafScanline; + int nXSize = GDALGetRasterBandXSize( hBand ); + + pafScanline = (float *) CPLMalloc(sizeof(float)*nXSize); + GDALRasterIO( hBand, GF_Read, 0, 0, nXSize, 1, + pafScanline, nXSize, 1, GDT_Float32, + 0, 0 ); +\endcode + +�� ����� Python: + +\code + scanline = band.ReadRaster( 0, 0, band.XSize, 1, \ + band.XSize, 1, GDT_Float32 ) +\endcode + +����� ������������ ������ ����� ��� string, � �������� xsize*4 ���� +������������ ������. ��� ������ ����� ���� ������������� � ������� ���� ����� +Python � ������� ������ <b>struct</b> �� ����������� ����������: + +\code + import struct + + tuple_of_floats = struct.unpack('f' * b2.XSize, scanline) +\endcode + +����� ������� The RasterIO ������������ �� ���������� �����������: +\code +CPLErr GDALRasterBand::RasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nPixelSpace, + int nLineSpace ) +\endcode + +�������, ��� ���� � ��� �� ����� RasterIO() ����������� ��� ��� ������, ��� � +��� ������, � ����������� �� �������� ����� eRWFlag (GF_Read ��� GF_Write). +��������� nXOff, nYOff, nXSize, nYSize ��������� ���� ������ ��� ������ (��� +������). ��� ���� ������������� ������ ��������� � ��������� ������� ������, +������ ���������� ����� ���� ����� �����������, ���� ������� ���������. + +pData --- ��� ��������� �� ����� � ������, ���� ������ ���� ��������� (��� +������ ��������) ������. ����������� ��� ����� ������ ������ ��������� � +�����, ������������ � ��������� eBufType, ��������, GDT_Float32 ��� GDT_Byte. +������� RasterIO() ����ͣ� �� ���� �������������� ����� ����� ������ ������ � +����� ������ ������. �������� ��������, ��� ��� �������������� ������������ +������ � ����� RasterIO() ��������� � ������� �������, � ���� �������� ������� +�� ����� ����������� ���������, ��� ������������� � ��������� ���������� +��������. ���, ��������, ��������, ��� ��� ������ 16-������ ������ � ����� +���� GDT_Byte ��� ��������, ����������� 255 ����� ���������� � �������� 255, +<b>��������������� ������ �� �������ģ�!</b> + +��������� nBufXSize � nBufYSize ������ ������ ������. ��� �������� ������ � +������ ���������� �� ����� ��������� � �������� ����. ������ ��� �������� +������������ ��������� ����������� ������ ������ ����� ���������� �������, ��� +������ ����. � ���� ������ RasterIO() ����� ������������ ���������� �������� +����������� (��������) ��� ����� ������������ �����/������. + +��������� nPixelSpace � nLineSpace ������ ����� ����, ��� �������� � +������������� �������� �� ���������. ������ ��� ����� ���� ������������ ��� +���������� �������� � ������ ������, ����� ����������� ������ � �����, ������� +��� �������� ������ ������, ������� ������� ��� ������. + +\section gdal_tutorial_ru_close �������� ������ ������ + +����������, ��������� �������, ��� ������� GDALRasterBand <i>�����������</i> � +������ ������ ������ � ��� ������� �� ������ ��������� � ������� ��������� +delete ����� C++. ������ ������ GDALDataset ����� ���� ������� ���� � ������� +������ ������� GDALClose(), ���� � �������������� ��������� delete ��� ������� +GDALDataset. ����� ������� �����ģ� � ����������� ������������ ������ � ������ +�� ���� ���� ������������ ������. + +\section gdal_tutorial_ru_creation ������� �������� ������ + +����� ����� � ��������, �������������� GDAL, ����� ���� ������� � ��� ������, +���� ������� ������� ������������ ��������. ���������� ��� �������� ������� +������� ����: CreateCopy() � Create(). + +������ CreateCopy ������������ ����� ������� CreateCopy() � ��������� +���������� �������� ��������� ������� � ��������� ��������� ������ ������, +����� �������� ������ ���� �������. ������ Create ������������ ����� ������ +Create() � ��������� ������������ ��������, � ����� ���������������� ������� +���� ���������� � ����������� ���������������� ���������� ��������. ��� +��������, ������� ����� ��������� ����� �����, ������������ ����� +CreateCopy(), ������ �� ��� ������������ ����� Create(). + +��� ����, ����� ����������, ����� ����� ������������ ���������� �������, ����� +��������� ���������� DCAP_CREATE � DCAP_CREATECOPY � ������� ��������. +���������, ��� ������� GDALAllRegister() ���� ������� ������, ��� �������� +������� GetDriverByName(). �� �������: + +�� ����� C++: +\code +#include "cpl_string.h" +... + const char *pszFormat = "GTiff"; + GDALDriver *poDriver; + char **papszMetadata; + + poDriver = GetGDALDriverManager()->GetDriverByName(pszFormat); + + if( poDriver == NULL ) + exit( 1 ); + + papszMetadata = poDriver->GetMetadata(); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) ) + printf( "������� %s ������������ ����� Create().\n", pszFormat ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) ) + printf( "������� %s ������������ ����� CreateCopy().\n", pszFormat ); +\endcode + +�� ����� C: +\code +#include "cpl_string.h" +... + const char *pszFormat = "GTiff"; + GDALDriver hDriver = GDALGetDriverByName( pszFormat ); + char **papszMetadata; + + if( hDriver == NULL ) + exit( 1 ); + + papszMetadata = GDALGetMetadata( hDriver, NULL ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, FALSE ) ) + printf( "������� %s ������������ ����� Create().\n", pszFormat ); + if( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATECOPY, FALSE ) ) + printf( "������� %s ������������ ����� CreateCopy().\n", pszFormat ); +\endcode + +�� ����� Python: + +\code + format = "GTiff" + driver = gdal.GetDriverByName( format ) + metadata = driver.GetMetadata() + if metadata.has_key(gdal.DCAP_CREATE) \ + and metadata[gdal.DCAP_CREATE] == 'YES': + print '������� %s ������������ ����� Create().' % format + if metadata.has_key(gdal.DCAP_CREATECOPY) \ + and metadata[gdal.DCAP_CREATECOPY] == 'YES': + print '������� %s ������������ ����� CreateCopy().' % format +\endcode + +�������, ��� ��������� �������� ����� ������ ������ ������ � �� ������������ +�� ����� Create(), �� CreateCopy(). + +\section gdal_tutorial_ru_createcopy ������������� ������ CreateCopy() + +������������� ������ GDALDriver::CreateCopy() ����������, ��������� ������� +����� ���������� �������� �� �������� ������ ������. ��� �� �����, ����� +��������� ���������� ���������, ����������� ��� ������������ ��������� +�������, � ����� ����� ����������� ���������� ��� �������� ����������� +������������. ���������� �������� ����������� �� ����� � ������ pszSrcFilename +� ����� ���� pszDstFilename � ����������� �� ��������� � � �������, ������� +�������� ��� �������������� ������, ����� ��������� ��������� �������: + +�� ����� C++: +\code + GDALDataset *poSrcDS = + (GDALDataset *) GDALOpen( pszSrcFilename, GA_ReadOnly ); + GDALDataset *poDstDS; + + poDstDS = poDriver->CreateCopy( pszDstFilename, poSrcDS, FALSE, + NULL, NULL, NULL ); + if( poDstDS != NULL ) + delete poDstDS; +\endcode + +�� ����� C: +\code + GDALDatasetH hSrcDS = GDALOpen( pszSrcFilename, GA_ReadOnly ); + GDALDatasetH hDstDS; + + hDstDS = GDALCreateCopy( hDriver, pszDstFilename, hSrcDS, FALSE, + NULL, NULL, NULL ); + if( hDstDS != NULL ) + GDALClose( hDstDS ); +\endcode + +�� ����� Python: + +\code + src_ds = gdal.Open( src_filename ) + dst_ds = driver.CreateCopy( dst_filename, src_ds, 0 ) +\endcode + +�������, ��� ����� CreateCopy() ���������� ����� ������, ��������� ��� ������ +� �� ������ ���� ��������������� ������� ������ ��� ���������� ������ � ������ +������ �� ����. � ������ ����� Python ��� �������ģ� �������������, ����� +"dst_ds" ������ �� ������� ���������. �������� FALSE (��� 0), ������������ ��� +��������� bStrict, ���������� ����� �� ������ ��������� ������ ������ � ������ +CreateCopy(), ����������, ��� CreateCopy() ������ ����������� ��� ��������� +������ ���� � ������, ���� ����������� ����� ������ �� ����� ���� ��������� +�������� ������. ����� ����� ���������, ��������, ��������� �������� ������ �� +������������ ��� ������ �������� �������, ��� ������, ��� �������� ������ �� +������������ �������������� ��������. + +����� ������� ������ ����� �������� �������� ���������� ��� �������� ��������� +����� � ������������� ���������� ���� ������: + +�� ����� C++: +\code +#include "cpl_string.h" +... + const char **papszOptions = NULL; + + papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" ); + papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" ); + poDstDS = poDriver->CreateCopy( pszDstFilename, poSrcDS, FALSE, + papzOptions, GDALTermProgress, NULL ); + if( poDstDS != NULL ) + delete poDstDS; +\endcode + +�� ����� C: +\code +#include "cpl_string.h" +... + const char **papszOptions = NULL; + + papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" ); + papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" ); + hDstDS = GDALCreateCopy( hDriver, pszDstFilename, hSrcDS, FALSE, + papzOptions, GDALTermProgres, NULL ); + if( hDstDS != NULL ) + GDALClose( hDstDS ); +\endcode + +�� ����� Python: + +\code + src_ds = gdal.Open( src_filename ) + dst_ds = driver.CreateCopy( dst_filename, src_ds, 0, + [ 'TILED=YES', 'COMPRESS=PACKBITS' ] ) +\endcode + +\section gdal_tutorial_ru_create ������������� ������ Create() + +� ��� �������, ����� �� �� ������ ������������� ������������ ���� � ����� +������, ����� ���� ���������� ��������� ����� GDALDriver::Create() (����� +����� ��������� ���������� ��������� �������� ��� ������������� ����������� +������ ��� ������ � ������). ����� Create() ��������� ������ ����������, +������� �� ����� �� ��� CreateCopy(), ������ ������� �����������, ����� +������� � ��� ������ ������ ���� ����� ���������������.<p> + +�� ����� C++: +\code + GDALDataset *poDstDS; + char **papszOptions = NULL; + + poDstDS = poDriver->Create( pszDstFilename, 512, 512, 1, GDT_Byte, + papszOptions ); +\endcode + +�� ����� C: +\code + GDALDatasetH hDstDS; + char **papszOptions = NULL; + + hDstDS = GDALCreate( hDriver, pszDstFilename, 512, 512, 1, GDT_Byte, + papszOptions ); +\endcode + +�� ����� Python: + +\code + dst_ds = driver.Create( dst_filename, 512, 512, 1, gdal.GDT_Byte ) +\endcode + +��� ������ ����� ������ ����� ������� ������, ��� ����������� ���������� � ���������� ����������� ������ ���� �������� � ����. ���������� ���������� ����� ������ ������� �� ������, �� � ���������� ������, ���������� ������ ��������, �������������� �������� � ���������� �����������, ����� ��������� ���:<p> + +�� ����� C++: +\code + double adfGeoTransform[6] = { 444720, 30, 0, 3751320, 0, -30 }; + OGRSpatialReference oSRS; + char *pszSRS_WKT = NULL; + GDALRasterBand *poBand; + GByte abyRaster[512*512]; + + poDstDS->SetGeoTransform( adfGeoTransform ); + + oSRS.SetUTM( 11, TRUE ); + oSRS.SetWellKnownGeogCS( "NAD27" ); + oSRS.exportToWkt( &pszSRS_WKT ); + poDstDS->SetProjection( pszSRS_WKT ); + CPLFree( pszSRS_WKT ); + + poBand = poDstDS->GetRasterBand(1); + poBand->RasterIO( GF_Write, 0, 0, 512, 512, + abyRaster, 512, 512, GDT_Byte, 0, 0 ); + + delete poDstDS; +\endcode + +�� ����� C: +\code + double adfGeoTransform[6] = { 444720, 30, 0, 3751320, 0, -30 }; + OGRSpatialReferenceH hSRS; + char *pszSRS_WKT = NULL; + GDALRasterBandH hBand; + GByte abyRaster[512*512]; + + GDALSetGeoTransform( hDstDS, adfGeoTransform ); + + hSRS = OSRNewSpatialReference( NULL ); + OSRSetUTM( hSRS, 11, TRUE ); + OSRSetWellKnownGeogCS( hSRS, "NAD27" ); + OSRExportToWkt( hSRS, &pszSRS_WKT ); + OSRDestroySpatialReference( hSRS ); + + GDALSetProjection( hDstDS, pszSRS_WKT ); + CPLFree( pszSRS_WKT ); + + hBand = GDALGetRasterBand( hDstDS, 1 ); + GDALRasterIO( hBand, GF_Write, 0, 0, 512, 512, + abyRaster, 512, 512, GDT_Byte, 0, 0 ); + + GDALClose( hDstDS ); +\endcode + +�� ����� Python: + +\code + import Numeric, osr + + dst_ds.SetGeoTransform( [ 444720, 30, 0, 3751320, 0, -30 ] ) + + srs = osr.SpatialReference() + srs.SetUTM( 11, 1 ) + srs.SetWellKnownGeogCS( 'NAD27' ) + dst_ds.SetProjection( srs.ExportToWkt() ) + + raster = Numeric.zeros( (512, 512) ) + dst_ds.GetRasterBand(1).WriteArray( raster ) +\endcode + +*/ + + + diff --git a/Utilities/GDAL/doc/ru/index_ru.dox b/Utilities/GDAL/doc/ru/index_ru.dox new file mode 100644 index 0000000000..f19b994358 --- /dev/null +++ b/Utilities/GDAL/doc/ru/index_ru.dox @@ -0,0 +1,155 @@ +#ifndef DOXYGEN_SKIP +/* $Id: index_ru.dox,v 1.1 2006/01/10 11:02:08 dron Exp $ */ +Translation corresponds to index.dox,v 1.6 2006/01/10 11:00:51 +Translator Andrey Kiselev <dron@ak4719.spb.edu> +#endif /* DOXYGEN_SKIP */ + +/*! \page index_ru GDAL - Geospatial Data Abstraction Library + +<center><b>Select language</b>: <a href="index.html">[English]</a>[Russian]</center> + +\htmlonly<img src="gdalicon.png" alt="GDAL">\endhtmlonly \latexonly GDAL \endlatexonly +--- ��� ���������� ��� ������ � ���������� ��������������� ��������� ������ +������. GDAL ���������������� �� �������� �������� <a +href="faq.html#license">X/MIT</a>, �.�. �������� �������� � <a +href="http://www.opensource.org/">�������� �������� �����</a>. ��� ����������, +GDAL ������������� ����������� ���������� <a href="gdal_datamodel.html">������ +����ݣ���� ������ ������</a> ��� ���� �������������� �������� ������ ������. +��������� � GDAL ���������� <a href="ogr">OGR</a> (�������� ������ ������� +������������ ������ � GDAL) ������������� ������� ����������� ��� ������ � +���������� �������. �� �������� <a href="NEWS.html">����������</a> �� ������� +����� �������� ������ 1.3.1, ���������� � ������� 2005 �.<p> + +������� ��������: http://www.gdal.org<br> +�������: http://www.remotesensing.org/gdal<br> +�������: http://gdal.maptools.org<br> +���������: +<a href="http://www.gdal.org/dl">http at gdal.org</a>, +<a href="ftp://ftp.remotesensing.org/gdal">ftp at remotesensing.org</a>, +<a href="http://gdal.maptools.org/dl">http at maptools.org</a><br> +�������� �����������: <a href="http://pobox.com/~warmerdam">Frank Warmerdam</a>.<p> + +\section index_primary_sponsor_ru �������� ������� + +<!-- XXX: we are using this small hack to workaround Doxygen deficiency +when processing HTML tags with arguments. --> +\htmlonly +<center><a href="http://www.ermapper.com/"><img src="ERMapperlogo_small.gif" alt="ER Mapper" border="0" width="154" height="46"></a></center> +\endhtmlonly +\latexonly +\image latex ERMapperlogo_small.gif +\endlatexonly + +�������� <a href="http://www.ermapper.com/">ER Mapper</a> ������� +������������� ���������� ����������� ��������� ������� GDAL � ������� 2005 �. +��� ����� �� ��������� � �������� ����������.<p> + +\section index_userdocs_ru ������������ ��� ������������� + +<ul> +<li> <a href="download.html">��������� - �������� ������ � �������� �����</a> +<li> <a href="formats_list.html">�������������� �������</a> +<li> <a href="gdal_utilities.html">������� GDAL</a> +<li> <a href="faq.html">����� ���������� �������</a> +<li> <a href="gdal_datamodel_ru.html">������ ������ GDAL</a> +<li> <a href="credits.html">�������������</a> +</ul> + +\section index_devdocs_ru ������������ ��� ������������� + +<ul> +<li> <a href="gdal_building_ru.html">������ GDAL �� �������� �������</a> +<li> <a href="hierarchy.html">�������� �������</a> +<li> <a href="gdal_tutorial_ru.html">����������� �� ������������� GDAL</a> +<li> <a href="gdal_drivertut.html">����������� �� ��������� ��������� GDAL</a> +<li> <a href="warptut.html">����������� �� ������������� ���������� �������������</a> +<li> <a href="ogr/osr_tutorial.html">����������� �� OGRSpatialReference</a> +<li> <a href="gdal_8h.html">gdal.h</a> - ��������� GDAL ��� ����� C. +<li> <a href="classGDALDataset.html">GDALDataset</a> +<li> <a href="classGDALRasterBand.html">GDALRasterBand</a> +</ul> + +\section index_maillist_ru ������ �������� + +��� ���������� �������� ���������� � �������� �� ������������� GDAL (� +��������� � �������� ����������) ���������� ������ �������� <a +href="mailto:gdal-dev@lists.maptools.org">gdal-dev@lists.maptools.org</a>. +����������� � ����������� ������ �������� ����� +<a href="http://lists.maptools.org/mailman/listinfo/gdal-dev/">�� ����������� +��������</a>. ������ �������� ����� �������� � ������ ������ ��� ������ �� +��������� NNTP +<a href="news://news.gmane.org/gmane.comp.gis.gdal.devel"> +news://news.gmane.org/gmane.comp.gis.gdal.devel</a> +� �� HTTP +<a href="http://news.gmane.org/gmane.comp.gis.gdal.devel"> +http://news.gmane.org/gmane.comp.gis.gdal.devel</a>.<p> + +������ ������������� � ������������� GDAL/OGR ����� ����� ����� �� IRC ������ +<a href="irc:irc.freenode.net/#gdal">#gdal</a> ������� irc.freenode.net.<p> + +\section index_bugs_ru ��ޣ�� �� ������� + +�� ������� GDAL +<a href="http://bugzilla.remotesensing.org/enter_bug.cgi?product=GDAL">����� ��������</a>, � +<a href="http://bugzilla.remotesensing.org/buglist.cgi?product=GDAL">�����������</a> ��� ������ BugZilla.<p> + +\section index_related_ru �������������� ���������� + +<ul> + +<li> <a href="http://home.gdal.org/projects/index.html"> +������ ������� Frank Warmerdam</a>, ������ �� ������� �������� � GDAL, +���� ���������� GDAL.<p> + +<li> <a href="http://rgdal.sourceforge.net/">������ ��������� GDAL ��� ����� +R</a>, ���������� Timothy H. Keitt.<p> + +</ul> + +\section index_projects_ru �������, ������������ GDAL + +<ul> + +<li> <a href="http://grass.itc.it/index.html">GRASS</a>: A raster/vector +open source GIS uses GDAL for raster import (via r.in.gdal). +<li> <a href="http://openev.sourceforge.net">OpenEV</a>: An OpenGL/GTK/Python +based graphical viewer which exclusively uses GDAL for raster access. +<li> <a href="http://www.ossim.org">OSSIM</a>: +Another geospatial viewing and analysis environment which uses GDAL as one +of several plugins. +<li> <a href="http://mapserver.gis.umn.edu/index.html">UMN MapServer</a>: +A popular web mapping application with GDAL support. +<li> <a href="http://www.vterrain.org">Virtual Terrain Project</a>: +The VTP libraries now use GDAL. +<li> <a href="http://thuban.intevation.org">Thuban</a>: +A multi-platform interactive geographic data viewer. +<li> <a href="http://qgis.sourceforge.net">Quantum GIS (QGIS)</a>: +A Geographic Information System (GIS) built for Linux/Unix. +QGIS supports vector, raster, and database formats. +<li> <a href="http://www.terrainengine.com">Demeter</a>: +A another OpenGL based terrain engine somewhat similar to VTP. +<li> <a href="http://www.cadcorp.com/">Cadcorp SIS</a>: A Windows GIS with +a GDAL plugin. +<li> <a href="http://www.safe.com/">FME</a>: A GIS translator package +includes a GDAL plugin. +<li> <a href="http://www.scanex.ru/software/scanmagic/">ScanMagic</a>: +Commercial Win32 application for visualization, analysis and processing of +remote sensing data (lite version for free). +<li> <a href="http://www.msmacrosystem.nl/Ilwis/index.html">MS MacroSystem</a>: 3D DEM Viewer. +<li> <a href="http://www.gstat.org/">gstat</a>: a geostatistical modelling +package. +<li> <a href="http://flighttrack.sourceforge.net/">flighttrack</a>: +GPS track viewing and downloading software for Mac. +<li> <a href="http://starspan.casil.ucdavis.edu/?StarSpan">StarSpan</a>: raster/vector analysis. +<li> <a href="http://www.gvsig.gva.es/">gvSIG</a>: Desktop GIS Client. +<li> <a href="http://libral.sourceforge.net/">libral</a>: A raster algebra +implementation and an experimental GUI+CLI GIS with Perl and GTK+. +<li> <a href="http://earth.google.com/">Google Earth</a>: A 3D world viewer. +<li> <a href="http://www.vrco.com/vGeo/OverviewvGeo.html">vGeo</a>: +Interactive data fusion and visual analysis tool. +<li> <a href="http://www.itc.nl/ilwis/">ILWIS</a>: Remote Sensing and GIS +Desktop Package. + +</ul> + +*/ diff --git a/Utilities/GDAL/doc/vb6_tutorial.dox b/Utilities/GDAL/doc/vb6_tutorial.dox new file mode 100644 index 0000000000..2a0f3ab5f7 --- /dev/null +++ b/Utilities/GDAL/doc/vb6_tutorial.dox @@ -0,0 +1,524 @@ +#ifndef DOXYGEN_SKIP +/* $Id: vb6_tutorial.dox,v 1.5 2005/10/27 16:25:08 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page vb6_tutorial GDAL VB6 Bindings Tutorial + +\section Intro Introduction + +A partial set of Visual Basic 6 bindings have been build for GDAL. Internally +these bindings use Declare based calls into the GDAL DLL C API but a set of +shadow classes are also provided to provide object oriented access to +GDAL services in VB6 similar to those provided in C++. + +Note that the VB6 bindings are nowhere near comprehensive, nor are they +documented. However, in combination with the corresponding C++ class +documentation, and the following docs, it should be possible to use GDAL +to accomplish a variety of operations. It is not believed that the VB6 +bindings will be of any utility with earlier version of VB nor with VB.Net. + +The classes for which access has been implemented includes +GDALDriver, GDALDataset, GDALRasterBand, GDALColorTable, OGRSpatialReference +and OGRCoordinateTransformation. + +A mailing list specifically on VB6 GDAL topics has been setup at +http://groups.yahoo.com/group/gdal-vb6-appdev . + +\section UsingVB6 Using GDAL VB6 Classes + +To use VB6 GDAL bindings it is necessary to ensure that GDAL has been +built with appropriate C entry points exported using the "stdcall" calling +convention. This is the current default, but was not as recently as GDAL +1.2.6. So ensure you get a version more recent than 1.2.6. + +Then add the GDAL VB6 class and module files to your VB6 project. These +come from the <a href="http://www.gdal.org/srctree/vb6">gdal/vb6 directory</a> +and include the following key files: + +<ul> +<li> GDAL.bas - The main user visible module. +<li> GDALCore.bas - This module is for internal use. +<li> GDALDriver.cls - The GDALDriver class. +<li> GDALDataset.cls - The GDALDataset class. +<li> GDALRasterBand.cls - The GDALRasterBand class. +<li> GDALColorTable.cls - The GDALColorTable class. +<li> OGRSpatialReference.cls - The OGRSpatialReference class. +<li> OGRCoordinateTransformation.cls - The OGRCoordinateTransformation class. +</ul> + +You may need to edit GDALCore.bas, and change occurrences of gdal12.dll +to match what your GDAL DLL is called. You can include a full path to the +DLL if it can't be guaranteed to be in the current working directory of the +application (or the windows system32 directory). + +You should also be able to load the "test" project from the gdal\\vb6\\test +directory. The test project has test menu items roughly corresponding to +the tasks in the following tutorial topics. + +\section TutorialRead Tutorial - Read Dataset + +This brief tutorial will demonstrate open a GDAL file, and fetching out +some information, about the dataset, and the individual bands. The +results are printed to the default from in the following example for +simplicity. + +Before opening the file we need to register the GDAL format drivers. +Normally we will just register all the drivers with GDALAllRegister(). + +\code + Call GDAL.AllRegister() +\endcode + +Then we need to try and open the dataset. The GDAL.OpenDS() function +returns a GDALDataset object, so we dimension an appropriate object for +this. GDAL.OpenDS() is the VB6 equivalent of the GDALDataset::GDALOpen() +function. + +\code + Dim ds As GDALDataset + + Set ds = GDAL.OpenDS( "utm.tif", GDAL.GA_ReadOnly ) +\endcode + +Then we need to check if the open succeeded, and if not report an error. + +\code + If not ds.IsValid() Then + Call MsgBox( "Open failed: " & GDAL.GetLastErrorMsg() ) + Exit Sub + End If +\endcode + +If things succeeded, we query width of the image in pixels (XSize), +Height of the image in pixels (YSize) and number of bands (BandCount) +from the dataset properties. + +\code + Print "Size: " & ds.XSize & "x" & ds.YSize & "x" & ds.BandCount +\endcode + +Next we read metadata from the dataset using the VB6 equivalent of the +GDALMajorObject::GetMetadata() method, and report it to the user. Metadata +is returned as an array of strings of "name=value" items. Array indices +start at zero in the returned array. The domain argument should normally +be vbNullString though in specialize circumstances other domains might +apply. + +\code + Dim MD As Variant + MD = ds.GetMetadata(vbNullString) + If (UBound(MD) > 0) Then + Print "Metadata:" + For i = 1 To UBound(MD) + Print " " & MD(i) + Next i + End If +\endcode + +Parsing the "name=value" strings from GetMetadata() can be a bit of a bother, +so if we were looking for specific values we could use GetMetadataItem() +and provide a specific item we want to extract. This would extract just +the value if it is found, or an empty string otherwise. The GetMetadataItem() +is an analog of the C++ GDALMajorObject::GetMetadataItem() method. + +\code + Dim MDValue As String + + MDValue = ds.GetMetadataItem( "TIFF_DATETIME", vbNullString ) + if MDValue <> "" Then + Print "Creation Date: " & MDValue + End If +\endcode + +The GDALDataset::GetGeoTransform() method is used to get fetch the affine +transformation used to relate pixel/line locations on the image to +georeferenced locations in the current coordinate system. In the most common +case (image is not rotated or sheared) you can just report the origin +(upper left corner) and pixel size from these values. The method returns +0 on success or an error class if it fails, so we only use the return result +(placed into the Geotransform array) on success. + +\code + Dim Geotransform(6) As Double + + If ds.GetGeoTransform( Geotransform ) = 0 Then + If Geotransform(2) = 0 and Geotransform(4) = 0 Then + Print "Origin: " & Geotransform(0) & "," & Geotransform(3) + Print "Pixel Size: " & Geotransform(1) & "x" & (-1 * Geotransform(5)) + End If + End If +\endcode + +The coordinate system can be fetched using the GDALDataset::GetProjectionRef() +analog, GDALDataset.GetProjection(). The returned string is in OpenGIS +Well Known Text format. A later example will show how to use an +OGRSpatialReference object to reformat the WKT into more readable format +and make other use of it. + +\code + Dim WKT As String + + WKT = ds.GetProjection() + If Len(WKT) > 0 Then + Print "Projection: " & WKT + End If +\endcode + +GDALDataset objects have one or more raster bands associated with them. +GDALRasterBand objects can have metadata (accessed the same as on the +GDALDataset) as well as an array of pixel values, and various specialize +metadata items like data type, color interpretation, offset/scale. Here +we report a few of the items. + +First we loop over all the bands, fetching a band object for each band +and report the band number, and block size. + +\code + For i = 1 To ds.BandCount + Dim band As GDALRasterBand + + Set band = ds.GetRasterBand(i) + Print "Band " & i & " BlockSize: " & band.BlockXSize & "x" & band.BlockYSize +\endcode + +The GDALRasterBand has a DataType property which has the value returned +by the C++ method GDALRasterBand::GetRasterDataType(). The returned value +is an integer, but may be compared to the predefined constants GDAL.GDT_Byte, +GDAL.GDT_UInt16, GDAL.GDT_Int16, GDAL.GDT_UInt32, GDAL.GDT_Int32, +GDAL.GDT_Float32, GDAL.GDT_Float64, GDAL.GDT_CInt16, GDAL.GDT_CInt32, +GDAL.GDT_CFloat32 and GDAL.GDT_CFloat64. In this case we use the +GDAL.GetDataTypeName() method to convert the data type into a name we +can show the user. + +\code + Print " DataType=" & GDAL.GetDataTypeName(band.DataType) _ +\endcode + +We also report the offset, scale, minimum and maximum for the band. + +\code + Print " Offset=" & band.GetOffset() & " Scale=" & band.GetScale() _ + & " Min=" & band.GetMinimum() & " Max=" & band.GetMaximum() +\endcode + +GDALRasterBands can also have GDALColorTable objects associated with them. +They are read with the GDALRasterBand::GetColorTable() analog in VB6. +Individual RGBA entries should be read into a 4 Integer array. + +\code + Dim ct As GDALColorTable + Set ct = band.GetColorTable() + If ct.IsValid() Then + Dim CEntry(4) As Integer + Print " Has Color Table, " & ct.EntryCount & " entries" + For iColor = 0 To ct.EntryCount - 1 + Call ct.GetColorEntryAsRGB(iColor, CEntry) + Print " " & iColor & ": " & CEntry(0) & "," & CEntry(1) & "," & CEntry(2) & "," & CEntry(3) + Next iColor + End If +\endcode + +But of course, the most important contents of a GDAL file is the raster +pixel values themselves. The C++ GDALRasterBand::RasterIO() method is +provided in a somewhat simplified form. A predimensioned 1D or 2D +array of type Byte, Int, Long, Float or Double is passed to the RasterIO() +method along with the band and window to be read. Internally the "buffer +size" and datatype is extracted from the dimensions of the passed in buffer. + +This example dimensions the RawData array to be the size of one scanline +of data (XSize x 1) and reads the first whole scanline of data from the +file, but only prints out the second and tenth values (since the buffer +indexes are zero based). + +\code + Dim err As Long + Dim RawData() As Double + ReDim RawData(ds.XSize) As Double + + err = band.RasterIO(GDAL.GF_Read, 0, 0, ds.XSize, 1, RawData) + if err = 0 Then + Print " Data: " & RawData(1) & " " & RawData(10) + End If +\endcode + +Finally, when done accessing a GDALDataset we can explicitly close +it using the CloseDS() method, or just let it fall out of scope in which +case it will be closed automatically. + +\code + Call ds.CloseDS() +\endcode + +\section TutorialCreate Tutorial - Creating Files + +Next we address creating a new file from an existing file. To create a +new file, you have to select a GDALDriver to do the creating. The GDALDriver +is essentially an object representing a file format. We fetch it with the +GetDriverByName() call from the GDAL module using the driver name. + +\code + Dim Drv As GDALDriver + + Call GDAL.AllRegister + Drv = GDALCore.GetDriverByName( "GTiff" ) + If Not Drv.IsValid() Then + Call MsgBox( "GTiff driver not found " ) + Exit Sub + End If +\endcode + +You could get a list of registered drivers, and identify which support +creation something like this: + +\code + drvCount = GDAL.GetDriverCount + For drvIndex = 0 To drvCount - 1 + Set Drv = GDAL.GetDriver(drvIndex) + If Drv.GetMetadataItem(GDAL.DCAP_CREATE, "") = "YES" _ + Or Drv.GetMetadataItem(GDAL.DCAP_CREATECOPY, "") = "YES" Then + xMsg = " (Read/Write)" + Else + xMsg = " (ReadOnly)" + End If + + Print Drv.GetShortName() & ": " & Drv.GetMetadataItem(GDAL.DMD_LONGNAME, "") & xMsg + Next drvIndex +\endcode + +Once we have the driver object, the simplest way of creating a new file +is to use CreateCopy(). This tries to create a copy of the input file +in the new format. A complete segment (without any error checking) +would look like the following. The CreateCopy() method corresponds to the +C++ method GDALDriver::CreateCopy(). The VB6 implementation does not +support the use of progress callbacks. + +\code + Dim Drv As GDALDriver + Dim SrcDS As GDALDataset, DstDS As GDALDataset + + Call GDAL.AllRegister + Set Drv = GDALCore.GetDriverByName( "GTiff" ) + + Set SrcDS = GDAL.Open( "in.tif", GDAL.GA_ReadOnly ) + Set DstDS = Drv.CreateCopy( "out.tif", SrcDS, True, Nothing ) +\endcode + +This is nice and simple, but sometimes we need to create a file with more +detailed control. So, next we show how to create a file and then copy +pieces of data to it "manually". The GDALDriver::Create() analog is +Create(). + +\code + Set DstDS = Drv.Create("out.tif", SrcDS.XSize, SrcDS.YSize, _ + SrcDS.BandCount, GDAL.GDT_Byte, Nothing) +\endcode + +In some cases we may want to provide some creation options, +which is demonstrated here. Creation options (like metadata set through the +SetMetadata() method) are arrays of Strings. + +\code + Dim CreateOptions(1) As String + + CreateOptions(1) = "PHOTOMETRIC=MINISWHITE" + Set DstDS = Drv.Create("out.tif", SrcDS.XSize, SrcDS.YSize, _ + SrcDS.BandCount, GDAL.GDT_Byte, CreateOptions) +\endcode + +When copying the GeoTransform, we take care to check that reading the +geotransform actually worked. Most methods which return CPLErr in C++ +also return it in VB6. A return value of 0 will indicate success, and non-zero +is failure. + +\code + Dim err As Long + Dim gt(6) As Double + + err = SrcDS.GetGeoTransform(gt) + If err = 0 Then + Call DstDS.SetGeoTransform(gt) + End If +\endcode + +Copy the projection. Even if GetProjection() fails we get an empty string +which is safe enough to set on the target. Similarly for metadata. + +\code + Call DstDS.SetProjection(SrcDS.GetProjection()) + Call DstDS.SetMetadata(SrcDS.GetMetadata(""), "") +\endcode + +Next we loop, processing bands, and copy some common data items. + +\code + For iBand = 1 To SrcDS.BandCount + Dim SrcBand As GDALRasterBand, DstBand As GDALRasterBand + + Set SrcBand = SrcDS.GetRasterBand(iBand) + Set DstBand = DstDS.GetRasterBand(iBand) + + Call DstBand.SetMetadata(SrcBand.GetMetadata(""), "") + Call DstBand.SetOffset(SrcBand.GetOffset()) + Call DstBand.SetScale(SrcBand.GetScale()) + + Dim NoDataValue As Double, Success As Long + + NoDataValue = SrcBand.GetNoDataValue(Success) + If Success <> 0 Then + Call DstBand.SetNoDataValue(NoDataValue) + End If +\endcode + +Then, if one is available, we copy the palette. + +\code + Dim ct As GDALColorTable + Set ct = SrcBand.GetColorTable() + If ct.IsValid() Then + err = DstBand.SetColorTable(ct) + End If +\endcode + +Finally, the meat and potatoes. We copy the image data. We do this one +scanline at a time so that we can support very large images without require +large amounts of RAM. Here we use a Double buffer for the scanline, but +if we knew in advance the type of the image, we could dimension a buffer +of the appropriate type. The RasterIO() method internally knows how to +convert pixel data types, so using Double ensures all data types (except +for complex) are properly preserved, though at the cost of some extra data +conversion internally. + +\code + Dim Scanline() As Double, iLine As Long + ReDim Scanline(SrcDS.XSize) As Double + + ' Copy band raster data. + For iLine = 0 To SrcDS.YSize - 1 + Call SrcBand.RasterIO(GDAL.GF_Read, 0, iLine, SrcDS.XSize, 1, _ + Scanline) + Call DstBand.RasterIO(GDAL.GF_Write, 0, iLine, SrcDS.XSize, 1, _ + Scanline) + Next iLine +\endcode + +\section OSRTut Tutorial - Coordinate Systems and Reprojection + +The GDAL VB6 bindings also include limited support for use of the +OGRSpatialReference and OGRCoordinateTransformation classes. The +OGRSpatialReference represents a coordinate system and can be used to +parse, manipulate and form WKT strings, such as those returned by the +GDALDataset.GetProjection() method. The OGRCoordinateTransformation +class provides a way of reprojecting between two coordinate systems. + +The following example shows how to report the corners of an image in +georeferenced and geographic (lat/long) coordinates. First, we open +the file, and read the geotransform. + +\code + Dim ds As GDALDataset + + Call GDALCore.GDALAllRegister + Set ds = GDAL.OpenDS(FileDlg.Filename, GDAL.GA_ReadOnly) + + If ds.IsValid() Then + Dim Geotransform(6) As Double + + Call ds.GetGeoTransform(Geotransform) +\endcode + +Next, we fetch the coordinate system, and if it is non-empty we try to +instantiate an OGRSpatialReference from it. + +\code + ' report projection in pretty format. + Dim WKT As String + Dim srs As New OGRSpatialReference + Dim latlong_srs As OGRSpatialReference + Dim ct As New OGRCoordinateTransformation + + WKT = ds.GetProjection() + If Len(WKT) > 0 Then + Print "Projection: " + Call srs.SetFromUserInput(WKT) + +\endcode + +If the coordinate system is projected it will have a PROJECTION node. In +that case we build a new coordinate system which is the corresponding +geographic coordinate system. So for instance if the "srs" was UTM 11 WGS84 +then it's corresponding geographic coordinate system would just be WGS84. +Once we have these two coordinate systems, we build a transformer to convert +between them. + +\code + If srs.GetAttrValue("PROJECTION", 0) <> "" Then + Set latlong_srs = srs.CloneGeogCS() + Set ct = GDAL.CreateCoordinateTransformation(srs, latlong_srs) + End If + End If +\endcode + +Next we call a helper function to report each corner, and the center. +We pass in the name of the corner, the pixel/line location at the corner, +and the geotransform and transformer object. + +\code + Call ReportCorner("Top Left ", 0, 0, _ + Geotransform, ct) + Call ReportCorner("Top Right ", ds.XSize, 0, _ + Geotransform, ct) + Call ReportCorner("Bottom Left ", 0, ds.YSize, _ + Geotransform, ct) + Call ReportCorner("Bottom Right ", ds.XSize, ds.YSize, _ + Geotransform, ct) + Call ReportCorner("Center ", ds.XSize / 2#, ds.YSize / 2#, _ + Geotransform, ct) +\endcode + +The ReportCorner subroutine starts by computing the corresponding +georeferenced x and y location using the pixel/line coordinates and the +geotransform. + +\code +Private Sub ReportCorner(CornerName As String, pixel As Double, line As Double, _ + gt() As Double, ct As OGRCoordinateTransformation) + + Dim geox As Double, geoy As Double + + geox = gt(0) + pixel * gt(1) + line * gt(2) + geoy = gt(3) + pixel * gt(4) + line * gt(5) +\endcode + +Next, if we have a transformer, we use it to compute a corresponding +latitude and longitude. + +\code + Dim longitude As Double, latitude As Double, Z As Double + Dim latlong_valid As Boolean + + latlong_valid = False + + If ct.IsValid() Then + Z = 0 + longitude = geox + latitude = geoy + latlong_valid = ct.TransformOne(longitude, latitude, Z) + End If +\endcode + +Then we report the corner location in georeferenced, and if we have it +geographic coordinates. + +\code + If latlong_valid Then + Print CornerName & geox & "," & geoy & " " & longitude & "," & latitude + Else + Print CornerName & geox & "," & geoy + End If +End Sub +\endcode + + +*/ + diff --git a/Utilities/GDAL/doc/warptut.dox b/Utilities/GDAL/doc/warptut.dox new file mode 100644 index 0000000000..09f4702b1b --- /dev/null +++ b/Utilities/GDAL/doc/warptut.dox @@ -0,0 +1,364 @@ +#ifndef DOXYGEN_SKIP +/* $Id: warptut.dox,v 1.1 2005/10/27 15:06:17 dron Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page warptut GDAL Warp API Tutorial + +\section warptut_overview Overview + +The GDAL Warp API (declared in gdalwarper.h) provides services for high +performance image warping using application provided geometric transformation +functions (GDALTransformerFunc), a variety of resampling kernels, and +various masking options. Files much larger than can be held in memory can +be warped. + +This tutorial demonstrates how to implement an application using the Warp API. +It assumes implementation in C++ as C and Python bindings are incomplete for +the Warp API. It also assumes familiarity with the +<a href="gdal_datamodel.html">GDAL Data Model</a>, and the general GDAL API. + +Applications normally perform a warp by initializing a GDALWarpOptions +structure with the options to be utilized, instantiating a GDALWarpOperation +based on these options, and then invoking the +GDALWarpOperation::ChunkAndWarpImage() method to perform the warp options +internally using the GDALWarpKernel class. + +\section warptut_simple A Simple Reprojection Case + +First we will construct a relatively simple example for reprojecting an image, +assuming an appropriate output file already exists, and with minimal error +checking. + +\code +#include "gdalwarper.h" + +int main() +{ + GDALDatasetH hSrcDS, hDstDS; + + // Open input and output files. + + GDALAllRegister(); + + hSrcDS = GDALOpen( "in.tif", GA_ReadOnly ); + hDstDS = GDALOpen( "out.tif", GA_Update ); + + // Setup warp options. + + GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions(); + + psWarpOptions->hSrcDS = hSrcDS; + psWarpOptions->hDstDS = hDstDS; + + psWarpOptions->nBandCount = 1; + psWarpOptions->panSrcBands = + (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount ); + psWarpOptions->panSrcBands[0] = 1; + psWarpOptions->panDstBands = + (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount ); + psWarpOptions->panDstBands[0] = 1; + + psWarpOptions->pfnProgress = GDALTermProgress; + + // Establish reprojection transformer. + + psWarpOptions->pTransformerArg = + GDALCreateGenImgProjTransformer( hSrcDS, + GDALGetProjectionRef(hSrcDS), + hDstDS, + GDALGetProjectionRef(hDstDS), + FALSE, 0.0, 1 ); + psWarpOptions->pfnTransformer = GDALGenImgProjTransform; + + // Initialize and execute the warp operation. + + GDALWarpOperation oOperation; + + oOperation.Initialize( psWarpOptions ); + oOperation.ChunkAndWarpImage( 0, 0, + GDALGetRasterXSize( hDstDS ), + GDALGetRasterYSize( hDstDS ) ); + + GDALDestroyGenImgProjTransformer( psWarpOptions->pTransformerArg ); + GDALDestroyWarpOptions( psWarpOptions ); + + GDALClose( hDstDS ); + GDALClose( hSrcDS ); + + return 0; +} +\endcode + +This example opens the existing input and output files (in.tif and out.tif). +A GDALWarpOptions structure is allocated (GDALCreateWarpOptions() sets lots +of sensible defaults for stuff, always use it for defaulting things), and +the input and output file handles, and band lists are set. The panSrcBands and +panDstBands lists are dynamically allocated here and will be free automatically +by GDALDestroyWarpOptions(). The simple terminal output progress monitor +(GDALTermProgress) is installed for reporting completion progress to the user. + +GDALCreateGenImgProjTransformer() is used to initialize the reprojection +transformation between the source and destination images. We assume that +they already have reasonable bounds and coordinate systems set. Use of +GCPs is disabled. + +Once the options structure is ready, a GDALWarpOperation is instantiated using +them, and the warp actually performed with +GDALWarpOperation::ChunkAndWarpImage(). Then the transformer, warp options +and datasets are cleaned up. + +Normally error check would be needed after opening files, setting up the +reprojection transformer (returns NULL on failure), and initializing the +warp. + +\section warptut_options Other Warping Options + +The GDALWarpOptions structures contains a number of items that can be set +to control warping behavior. A few of particular interest are: + +<ol> + +<li> GDALWarpOptions::dfWarpMemoryLimit - Set the maximum amount of memory to +be used by the GDALWarpOperation when selecting a size of image chunk to +operate on. The value is in bytes, and the default is likely to be +conservative (small). Increasing the chunk size can help substantially in +some situations but care should be taken to ensure that this size, plus the +GDAL cache size plus the working set of GDAL, your application and the +operating system are less than the size of RAM or else excessive swapping is +likely to interfere with performance. On a system with 256MB of RAM, a value +of at least 64MB (roughly 64000000 bytes) is reasonable. Note that this +value does <b>not</b> include the memory used by GDAL for low level block +caching. + +<li> GDALWarpOpations::eResampleAlg - One of GRA_NearestNeighbour (the default, +and fastest), GRA_Bilinear (2x2 bilinear resampling) or GRA_Cubic. The +GRA_NearestNeighbour type should generally be used for thematic or colormapped +images. The other resampling types may give better results for thematic +images, especially when substantially changing resolution. + +<li> GDALWarpOptions::padfSrcNoDataReal - This array (one entry per band +being processed) may be setup with a "nodata" value for each band if you wish +to avoid having pixels of some background value copied to the destination +image. + +<li><a name="#warpoptions"></a> GDALWarpOptions::papszOptions - This is +a string list of NAME=VALUE options passed to the warper. Currently +supported options include: + +<ul> +<li> INIT_DEST=[value] or INIT_DEST=NO_DATA: This option forces the + destination image to be initialized to the indicated value (for all bands) + or indicates that it should be initialized to the NO_DATA value in + padfDstNoDataReal/padfDstNoDataImag. If this value isn't set the + destination image will be read and the source warp overlayed on it. + +<li> WRITE_FLUSH=YES/NO: This option forces a flush to disk of data after + each chunk is processed. In some cases this helps ensure a serial + writing of the output data otherwise a block of data may be written to disk + each time a block of data is read for the input buffer resulting in a lot + of extra seeking around the disk, and reduced IO throughput. The default + at this time is NO. +</ul> + +</ol> + +\section warptut_output Creating the Output File + +In the previous case an appropriate output file was already assumed to +exist. Now we will go through a case where a new file with appropriate +bounds in a new coordinate system is created. This operation doesn't +relate specifically to the warp API. It is just using the transformation API. + +\code +#include "gdalwarper.h" +#include "ogr_spatialref.h" + +... + + GDALDriverH hDriver; + GDALDataType eDT; + GDALDatasetH hDstDS; + GDALDatasetH hSrcDS; + + // Open the source file. + + hSrcDS = GDALOpen( "in.tif", GA_ReadOnly ); + CPLAssert( hSrcDS != NULL ); + + // Create output with same datatype as first input band. + + eDT = GDALGetRasterDataType(GDALGetRasterBand(hSrcDS,1)); + + // Get output driver (GeoTIFF format) + + hDriver = GDALGetDriverByName( "GTiff" ); + CPLAssert( hDriver != NULL ); + + // Get Source coordinate system. + + const char *pszSrcWKT, *pszDstWKT = NULL; + + pszSrcWKT = GDALGetProjectionRef( hSrcDS ); + CPLAssert( pszSrcWKT != NULL && strlen(pszSrcWKT) > 0 ); + + // Setup output coordinate system that is UTM 11 WGS84. + + OGRSpatialReference oSRS; + + oSRS.SetUTM( 11, TRUE ); + oSRS.SetWellKnownGeogCS( "WGS84" ); + + oSRS.exportToWkt( &pszDstWKT ); + + // Create a transformer that maps from source pixel/line coordinates + // to destination georeferenced coordinates (not destination + // pixel line). We do that by omitting the destination dataset + // handle (setting it to NULL). + + void *hTransformArg; + + hTransformArg = + GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT, + FALSE, 0, 1 ); + CPLAssert( hTransformArg != NULL ); + + // Get approximate output georeferenced bounds and resolution for file. + + double adfDstGeoTransform[6]; + int nPixels=0, nLines=0; + CPLErr eErr; + + eErr = GDALSuggestedWarpOutput( hSrcDS, + GDALGenImgProjTransform, hTransformArg, + adfDstGeoTransform, &nPixels, &nLines ); + CPLAssert( eErr == CE_None ); + + GDALDestroyGenImgProjTransformer( hTransformArg ); + + // Create the output file. + + hDstDS = GDALCreate( hDriver, "out.tif", nPixels, nLines, + GDALGetRasterCount(hSrcDS), eDT, NULL ); + + CPLAssert( hDstDS != NULL ); + + // Write out the projection definition. + + GDALSetProjection( hDstDS, pszDstWKT ); + GDALSetGeoTransform( hDstDS, adfDstGeoTransform ); + + // Copy the color table, if required. + + GDALColorTableH hCT; + + hCT = GDALGetRasterColorTable( GDALGetRasterBand(hSrcDS,1) ); + if( hCT != NULL ) + GDALSetRasterColorTable( GDALGetRasterBand(hDstDS,1), hCT ); + + ... proceed with warp as before ... +\endcode + +Some notes on this logic: + +<ul> + +<li> We need to create the transformer to output coordinates such that the +output of the transformer is georeferenced, not pixel line coordinates since +we use the transformer to map pixels around the source image into destination +georeferenced coordinates. + +<li> The GDALSuggestedWarpOutput() function will return an adfDstGeoTransform, +nPixels and nLines that describes an output image size and georeferenced +extents that should hold all pixels from the source image. The resolution +is intended to be comparable to the source, but the output pixels are always +square regardless of the shape of input pixels. + +<li> The warper requires an output file in a format that can be "randomly" +written to. This generally limits things to uncompressed formats that +have an implementation of the Create() method (as opposed to CreateCopy()). +To warp to compressed formats, or CreateCopy() style formats it is necessary +to produce a full temporary copy of the image in a better behaved format, and +then CreateCopy() it to the desired final format. + +<li> The Warp API copies only pixels. All colormaps, georeferencing and +other metadata must be copied to the destination by the application. + +</ul> + +\section warptut_perfomance Performance Optimization + +There are a number of things that can be done to optimize the performance +of the warp API. + +<ol> + +<li> Increase the amount of memory available for the Warp API chunking so that +larger chunks can be operated on at a time. This is the +GDALWarpOptions::dfWarpMemoryLimit parameter. In theory the larger the chunk +size operated on the more efficient the I/O strategy, and the more efficient +the approximated transformation will be. However, the sum of the warp +memory and the GDAL cache should be less than RAM size, likely around 2/3 +of RAM size. + +<li> Increase the amount of memory for GDAL caching. This is especially +important when working with very large input and output images that are +scanline oriented. If all the input or output scanlines have to be re-read +for each chunk they intersect performance may degrade greatly. Use +GDALSetCacheMax() to control the amount of memory available for caching +within GDAL. + +<li> Use an approximated transformation instead of exact reprojection for +each pixel to be transformed. This code illustrates how an approximated +transformation could be created based on a reprojection transformation, but +with a given error threshold (dfErrorThreshold in output pixels). + +\code + hTransformArg = + GDALCreateApproxTransformer( GDALGenImgProjTransform, + hGenImgProjArg, dfErrorThreshold ); + pfnTransformer = GDALApproxTransform; +\endcode + +<li> When writing to a blank output file, use the INIT_DEST option in the +GDALWarpOptions::papszWarpOptions to cause the output chunks to be +initialized to a fixed value, instead of being read from the output. This +can substantially reduce unnecessary IO work. + +<li> Use tiled input and output formats. Tiled formats allow a given +chunk of source and destination imagery to be accessed without having to +touch a great deal of extra image data. Large scanline oriented files +can result in a great deal of wasted extra IO. + +<li> Process all bands in one call. This ensures the transformation +calculations don't have to be performed for each band. + +<li> Use the GDALWarpOperation::ChunkAndWarpMulti() method instead of +GDALWarpOperation::ChunkAndWarpImage(). It uses a separate thread for the +IO and the actual image warp operation allowing more effective use of CPU +and IO bandwidth. For this to work GDAL needs to have been built with +multi-threading support (default on Win32, --with-pthreads on Unix). + +<li> The resampling kernels vary is work required from nearest neighbour +being least, then bilinear then cubic. Don't use a more complex resampling +kernel than needed. + +<li> Avoid use of esoteric masking options so that special simplified +logic case be used for common special cases. For instance, nearest +neighbour resampling with no masking on 8bit data is highly optimized +compared to the general case. + +</ol> + +\section warptut_other_opts Other Masking Options + +The GDALWarpOptions include a bunch of esoteric masking capabilities, for +validity masks, and density masks on input and output. Some of these are +not yet implemented and others are implemented but poorly tested. Other +than per-band validity masks it is advised that these features be used with +caution at this time. + +*/ + + + diff --git a/Utilities/GDAL/doc/wince_port.dox b/Utilities/GDAL/doc/wince_port.dox new file mode 100644 index 0000000000..dfcc23040c --- /dev/null +++ b/Utilities/GDAL/doc/wince_port.dox @@ -0,0 +1,180 @@ +#ifndef DOXYGEN_SKIP +/* $Id: wince_port.dox,v 1.3 2006/03/28 22:56:33 mloskot Exp $ */ +#endif /* DOXYGEN_SKIP */ + +/*! +\page wince GDAL for Windows CE + +\section wince_overview Overview + +This document is devoted to give some overview of the GDAL port for Windows CE operating system. The OGR port is the first attempt to get GDAL library working on Windows CE. + +\section wince_status Current Status + +Currently, only vector data support is available in form of OGR library port for Windows CE. Next milestone will be to port raster data features to make Windows CE port of GDAL more complete. + +List of GDAL features ported to Windows CE: +<ul> + <li>\link cpl_port.h CPL\endlink library</li> +<li>Base OGR API </li> +<li>Subset of OGR data drivers (ogr\ogrsf_frmts): + <ul> + <li>Generic</li> + <li><a href="ogr/drv_mitab.html">Mitab</a></li> + <li><a href="ogr/drv_shapefile.html">Shape</a></li> + </ul> +</li> +<li><a href="http://sourceforge.net/projects/wcelibcex/">WCELibCEx</a> - extensions for C library available on Windows CE operating system<br />This is a separate project derived from the work made on GDAL port for Windows CE.</li> +</ul> + +List of features not included in the GDAL port for Windows CE: +<ul> + <li>Raster data support</li> + <li><a href="http://geos.refractions.net">GEOS</a> has not been ported yet, so OGR for Windows CE compiles without GEOS support (work in progress)</li> + <li><a href="ogr/ogr_formats.html">OGR drivers</a> not listed in the features list above</li> +</ul> + +\section wince_platforms Supported Platforms + +GDAL port for Windows CE has been tested on Windows Mobile for Pocket PC 2003 operating system (see \ref wince_wince). It is based on Windows CE 4.2 .NET version. There should be no problems with running it on systems based on latest Windows CE 5.0. + +The GDAL port was tested with following compiler for Windows CE devices (see \ref wince_msvc): +<ul> + <li>Microsoft eMbedded Visual C++ 4.0 (SP 4)</li> + <li>Microsoft Visual C++ 2005</li> +</ul> + +\subsection wince_wince About Windows CE + +<a href="http://www.microsoft.com/windows/embedded/default.mspx">Windows CE</a> is one of two embedded operating systems create by Microsoft. The second is <a href="http://msdn.microsoft.com/embedded/windowsxpembedded/default.aspx">Windows XP Embedded</a>. The GDAL port is dedicated to the first one - Windows CE system. It may work on Windows XP Embedded as well but I have not tested it. (If you're interested in differences between those two systems, look at the <a href="http://www.embeddedtechnologyjournal.com/articles_2005/20051004_msft.htm">Comparing Windows CE and Windows XP Embedded</a> by Mike Hall.) + +So, remember, in order use GDAL port you will need a mobile device running Windows CE. + +Now, a few words about Windows CE and derived systems versions. +Usually, users are quite confused about all those different versions of Windows CE and derived systems. In fact, the idea is quite simple. +Windows CE is a name of base operating system and can be seen as equivalent of Windows NT for Windows on desktop. All desktop versions like Windows 2000 or XP are still Windows NT systems. +Windows CE is highly modular system and can be used as a base operating system by everyone who wants to build his own system. Microsoft provides a few officially configured versions and called them Windows Mobile. Now, you have a few versions of Windows Mobile: +<ul> + <li>Windows Mobile for Pocket PC</li> + <li>Windows Mobile for Smartphone</li> +</ul> + +All those Windows CE derived systems are still Windows CE. So, GDAL port for Windows CE should work on all of them without any problems. + +As I said, I tested GDAL port on Windows CE 4.2. That means it will work on: +<ul> + <li>Windows Mobile 2003</li> + <li>Windows Mobile 2003 Second Edition</li> +</ul> + +It's also expected to work on latest Windows Mobile 5.0. + +For better understanding of versions of Windows CE, please take a look at these web sites: +<ul> + <li><a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsMobileFeedback">What's the Windows Mobile platform?</a></li> + <li><a href="http://en.wikipedia.org/wiki/Image:Windows_CE_Timeline.png">Windows CE Timeline</a></li> +</ul> + +\subsection wince_msvc About Visual C++ IDE + +First, if you have not decided which tool you need, take a look at this <a href="http://blogs.msdn.com/windowsmobile/archive/2005/06/02/424382.aspx">Windows Mobile Tool Support Matrix</a>. + +Microsoft eMbedded Visual C++ 4.0 (eVC++ 4.0) is available free of charge and can be downloaded from following <a href="http://www.microsoft.com/downloads/details.aspx?familyid=1DACDB3D-50D1-41B2-A107-FA75AE960856&displaylang=en">download</a> website. Also, remember to <a href="http://www.microsoft.com/downloads/details.aspx?familyid=4a4ed1f4-91d3-4dbe-986e-a812984318e5&displaylang=en">download</a> and install latest Service Pack (currently, it's SP4). + +Recently, Microsoft included C++ compiler for mobile devices into the \em big Visual C++ compiler, starting from 2005 (8.0) version. So, it seems there will be no new releases of eVC++. +In order to use GDAL port for Windows CE with <a href="http://msdn.microsoft.com/visualc/">Visual C++ 2005</a> compiler you will need the Standard Edition or higher because Express Edition does not provide support for Windows CE mobile devices. For more details see this <a href="http://msdn.microsoft.com/vstudio/products/compare/default.aspx">comparison</a>. + +\section wince_howto Getting Started + +This section explains how to build GDAL for Windows CE as a library. There are not much details about how to use it but it should not be a problem. As explained above, for now, GDAL for Windows CE includes OGR features only, so in order to use it just follow instructions from the <a href="ogr/ogr_apitut.html">OGR API Tutorial</a>. To help you to make the start easier, there are a few test applications based on this tutorial, so try to build and run them. If new features will be added in future, like rasters support, this section will be updated as well. + +\subsection wince_howto_get Downloading GDAL port sources + +GDAL port for Windows CE is available from the official CVS repository. Follow instructions in CVS section on the <a href="http://www.gdal.org/download.html#download_sources_cvs">GDAL download page</a>. + +After you checkout GDAL sources, you will get also <em>gdal\wince</em> directory. This directory consists of all files related to Window CE port. + +Now, the first thing you should do is to read <em>gdal/wince/README</em> file. There you will find all details about content of <em>gdal/wince</em> directory and building instructions. + +\subsection wince_howto_build_evc4 Building GDAL port using eVC++ and makefiles + +<ol> + <li>Open command line (cmd.exe) on your Windows box and go to GDAL sources directory. In example to: + + \code + C:\gdal + \endcode + </li> + + <li>Run configuration script for ARM target. It's default location is: + + \code + C:\Program Files\Microsoft eMbedded C++ 4.0\EVC\wce420\bin\WCEARMV4.BAT + \endcode + + Now, runs some commands to check if everything is configured well: + + \code + C:\gdal> clarm.exe /? + Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM + Copyright (C) Microsoft Corp 1984-2002. All rights reserved. + + C:\gdal> echo %PLATFORM% + POCKET PC 2003 + + C:\gdal> echo %OSVERSION% + WCE420 + \endcode + </li> + <li>Build GDAL library:<br /> + + \code + C:\gdal> nmake /f makefile.evc4 + \endcode + </li> + + <li>If everything went without any errors you should have following files in gdal root directory (C:\gdal): + <ul> + <li>gdalce.lib - static library (PREFERED)</li> + <li>gdalce13.dll - Dynamic-Link Library (DLL) (See IMPORTANT note)</li> + <li>gdalce_i.exp - export file for DLL</li> + <li>gdalce_i.lib - import library for DLL</li> + </ul> + </li> + + \note Currently \em gdalce13.dll built with NMake seems to be broken. So, if you want to use GDAL for Windows CE as a DLL please use eVC++ 4.0 project file from \em evc4_gdalce_dll directory at the moment. This issue is known and waiting for fix :-) + +\subsection wince_howto_build_evc4_proj Building GDAL port using eVC++ project files + +The easiest way is to build GDAL port for Windows CE using Visual C++ project files. There are two project files available in the <em>gdal/wince</em> directory: +<ul> + <li>evc4_gdalce_lib - project file for eMbedded Visual C++ 4.0 to build GDAL port for Windows CE as a static library</li> + <li>evc4_gdalce_dll - project file for eMbedded Visual C++ 4.0 to build GDAL port for Windows CE as a DLL</li> +</ul> + +So, just open workspace file (\em .vcw) you want to use in the eVC++ IDE and build it. + +\note There are also some project files and test applications provided. Look into the <em>gdal/wince/README</em> file for details. + +\subsection wince_howto_build_vc2005_proj Building GDAL port using VC++ 2005 project file + +Recently, I also added project file to build GDAL for Windows CE using Visual C++ 2005. This project file is available in the <em>gdal/wince/msvc8_gdalce_lib</em> directory. Sibling test project is available in the <em>gdal/wince/msvc8_gdalce_lib_test</em>. + +\section wince_help How can I help? + +I'd like to encourage everyone interested in using GDAL on Windows CE devices to help in its development. +Here is a list of what you can do as a contribution to the project: +<ul> + <li>You can build GDAL for Windows CE and report problems if you will meet any</li> + <li>You can try to build new OGR drivers</li> + <li>You can test GDAL/OGR on different Windows CE devices</li> + <li>You can write sample applications using GDAL/OGR and announce them on the <a href="http://lists.maptools.org/mailman/listinfo/gdal-dev/">GDAL mailing list</a></li> + <li>If you have found a bug or something is not working on the Windows CE, please report it on the <a href="http://bugzilla.remotesensing.org">GDAL's Bugzilla</a> +</ul> + +There is also <em>gdal/wince/TODO</em> file where you can find list of things we are going to do. + +If you have any comments or questions, please sent them to the gdal-dev@lists.maptools.org mailing list or directly to me on mateusz@loskot.net . + +*/ + diff --git a/Utilities/GDAL/frmts/GNUmakefile b/Utilities/GDAL/frmts/GNUmakefile new file mode 100644 index 0000000000..4d7956412f --- /dev/null +++ b/Utilities/GDAL/frmts/GNUmakefile @@ -0,0 +1,27 @@ + + +include ../GDALmake.opt + +OBJ = o/gdalallregister.o + +FRMT_FLAGS = $(foreach FRMT, $(GDAL_FORMATS), -DFRMT_$(FRMT)) + +%-install-obj: + $(MAKE) -C $* install-obj + +default: $(OBJ) $(foreach d,$(GDAL_FORMATS),$(d)-install-obj) + +clean: $(foreach d,$(GDAL_FORMATS),$(d)-clean) + rm -f *.o o/*.o o/*.a + $(RM) o/*.lo + +o/gdalallregister.o: gdalallregister.cpp ../GDALmake.opt + $(CXX) -c $(GDAL_INCLUDE) $(CXXFLAGS) $(FRMT_FLAGS) \ + -DGDAL_FORMATS="$(GDAL_FORMATS)" \ + gdalallregister.cpp -o o/gdalallregister.o + +# We might want to add dynamically generated drivers here eventually. +install: + $(MAKE) -C vrt install + $(MAKE) -C mem install + $(MAKE) -C raw install diff --git a/Utilities/GDAL/frmts/aigrid/.cvsignore b/Utilities/GDAL/frmts/aigrid/.cvsignore new file mode 100644 index 0000000000..e84001e2cf --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/.cvsignore @@ -0,0 +1 @@ +aitest diff --git a/Utilities/GDAL/frmts/aigrid/GNUmakefile b/Utilities/GDAL/frmts/aigrid/GNUmakefile new file mode 100644 index 0000000000..61f24cdd86 --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/GNUmakefile @@ -0,0 +1,30 @@ + +include ../../GDALmake.opt + +AIGOBJ = gridlib.o aigopen.o aigccitt.o +OBJ = aigdataset.o $(AIGOBJ) + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o aitest $(OBJ) + +aitest: aitest.o $(AIGOBJ) + $(CXX) aitest.o $(AIGOBJ) ../../port/*.o $(CONFIG_LIBS) -o aitest + +aigrid2tif: aigrid2tif.o $(AIGOBJ) + $(CXX) aigrid2tif.o $(AIGOBJ) ../../port/*.o $(LIBS) -ltiff \ + -o aigrid2tif + +install-obj: $(O_OBJ) + +aitest-dist: + rm -rf aitest_dist + mkdir aitest_dist + cp gridlib.c aitest.c aigrid.h aigopen.c aigccitt.c aitest_dist + cp ../../port/cpl_{vsisimple,conv,error}.cpp aitest_dist + cp ../../port/cpl_{port,conv,vsi,config,error}.h aitest_dist + cp Makefile.dist aitest_dist/Makefile + diff --git a/Utilities/GDAL/frmts/aigrid/Makefile.dist b/Utilities/GDAL/frmts/aigrid/Makefile.dist new file mode 100644 index 0000000000..437ccf377b --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/Makefile.dist @@ -0,0 +1,19 @@ + + +OBJ = aigopen.o gridlib.o aigccitt.o \ + cpl_vsisimple.o cpl_conv.o cpl_error.o + +default: aitest + +aitest: $(OBJ) + $(CXX) aitest.c $(OBJ) -o aitest + +cpl_vsisimple.o: cpl_vsisimple.cpp + $(CXX) -c cpl_vsisimple.cpp + +cpl_conv.o: cpl_conv.cpp + $(CXX) -c cpl_conv.cpp + +cpl_error.o: cpl_error.cpp + $(CXX) -c cpl_error.cpp + diff --git a/Utilities/GDAL/frmts/aigrid/aigccitt.c b/Utilities/GDAL/frmts/aigrid/aigccitt.c new file mode 100644 index 0000000000..2b3763fbcf --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/aigccitt.c @@ -0,0 +1,1926 @@ +/****************************************************************************** + * $Id$ + * + * Project: Arc/Info Binary Grid Translator + * Purpose: Code for decoding CCITT RLE (G1) compressed data. + * Author: Frank Warmerdam, warmerdam@pobox.com + * Code derived from libtiff (tif_fax3), which originally was + * derived from code by Fred Cringle in viewfax. + * + ****************************************************************************** + * Copyright (c) 2002 Frank Warmerdam <warmerdam@pobox.com> + * Copyright (c) 1990-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + ****************************************************************************** + * + * $Log: aigccitt.c,v $ + * Revision 1.4 2002/10/31 03:55:46 warmerda + * make some more stuff static + * + * Revision 1.3 2002/10/31 03:53:22 warmerda + * fixed special types + * + * Revision 1.2 2002/10/31 03:24:49 warmerda + * fixed assert + * + * Revision 1.1 2002/10/31 03:07:58 warmerda + * New + * + */ + +#include <assert.h> +#include "aigrid.h" + +/* ==================================================================== */ +/* Various declarations for the decompression state machine */ +/* cribbed from tif_fax3.h in libtiff. */ +/* ==================================================================== */ + +#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ +#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ +#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ +#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ +#define FAXMODE_WORDALIGN 0x0008 /* word align row */ +#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ + +/* + * To override the default routine used to image decoded + * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. + * The routine must have the type signature given below; + * for example: + * + * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) + * + * where buf is place to set the bits, runs is the array of b&w run + * lengths (white then black), erun is the last run in the array, and + * lastx is the width of the row in pixels. Fill routines can assume + * the run array has room for at least lastx runs and can overwrite + * data in the run array as needed (e.g. to append zero runs to bring + * the count up to a nice multiple). + */ +typedef void (*TIFFFaxFillFunc)(unsigned char*, GUInt32*, GUInt32*, GUInt32); + +/* finite state machine codes */ + + +#define S_Null 0 +#define S_Pass 1 +#define S_Horiz 2 +#define S_V0 3 +#define S_VR 4 +#define S_VL 5 +#define S_Ext 6 +#define S_TermW 7 +#define S_TermB 8 +#define S_MakeUpW 9 +#define S_MakeUpB 10 +#define S_MakeUp 11 +#define S_EOL 12 + +typedef struct { /* state table entry */ + unsigned char State; /* see above */ + unsigned char Width; /* width of code in bits */ + GUInt32 Param; /* unsigned 32-bit run length in bits */ +} TIFFFaxTabEnt; + +static const TIFFFaxTabEnt TIFFFaxMainTable[128] = { +12,7,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, +2,3,0,3,1,0,4,3,1,3,1,0,5,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, +1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,5,7,3,3,1,0,5,3,1,3,1,0, +2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, +4,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, +2,3,0,3,1,0,4,3,1,3,1,0,6,7,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, +1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,5,6,2,3,1,0,5,3,1,3,1,0, +2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, +4,7,3,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0,1,4,0,3,1,0,5,3,1,3,1,0, +2,3,0,3,1,0,4,3,1,3,1,0,4,6,2,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0, +1,4,0,3,1,0,5,3,1,3,1,0,2,3,0,3,1,0,4,3,1,3,1,0 +}; +static const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = { +12,11,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,11,1792,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, +7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, +7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, +7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, +7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +11,11,1856,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, +7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, +7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, +7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, +9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, +7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, +7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, +7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, +7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,11,12,2112,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, +7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, +7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, +7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2368,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, +7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, +7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, +7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6, +7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +11,12,1984,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6, +7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, +7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, +7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, +9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, +7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5, +7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, +7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6, +7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,11,11,1920,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, +7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, +7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, +7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2240,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, +7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, +7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, +7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, +7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +11,12,2496,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, +7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, +7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, +7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, +9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,12,11,0,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, +7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, +7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, +7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, +7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,11,11,1792,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, +7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, +7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, +7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,11,1856,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, +7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, +7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, +7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6, +7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +11,12,2176,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6, +7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, +7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, +7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, +9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, +7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5, +7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, +7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6, +7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,11,12,2432,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, +7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, +7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, +7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1472,7,4,5,7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,960,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2048,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5, +7,8,44,7,6,17,9,9,1344,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15, +7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7, +7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6, +7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +11,11,1920,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6, +7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5, +7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1728,7,4,5,7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5, +7,8,42,7,6,16,9,9,1152,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15, +9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,0,0,0,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6,7,7,19,7,5,8,7,8,55,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5,7,8,53,7,5,9,9,8,448,7,4,6, +7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1472,7,4,5, +7,8,43,7,6,17,9,9,1216,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,33,9,5,128,7,8,49,7,6,14, +7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5,7,8,41,7,6,16,9,9,960,7,4,6, +7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,9,704,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15,9,8,320,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,11,12,2304,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5, +7,8,40,7,6,16,9,9,832,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6,7,8,36,9,5,128,7,8,52,7,6,15, +7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1600,7,4,5,7,8,44,7,6,17,9,9,1344,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,30,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14,7,8,62,7,4,4,7,4,2,7,4,7, +7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1088,7,4,6,7,8,32,7,5,8,7,8,58,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,8,640,7,4,6, +7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5, +7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +0,0,0,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14, +7,7,28,7,4,4,7,4,2,7,4,7,7,7,23,7,4,3,7,7,27,7,4,5,7,8,39,7,6,16,9,8,576,7,4,6, +7,7,19,7,5,8,7,8,55,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,8,45,7,4,3,7,5,11,7,4,5, +7,8,53,7,5,9,9,8,448,7,4,6,7,8,35,9,5,128,7,8,51,7,6,15,7,8,63,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,9,9,1536,7,4,5,7,8,43,7,6,17,9,9,1280,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,29,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6, +7,8,33,9,5,128,7,8,49,7,6,14,7,8,61,7,4,4,7,4,2,7,4,7,7,8,47,7,4,3,7,8,59,7,4,5, +7,8,41,7,6,16,9,9,1024,7,4,6,7,8,31,7,5,8,7,8,57,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,7,22,7,4,3,7,5,11,7,4,5,7,7,26,7,5,9,9,9,768,7,4,6,7,8,37,9,5,128,7,7,25,7,6,15, +9,8,320,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6, +7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,11,12,2560,7,4,3,7,5,11,7,4,5, +7,6,12,7,5,9,9,6,1664,7,4,6,7,7,20,9,5,128,7,7,24,7,6,14,7,7,28,7,4,4,7,4,2,7,4,7, +7,7,23,7,4,3,7,7,27,7,4,5,7,8,40,7,6,16,9,9,896,7,4,6,7,7,19,7,5,8,7,8,56,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7,7,8,46,7,4,3,7,5,11,7,4,5,7,8,54,7,5,9,9,8,512,7,4,6, +7,8,36,9,5,128,7,8,52,7,6,15,7,8,0,7,4,4,7,4,2,7,4,7,7,6,13,7,4,3,9,9,1728,7,4,5, +7,8,44,7,6,17,9,9,1408,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7, +7,8,30,7,4,3,7,5,11,7,4,5,7,6,12,7,5,9,9,6,1664,7,4,6,7,8,34,9,5,128,7,8,50,7,6,14, +7,8,62,7,4,4,7,4,2,7,4,7,7,8,48,7,4,3,7,8,60,7,4,5,7,8,42,7,6,16,9,9,1152,7,4,6, +7,8,32,7,5,8,7,8,58,9,5,64,7,5,10,7,4,4,7,4,2,7,4,7,7,7,22,7,4,3,7,5,11,7,4,5, +7,7,26,7,5,9,9,8,640,7,4,6,7,8,38,9,5,128,7,7,25,7,6,15,9,8,384,7,4,4,7,4,2,7,4,7, +7,6,13,7,4,3,7,7,18,7,4,5,7,7,21,7,6,17,9,7,256,7,4,6,7,6,1,7,5,8,9,6,192,9,5,64, +7,5,10,7,4,4,7,4,2,7,4,7 +}; +static const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = { +12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,12,128,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,56,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,30,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,57,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,54,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,52,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,48,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,2112,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,44,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,36,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,384,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,28,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,60,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,40,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2368,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,1984,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,50,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,34,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,1664,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,26,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,1408,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,32,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,61,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,42,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1024,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,768,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,62,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2240,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,46,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,38,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,512,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2496,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,12,11,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,25,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,12,192,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,1280,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,31,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1856,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,58,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,21,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,896,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,640,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,49,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2176,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,45,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,37,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,12,448,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,29,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,1536,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,41,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,2432,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2048,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,51,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,35,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,12,320,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,27,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,59,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,33,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,256,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,43,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,1152,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,55,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,63,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,2304,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,47,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,39,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,53,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2560,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,11,1792,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,20,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,128,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,56,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,30,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,57,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,54,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,52,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,48,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2112,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,44,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,36,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,12,384,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,28,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,60,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,40,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2368,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,1984,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,50,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,34,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1728,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,26,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,1472,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,32,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,61,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,42,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,1088,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,832,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,62,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2240,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,46,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,38,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,576,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,24,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,2496,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +12,11,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,11,1792,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,23,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,20,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,25,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,12,192,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1344,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,31,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,11,1856,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,58,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,11,21,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,960,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,13,704,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,49,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,12,2176,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,45,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,37,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,12,448,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,29,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,13,1600,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,41,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2432,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,18,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,10,17,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2048,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,51,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,35,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,12,320,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,27,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,59,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,33,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,11,11,1920,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +10,12,256,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,43,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,10,13,1216,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,13,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,9,15,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,55,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,63,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,11,12,2304,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,12,47,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,12,39,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,12,53,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,8,14,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,0,0,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,13,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,19,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,11,24,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,7,11,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,11,22,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +11,12,2560,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,9,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,10,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,10,16,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,10,0,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,10,10,64,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,6,9,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2,8,7,11,8,2,3,8,3,1,8,2,2, +8,4,6,8,2,3,8,3,4,8,2,2,8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2, +8,8,14,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2,8,6,8,8,2,3,8,3,1,8,2,2, +8,4,5,8,2,3,8,3,4,8,2,2,8,7,12,8,2,3,8,3,1,8,2,2,8,4,6,8,2,3,8,3,4,8,2,2, +8,5,7,8,2,3,8,3,1,8,2,2,8,4,5,8,2,3,8,3,4,8,2,2 +}; + +static const unsigned char TIFFBitRevTable[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; +static const unsigned char TIFFNoBitRevTable[256] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +}; + +/* + * The following macros define the majority of the G3/G4 decoder + * algorithm using the state tables defined elsewhere. To build + * a decoder you need some setup code and some glue code. Note + * that you may also need/want to change the way the NeedBits* + * macros get input data if, for example, you know the data to be + * decoded is properly aligned and oriented (doing so before running + * the decoder can be a big performance win). + * + * Consult the decoder in the TIFF library for an idea of what you + * need to define and setup to make use of these definitions. + * + * NB: to enable a debugging version of these macros define FAX3_DEBUG + * before including this file. Trace output goes to stdout. + */ + +#ifndef EndOfData +#define EndOfData() (cp >= ep) +#endif +/* + * Need <=8 or <=16 bits of input data. Unlike viewfax we + * cannot use/assume a word-aligned, properly bit swizzled + * input data set because data may come from an arbitrarily + * aligned, read-only source such as a memory-mapped file. + * Note also that the viewfax decoder does not check for + * running off the end of the input data buffer. This is + * possible for G3-encoded data because it prescans the input + * data to count EOL markers, but can cause problems for G4 + * data. In any event, we don't prescan and must watch for + * running out of data since we can't permit the library to + * scan past the end of the input data buffer. + * + * Finally, note that we must handle remaindered data at the end + * of a strip specially. The coder asks for a fixed number of + * bits when scanning for the next code. This may be more bits + * than are actually present in the data stream. If we appear + * to run out of data but still have some number of valid bits + * remaining then we makeup the requested amount with zeros and + * return successfully. If the returned data is incorrect then + * we should be called again and get a premature EOF error; + * otherwise we should get the right answer. + */ +#ifndef NeedBits8 +#define NeedBits8(n,eoflab) do { \ + if (BitsAvail < (n)) { \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= ((GUInt32) bitmap[*cp++])<<BitsAvail; \ + BitsAvail += 8; \ + } \ + } \ +} while (0) +#endif +#ifndef NeedBits16 +#define NeedBits16(n,eoflab) do { \ + if (BitsAvail < (n)) { \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= ((GUInt32) bitmap[*cp++])<<BitsAvail; \ + if ((BitsAvail += 8) < (n)) { \ + if (EndOfData()) { \ + /* NB: we know BitsAvail is non-zero here */ \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= ((GUInt32) bitmap[*cp++])<<BitsAvail; \ + BitsAvail += 8; \ + } \ + } \ + } \ + } \ +} while (0) +#endif +#define GetBits(n) (BitAcc & ((1<<(n))-1)) +#define ClrBits(n) do { \ + BitsAvail -= (n); \ + BitAcc >>= (n); \ +} while (0) + +#ifdef FAX3_DEBUG +static const char* StateNames[] = { + "Null ", + "Pass ", + "Horiz ", + "V0 ", + "VR ", + "VL ", + "Ext ", + "TermW ", + "TermB ", + "MakeUpW", + "MakeUpB", + "MakeUp ", + "EOL ", +}; +#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') +#define LOOKUP8(wid,tab,eoflab) do { \ + int t; \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + int t; \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) + +#define SETVAL(x) do { \ + *pa++ = RunLength + (x); \ + printf("SETVAL: %d\t%d\n", RunLength + (x), a0); \ + a0 += x; \ + RunLength = 0; \ +} while (0) +#else +#define LOOKUP8(wid,tab,eoflab) do { \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) + +/* + * Append a run to the run length array for the + * current row and reset decoding state. + */ +#define SETVAL(x) do { \ + *pa++ = RunLength + (x); \ + a0 += (x); \ + RunLength = 0; \ +} while (0) +#endif + +/* + * Synchronize input decoding at the start of each + * row by scanning for an EOL (if appropriate) and + * skipping any trash data that might be present + * after a decoding error. Note that the decoding + * done elsewhere that recognizes an EOL only consumes + * 11 consecutive zero bits. This means that if EOLcnt + * is non-zero then we still need to scan for the final flag + * bit that is part of the EOL code. + */ +#define SYNC_EOL(eoflab) do { \ + if (EOLcnt == 0) { \ + for (;;) { \ + NeedBits16(11,eoflab); \ + if (GetBits(11) == 0) \ + break; \ + ClrBits(1); \ + } \ + } \ + for (;;) { \ + NeedBits8(8,eoflab); \ + if (GetBits(8)) \ + break; \ + ClrBits(8); \ + } \ + while (GetBits(1) == 0) \ + ClrBits(1); \ + ClrBits(1); /* EOL bit */ \ + EOLcnt = 0; /* reset EOL counter/flag */ \ +} while (0) + +/* + * Cleanup the array of runs after decoding a row. + * We adjust final runs to insure the user buffer is not + * overwritten and/or undecoded area is white filled. + */ +#define CLEANUP_RUNS() do { \ + if (RunLength) \ + SETVAL(0); \ + if (a0 != lastx) { \ + badlength(a0, lastx); \ + while (a0 > lastx && pa > thisrun) \ + a0 -= *--pa; \ + if (a0 < lastx) { \ + if (a0 < 0) \ + a0 = 0; \ + if ((pa-thisrun)&1) \ + SETVAL(0); \ + SETVAL(lastx - a0); \ + } else if (a0 > lastx) { \ + SETVAL(lastx); \ + SETVAL(0); \ + } \ + } \ +} while (0) + +/* + * Decode a line of 1D-encoded data. + * + * The line expanders are written as macros so that they can be reused + * but still have direct access to the local variables of the "calling" + * function. + * + * Note that unlike the original version we have to explicitly test for + * a0 >= lastx after each black/white run is decoded. This is because + * the original code depended on the input data being zero-padded to + * insure the decoder recognized an EOL before running out of data. + */ + +/* + * Update the value of b1 using the array + * of runs for the reference line. + */ +#define CHECK_b1 do { \ + if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ + b1 += pb[0] + pb[1]; \ + pb += 2; \ + } \ +} while (0) + +/* ==================================================================== */ +/* Declarations from tif_fax3.c */ +/* ==================================================================== */ + +/* + * Compression+decompression state blocks are + * derived from this ``base state'' block. + */ +typedef struct { + int rw_mode; /* O_RDONLY for decode, else encode */ + int mode; /* operating mode */ + GUInt32 rowbytes; /* bytes in a decoded scanline */ + GUInt32 rowpixels; /* pixels in a scanline */ + + GUInt16 cleanfaxdata; /* CleanFaxData tag */ + GUInt32 badfaxrun; /* BadFaxRun tag */ + GUInt32 badfaxlines; /* BadFaxLines tag */ + GUInt32 groupoptions; /* Group 3/4 options tag */ + GUInt32 recvparams; /* encoded Class 2 session params */ + char* subaddress; /* subaddress string */ + GUInt32 recvtime; /* time spent receiving (secs) */ +} Fax3BaseState; +#define Fax3State(tif) ((Fax3BaseState*) tif) + +typedef struct { + Fax3BaseState b; + const unsigned char* bitmap; /* bit reversal table */ + GUInt32 data; /* current i/o byte/word */ + int bit; /* current i/o bit in byte */ + int EOLcnt; /* count of EOL codes recognized */ + TIFFFaxFillFunc fill; /* fill routine */ + GUInt32* runs; /* b&w runs for current/previous row */ + GUInt32* refruns; /* runs for reference line */ + GUInt32* curruns; /* runs for current line */ +} Fax3DecodeState; +#define DecoderState(tif) ((Fax3DecodeState*) Fax3State(tif)) + +typedef enum { G3_1D, G3_2D } Ttag; +#ifdef notdef +typedef struct { + Fax3BaseState b; + int data; /* current i/o byte */ + int bit; /* current i/o bit in byte */ + Ttag tag; /* encoding state */ + unsigned char* refline; /* reference line for 2d decoding */ + int k; /* #rows left that can be 2d encoded */ + int maxk; /* max #rows that can be 2d encoded */ +} Fax3EncodeState; +#define EncoderState(tif) ((Fax3EncodeState*) Fax3State(tif)) +#endif + +#define is2DEncoding(sp) \ + (sp->b.groupoptions & GROUP3OPT_2DENCODING) +#define isAligned(p,t) ((((unsigned long)(p)) & (sizeof (t)-1)) == 0) + +/* + * Group 3 and Group 4 Decoding. + */ + +/* + * These macros glue the TIFF library state to + * the state expected by Frank's decoder. + */ +#define DECLARE_STATE(tif, sp) \ + Fax3DecodeState* sp = DecoderState(tif); \ + int a0; /* reference element */ \ + int lastx = sp->b.rowpixels; /* last element in row */ \ + GUInt32 BitAcc; /* bit accumulator */ \ + int BitsAvail; /* # valid bits in BitAcc */ \ + int RunLength; /* length of current run */ \ + unsigned char* cp; /* next byte of input data */ \ + unsigned char* ep; /* end of input data */ \ + GUInt32* pa; /* place to stuff next run */ \ + GUInt32* thisrun; /* current row's run array */ \ + int EOLcnt; /* # EOL codes recognized */ \ + const unsigned char* bitmap = sp->bitmap; /* input data bit reverser */ \ + const TIFFFaxTabEnt* TabEnt +#define DECLARE_STATE_2D(tif, sp, mod) \ + DECLARE_STATE(tif, sp, mod); \ + int b1; /* next change on prev line */ \ + GUInt32* pb /* next run in reference line */\ +/* + * Load any state that may be changed during decoding. + */ +#define CACHE_STATE(sp) do { \ + BitAcc = sp->data; \ + BitsAvail = sp->bit; \ + EOLcnt = sp->EOLcnt; \ + cp = (unsigned char*) rawcp; \ + ep = cp + rawcc; \ +} while (0) +/* + * Save state possibly changed during decoding. + */ +#define UNCACHE_STATE(sp) do { \ + sp->bit = BitsAvail; \ + sp->data = BitAcc; \ + sp->EOLcnt = EOLcnt; \ + rawcc -= (unsigned char *) cp - rawcp; \ + rawcp = (unsigned char *) cp; \ +} while (0) + +/* + * Routine for handling various errors/conditions. + * Note how they are "glued into the decoder" by + * overriding the definitions used by the decoder. + */ + +static void +Fax3Unexpected() +{ + CPLError( CE_Failure, CPLE_AppDefined, + "Bad code word" ); +} +#define unexpected(table, a0) Fax3Unexpected() + +static void +Fax3BadLength(GUInt32 a0, GUInt32 lastx) +{ + CPLError( CE_Warning, CPLE_AppDefined, + "%s (got %lu, expected %lu)", + a0 < lastx ? "Premature EOL" : "Line length mismatch", + (unsigned long) a0, (unsigned long) lastx ); +} + +#define badlength(a0,lastx) Fax3BadLength(a0, lastx) + +static void +Fax3PrematureEOF() +{ + CPLError( CE_Warning, CPLE_AppDefined, + "Premature EOF" ); +} +#define prematureEOF(a0) Fax3PrematureEOF() + +#define Nop + +/* + * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. + * For machines with 64-bit longs this is <16 bytes; otherwise + * this is <8 bytes. We optimize the code here to reflect the + * machine characteristics. + */ +#if defined(__alpha) || _MIPS_SZLONG == 64 || defined(__LP64__) || defined(__arch64__) +#define FILL(n, cp) \ + switch (n) { \ + case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ + case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\ + case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\ + case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\ + case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ + case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ + } +#define ZERO(n, cp) \ + switch (n) { \ + case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \ + case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \ + case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \ + case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \ + case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ + case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ + } +#else +#define FILL(n, cp) \ + switch (n) { \ + case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \ + case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ + case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ + } +#define ZERO(n, cp) \ + switch (n) { \ + case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \ + case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ + case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ + } +#endif + +/************************************************************************/ +/* _TIFFFax3fillruns() */ +/* */ +/* Bit-fill a row according to the white/black */ +/* runs generated during G3/G4 decoding. */ +/************************************************************************/ + +static void +_TIFFFax3fillruns(unsigned char* buf, GUInt32* runs, GUInt32* erun, + GUInt32 lastx) +{ + static const unsigned char _fillmasks[] = + { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; + unsigned char* cp; + GUInt32 x, bx, run; + GInt32 n, nw; + long* lp; + + if ((erun-runs)&1) + *erun++ = 0; + x = 0; + for (; runs < erun; runs += 2) { + run = runs[0]; + if (x+run > lastx || run > lastx ) + run = runs[0] = (GUInt32) (lastx - x); + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ &= 0xff << (8-bx); + run -= 8-bx; + } + if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0x00; + lp = (long*) cp; + nw = (GInt32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = 0L; + } while (--nw); + cp = (unsigned char*) lp; + } + ZERO(n, cp); + run &= 7; + } + if (run) + cp[0] &= 0xff >> run; + } else + cp[0] &= ~(_fillmasks[run]>>bx); + x += runs[0]; + } + run = runs[1]; + if (x+run > lastx || run > lastx ) + run = runs[1] = lastx - x; + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ |= 0xff >> bx; + run -= 8-bx; + } + if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0xff; + lp = (long*) cp; + nw = (GInt32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = -1L; + } while (--nw); + cp = (unsigned char*) lp; + } + FILL(n, cp); + run &= 7; + } + if (run) + cp[0] |= 0xff00 >> run; + } else + cp[0] |= _fillmasks[run]>>bx; + x += runs[1]; + } + } + assert(x == lastx); +} +#undef ZERO +#undef FILL + +/************************************************************************/ +/* Fax3DecodeRLE() */ +/* */ +/* Decode the requested amount of RLE-encoded data. */ +/************************************************************************/ + +static int +Fax3DecodeRLE(Fax3BaseState* tif, unsigned char *buf, int occ, + unsigned char *rawcp, int rawcc ) +{ + DECLARE_STATE(tif, sp); + int mode = sp->b.mode; + + CACHE_STATE(sp); + thisrun = sp->curruns; + while ((long)occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun; +#ifdef FAX3_DEBUG + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- \n"); + fflush(stdout); +#endif + +/* -------------------------------------------------------------------- */ +/* EXPAND1D() */ +/* */ +/* */ +/* Decode a line of 1D-encoded data. */ +/* */ +/* The line expanders are written as macros so that they can */ +/* be reused but still have direct access to the local */ +/* variables of the "calling" function. */ +/* */ +/* Note that unlike the original version we have to explicitly */ +/* test for a0 >= lastx after each black/white run is decoded. */ +/* This is because the original code depended on the input data */ +/* being zero-padded to insure the decoder recognized an EOL */ +/* before running out of data. */ +/* -------------------------------------------------------------------- */ + do { + for (;;) { + for (;;) { + LOOKUP16(12, TIFFFaxWhiteTable, eof1d); + switch (TabEnt->State) { + case S_EOL: + EOLcnt = 1; + goto done1d; + case S_TermW: + SETVAL(TabEnt->Param); + goto doneWhite1d; + case S_MakeUpW: + case S_MakeUp: + a0 += TabEnt->Param; + RunLength += TabEnt->Param; + break; + default: + unexpected("WhiteTable", a0); + goto done1d; + } + } + doneWhite1d: + if (a0 >= lastx) + goto done1d; + for (;;) { + LOOKUP16(13, TIFFFaxBlackTable, eof1d); + switch (TabEnt->State) { + case S_EOL: + EOLcnt = 1; + goto done1d; + case S_TermB: + SETVAL(TabEnt->Param); + goto doneBlack1d; + case S_MakeUpB: + case S_MakeUp: + a0 += TabEnt->Param; + RunLength += TabEnt->Param; + break; + default: + unexpected("BlackTable", a0); + goto done1d; + } + } + doneBlack1d: + if (a0 >= lastx) + goto done1d; + if( *(pa-1) == 0 && *(pa-2) == 0 ) + pa -= 2; + } + eof1d: + prematureEOF(a0); + CLEANUP_RUNS(); + goto EOFRLE; + done1d: + CLEANUP_RUNS(); + } while (0); + +/* -------------------------------------------------------------------- */ +/* Fill */ +/* -------------------------------------------------------------------- */ + (*sp->fill)(buf, thisrun, pa, lastx); + /* + * Cleanup at the end of the row. + */ + if (mode & FAXMODE_BYTEALIGN) { + int n = BitsAvail - (BitsAvail &~ 7); + ClrBits(n); + } else if (mode & FAXMODE_WORDALIGN) { + int n = BitsAvail - (BitsAvail &~ 15); + ClrBits(n); + if (BitsAvail == 0 && !isAligned(cp, GUInt16)) + cp++; + } + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; +#ifdef notdef + if (occ != 0) + tif->tif_row++; +#endif + continue; + EOFRLE: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(sp); + return (-1); + } + UNCACHE_STATE(sp); + + return (1); +} + + +/************************************************************************/ +/* DecompressCCITTRLETile() */ +/************************************************************************/ + +CPLErr DecompressCCITTRLETile( unsigned char *pabySrcData, int nSrcBytes, + unsigned char *pabyDstData, int nDstBytes, + int nBlockXSize, int nBlockYSize ) + +{ + Fax3DecodeState sDecoderState; + Fax3BaseState* sp = (Fax3BaseState *) &sDecoderState; + unsigned char runs_buf[4000]; + long rowbytes, rowpixels; + + memset( &sDecoderState, 0, sizeof(sDecoderState) ); + + sp->groupoptions = 0; + sp->recvparams = 0; + sp->subaddress = NULL; + + DecoderState(sp)->runs = NULL; + DecoderState(sp)->fill = _TIFFFax3fillruns; + + assert( sizeof(runs_buf) >= (nBlockXSize * 2 + 3) ); + +/* -------------------------------------------------------------------- */ +/* */ +/* -------------------------------------------------------------------- */ + /* + * Calculate the scanline/tile widths. + */ + rowbytes = nBlockXSize / 8; + rowpixels = nBlockXSize; + + sp->rowbytes = (GUInt32) rowbytes; + sp->rowpixels = (GUInt32) rowpixels; + sp->mode |= FAXMODE_BYTEALIGN; + /* + * Allocate any additional space required for decoding/encoding. + */ + { + Fax3DecodeState* dsp = DecoderState(sp); + + dsp->runs = (GUInt32*) runs_buf; + dsp->curruns = dsp->runs; + dsp->refruns = NULL; + } + +/* -------------------------------------------------------------------- */ +/* */ +/* -------------------------------------------------------------------- */ + DecoderState(sp)->bit = 0; /* force initial read */ + DecoderState(sp)->data = 0; + DecoderState(sp)->EOLcnt = 0; /* force initial scan for EOL */ + + DecoderState(sp)->bitmap = TIFFBitRevTable; + + if (DecoderState(sp)->refruns) { /* init reference line to white */ + DecoderState(sp)->refruns[0] = (GUInt32) DecoderState(sp)->b.rowpixels; + DecoderState(sp)->refruns[1] = 0; + } + + if( Fax3DecodeRLE( sp, pabyDstData, nDstBytes, + pabySrcData, nSrcBytes ) == 1 ) + return CE_None; + else + return CE_Failure; +} diff --git a/Utilities/GDAL/frmts/aigrid/aigdataset.cpp b/Utilities/GDAL/frmts/aigrid/aigdataset.cpp new file mode 100644 index 0000000000..95a65fa5b4 --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/aigdataset.cpp @@ -0,0 +1,673 @@ +/****************************************************************************** + * $Id: aigdataset.cpp,v 1.26 2005/11/24 20:25:32 fwarmerdam Exp $ + * + * Project: Arc/Info Binary Grid Driver + * Purpose: Implements GDAL interface to underlying library. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: aigdataset.cpp,v $ + * Revision 1.26 2005/11/24 20:25:32 fwarmerdam + * Test for hdf.adf and w001001x.adf in ::Open() method, so we don't + * have to suppress error messages for AIGOpen(). Added error checking + * in the AIGReadBlockIndex() to recognise corrupted files. + * + * Revision 1.25 2005/09/16 20:38:19 fwarmerdam + * added overview support + * + * Revision 1.24 2005/05/05 15:52:48 fwarmerdam + * PAM Enabled + * + * Revision 1.23 2005/02/21 03:04:18 fwarmerdam + * fixed for files in arcseconds (bug 775) + * + * Revision 1.22 2004/02/02 15:34:05 warmerda + * Use CPLFormCIFilename() to get PRJ.ADF as well as prj.adf. + * http://bugzilla.remotesensing.org/show_bug.cgi?id=480 + * + * Revision 1.21 2003/07/08 15:35:22 warmerda + * avoid warnings + * + * Revision 1.20 2003/04/09 13:45:12 warmerda + * added limited colortable support + * + * Revision 1.19 2003/03/03 15:27:54 warmerda + * The ULX and ULY values are edges, not pixel centers. Fixed geotransform. + * + * Revision 1.18 2003/02/13 17:22:37 warmerda + * updated email + * + * Revision 1.17 2002/11/05 03:29:29 warmerda + * added GInt16 handling + * + * Revision 1.16 2002/11/05 03:19:29 warmerda + * remap nodata to 255, and only use byte type if max < 255 + * + * Revision 1.15 2002/09/04 06:50:36 warmerda + * avoid static driver pointers + * + * Revision 1.14 2002/07/10 17:43:20 warmerda + * Fixed error supression. + * + * Revision 1.13 2002/06/12 21:12:24 warmerda + * update to metadata based driver info + * + * Revision 1.12 2002/02/21 15:38:32 warmerda + * fixed nodata value for floats + * + * Revision 1.11 2001/11/11 23:50:59 warmerda + * added required class keyword to friend declarations + * + * Revision 1.10 2001/09/11 13:46:25 warmerda + * return nodata value + * + * Revision 1.9 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.8 2001/03/13 19:39:24 warmerda + * changed short name to AIG, added help link + * + * Revision 1.7 2000/11/09 06:22:51 warmerda + * fixed geotransform, added limited projection support + * + * Revision 1.6 2000/04/20 14:05:16 warmerda + * added support for provided min/max + * + * Revision 1.5 2000/02/28 16:32:19 warmerda + * use SetBand method + * + * Revision 1.4 1999/08/13 03:27:50 warmerda + * added support for GDT_Int32 and GDT_Float32 access + * + * Revision 1.3 1999/07/23 14:28:26 warmerda + * supress errors in AIGOpen() since we don't know if it's really AIG yet + * + * Revision 1.2 1999/06/26 21:00:38 warmerda + * Relax checking that filename is a directory ... AIGOpen() now handles. + * + * Revision 1.1 1999/02/04 22:15:44 warmerda + * New + * + */ + +#include "gdal_pam.h" +#include "cpl_string.h" +#include "ogr_spatialref.h" +#include "aigrid.h" + +CPL_CVSID("$Id: aigdataset.cpp,v 1.26 2005/11/24 20:25:32 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_AIGrid(void); +CPL_C_END + +static const char*OSR_GDS( char **papszNV, const char * pszField, + const char *pszDefaultValue ); + + +/************************************************************************/ +/* ==================================================================== */ +/* AIGDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class AIGRasterBand; + +class CPL_DLL AIGDataset : public GDALPamDataset +{ + friend class AIGRasterBand; + + AIGInfo_t *psInfo; + + char **papszPrj; + char *pszProjection; + + GDALColorTable *poCT; + + void TranslateColorTable( const char * ); + + public: + AIGDataset(); + ~AIGDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual const char *GetProjectionRef(void); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* AIGRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class AIGRasterBand : public GDALPamRasterBand +{ + friend class AIGDataset; + + public: + + AIGRasterBand( AIGDataset *, int ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual double GetMinimum( int *pbSuccess ); + virtual double GetMaximum( int *pbSuccess ); + virtual double GetNoDataValue( int *pbSuccess ); + + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); +}; + +/************************************************************************/ +/* AIGRasterBand() */ +/************************************************************************/ + +AIGRasterBand::AIGRasterBand( AIGDataset *poDS, int nBand ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + nBlockXSize = poDS->psInfo->nBlockXSize; + nBlockYSize = poDS->psInfo->nBlockYSize; + + if( poDS->psInfo->nCellType == AIG_CELLTYPE_INT + && poDS->psInfo->dfMin >= 0.0 && poDS->psInfo->dfMax <= 254.0 ) + { + eDataType = GDT_Byte; + } + else if( poDS->psInfo->nCellType == AIG_CELLTYPE_INT + && poDS->psInfo->dfMin >= -32767 && poDS->psInfo->dfMax <= 32767 ) + { + eDataType = GDT_Int16; + } + else if( poDS->psInfo->nCellType == AIG_CELLTYPE_INT ) + { + eDataType = GDT_Int32; + } + else + { + eDataType = GDT_Float32; + } +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr AIGRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + AIGDataset *poODS = (AIGDataset *) poDS; + GInt32 *panGridRaster; + int i; + + if( poODS->psInfo->nCellType == AIG_CELLTYPE_INT ) + { + panGridRaster = (GInt32 *) CPLMalloc(4*nBlockXSize*nBlockYSize); + if( AIGReadTile( poODS->psInfo, nBlockXOff, nBlockYOff, panGridRaster ) + != CE_None ) + { + CPLFree( panGridRaster ); + return CE_Failure; + } + + if( eDataType == GDT_Byte ) + { + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + if( panGridRaster[i] == ESRI_GRID_NO_DATA ) + ((GByte *) pImage)[i] = 255; + else + ((GByte *) pImage)[i] = (GByte) panGridRaster[i]; + } + } + else if( eDataType == GDT_Int16 ) + { + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + if( panGridRaster[i] == ESRI_GRID_NO_DATA ) + ((GInt16 *) pImage)[i] = -32768; + else + ((GInt16 *) pImage)[i] = (GInt16) panGridRaster[i]; + } + } + else + { + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + ((GInt32 *) pImage)[i] = panGridRaster[i]; + } + + CPLFree( panGridRaster ); + + return CE_None; + } + else + { + return AIGReadFloatTile( poODS->psInfo, nBlockXOff, nBlockYOff, + (float *) pImage ); + } +} + +/************************************************************************/ +/* GetMinimum() */ +/************************************************************************/ + +double AIGRasterBand::GetMinimum( int *pbSuccess ) + +{ + AIGDataset *poODS = (AIGDataset *) poDS; + + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + + return poODS->psInfo->dfMin; +} + +/************************************************************************/ +/* GetMaximum() */ +/************************************************************************/ + +double AIGRasterBand::GetMaximum( int *pbSuccess ) + +{ + AIGDataset *poODS = (AIGDataset *) poDS; + + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + + return poODS->psInfo->dfMax; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double AIGRasterBand::GetNoDataValue( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + + if( eDataType == GDT_Float32 ) + return ESRI_GRID_FLOAT_NO_DATA; + else if( eDataType == GDT_Int16 ) + return -32768; + else if( eDataType == GDT_Byte ) + return 255; + else + return ESRI_GRID_NO_DATA; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp AIGRasterBand::GetColorInterpretation() + +{ + AIGDataset *poODS = (AIGDataset *) poDS; + + if( poODS->poCT != NULL ) + return GCI_PaletteIndex; + else + return GCI_Undefined; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *AIGRasterBand::GetColorTable() + +{ + AIGDataset *poODS = (AIGDataset *) poDS; + + return poODS->poCT; +} + +/************************************************************************/ +/* ==================================================================== */ +/* AIGDataset */ +/* ==================================================================== */ +/************************************************************************/ + + +/************************************************************************/ +/* AIGDataset() */ +/************************************************************************/ + +AIGDataset::AIGDataset() + +{ + psInfo = NULL; + papszPrj = NULL; + pszProjection = CPLStrdup(""); + poCT = NULL; +} + +/************************************************************************/ +/* ~AIGDataset() */ +/************************************************************************/ + +AIGDataset::~AIGDataset() + +{ + FlushCache(); + CPLFree( pszProjection ); + CSLDestroy( papszPrj ); + if( psInfo != NULL ) + AIGClose( psInfo ); + + if( poCT != NULL ) + delete poCT; +} + + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *AIGDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + AIGInfo_t *psInfo; + +/* -------------------------------------------------------------------- */ +/* If the pass name ends in .adf assume a file within the */ +/* coverage has been selected, and strip that off the coverage */ +/* name. */ +/* -------------------------------------------------------------------- */ + CPLString osCoverName; + + osCoverName = poOpenInfo->pszFilename; + if( osCoverName.size() > 4 + && EQUAL(osCoverName.c_str()+osCoverName.size()-4,".adf") ) + { + osCoverName = CPLGetDirname( poOpenInfo->pszFilename ); + if( osCoverName == "" ) + osCoverName = "."; + } + +/* -------------------------------------------------------------------- */ +/* Verify that a few of the "standard" files are available. */ +/* -------------------------------------------------------------------- */ + VSIStatBufL sStatBuf; + CPLString osTestName; + + osTestName.Printf( "%s/hdr.adf", osCoverName.c_str() ); + if( VSIStatL( osTestName, &sStatBuf ) != 0 ) + return NULL; + + osTestName.Printf( "%s/w001001x.adf", osCoverName.c_str() ); + if( VSIStatL( osTestName, &sStatBuf ) != 0 ) + return NULL; + + osTestName.Printf( "%s/w001001.adf", osCoverName.c_str() ); + if( VSIStatL( osTestName, &sStatBuf ) != 0 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + psInfo = AIGOpen( osCoverName.c_str(), "r" ); + + if( psInfo == NULL ) + { + CPLErrorReset(); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + AIGDataset *poDS; + + poDS = new AIGDataset(); + + poDS->psInfo = psInfo; + +/* -------------------------------------------------------------------- */ +/* Try to read a color table (.clr). It seems it is legal to */ +/* have more than one so we just use the first one found. */ +/* -------------------------------------------------------------------- */ + int iFile; + char **papszFiles = CPLReadDir( psInfo->pszCoverName ); + + for( iFile = 0; papszFiles != NULL && papszFiles[iFile] != NULL; iFile++ ) + { + const char *pszClrFilename; + + if( !EQUAL(CPLGetExtension(papszFiles[iFile]),"clr") ) + continue; + + pszClrFilename = CPLFormFilename( psInfo->pszCoverName, + papszFiles[iFile], NULL ); + + poDS->TranslateColorTable( pszClrFilename ); + break; + } + + CSLDestroy( papszFiles ); + +/* -------------------------------------------------------------------- */ +/* Establish raster info. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = psInfo->nPixels; + poDS->nRasterYSize = psInfo->nLines; + poDS->nBands = 1; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->SetBand( 1, new AIGRasterBand( poDS, 1 ) ); + +/* -------------------------------------------------------------------- */ +/* Try to read projection file. */ +/* -------------------------------------------------------------------- */ + const char *pszPrjFilename; + + pszPrjFilename = CPLFormCIFilename( psInfo->pszCoverName, "prj", "adf" ); + if( VSIStatL( pszPrjFilename, &sStatBuf ) == 0 ) + { + OGRSpatialReference oSRS; + + poDS->papszPrj = CSLLoad( pszPrjFilename ); + + if( oSRS.importFromESRI( poDS->papszPrj ) == OGRERR_NONE ) + { + // If geographic values are in seconds, we must transform. + // Is there a code for minutes too? + if( oSRS.IsGeographic() + && EQUAL(OSR_GDS( poDS->papszPrj, "Units", ""), "DS") ) + { + psInfo->dfLLX /= 3600.0; + psInfo->dfURY /= 3600.0; + psInfo->dfCellSizeX /= 3600.0; + psInfo->dfCellSizeY /= 3600.0; + } + + CPLFree( poDS->pszProjection ); + oSRS.exportToWkt( &(poDS->pszProjection) ); + } + + } + +/* -------------------------------------------------------------------- */ +/* Open overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( psInfo->pszCoverName ); + poDS->TryLoadXML(); + + return( poDS ); +} + + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr AIGDataset::GetGeoTransform( double * padfTransform ) + +{ + padfTransform[0] = psInfo->dfLLX; + padfTransform[1] = psInfo->dfCellSizeX; + padfTransform[2] = 0; + + padfTransform[3] = psInfo->dfURY; + padfTransform[4] = 0; + padfTransform[5] = -psInfo->dfCellSizeY; + + return( CE_None ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *AIGDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* TranslateColorTable() */ +/************************************************************************/ + +void AIGDataset::TranslateColorTable( const char *pszClrFilename ) + +{ + int iLine; + char **papszClrLines; + + papszClrLines = CSLLoad( pszClrFilename ); + if( papszClrLines == NULL ) + return; + + poCT = new GDALColorTable(); + + for( iLine = 0; papszClrLines[iLine] != NULL; iLine++ ) + { + char **papszTokens = CSLTokenizeString( papszClrLines[iLine] ); + + if( CSLCount(papszTokens) >= 4 && papszTokens[0][0] != '#' ) + { + int nIndex; + GDALColorEntry sEntry; + + nIndex = atoi(papszTokens[0]); + sEntry.c1 = (short) atoi(papszTokens[1]); + sEntry.c2 = (short) atoi(papszTokens[2]); + sEntry.c3 = (short) atoi(papszTokens[3]); + sEntry.c4 = 255; + + if( (nIndex < 0 || nIndex > 33000) + || (sEntry.c1 < 0 || sEntry.c1 > 255) + || (sEntry.c2 < 0 || sEntry.c2 > 255) + || (sEntry.c3 < 0 || sEntry.c3 > 255) ) + { + CSLDestroy( papszTokens ); + CPLError( CE_Failure, CPLE_AppDefined, + "Color table entry appears to be corrupt, skipping the rest. " ); + break; + } + + poCT->SetColorEntry( nIndex, &sEntry ); + } + + CSLDestroy( papszTokens ); + } + + CSLDestroy( papszClrLines ); +} + +/************************************************************************/ +/* OSR_GDS() */ +/************************************************************************/ + +static const char*OSR_GDS( char **papszNV, const char * pszField, + const char *pszDefaultValue ) + +{ + int iLine; + + if( papszNV == NULL || papszNV[0] == NULL ) + return pszDefaultValue; + + for( iLine = 0; + papszNV[iLine] != NULL && + !EQUALN(papszNV[iLine],pszField,strlen(pszField)); + iLine++ ) {} + + if( papszNV[iLine] == NULL ) + return pszDefaultValue; + else + { + static char szResult[80]; + char **papszTokens; + + papszTokens = CSLTokenizeString(papszNV[iLine]); + + if( CSLCount(papszTokens) > 1 ) + strncpy( szResult, papszTokens[1], sizeof(szResult)); + else + strncpy( szResult, pszDefaultValue, sizeof(szResult)); + + CSLDestroy( papszTokens ); + return szResult; + } +} + +/************************************************************************/ +/* GDALRegister_AIG() */ +/************************************************************************/ + +void GDALRegister_AIGrid() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "AIG" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "AIG" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Arc/Info Binary Grid" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#AIG" ); + + poDriver->pfnOpen = AIGDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/aigrid/aigopen.c b/Utilities/GDAL/frmts/aigrid/aigopen.c new file mode 100644 index 0000000000..ca848f0863 --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/aigopen.c @@ -0,0 +1,336 @@ +/****************************************************************************** + * $Id$ + * + * Project: Arc/Info Binary Grid Translator + * Purpose: Grid file access cover API for non-GDAL use. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: aigopen.c,v $ + * Revision 1.18 2005/10/31 04:51:55 fwarmerdam + * upgraded to use large file API and GUInt32 for block offsets + * + * Revision 1.17 2004/01/29 20:48:10 warmerda + * Make sure that if a bare "w001001.adf" is given to AIGOpen() it will + * work. The name is changed to ".". + * + * Revision 1.16 2003/07/08 15:36:10 warmerda + * avoid warnings + * + * Revision 1.15 2002/11/11 18:29:03 warmerda + * added AIGLLOpen() to support upper case names too + * + * Revision 1.14 2002/11/05 03:19:08 warmerda + * avoid nodata remapping in gridlib, use GInt32 not GUInt for image data + * + * Revision 1.13 2002/10/31 03:08:47 warmerda + * fixed email + * + * Revision 1.12 2002/05/14 21:38:57 warmerda + * fixed up nPixel and nLines calculation to avoid roundoff error + * + * Revision 1.11 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.10 2000/11/09 06:22:40 warmerda + * save cover name + * + * Revision 1.9 2000/09/13 14:42:38 warmerda + * Improved casting thanks for Ian Macleod (Geosoft). + * + * Revision 1.8 2000/02/18 14:47:12 warmerda + * Avoid warnings. + * + * Revision 1.7 2000/02/18 04:55:02 warmerda + * Set bHasWarned flag. + * + * Revision 1.6 1999/07/23 14:04:34 warmerda + * Removed extra printf. + * + * Revision 1.5 1999/06/28 01:21:39 warmerda + * added support for selecting .adf files as well as coverage dir + * + * Revision 1.4 1999/05/17 01:52:35 warmerda + * Fixed argument type problem. + * + * Revision 1.3 1999/04/21 16:51:30 warmerda + * fixed up floating point support + * + * Revision 1.2 1999/02/04 22:15:33 warmerda + * fleshed out implementation + * + * Revision 1.1 1999/02/03 14:12:56 warmerda + * New + */ + +#include "aigrid.h" + +CPL_CVSID("$Id$"); + +/************************************************************************/ +/* AIGOpen() */ +/************************************************************************/ + +AIGInfo_t *AIGOpen( const char * pszInputName, const char * pszAccess ) + +{ + AIGInfo_t *psInfo; + char *pszHDRFilename; + char *pszCoverName; + + (void) pszAccess; + +/* -------------------------------------------------------------------- */ +/* If the pass name ends in .adf assume a file within the */ +/* coverage has been selected, and strip that off the coverage */ +/* name. */ +/* -------------------------------------------------------------------- */ + pszCoverName = CPLStrdup( pszInputName ); + if( EQUAL(pszCoverName+strlen(pszCoverName)-4, ".adf") ) + { + int i; + + for( i = strlen(pszCoverName)-1; i > 0; i-- ) + { + if( pszCoverName[i] == '\\' || pszCoverName[i] == '/' ) + { + pszCoverName[i] = '\0'; + break; + } + } + + if( i == 0 ) + strcpy(pszCoverName,"."); + } + +/* -------------------------------------------------------------------- */ +/* Allocate info structure. */ +/* -------------------------------------------------------------------- */ + psInfo = (AIGInfo_t *) CPLCalloc(sizeof(AIGInfo_t),1); + psInfo->bHasWarned = FALSE; + psInfo->pszCoverName = pszCoverName; + +/* -------------------------------------------------------------------- */ +/* Read the header file. */ +/* -------------------------------------------------------------------- */ + if( AIGReadHeader( pszCoverName, psInfo ) != CE_None ) + { + CPLFree( pszCoverName ); + CPLFree( psInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Open the file w001001.adf file itself. */ +/* -------------------------------------------------------------------- */ + pszHDRFilename = (char *) CPLMalloc(strlen(pszCoverName)+40); + sprintf( pszHDRFilename, "%s/w001001.adf", pszCoverName ); + + psInfo->fpGrid = AIGLLOpen( pszHDRFilename, "rb" ); + + if( psInfo->fpGrid == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open grid file:\n%s\n", + pszHDRFilename ); + + CPLFree( psInfo ); + CPLFree( pszHDRFilename ); + CPLFree( pszCoverName ); + return( NULL ); + } + + CPLFree( pszHDRFilename ); + pszHDRFilename = NULL; + +/* -------------------------------------------------------------------- */ +/* Read the block index file. */ +/* -------------------------------------------------------------------- */ + if( AIGReadBlockIndex( pszCoverName, psInfo ) != CE_None ) + { + VSIFCloseL( psInfo->fpGrid ); + + CPLFree( psInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read the extents. */ +/* -------------------------------------------------------------------- */ + if( AIGReadBounds( pszCoverName, psInfo ) != CE_None ) + { + VSIFCloseL( psInfo->fpGrid ); + + CPLFree( psInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read the statistics. */ +/* -------------------------------------------------------------------- */ + if( AIGReadStatistics( pszCoverName, psInfo ) != CE_None ) + { + VSIFCloseL( psInfo->fpGrid ); + + CPLFree( psInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Compute the number of pixels and lines. */ +/* -------------------------------------------------------------------- */ + psInfo->nPixels = (int) + ((psInfo->dfURX - psInfo->dfLLX + 0.5 * psInfo->dfCellSizeX) + / psInfo->dfCellSizeX); + psInfo->nLines = (int) + ((psInfo->dfURY - psInfo->dfLLY + 0.5 * psInfo->dfCellSizeY) + / psInfo->dfCellSizeY); + + return( psInfo ); +} + +/************************************************************************/ +/* AIGReadTile() */ +/************************************************************************/ + +CPLErr AIGReadTile( AIGInfo_t * psInfo, int nBlockXOff, int nBlockYOff, + GInt32 *panData ) + +{ + int nBlockID; + CPLErr eErr; + + nBlockID = nBlockXOff + nBlockYOff * psInfo->nBlocksPerRow; + if( nBlockID < 0 || nBlockID >= psInfo->nBlocks ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + eErr = AIGReadBlock( psInfo->fpGrid, + psInfo->panBlockOffset[nBlockID], + psInfo->panBlockSize[nBlockID], + psInfo->nBlockXSize, psInfo->nBlockYSize, + panData, psInfo->nCellType ); + + if( eErr == CE_None && psInfo->nCellType == AIG_CELLTYPE_FLOAT ) + { + float *pafData = (float *) panData; + int i, nPixels = psInfo->nBlockXSize * psInfo->nBlockYSize; + + for( i = 0; i < nPixels; i++ ) + { + panData[i] = (int) pafData[i]; + } + } + + return( eErr ); +} + +/************************************************************************/ +/* AIGReadFloatTile() */ +/************************************************************************/ + +CPLErr AIGReadFloatTile( AIGInfo_t * psInfo, int nBlockXOff, int nBlockYOff, + float *pafData ) + +{ + int nBlockID; + CPLErr eErr; + + nBlockID = nBlockXOff + nBlockYOff * psInfo->nBlocksPerRow; + if( nBlockID < 0 || nBlockID >= psInfo->nBlocks ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + eErr = AIGReadBlock( psInfo->fpGrid, + psInfo->panBlockOffset[nBlockID], + psInfo->panBlockSize[nBlockID], + psInfo->nBlockXSize, psInfo->nBlockYSize, + (GInt32 *) pafData, psInfo->nCellType ); + + if( eErr == CE_None && psInfo->nCellType == AIG_CELLTYPE_INT ) + { + GUInt32 *panData = (GUInt32 *) pafData; + int i, nPixels = psInfo->nBlockXSize * psInfo->nBlockYSize; + + for( i = 0; i < nPixels; i++ ) + { + pafData[i] = (float) panData[i]; + } + } + + return( eErr ); +} + +/************************************************************************/ +/* AIGClose() */ +/************************************************************************/ + +void AIGClose( AIGInfo_t * psInfo ) + +{ + VSIFCloseL( psInfo->fpGrid ); + + CPLFree( psInfo->panBlockOffset ); + CPLFree( psInfo->panBlockSize ); + CPLFree( psInfo->pszCoverName ); + CPLFree( psInfo ); +} + +/************************************************************************/ +/* AIGLLOpen() */ +/* */ +/* Low level fopen() replacement that will try provided, and */ +/* upper cased versions of file names. */ +/************************************************************************/ + +FILE *AIGLLOpen( const char *pszFilename, const char *pszAccess ) + +{ + FILE *fp; + + fp = VSIFOpenL( pszFilename, pszAccess ); + if( fp == NULL ) + { + char *pszUCFilename = CPLStrdup(pszFilename); + int i; + + for( i = strlen(pszUCFilename)-1; + pszUCFilename[i] != '/' && pszUCFilename[i] != '\\'; + i-- ) + { + pszUCFilename[i] = (char) toupper(pszUCFilename[i]); + } + + fp = VSIFOpenL( pszUCFilename, pszAccess ); + + CPLFree( pszUCFilename ); + } + + return fp; +} + diff --git a/Utilities/GDAL/frmts/aigrid/aigrid.h b/Utilities/GDAL/frmts/aigrid/aigrid.h new file mode 100644 index 0000000000..21a98ad66e --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/aigrid.h @@ -0,0 +1,162 @@ +/****************************************************************************** + * $Id$ + * + * Project: Arc/Info Binary Grid Translator + * Purpose: Grid file access include file. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: aigrid.h,v $ + * Revision 1.13 2005/10/31 04:51:55 fwarmerdam + * upgraded to use large file API and GUInt32 for block offsets + * + * Revision 1.12 2002/11/11 18:29:03 warmerda + * added AIGLLOpen() to support upper case names too + * + * Revision 1.11 2002/11/05 03:19:08 warmerda + * avoid nodata remapping in gridlib, use GInt32 not GUInt for image data + * + * Revision 1.10 2002/10/31 03:09:11 warmerda + * added new CCITTRLE decompress func + * + * Revision 1.9 2002/02/21 15:38:32 warmerda + * fixed nodata value for floats + * + * Revision 1.8 2000/11/09 06:22:40 warmerda + * save cover name + * + * Revision 1.7 2000/07/18 13:58:58 warmerda + * no RTileType for float tiles + * + * Revision 1.6 2000/04/20 14:05:02 warmerda + * added more raw float magic codes + * + * Revision 1.5 2000/02/18 05:04:50 warmerda + * added bHasWarned + * + * Revision 1.4 1999/08/12 19:10:54 warmerda + * added ESRI_GRID_NO_DATA + * + * Revision 1.3 1999/04/21 16:51:30 warmerda + * fixed up floating point support + * + * Revision 1.2 1999/02/04 22:15:33 warmerda + * fleshed out implementation + * + * Revision 1.1 1999/02/03 14:12:56 warmerda + * New + * + */ + +#ifndef _AIGRID_H_INCLUDED +#define _AIGRID_H_INCLUDED + +#include "cpl_conv.h" + +CPL_C_START + +#define ESRI_GRID_NO_DATA -2147483647 +/*#define ESRI_GRID_FLOAT_NO_DATA -340282306073709652508363335590014353408.0 */ +#define ESRI_GRID_FLOAT_NO_DATA -340282346638528859811704183484516925440.0 + +/* ==================================================================== */ +/* Grid Instance */ +/* ==================================================================== */ +typedef struct { + /* Private information */ + + int nBlocks; + GUInt32 *panBlockOffset; + int *panBlockSize; + + FILE *fpGrid; /* the w001001.adf file */ + + int bHasWarned; + + /* public information */ + + char *pszCoverName; /* path of coverage directory */ + + int nCellType; + +#define AIG_CELLTYPE_INT 1 +#define AIG_CELLTYPE_FLOAT 2 + + int nBlockXSize; + int nBlockYSize; + + int nBlocksPerRow; + int nBlocksPerColumn; + + double dfLLX; + double dfLLY; + double dfURX; + double dfURY; + + double dfCellSizeX; + double dfCellSizeY; + + int nPixels; + int nLines; + + double dfMin; + double dfMax; + double dfMean; + double dfStdDev; + +} AIGInfo_t; + +/* ==================================================================== */ +/* Private APIs */ +/* ==================================================================== */ + +CPLErr AIGReadBlock( FILE * fp, GUInt32 nBlockOffset, int nBlockSize, + int nBlockXSize, int nBlockYSize, GInt32 * panData, + int nCellType ); + +CPLErr AIGReadHeader( const char *, AIGInfo_t * ); +CPLErr AIGReadBlockIndex( const char *, AIGInfo_t * ); +CPLErr AIGReadBounds( const char *, AIGInfo_t * ); +CPLErr AIGReadStatistics( const char *, AIGInfo_t * ); + +CPLErr DecompressCCITTRLETile( unsigned char *pabySrcData, int nSrcBytes, + unsigned char *pabyDstData, int nDstBytes, + int nBlockXSize, int nBlockYSize ); + +/* ==================================================================== */ +/* Public APIs */ +/* ==================================================================== */ + +AIGInfo_t *AIGOpen( const char *, const char * ); + +CPLErr AIGReadTile( AIGInfo_t *, int, int, GInt32 * ); +CPLErr AIGReadFloatTile( AIGInfo_t *, int, int, float * ); + +void AIGClose( AIGInfo_t * ); + +FILE *AIGLLOpen( const char *, const char * ); + +CPL_C_END + +#endif /* ndef _AIGRID_H_INCLUDED */ diff --git a/Utilities/GDAL/frmts/aigrid/aitest.c b/Utilities/GDAL/frmts/aigrid/aitest.c new file mode 100644 index 0000000000..1bdbc54268 --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/aitest.c @@ -0,0 +1,231 @@ +/****************************************************************************** + * $Id$ + * + * Project: Arc/Info Binary Grid Translator + * Purpose: Test mainline for examining AIGrid files. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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. + *****************************************************************************/ + +#include "aigrid.h" + +CPL_CVSID("$Id$"); + +/************************************************************************/ +/* DumpMagic() */ +/* */ +/* Dump the magic ``block type byte'' for each existing block. */ +/************************************************************************/ + +static void DumpMagic( AIGInfo_t * psInfo, int bVerbose ) + +{ + int i; + + for( i = 0; i < psInfo->nBlocks; i++ ) + { + GByte byMagic; + int bReport = bVerbose; + unsigned char abyBlockSize[2]; + const char *pszMessage = ""; + + if( psInfo->panBlockSize[i] == 0 ) + continue; + + VSIFSeek( psInfo->fpGrid, psInfo->panBlockOffset[i], SEEK_SET ); + VSIFRead( abyBlockSize, 2, 1, psInfo->fpGrid ); + + if( psInfo->nCellType == AIG_CELLTYPE_INT ) + { + VSIFRead( &byMagic, 1, 1, psInfo->fpGrid ); + + if( byMagic != 0 && byMagic != 0x43 && byMagic != 0x04 + && byMagic != 0x08 && byMagic != 0x10 && byMagic != 0xd7 + && byMagic != 0xdf && byMagic != 0xe0 && byMagic != 0xfc + && byMagic != 0xf8 && byMagic != 0xff && byMagic != 0x41 + && byMagic != 0x40 && byMagic != 0x42 && byMagic != 0xf0 + && byMagic != 0xcf && byMagic != 0x01 ) + { + pszMessage = "(unhandled magic number)"; + bReport = TRUE; + } + + if( byMagic == 0 && psInfo->panBlockSize[i] > 8 ) + { + pszMessage = "(wrong size for 0x00 block, should be 8 bytes)"; + bReport = TRUE; + } + + if( (abyBlockSize[0] * 256 + abyBlockSize[1])*2 != + psInfo->panBlockSize[i] ) + { + pszMessage = "(block size in data doesn't match index)"; + bReport = TRUE; + } + } + else + { + if( psInfo->panBlockSize[i] != + psInfo->nBlockXSize*psInfo->nBlockYSize*sizeof(float) ) + { + pszMessage = "(floating point block size is wrong)"; + bReport = TRUE; + } + } + + if( bReport ) + { + printf( " %02x %5d %5d @ %d %s\n", byMagic, i, + psInfo->panBlockSize[i], + psInfo->panBlockOffset[i], + pszMessage ); + } + } +} + + +/************************************************************************/ +/* main() */ +/************************************************************************/ + +int main( int argc, char ** argv ) + +{ + AIGInfo_t *psInfo; + GUInt32 *panRaster; + int i, j; + int bMagic = FALSE, bSupressMagic = FALSE; + +/* -------------------------------------------------------------------- */ +/* Process arguments. */ +/* -------------------------------------------------------------------- */ + while( argc > 1 && argv[1][0] == '-' ) + { + if( EQUAL(argv[1],"-magic") ) + bMagic = TRUE; + + else if( EQUAL(argv[1],"-nomagic") ) + bSupressMagic = TRUE; + + argc--; + argv++; + } + + if( argc < 2 ) { + printf( "Usage: aitest [-magic] coverage [block numbers...]\n" ); + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* Open dataset. */ +/* -------------------------------------------------------------------- */ + psInfo = AIGOpen( argv[1], "r" ); + if( psInfo == NULL ) + exit( 1 ); + +/* -------------------------------------------------------------------- */ +/* Dump general information */ +/* -------------------------------------------------------------------- */ + printf( "%d pixels x %d lines.\n", psInfo->nPixels, psInfo->nLines ); + printf( "Lower Left = (%f,%f) Upper Right = (%f,%f)\n", + psInfo->dfLLX, + psInfo->dfLLY, + psInfo->dfURX, + psInfo->dfURY ); + + if( psInfo->nCellType == AIG_CELLTYPE_INT ) + printf( "Integer coverage, %dx%d blocks.\n", + psInfo->nBlockXSize, psInfo->nBlockYSize ); + else + printf( "Floating point coverage, %dx%d blocks.\n", + psInfo->nBlockXSize, psInfo->nBlockYSize ); + + printf( "Stats - Min=%f, Max=%f, Mean=%f, StdDev=%f\n", + psInfo->dfMin, + psInfo->dfMax, + psInfo->dfMean, + psInfo->dfStdDev ); + +/* -------------------------------------------------------------------- */ +/* Do we want a dump of all the ``magic'' numbers for */ +/* instantated blocks? */ +/* -------------------------------------------------------------------- */ + if( !bSupressMagic ) + DumpMagic( psInfo, bMagic ); + +/* -------------------------------------------------------------------- */ +/* Read a block, and report it's contents. */ +/* -------------------------------------------------------------------- */ + panRaster = (GUInt32 *) + CPLMalloc(psInfo->nBlockXSize * psInfo->nBlockYSize * 4); + + while( argc > 2 && (atoi(argv[2]) > 0 || argv[2][0] == '0') ) + { + int nBlock = atoi(argv[2]); + CPLErr eErr; + + argv++; + argc--; + + eErr = AIGReadBlock( psInfo->fpGrid, + psInfo->panBlockOffset[nBlock], + psInfo->panBlockSize[nBlock], + psInfo->nBlockXSize, psInfo->nBlockYSize, + panRaster, psInfo->nCellType ); + + printf( "\nBlock %d:\n", nBlock ); + + if( eErr != CE_None ) + { + printf( " Error! Skipping block.\n" ); + continue; + } + + for( j = 0; j < psInfo->nBlockYSize; j++ ) + { + for( i = 0; i < psInfo->nBlockXSize; i++ ) + { + if( i > 18 ) + { + printf( "..." ); + break; + } + + if( panRaster[i+j*psInfo->nBlockXSize] == ESRI_GRID_NO_DATA ) + printf( "-*- " ); + else if( psInfo->nCellType == AIG_CELLTYPE_FLOAT ) + printf( "%f ", + ((float *) panRaster)[i+j*psInfo->nBlockXSize] ); + else + printf( "%3d ", panRaster[i+j*psInfo->nBlockXSize] ); + } + printf( "\n" ); + } + } + + CPLFree( panRaster ); + + AIGClose( psInfo ); + + exit( 0 ); +} diff --git a/Utilities/GDAL/frmts/aigrid/gridlib.c b/Utilities/GDAL/frmts/aigrid/gridlib.c new file mode 100644 index 0000000000..c01765cd66 --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/gridlib.c @@ -0,0 +1,1064 @@ +/****************************************************************************** + * $Id$ + * + * Project: Arc/Info Binary Grid Translator + * Purpose: Grid file reading code. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: gridlib.c,v $ + * Revision 1.25 2005/11/24 20:25:32 fwarmerdam + * Test for hdf.adf and w001001x.adf in ::Open() method, so we don't + * have to suppress error messages for AIGOpen(). Added error checking + * in the AIGReadBlockIndex() to recognise corrupted files. + * + * Revision 1.24 2005/10/31 04:51:55 fwarmerdam + * upgraded to use large file API and GUInt32 for block offsets + * + * Revision 1.23 2004/04/05 19:59:05 warmerda + * Fixed 0x01 support, wasn't including nMin. + * + * Revision 1.22 2004/03/26 20:38:58 warmerda + * Added support for 0x20 blocks as per bug 533 + * + * Revision 1.21 2002/11/11 18:29:03 warmerda + * added AIGLLOpen() to support upper case names too + * + * Revision 1.20 2002/11/05 03:19:08 warmerda + * avoid nodata remapping in gridlib, use GInt32 not GUInt for image data + * + * Revision 1.19 2002/10/31 03:50:21 warmerda + * fixed check in AIGProcessBlock + * + * Revision 1.18 2002/10/31 03:09:35 warmerda + * added support for FF blocks + * + * Revision 1.17 2002/10/28 21:34:55 warmerda + * made handling of corrupt files much more bulletproof + * + * Revision 1.16 2001/12/14 20:36:08 warmerda + * fixed interpretation of the sign of short RMin values + * + * Revision 1.15 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.14 2000/07/18 13:58:58 warmerda + * no RTileType for float tiles + * + * Revision 1.13 2000/04/20 14:05:03 warmerda + * added more raw float magic codes + * + * Revision 1.12 2000/03/15 02:00:52 warmerda + * Added type 0x01 (untested). + * + * Revision 1.11 2000/02/18 14:47:25 warmerda + * Avoid unused variable warnings. + * + * Revision 1.10 2000/02/18 14:41:00 warmerda + * added support for 0xcf + * + * Revision 1.9 2000/02/18 05:05:16 warmerda + * Do one time warning for unsupported tile types - don't blow assert + * + * Revision 1.8 2000/02/18 04:54:40 warmerda + * Added support for 0xf0 (16bit run length encoded). + * Fixed up handling of min value and no data values to be more generic. + * + * Revision 1.7 1999/08/13 03:28:12 warmerda + * treat 0x3f to 0x43 as raw 32bit data + * + * Revision 1.6 1999/08/12 19:11:17 warmerda + * corrected negative min handling, and no data values + * + * Revision 1.5 1999/08/09 16:30:44 warmerda + * Modified 0x00 integer blocks to be treated as a constant min valued block. + * + * Revision 1.4 1999/04/21 16:51:30 warmerda + * fixed up floating point support + * + * Revision 1.3 1999/03/02 21:10:28 warmerda + * added some floating point support + * + * Revision 1.2 1999/02/04 22:15:33 warmerda + * fleshed out implementation + * + * Revision 1.1 1999/02/03 14:12:56 warmerda + * New + * + */ + +#include "aigrid.h" + +CPL_CVSID("$Id$"); + +/************************************************************************/ +/* AIGProcessRaw32bitFloatBlock() */ +/* */ +/* Process a block using ``00'' (32 bit) raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRaw32BitFloatBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + float * pafData ) + +{ + int i; + + (void) nDataSize; + (void) nMin; + + CPLAssert( nDataSize >= nBlockXSize*nBlockYSize*4 ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + float fWork; + +#ifdef CPL_LSB + ((GByte *) &fWork)[3] = *(pabyCur++); + ((GByte *) &fWork)[2] = *(pabyCur++); + ((GByte *) &fWork)[1] = *(pabyCur++); + ((GByte *) &fWork)[0] = *(pabyCur++); +#else + ((GByte *) &fWork)[0] = *(pabyCur++); + ((GByte *) &fWork)[1] = *(pabyCur++); + ((GByte *) &fWork)[2] = *(pabyCur++); + ((GByte *) &fWork)[3] = *(pabyCur++); +#endif + + pafData[i] = fWork; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcessIntConstBlock() */ +/* */ +/* Process a block using ``00'' constant 32bit integer format. */ +/************************************************************************/ + +static +CPLErr AIGProcessIntConstBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ + int i; + + (void) pabyCur; + (void) nDataSize; + + CPLAssert( nDataSize <= 8 ); + +/* -------------------------------------------------------------------- */ +/* Apply constant min value. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + panData[i] = nMin; + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcess32bitRawBlock() */ +/* */ +/* Process a block using ``20'' (thirtytwo bit) raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRaw32BitBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ + int i; + + (void) nDataSize; + + CPLAssert( nDataSize >= nBlockXSize*nBlockYSize*2 ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + panData[i] = pabyCur[0] * 256 * 256 * 256 + + pabyCur[1] * 256 * 256 + + pabyCur[2] * 256 + + pabyCur[3] + nMin; + pabyCur += 4; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcess16bitRawBlock() */ +/* */ +/* Process a block using ``10'' (sixteen bit) raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRaw16BitBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ + int i; + + (void) nDataSize; + + CPLAssert( nDataSize >= nBlockXSize*nBlockYSize*2 ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + panData[i] = pabyCur[0] * 256 + pabyCur[1] + nMin; + pabyCur += 2; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcess4BitRawBlock() */ +/* */ +/* Process a block using ``08'' raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRaw4BitBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ + int i; + + (void) nDataSize; + CPLAssert( nDataSize >= (nBlockXSize*nBlockYSize+1)/2 ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + if( i % 2 == 0 ) + panData[i] = ((*(pabyCur) & 0xf0) >> 4) + nMin; + else + panData[i] = (*(pabyCur++) & 0xf) + nMin; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcess1BitRawBlock() */ +/* */ +/* Process a block using ``0x01'' raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRaw1BitBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ + int i; + + (void) nDataSize; + CPLAssert( nDataSize >= (nBlockXSize*nBlockYSize+7)/8 ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + if( pabyCur[i>>3] & (0x80 >> (i&0x7)) ) + panData[i] = 1 + nMin; + else + panData[i] = 0 + nMin; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcessRawBlock() */ +/* */ +/* Process a block using ``08'' raw format. */ +/************************************************************************/ + +static +CPLErr AIGProcessRawBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, GInt32 * panData ) + +{ + int i; + + (void) nDataSize; + + CPLAssert( nDataSize >= nBlockXSize*nBlockYSize ); + +/* -------------------------------------------------------------------- */ +/* Collect raw data. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + panData[i] = *(pabyCur++) + nMin; + } + + return( CE_None ); +} + +/************************************************************************/ +/* AIGProcessFFBlock() */ +/* */ +/* Process a type 0xFF (CCITT RLE) compressed block. */ +/************************************************************************/ + +static +CPLErr AIGProcessFFBlock( GByte *pabyCur, int nDataSize, int nMin, + int nBlockXSize, int nBlockYSize, + GInt32 * panData ) + +{ +/* -------------------------------------------------------------------- */ +/* Convert CCITT compress bitstream into 1bit raw data. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr; + int i, nDstBytes = (nBlockXSize * nBlockYSize + 7) / 8; + unsigned char *pabyIntermediate; + + pabyIntermediate = (unsigned char *) CPLMalloc(nDstBytes); + + eErr = DecompressCCITTRLETile( pabyCur, nDataSize, + pabyIntermediate, nDstBytes, + nBlockXSize, nBlockYSize ); + if( eErr != CE_None ) + return eErr; + +/* -------------------------------------------------------------------- */ +/* Convert the bit buffer into 32bit integers and account for */ +/* nMin. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + { + if( pabyIntermediate[i>>3] & (0x80 >> (i&0x7)) ) + panData[i] = nMin+1; + else + panData[i] = nMin; + } + + CPLFree( pabyIntermediate ); + + return( CE_None ); +} + + + +/************************************************************************/ +/* AIGProcessBlock() */ +/* */ +/* Process a block using ``D7'', ``E0'' or ``DF'' compression. */ +/************************************************************************/ + +static +CPLErr AIGProcessBlock( GByte *pabyCur, int nDataSize, int nMin, int nMagic, + int nBlockXSize, int nBlockYSize, GInt32 * panData ) + +{ + int nTotPixels, nPixels; + int i; + +/* ==================================================================== */ +/* Process runs till we are done. */ +/* ==================================================================== */ + nTotPixels = nBlockXSize * nBlockYSize; + nPixels = 0; + + while( nPixels < nTotPixels && nDataSize > 0 ) + { + int nMarker = *(pabyCur++); + + nDataSize--; + +/* -------------------------------------------------------------------- */ +/* Repeat data - four byte data block (0xE0) */ +/* -------------------------------------------------------------------- */ + if( nMagic == 0xE0 ) + { + GInt32 nValue; + + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + nValue = 0; + memcpy( &nValue, pabyCur, 4 ); + pabyCur += 4; + nDataSize -= 4; + + nValue = CPL_MSBWORD32( nValue ); + + nValue += nMin; + for( i = 0; i < nMarker; i++ ) + panData[nPixels++] = nValue; + } + +/* -------------------------------------------------------------------- */ +/* Repeat data - two byte data block (0xF0) */ +/* -------------------------------------------------------------------- */ + else if( nMagic == 0xF0 ) + { + GInt32 nValue; + + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + nValue = (pabyCur[0] * 256 + pabyCur[1]) + nMin; + pabyCur += 2; + + for( i = 0; i < nMarker; i++ ) + panData[nPixels++] = nValue; + } + +/* -------------------------------------------------------------------- */ +/* Repeat data - one byte data block (0xFC) */ +/* -------------------------------------------------------------------- */ + else if( nMagic == 0xFC || nMagic == 0xF8 ) + { + GInt32 nValue; + + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + nValue = *(pabyCur++) + nMin; + nDataSize--; + + for( i = 0; i < nMarker; i++ ) + panData[nPixels++] = nValue; + } + +/* -------------------------------------------------------------------- */ +/* Repeat data - no actual data, just assign minimum (0xDF) */ +/* -------------------------------------------------------------------- */ + else if( nMagic == 0xDF && nMarker < 128 ) + { + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + for( i = 0; i < nMarker; i++ ) + panData[nPixels++] = nMin; + } + +/* -------------------------------------------------------------------- */ +/* Literal data (0xD7): 8bit values. */ +/* -------------------------------------------------------------------- */ + else if( nMagic == 0xD7 && nMarker < 128 ) + { + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + while( nMarker > 0 && nDataSize > 0 ) + { + panData[nPixels++] = *(pabyCur++) + nMin; + nMarker--; + nDataSize--; + } + } + +/* -------------------------------------------------------------------- */ +/* Literal data (0xCF): 16 bit values. */ +/* -------------------------------------------------------------------- */ + else if( nMagic == 0xCF && nMarker < 128 ) + { + GInt32 nValue; + + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + while( nMarker > 0 && nDataSize > 0 ) + { + nValue = pabyCur[0] * 256 + pabyCur[1] + nMin; + panData[nPixels++] = nValue; + pabyCur += 2; + + nMarker--; + nDataSize -= 2; + } + } + +/* -------------------------------------------------------------------- */ +/* Nodata repeat */ +/* -------------------------------------------------------------------- */ + else if( nMarker > 128 ) + { + nMarker = 256 - nMarker; + + if( nMarker + nPixels > nTotPixels ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Run too long in AIGProcessBlock, needed %d values, got %d.", + nTotPixels - nPixels, nMarker ); + return CE_Failure; + } + + while( nMarker > 0 ) + { + panData[nPixels++] = ESRI_GRID_NO_DATA; + nMarker--; + } + } + + else + { + return CE_Failure; + } + + } + + if( nPixels < nTotPixels || nDataSize < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Ran out of data processing block with nMagic=%d.", + nMagic ); + return CE_Failure; + } + + return CE_None; +} + +/************************************************************************/ +/* AIGReadBlock() */ +/* */ +/* Read a single block of integer grid data. */ +/************************************************************************/ + +CPLErr AIGReadBlock( FILE * fp, GUInt32 nBlockOffset, int nBlockSize, + int nBlockXSize, int nBlockYSize, + GInt32 *panData, int nCellType ) + +{ + GByte *pabyRaw, *pabyCur; + CPLErr eErr; + int i, nMagic, nMinSize=0, nDataSize; + GInt32 nMin = 0; + +/* -------------------------------------------------------------------- */ +/* If the block has zero size it is all dummies. */ +/* -------------------------------------------------------------------- */ + if( nBlockSize == 0 ) + { + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + panData[i] = ESRI_GRID_NO_DATA; + + return( CE_None ); + } + +/* -------------------------------------------------------------------- */ +/* Read the block into memory. */ +/* -------------------------------------------------------------------- */ + pabyRaw = (GByte *) CPLMalloc(nBlockSize+2); + if( VSIFSeekL( fp, nBlockOffset, SEEK_SET ) != 0 + || VSIFReadL( pabyRaw, nBlockSize+2, 1, fp ) != 1 ) + { + memset( panData, 0, nBlockXSize*nBlockYSize*4 ); + CPLError( CE_Failure, CPLE_AppDefined, + "Read of %d bytes from offset %d for grid block failed.", + nBlockSize+2, nBlockOffset ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Verify the block size. */ +/* -------------------------------------------------------------------- */ + if( nBlockSize != (pabyRaw[0]*256 + pabyRaw[1])*2 ) + { + memset( panData, 0, nBlockXSize*nBlockYSize*4 ); + CPLError( CE_Failure, CPLE_AppDefined, + "Block is corrupt, block size was %d, but expected to be %d.", + (pabyRaw[0]*256 + pabyRaw[1])*2, nBlockSize ); + + return CE_Failure; + } + + nDataSize = nBlockSize; + +/* -------------------------------------------------------------------- */ +/* Handle float files directly. */ +/* -------------------------------------------------------------------- */ + if( nCellType == AIG_CELLTYPE_FLOAT ) + { + AIGProcessRaw32BitFloatBlock( pabyRaw + 2, nDataSize, 0, + nBlockXSize, nBlockYSize, + (float *) panData ); + CPLFree( pabyRaw ); + + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Collect minimum value. */ +/* -------------------------------------------------------------------- */ + pabyCur = pabyRaw + 2; + + nMinSize = pabyCur[1]; + pabyCur += 2; + + if( nMinSize > 4 ) + { + memset( panData, 0, nBlockXSize*nBlockYSize*4 ); + CPLError( CE_Failure, CPLE_AppDefined, + "Corrupt 'minsize' of %d in block header. Read aborted.", + nMinSize ); + return CE_Failure; + } + + if( nMinSize == 4 ) + { + memcpy( &nMin, pabyCur, 4 ); + nMin = CPL_MSBWORD32( nMin ); + pabyCur += 4; + } + else + { + nMin = 0; + for( i = 0; i < nMinSize; i++ ) + { + nMin = nMin * 256 + *pabyCur; + pabyCur++; + } + + if( pabyRaw[4] > 127 ) + { + if( nMinSize == 2 ) + nMin = nMin - 65536; + else if( nMinSize == 1 ) + nMin = nMin - 256; + else if( nMinSize == 3 ) + nMin = nMin - 256*256*256; + } + } + + nDataSize -= 2+nMinSize; + +/* -------------------------------------------------------------------- */ +/* Call an apppropriate handler depending on magic code. */ +/* -------------------------------------------------------------------- */ + nMagic = pabyRaw[2]; + + if( nMagic == 0x08 ) + { + AIGProcessRawBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else if( nMagic == 0x04 ) + { + AIGProcessRaw4BitBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else if( nMagic == 0x01 ) + { + AIGProcessRaw1BitBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else if( nMagic == 0x00 ) + { + AIGProcessIntConstBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, panData ); + } + else if( nMagic == 0x10 ) + { + AIGProcessRaw16BitBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else if( nMagic == 0x20 ) + { + AIGProcessRaw32BitBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else if( nMagic == 0xFF ) + { + AIGProcessFFBlock( pabyCur, nDataSize, nMin, + nBlockXSize, nBlockYSize, + panData ); + } + else + { + eErr = AIGProcessBlock( pabyCur, nDataSize, nMin, nMagic, + nBlockXSize, nBlockYSize, panData ); + + if( eErr == CE_Failure ) + { + static int bHasWarned = FALSE; + + for( i = 0; i < nBlockXSize * nBlockYSize; i++ ) + panData[i] = ESRI_GRID_NO_DATA; + + if( !bHasWarned ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unsupported Arc/Info Binary Grid tile of type 0x%X" + " encountered.\n" + "This and subsequent unsupported tile types set to" + " no data value.\n", + nMagic ); + bHasWarned = TRUE; + } + } + } + + CPLFree( pabyRaw ); + + return CE_None; +} + +/************************************************************************/ +/* AIGReadHeader() */ +/* */ +/* Read the hdr.adf file, and populate the given info structure */ +/* appropriately. */ +/************************************************************************/ + +CPLErr AIGReadHeader( const char * pszCoverName, AIGInfo_t * psInfo ) + +{ + char *pszHDRFilename; + FILE *fp; + GByte abyData[308]; + +/* -------------------------------------------------------------------- */ +/* Open the file hdr.adf file. */ +/* -------------------------------------------------------------------- */ + pszHDRFilename = (char *) CPLMalloc(strlen(pszCoverName)+30); + sprintf( pszHDRFilename, "%s/hdr.adf", pszCoverName ); + + fp = AIGLLOpen( pszHDRFilename, "rb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open grid header file:\n%s\n", pszHDRFilename ); + + CPLFree( pszHDRFilename ); + return( CE_Failure ); + } + + CPLFree( pszHDRFilename ); + +/* -------------------------------------------------------------------- */ +/* Read the whole file (we expect it to always be 308 bytes */ +/* long. */ +/* -------------------------------------------------------------------- */ + + VSIFReadL( abyData, 1, 308, fp ); + + VSIFCloseL( fp ); + +/* -------------------------------------------------------------------- */ +/* Read the block size information. */ +/* -------------------------------------------------------------------- */ + memcpy( &(psInfo->nCellType), abyData+16, 4 ); + memcpy( &(psInfo->nBlocksPerRow), abyData+288, 4 ); + memcpy( &(psInfo->nBlocksPerColumn), abyData+292, 4 ); + memcpy( &(psInfo->nBlockXSize), abyData+296, 4 ); + memcpy( &(psInfo->nBlockYSize), abyData+304, 4 ); + memcpy( &(psInfo->dfCellSizeX), abyData+256, 8 ); + memcpy( &(psInfo->dfCellSizeY), abyData+264, 8 ); + +#ifdef CPL_LSB + psInfo->nCellType = CPL_SWAP32( psInfo->nCellType ); + psInfo->nBlocksPerRow = CPL_SWAP32( psInfo->nBlocksPerRow ); + psInfo->nBlocksPerColumn = CPL_SWAP32( psInfo->nBlocksPerColumn ); + psInfo->nBlockXSize = CPL_SWAP32( psInfo->nBlockXSize ); + psInfo->nBlockYSize = CPL_SWAP32( psInfo->nBlockYSize ); + CPL_SWAPDOUBLE( &(psInfo->dfCellSizeX) ); + CPL_SWAPDOUBLE( &(psInfo->dfCellSizeY) ); +#endif + + return( CE_None ); +} + +/************************************************************************/ +/* AIGReadBlockIndex() */ +/* */ +/* Read the w001001x.adf file, and populate the given info */ +/* structure with the block offsets, and sizes. */ +/************************************************************************/ + +CPLErr AIGReadBlockIndex( const char * pszCoverName, AIGInfo_t * psInfo ) + +{ + char *pszHDRFilename; + FILE *fp; + int nLength, i; + GInt32 nValue; + GUInt32 *panIndex; + GByte abyHeader[8]; + +/* -------------------------------------------------------------------- */ +/* Open the file hdr.adf file. */ +/* -------------------------------------------------------------------- */ + pszHDRFilename = (char *) CPLMalloc(strlen(pszCoverName)+40); + sprintf( pszHDRFilename, "%s/w001001x.adf", pszCoverName ); + + fp = AIGLLOpen( pszHDRFilename, "rb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open grid block index file:\n%s\n", + pszHDRFilename ); + + CPLFree( pszHDRFilename ); + return( CE_Failure ); + } + + CPLFree( pszHDRFilename ); + +/* -------------------------------------------------------------------- */ +/* Verify the magic number. This is often corrupted by CR/LF */ +/* translation. */ +/* -------------------------------------------------------------------- */ + VSIFReadL( abyHeader, 1, 8, fp ); + if( abyHeader[3] == 0x0D && abyHeader[4] == 0x0A ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "w001001x.adf file header has been corrupted by unix to dos text conversion." ); + VSIFCloseL( fp ); + return CE_Failure; + } + + if( abyHeader[0] != 0x00 + || abyHeader[1] != 0x00 + || abyHeader[2] != 0x27 + || abyHeader[3] != 0x0A + || abyHeader[4] != 0xFF + || abyHeader[5] != 0xFF ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "w001001x.adf file header magic number is corrupt." ); + VSIFCloseL( fp ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Get the file length (in 2 byte shorts) */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( fp, 24, SEEK_SET ); + VSIFReadL( &nValue, 1, 4, fp ); + + nLength = CPL_MSBWORD32(nValue) * 2; + +/* -------------------------------------------------------------------- */ +/* Allocate buffer, and read the file (from beyond the header) */ +/* into the buffer. */ +/* -------------------------------------------------------------------- */ + psInfo->nBlocks = (nLength-100) / 8; + panIndex = (GUInt32 *) CPLMalloc(psInfo->nBlocks * 8); + VSIFSeekL( fp, 100, SEEK_SET ); + VSIFReadL( panIndex, 8, psInfo->nBlocks, fp ); + + VSIFCloseL( fp ); + +/* -------------------------------------------------------------------- */ +/* Allocate AIGInfo block info arrays. */ +/* -------------------------------------------------------------------- */ + psInfo->panBlockOffset = (GUInt32 *) CPLMalloc(4 * psInfo->nBlocks); + psInfo->panBlockSize = (int *) CPLMalloc(4 * psInfo->nBlocks); + +/* -------------------------------------------------------------------- */ +/* Populate the block information. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psInfo->nBlocks; i++ ) + { + psInfo->panBlockOffset[i] = CPL_MSBWORD32(panIndex[i*2]) * 2; + psInfo->panBlockSize[i] = CPL_MSBWORD32(panIndex[i*2+1]) * 2; + } + + CPLFree( panIndex ); + + return( CE_None ); +} + +/************************************************************************/ +/* AIGReadBounds() */ +/* */ +/* Read the dblbnd.adf file for the georeferenced bounds. */ +/************************************************************************/ + +CPLErr AIGReadBounds( const char * pszCoverName, AIGInfo_t * psInfo ) + +{ + char *pszHDRFilename; + FILE *fp; + double adfBound[4]; + +/* -------------------------------------------------------------------- */ +/* Open the file dblbnd.adf file. */ +/* -------------------------------------------------------------------- */ + pszHDRFilename = (char *) CPLMalloc(strlen(pszCoverName)+40); + sprintf( pszHDRFilename, "%s/dblbnd.adf", pszCoverName ); + + fp = AIGLLOpen( pszHDRFilename, "rb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open grid bounds file:\n%s\n", + pszHDRFilename ); + + CPLFree( pszHDRFilename ); + return( CE_Failure ); + } + + CPLFree( pszHDRFilename ); + +/* -------------------------------------------------------------------- */ +/* Get the contents - four doubles. */ +/* -------------------------------------------------------------------- */ + VSIFReadL( adfBound, 1, 32, fp ); + + VSIFCloseL( fp ); + +#ifdef CPL_LSB + CPL_SWAPDOUBLE(adfBound+0); + CPL_SWAPDOUBLE(adfBound+1); + CPL_SWAPDOUBLE(adfBound+2); + CPL_SWAPDOUBLE(adfBound+3); +#endif + + psInfo->dfLLX = adfBound[0]; + psInfo->dfLLY = adfBound[1]; + psInfo->dfURX = adfBound[2]; + psInfo->dfURY = adfBound[3]; + + return( CE_None ); +} + +/************************************************************************/ +/* AIGReadStatistics() */ +/* */ +/* Read the sta.adf file for the layer statistics. */ +/************************************************************************/ + +CPLErr AIGReadStatistics( const char * pszCoverName, AIGInfo_t * psInfo ) + +{ + char *pszHDRFilename; + FILE *fp; + double adfStats[4]; + + psInfo->dfMin = 0.0; + psInfo->dfMax = 0.0; + psInfo->dfMean = 0.0; + psInfo->dfStdDev = 0.0; + +/* -------------------------------------------------------------------- */ +/* Open the file sta.adf file. */ +/* -------------------------------------------------------------------- */ + pszHDRFilename = (char *) CPLMalloc(strlen(pszCoverName)+40); + sprintf( pszHDRFilename, "%s/sta.adf", pszCoverName ); + + fp = AIGLLOpen( pszHDRFilename, "rb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open grid statistics file:\n%s\n", + pszHDRFilename ); + + CPLFree( pszHDRFilename ); + return( CE_Failure ); + } + + CPLFree( pszHDRFilename ); + +/* -------------------------------------------------------------------- */ +/* Get the contents - four doubles. */ +/* -------------------------------------------------------------------- */ + VSIFReadL( adfStats, 1, 32, fp ); + + VSIFCloseL( fp ); + +#ifdef CPL_LSB + CPL_SWAPDOUBLE(adfStats+0); + CPL_SWAPDOUBLE(adfStats+1); + CPL_SWAPDOUBLE(adfStats+2); + CPL_SWAPDOUBLE(adfStats+3); +#endif + + psInfo->dfMin = adfStats[0]; + psInfo->dfMax = adfStats[1]; + psInfo->dfMean = adfStats[2]; + psInfo->dfStdDev = adfStats[3]; + + return( CE_None ); +} + + + + + diff --git a/Utilities/GDAL/frmts/aigrid/makefile.vc b/Utilities/GDAL/frmts/aigrid/makefile.vc new file mode 100644 index 0000000000..26c5c7fb4b --- /dev/null +++ b/Utilities/GDAL/frmts/aigrid/makefile.vc @@ -0,0 +1,19 @@ + +OBJ = aigdataset.obj aigopen.obj gridlib.obj aigccitt.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +all: $(OBJ) aitest.exe + +aitest.exe: $(OBJ) aitest.c + $(CC) $(CFLAGS) aitest.c aigopen.obj gridlib.obj \ + $(GDAL_ROOT)/port/cpl.lib + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/ceos/GNUmakefile b/Utilities/GDAL/frmts/ceos/GNUmakefile new file mode 100644 index 0000000000..6e551d26e8 --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/GNUmakefile @@ -0,0 +1,17 @@ + + +include ../../GDALmake.opt + +OBJ = ceosopen.o ceosdataset.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + +ceostest: ceostest.o ceosopen.o + $(CXX) ceostest.o ceosopen.o ../../port/*.o $(LIBS) -o ceostest + +install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/ceos/ceosdataset.cpp b/Utilities/GDAL/frmts/ceos/ceosdataset.cpp new file mode 100644 index 0000000000..ff854cef85 --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/ceosdataset.cpp @@ -0,0 +1,264 @@ +/****************************************************************************** + * $Id: ceosdataset.cpp,v 1.11 2006/04/04 00:34:39 fwarmerdam Exp $ + * + * Project: CEOS Translator + * Purpose: GDALDataset driver for CEOS translator. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: ceosdataset.cpp,v $ + * Revision 1.11 2006/04/04 00:34:39 fwarmerdam + * updated contact info + * + * Revision 1.10 2005/05/05 14:01:36 fwarmerdam + * PAM Enable + * + * Revision 1.9 2002/09/04 06:50:36 warmerda + * avoid static driver pointers + * + * Revision 1.8 2002/06/12 21:12:24 warmerda + * update to metadata based driver info + * + * Revision 1.7 2001/11/11 23:50:59 warmerda + * added required class keyword to friend declarations + * + * Revision 1.6 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.5 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.4 2000/06/20 17:35:58 warmerda + * added overview support + * + * Revision 1.3 2000/02/28 16:32:20 warmerda + * use SetBand method + * + * Revision 1.2 1999/05/17 01:52:55 warmerda + * Removed unused variable. + * + * Revision 1.1 1999/05/05 17:32:38 warmerda + * New + * + */ + +#include "ceosopen.h" +#include "gdal_pam.h" + +CPL_CVSID("$Id: ceosdataset.cpp,v 1.11 2006/04/04 00:34:39 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_CEOS(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* CEOSDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class CEOSRasterBand; + +class CEOSDataset : public GDALPamDataset +{ + friend class CEOSRasterBand; + + CEOSImage *psCEOS; + + public: + CEOSDataset(); + ~CEOSDataset(); + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* CEOSRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class CEOSRasterBand : public GDALPamRasterBand +{ + friend class CEOSDataset; + + public: + + CEOSRasterBand( CEOSDataset *, int ); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + + +/************************************************************************/ +/* CEOSRasterBand() */ +/************************************************************************/ + +CEOSRasterBand::CEOSRasterBand( CEOSDataset *poDS, int nBand ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + eDataType = GDT_Byte; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr CEOSRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + CEOSDataset *poCEOS_DS = (CEOSDataset *) poDS; + + CPLAssert( nBlockXOff == 0 ); + + return( CEOSReadScanline(poCEOS_DS->psCEOS, nBand, nBlockYOff+1, pImage) ); +} + +/************************************************************************/ +/* ==================================================================== */ +/* CEOSDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* CEOSDataset() */ +/************************************************************************/ + +CEOSDataset::CEOSDataset() + +{ + psCEOS = NULL; +} + +/************************************************************************/ +/* ~CEOSDataset() */ +/************************************************************************/ + +CEOSDataset::~CEOSDataset() + +{ + FlushCache(); + if( psCEOS ) + CEOSClose( psCEOS ); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *CEOSDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + CEOSImage *psCEOS; + int i; + +/* -------------------------------------------------------------------- */ +/* Before trying CEOSOpen() we first verify that the first */ +/* record is in fact a CEOS file descriptor record. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 100 ) + return NULL; + + if( poOpenInfo->pabyHeader[4] != 0x3f + || poOpenInfo->pabyHeader[5] != 0xc0 + || poOpenInfo->pabyHeader[6] != 0x12 + || poOpenInfo->pabyHeader[7] != 0x12 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + psCEOS = CEOSOpen( poOpenInfo->pszFilename, "rb" ); + + if( psCEOS == NULL ) + return( NULL ); + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + CEOSDataset *poDS; + + poDS = new CEOSDataset(); + + poDS->psCEOS = psCEOS; + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = psCEOS->nPixels; + poDS->nRasterYSize = psCEOS->nLines; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = psCEOS->nBands;; + + for( i = 0; i < poDS->nBands; i++ ) + poDS->SetBand( i+1, new CEOSRasterBand( poDS, i+1 ) ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_GTiff() */ +/************************************************************************/ + +void GDALRegister_CEOS() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "CEOS" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "CEOS" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "CEOS Image" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#CEOS" ); + + poDriver->pfnOpen = CEOSDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/ceos/ceosopen.c b/Utilities/GDAL/frmts/ceos/ceosopen.c new file mode 100644 index 0000000000..32ce5be80b --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/ceosopen.c @@ -0,0 +1,355 @@ +/****************************************************************************** + * $Id$ + * + * Project: CEOS Translator + * Purpose: Implementation of non-GDAL dependent CEOS support. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: ceosopen.c,v $ + * Revision 1.5 2006/04/04 00:34:40 fwarmerdam + * updated contact info + * + * Revision 1.4 2003/07/08 15:34:04 warmerda + * avoid warnings + * + * Revision 1.3 2001/10/29 17:48:34 warmerda + * Change sequence number check to a warning since the sequence numbers are + * apparently screwy in some otherwise interesting ESA/CEOS Landsat 7 files. + * + * Revision 1.2 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.1 1999/05/05 17:32:38 warmerda + * New + * + */ + +#include "ceosopen.h" + +CPL_CVSID("$Id$"); + +/************************************************************************/ +/* CEOSScanInt() */ +/* */ +/* Read up to nMaxChars from the passed string, and interpret */ +/* as an integer. */ +/************************************************************************/ + +static long CEOSScanInt( const char * pszString, int nMaxChars ) + +{ + char szWorking[33]; + int i; + + if( nMaxChars > 32 || nMaxChars == 0 ) + nMaxChars = 32; + + for( i = 0; i < nMaxChars && pszString[i] != '\0'; i++ ) + szWorking[i] = pszString[i]; + + szWorking[i] = '\0'; + + return( atoi(szWorking) ); +} + +/************************************************************************/ +/* CEOSReadRecord() */ +/* */ +/* Read a single CEOS record at the current point in the file. */ +/* Return NULL after reporting an error if it fails, otherwise */ +/* return the record. */ +/************************************************************************/ + +CEOSRecord * CEOSReadRecord( FILE * fp ) + +{ + GByte abyHeader[12]; + CEOSRecord *psRecord; + +/* -------------------------------------------------------------------- */ +/* Read the standard CEOS header. */ +/* -------------------------------------------------------------------- */ + if( VSIFEof( fp ) ) + return NULL; + + if( VSIFRead( abyHeader, 1, 12, fp ) != 12 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Ran out of data reading CEOS record." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Extract this information. */ +/* -------------------------------------------------------------------- */ + psRecord = (CEOSRecord *) CPLMalloc(sizeof(CEOSRecord)); + psRecord->nRecordNum = abyHeader[0] * 256 * 256 * 256 + + abyHeader[1] * 256 * 256 + + abyHeader[2] * 256 + + abyHeader[3]; + + psRecord->nRecordType = abyHeader[4] * 256 * 256 * 256 + + abyHeader[5] * 256 * 256 + + abyHeader[6] * 256 + + abyHeader[7]; + + psRecord->nLength = abyHeader[8] * 256 * 256 * 256 + + abyHeader[9] * 256 * 256 + + abyHeader[10] * 256 + + abyHeader[11]; + +/* -------------------------------------------------------------------- */ +/* Does it look reasonable? We assume there can't be too many */ +/* records and that the length must be between 12 and 200000. */ +/* -------------------------------------------------------------------- */ + if( psRecord->nRecordNum < 0 || psRecord->nRecordNum > 200000 + || psRecord->nLength < 12 || psRecord->nLength > 200000 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "CEOS record leader appears to be corrupt.\n" + "Record Number = %d, Record Length = %d\n", + psRecord->nRecordNum, psRecord->nLength ); + CPLFree( psRecord ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read the remainder of the record into a buffer. Ensure that */ +/* the first 12 bytes gets moved into this buffer as well. */ +/* -------------------------------------------------------------------- */ + psRecord->pachData = (char *) VSIMalloc(psRecord->nLength ); + if( psRecord->pachData == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Out of memory allocated %d bytes for CEOS record data.\n" + "Are you sure you aren't leaking CEOSRecords?\n", + psRecord->nLength ); + return NULL; + } + + memcpy( psRecord->pachData, abyHeader, 12 ); + + if( (int)VSIFRead( psRecord->pachData + 12, 1, psRecord->nLength-12, fp ) + != psRecord->nLength - 12 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Short read on CEOS record data.\n" ); + CPLFree( psRecord ); + return NULL; + } + + return psRecord; +} + +/************************************************************************/ +/* CEOSDestroyRecord() */ +/* */ +/* Free a record. */ +/************************************************************************/ + +void CEOSDestroyRecord( CEOSRecord * psRecord ) + +{ + CPLFree( psRecord->pachData ); + CPLFree( psRecord ); +} + +/************************************************************************/ +/* CEOSOpen() */ +/************************************************************************/ + +/** + * Open a CEOS transfer. + * + * @param Filename The name of the CEOS imagery file (ie. imag_01.dat). + * @param Access An fopen() style access string. Should be either "rb" for + * read-only access, or "r+b" for read, and update access. + * + * @return A CEOSImage pointer as a handle to the image. The CEOSImage also + * has various information about the image available. A NULL is returned + * if an error occurs. + */ + +CEOSImage * CEOSOpen( const char * pszFilename, const char * pszAccess ) + +{ + FILE *fp; + CEOSRecord *psRecord; + CEOSImage *psImage; + int nSeqNum, i; + +/* -------------------------------------------------------------------- */ +/* Try to open the imagery file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpen( pszFilename, pszAccess ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open CEOS file `%s' with access `%s'.\n", + pszFilename, pszAccess ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to read the header record. */ +/* -------------------------------------------------------------------- */ + psRecord = CEOSReadRecord( fp ); + if( psRecord == NULL ) + return NULL; + + if( psRecord->nRecordType != CRT_IMAGE_FDR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Got a %X type record, instead of the expected\n" + "file descriptor record on file %s.\n", + psRecord->nRecordType, pszFilename ); + + CEOSDestroyRecord( psRecord ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* The sequence number should be 2 indicating this is the */ +/* imagery file. */ +/* -------------------------------------------------------------------- */ + nSeqNum = CEOSScanInt( psRecord->pachData + 44, 4 ); + if( nSeqNum != 2 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Got a %d file sequence number, instead of the expected\n" + "2 indicating imagery on file %s.\n" + "Continuing to access anyways.\n", + nSeqNum, pszFilename ); + } + +/* -------------------------------------------------------------------- */ +/* Create a CEOSImage structure, and initialize it. */ +/* -------------------------------------------------------------------- */ + psImage = (CEOSImage *) CPLMalloc(sizeof(CEOSImage)); + psImage->fpImage = fp; + + psImage->nPixels = psImage->nLines = psImage->nBands = 0; + +/* -------------------------------------------------------------------- */ +/* Extract various information. */ +/* -------------------------------------------------------------------- */ + psImage->nImageRecCount = CEOSScanInt( psRecord->pachData+180, 6 ); + psImage->nImageRecLength = CEOSScanInt( psRecord->pachData+186, 6 ); + psImage->nBitsPerPixel = CEOSScanInt( psRecord->pachData+216, 4 ); + psImage->nBands = CEOSScanInt( psRecord->pachData+232, 4 ); + psImage->nLines = CEOSScanInt( psRecord->pachData+236, 8 ); + psImage->nPixels = CEOSScanInt( psRecord->pachData+248, 8 ); + + psImage->nPrefixBytes = CEOSScanInt( psRecord->pachData+276, 4 ); + psImage->nSuffixBytes = CEOSScanInt( psRecord->pachData+288, 4 ); + +/* -------------------------------------------------------------------- */ +/* Try to establish the layout of the imagery data. */ +/* -------------------------------------------------------------------- */ + psImage->nLineOffset = psImage->nBands * psImage->nImageRecLength; + + psImage->panDataStart = (int *) CPLMalloc(sizeof(int) * psImage->nBands); + + for( i = 0; i < psImage->nBands; i++ ) + { + psImage->panDataStart[i] = + psRecord->nLength + i * psImage->nImageRecLength + + 12 + psImage->nPrefixBytes; + } + + return psImage; +} + +/************************************************************************/ +/* CEOSReadScanline() */ +/************************************************************************/ + +/** + * Read a scanline of image. + * + * @param psCEOS The CEOS dataset handle returned by CEOSOpen(). + * @param nBand The band number (ie. 1, 2, 3). + * @param nScanline The scanline requested, one based. + * @param pData The data buffer to read into. Must be at least nPixels * + * nBitesPerPixel bits long. + * + * @return CPLErr Returns error indicator or CE_None if the read succeeds. + */ + +CPLErr CEOSReadScanline( CEOSImage * psCEOS, int nBand, int nScanline, + void * pData ) + +{ + int nOffset, nBytes; + + /* + * As a short cut, I currently just seek to the data, and read it + * raw, rather than trying to read ceos records properly. + */ + + nOffset = psCEOS->panDataStart[nBand-1] + + (nScanline-1) * psCEOS->nLineOffset; + + if( VSIFSeek( psCEOS->fpImage, nOffset, SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Seek to %d for scanline %d failed.\n", + nOffset, nScanline ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Read the data. */ +/* -------------------------------------------------------------------- */ + nBytes = psCEOS->nPixels * psCEOS->nBitsPerPixel / 8; + if( (int) VSIFRead( pData, 1, nBytes, psCEOS->fpImage ) != nBytes ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Read of %d bytes for scanline %d failed.\n", + nBytes, nScanline ); + return CE_Failure; + } + + return CE_None; +} + +/************************************************************************/ +/* CEOSClose() */ +/************************************************************************/ + +/** + * Close a CEOS transfer. Any open files are closed, and memory deallocated. + * + * @param psCEOS The CEOSImage handle from CEOSOpen to be closed. + */ + +void CEOSClose( CEOSImage * psCEOS ) + +{ + VSIFClose( psCEOS->fpImage ); + CPLFree( psCEOS ); +} + diff --git a/Utilities/GDAL/frmts/ceos/ceosopen.h b/Utilities/GDAL/frmts/ceos/ceosopen.h new file mode 100644 index 0000000000..3cbb833a38 --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/ceosopen.h @@ -0,0 +1,115 @@ +/****************************************************************************** + * $Id$ + * + * Project: CEOS Translator + * Purpose: Public (C callable) interface for CEOS and related formats such + * as Spot CAP. This stuff can be used independently of GDAL. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: ceosopen.h,v $ + * Revision 1.2 2006/04/04 00:34:40 fwarmerdam + * updated contact info + * + * Revision 1.1 1999/05/05 17:32:38 warmerda + * New + * + */ + +#ifndef _CEOSOPEN_H_INCLUDED +#define _CEOSOPEN_H_INCLUDED + +/* -------------------------------------------------------------------- */ +/* Include standard portability stuff. */ +/* -------------------------------------------------------------------- */ +#include "cpl_conv.h" +#include "cpl_string.h" + +/* -------------------------------------------------------------------- */ +/* Base ``class'' for ceos records. */ +/* -------------------------------------------------------------------- */ + +CPL_C_START + +typedef struct { + int nRecordNum; + GUInt32 nRecordType; + int nLength; + + char *pachData; +}CEOSRecord; + +/* well known record types */ +#define CRT_IMAGE_FDR 0x3FC01212 +#define CRT_IMAGE_DATA 0xEDED1212 + + +/* -------------------------------------------------------------------- */ +/* Main CEOS info structure. */ +/* -------------------------------------------------------------------- */ + +typedef struct { + + /* public information */ + int nPixels; + int nLines; + int nBands; + + int nBitsPerPixel; + + /* private information */ + FILE *fpImage; + + int nImageRecCount; + int nImageRecLength; + + int nPrefixBytes; + int nSuffixBytes; + + int *panDataStart; + int nLineOffset; + +} CEOSImage; + +/* -------------------------------------------------------------------- */ +/* External Prototypes */ +/* -------------------------------------------------------------------- */ + +CEOSImage CPL_DLL *CEOSOpen( const char *, const char * ); +void CPL_DLL CEOSClose( CEOSImage * ); +CPLErr CPL_DLL CEOSReadScanline( CEOSImage *psImage, int nBand, + int nScanline, void * pData ); + +/* -------------------------------------------------------------------- */ +/* Internal prototypes. */ +/* -------------------------------------------------------------------- */ +CEOSRecord CPL_DLL *CEOSReadRecord( FILE * ); +void CPL_DLL CEOSDestroyRecord( CEOSRecord * ); + +CPL_C_END + +#endif /* ndef _CEOSOPEN_H_INCLUDED */ + + + diff --git a/Utilities/GDAL/frmts/ceos/ceostest.c b/Utilities/GDAL/frmts/ceos/ceostest.c new file mode 100644 index 0000000000..2a88a143f2 --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/ceostest.c @@ -0,0 +1,84 @@ +/****************************************************************************** + * $Id$ + * + * Project: CEOS Translator + * Purpose: Test mainline. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: ceostest.c,v $ + * Revision 1.4 2006/04/04 00:34:40 fwarmerdam + * updated contact info + * + * Revision 1.3 2001/11/07 14:11:25 warmerda + * changed to just dump records + * + * Revision 1.2 2001/10/19 15:36:55 warmerda + * added support for filename on commandline + * + * Revision 1.1 1999/05/05 17:32:38 warmerda + * New + * + */ + +#include "ceosopen.h" + +/************************************************************************/ +/* main() */ +/************************************************************************/ + +int main( int nArgc, char ** papszArgv ) + +{ + const char *pszFilename; + FILE *fp; + CEOSRecord *psRecord; + int nPosition = 0; + + if( nArgc > 1 ) + pszFilename = papszArgv[1]; + else + pszFilename = "imag_01.dat"; + + fp = VSIFOpen( pszFilename, "rb" ); + if( fp == NULL ) + { + fprintf( stderr, "Can't open %s at all.\n", pszFilename ); + exit( 1 ); + } + + while( !VSIFEof(fp) + && (psRecord = CEOSReadRecord( fp )) != NULL ) + { + printf( "%9d:%4d:%8x:%d\n", + nPosition, psRecord->nRecordNum, + psRecord->nRecordType, psRecord->nLength ); + CEOSDestroyRecord( psRecord ); + + nPosition = (int) VSIFTell( fp ); + } + VSIFClose( fp ); + + exit( 0 ); +} diff --git a/Utilities/GDAL/frmts/ceos/makefile.vc b/Utilities/GDAL/frmts/ceos/makefile.vc new file mode 100644 index 0000000000..263b3851fe --- /dev/null +++ b/Utilities/GDAL/frmts/ceos/makefile.vc @@ -0,0 +1,13 @@ + +OBJ = ceosopen.obj ceosdataset.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/dted/GNUmakefile b/Utilities/GDAL/frmts/dted/GNUmakefile new file mode 100644 index 0000000000..5637eb798b --- /dev/null +++ b/Utilities/GDAL/frmts/dted/GNUmakefile @@ -0,0 +1,18 @@ + + +include ../../GDALmake.opt + +OBJ = dted_api.o dteddataset.o dted_create.o dted_ptstream.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o + +install-obj: $(O_OBJ) + +dted_test: dted_test.o $(OBJ) + $(CXX) -o dted_test dted_test.o dted_api.o dted_create.o dted_ptstream.o \ + -lgdal -lm diff --git a/Utilities/GDAL/frmts/dted/dted_api.c b/Utilities/GDAL/frmts/dted/dted_api.c new file mode 100644 index 0000000000..29d27fb6ea --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dted_api.c @@ -0,0 +1,617 @@ +/****************************************************************************** + * $Id$ + * + * Project: DTED Translator + * Purpose: Implementation of DTED/CDED access functions. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: dted_api.c,v $ + * Revision 1.16 2006/04/04 01:00:44 fwarmerdam + * updated contact info + * + * Revision 1.15 2004/01/29 23:35:22 gwalter + * Add a few more metadata fields, make sure that + * nodata value is recognized. + * + * Revision 1.14 2003/10/15 15:51:53 warmerda + * Fixed C++ style comments. + * + * Revision 1.13 2003/08/04 18:23:07 warmerda + * added warning when twos complement hack applied + * + * Revision 1.12 2003/05/30 16:17:21 warmerda + * fix warnings with casting and unused parameters + * + * Revision 1.11 2003/02/26 15:30:41 warmerda + * Modified reading code to treat any large negative values as if negative + * values are being stored in twos complement form, as per + * http://bugzilla.remotesensing.org/show_bug.cgi?id=286. + * + * Revision 1.10 2002/03/05 14:26:01 warmerda + * expanded tabs + * + * Revision 1.9 2002/02/15 18:26:29 warmerda + * fixed error code + * + * Revision 1.8 2002/01/28 18:17:33 warmerda + * fixed setting of nUHLOffset + * + * Revision 1.7 2002/01/26 05:51:40 warmerda + * added metadata read/write support + * + * Revision 1.6 2001/11/13 15:43:41 warmerda + * preliminary dted creation working + * + * Revision 1.5 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.4 2000/07/07 14:20:57 warmerda + * fixed AVOID_CPL support + * + * Revision 1.3 2000/01/24 13:58:25 warmerda + * support rb access + * + * Revision 1.2 2000/01/12 19:25:57 warmerda + * Dale Lutz provided fixes to avoid calling DTEDGetField() more than + * onces within an expression, and to ensure values evaluated with + * atoi() don't have leading zeros to avoid treatment as octal. + * + * Revision 1.1 1999/12/07 18:01:28 warmerda + * New + */ + +#include "dted_api.h" + +CPL_CVSID("$Id$"); + +/************************************************************************/ +/* DTEDGetField() */ +/* */ +/* Extract a field as a zero terminated string. Address is */ +/* deliberately 1 based so the getfield arguments will be the */ +/* same as the numbers in the file format specification. */ +/************************************************************************/ + +static +const char *DTEDGetField( const char *pachRecord, int nStart, int nSize ) + +{ + static char szResult[81]; + + CPLAssert( nSize < sizeof(szResult) ); + memcpy( szResult, pachRecord + nStart - 1, nSize ); + szResult[nSize] = '\0'; + + return szResult; +} + +/************************************************************************/ +/* StripLeadingZeros() */ +/* */ +/* Return a pointer to the first non-zero character in BUF. */ +/* BUF must be null terminated. */ +/* If buff is all zeros, then it will point to the last non-zero */ +/************************************************************************/ + +static const char* stripLeadingZeros(const char* buf) +{ + const char* ptr = buf; + + /* Go until we run out of characters or hit something non-zero */ + + while( *ptr == '0' && *(ptr+1) != '\0' ) + { + ptr++; + } + + return ptr; +} + +/************************************************************************/ +/* DTEDOpen() */ +/************************************************************************/ + +DTEDInfo * DTEDOpen( const char * pszFilename, + const char * pszAccess, + int bTestOpen ) + +{ + FILE *fp; + char achRecord[DTED_UHL_SIZE]; + DTEDInfo *psDInfo = NULL; + double dfLLOriginX, dfLLOriginY; + int deg = 0; + int min = 0; + int sec = 0; + +/* -------------------------------------------------------------------- */ +/* Open the physical file. */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszAccess,"r") || EQUAL(pszAccess,"rb") ) + pszAccess = "rb"; + else + pszAccess = "r+b"; + + fp = VSIFOpen( pszFilename, pszAccess ); + + if( fp == NULL ) + { +#ifndef AVOID_CPL + if( !bTestOpen ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to open file %s.", + pszFilename ); + } +#endif + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read, trying to find the UHL record. Skip VOL or HDR */ +/* records if they are encountered. */ +/* -------------------------------------------------------------------- */ + do + { + if( VSIFRead( achRecord, 1, DTED_UHL_SIZE, fp ) != DTED_UHL_SIZE ) + { +#ifndef AVOID_CPL + if( !bTestOpen ) + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to read header, %s is not DTED.", + pszFilename ); +#endif + VSIFClose( fp ); + return NULL; + } + + } while( EQUALN(achRecord,"VOL",3) || EQUALN(achRecord,"HDR",3) ); + + if( !EQUALN(achRecord,"UHL",3) ) + { +#ifndef AVOID_CPL + if( !bTestOpen ) + CPLError( CE_Failure, CPLE_OpenFailed, + "No UHL record. %s is not a DTED file.", + pszFilename ); +#endif + + VSIFClose( fp ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create and initialize the DTEDInfo structure. */ +/* -------------------------------------------------------------------- */ + psDInfo = (DTEDInfo *) CPLCalloc(1,sizeof(DTEDInfo)); + + psDInfo->fp = fp; + + psDInfo->bUpdate = EQUAL(pszAccess,"r+b"); + + psDInfo->nXSize = atoi(DTEDGetField(achRecord,48,4)); + psDInfo->nYSize = atoi(DTEDGetField(achRecord,52,4)); + + psDInfo->nUHLOffset = VSIFTell( fp ) - DTED_UHL_SIZE; + psDInfo->pachUHLRecord = (char *) CPLMalloc(DTED_UHL_SIZE); + memcpy( psDInfo->pachUHLRecord, achRecord, DTED_UHL_SIZE ); + + psDInfo->nDSIOffset = VSIFTell( fp ); + psDInfo->pachDSIRecord = (char *) CPLMalloc(DTED_DSI_SIZE); + VSIFRead( psDInfo->pachDSIRecord, 1, DTED_DSI_SIZE, fp ); + + psDInfo->nACCOffset = VSIFTell( fp ); + psDInfo->pachACCRecord = (char *) CPLMalloc(DTED_ACC_SIZE); + VSIFRead( psDInfo->pachACCRecord, 1, DTED_ACC_SIZE, fp ); + + if( !EQUALN(psDInfo->pachDSIRecord,"DSI",3) + || !EQUALN(psDInfo->pachACCRecord,"ACC",3) ) + { +#ifndef AVOID_CPL + CPLError( CE_Failure, CPLE_OpenFailed, +#else + fprintf( stderr, +#endif + "DSI or ACC record missing. DTED access to\n%s failed.", + pszFilename ); + + VSIFClose( fp ); + return NULL; + } + + psDInfo->nDataOffset = VSIFTell( fp ); + +/* -------------------------------------------------------------------- */ +/* Parse out position information. Note that we are extracting */ +/* the top left corner of the top left pixel area, not the */ +/* center of the area. */ +/* -------------------------------------------------------------------- */ + psDInfo->dfPixelSizeX = + atoi(DTEDGetField(achRecord,21,4)) / 36000.0; + + psDInfo->dfPixelSizeY = + atoi(DTEDGetField(achRecord,25,4)) / 36000.0; + + /* create a scope so I don't need to declare these up top */ + deg = atoi(stripLeadingZeros(DTEDGetField(achRecord,5,3))); + min = atoi(stripLeadingZeros(DTEDGetField(achRecord,8,2))); + sec = atoi(stripLeadingZeros(DTEDGetField(achRecord,10,2))); + + dfLLOriginX = deg + min / 60.0 + sec / 3600.0; + if( achRecord[11] == 'W' ) + dfLLOriginX *= -1; + + deg = atoi(stripLeadingZeros(DTEDGetField(achRecord,13,3))); + min = atoi(stripLeadingZeros(DTEDGetField(achRecord,16,2))); + sec = atoi(stripLeadingZeros(DTEDGetField(achRecord,18,2))); + + dfLLOriginY = deg + min / 60.0 + sec / 3600.0; + if( achRecord[19] == 'S' ) + dfLLOriginY *= -1; + + psDInfo->dfULCornerX = dfLLOriginX - 0.5 * psDInfo->dfPixelSizeX; + psDInfo->dfULCornerY = dfLLOriginY - 0.5 * psDInfo->dfPixelSizeY + + psDInfo->nYSize * psDInfo->dfPixelSizeY; + + return psDInfo; +} + +/************************************************************************/ +/* DTEDReadProfile() */ +/* */ +/* Read one profile line. These are organized in bottom to top */ +/* order starting from the leftmost column (0). */ +/************************************************************************/ + +int DTEDReadProfile( DTEDInfo * psDInfo, int nColumnOffset, + GInt16 * panData ) + +{ + int nOffset; + int i; + GByte *pabyRecord; + +/* -------------------------------------------------------------------- */ +/* Read data record from disk. */ +/* -------------------------------------------------------------------- */ + pabyRecord = (GByte *) CPLMalloc(12 + psDInfo->nYSize*2); + + nOffset = psDInfo->nDataOffset + nColumnOffset * (12+psDInfo->nYSize*2); + + if( VSIFSeek( psDInfo->fp, nOffset, SEEK_SET ) != 0 + || VSIFRead( pabyRecord, (12+psDInfo->nYSize*2), 1, psDInfo->fp ) != 1) + { +#ifndef AVOID_CPL + CPLError( CE_Failure, CPLE_FileIO, +#else + fprintf( stderr, +#endif + "Failed to seek to, or read profile %d at offset %d\n" + "in DTED file.\n", + nColumnOffset, nOffset ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Translate data values from "signed magnitude" to standard */ +/* binary. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psDInfo->nYSize; i++ ) + { + panData[i] = (pabyRecord[8+i*2] & 0x7f) * 256 + pabyRecord[8+i*2+1]; + + if( pabyRecord[8+i*2] & 0x80 ) + { + panData[i] *= -1; + + /* + ** It seems that some files are improperly generated in twos + ** complement form for negatives. For these, redo the job + ** in twos complement. eg. w_069_s50.dt0 + */ + if(( panData[i] < -16000 ) && (panData[i] != DTED_NODATA_VALUE)) + { + static int bWarned = FALSE; + + memcpy( panData + i, pabyRecord + 8+i*2, 2 ); + panData[i] = CPL_MSBWORD16( panData[i] ); + + if( !bWarned ) + { + bWarned = TRUE; + CPLError( CE_Warning, CPLE_AppDefined, + "The DTED driver found values less than -16000, and has adjusted\n" + "them assuming they are improperly two-complemented. No more warnings\n" + "will be issued in this session about this operation." ); + } + } + } + } + + CPLFree( pabyRecord ); + + return TRUE; +} + +/************************************************************************/ +/* DTEDWriteProfile() */ +/************************************************************************/ + +int DTEDWriteProfile( DTEDInfo * psDInfo, int nColumnOffset, + GInt16 * panData ) + +{ + int nOffset; + int i, nCheckSum = 0; + GByte *pabyRecord; + +/* -------------------------------------------------------------------- */ +/* Format the data record. */ +/* -------------------------------------------------------------------- */ + pabyRecord = (GByte *) CPLMalloc(12 + psDInfo->nYSize*2); + + for( i = 0; i < psDInfo->nYSize; i++ ) + { + int nABSVal = ABS(panData[psDInfo->nYSize-i-1]); + pabyRecord[8+i*2] = (GByte) ((nABSVal >> 8) & 0x7f); + pabyRecord[8+i*2+1] = (GByte) (nABSVal & 0xff); + + if( panData[psDInfo->nYSize-i-1] < 0 ) + pabyRecord[8+i*2] |= 0x80; + } + + pabyRecord[0] = 0xaa; + pabyRecord[1] = 0; + pabyRecord[2] = (GByte) (nColumnOffset / 256); + pabyRecord[3] = (GByte) (nColumnOffset % 256); + pabyRecord[4] = (GByte) (nColumnOffset / 256); + pabyRecord[5] = (GByte) (nColumnOffset % 256); + pabyRecord[6] = 0; + pabyRecord[7] = 0; + +/* -------------------------------------------------------------------- */ +/* Compute the checksum. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psDInfo->nYSize*2 + 8; i++ ) + nCheckSum += pabyRecord[i]; + + pabyRecord[8+psDInfo->nYSize*2+0] = (GByte) ((nCheckSum >> 24) & 0xff); + pabyRecord[8+psDInfo->nYSize*2+1] = (GByte) ((nCheckSum >> 16) & 0xff); + pabyRecord[8+psDInfo->nYSize*2+2] = (GByte) ((nCheckSum >> 8) & 0xff); + pabyRecord[8+psDInfo->nYSize*2+3] = (GByte) (nCheckSum & 0xff); + +/* -------------------------------------------------------------------- */ +/* Write the record. */ +/* -------------------------------------------------------------------- */ + nOffset = psDInfo->nDataOffset + nColumnOffset * (12+psDInfo->nYSize*2); + + if( VSIFSeek( psDInfo->fp, nOffset, SEEK_SET ) != 0 + || VSIFWrite( pabyRecord,(12+psDInfo->nYSize*2),1,psDInfo->fp ) != 1) + { + CPLFree( pabyRecord ); +#ifndef AVOID_CPL + CPLError( CE_Failure, CPLE_FileIO, +#else + fprintf( stderr, +#endif + "Failed to seek to, or write profile %d at offset %d\n" + "in DTED file.\n", + nColumnOffset, nOffset ); + return FALSE; + } + + CPLFree( pabyRecord ); + + return TRUE; + +} + +/************************************************************************/ +/* DTEDGetMetadataLocation() */ +/************************************************************************/ + +static void DTEDGetMetadataLocation( DTEDInfo *psDInfo, + DTEDMetaDataCode eCode, + char **ppszLocation, int *pnLength ) +{ + switch( eCode ) + { + case DTEDMD_VERTACCURACY_UHL: + *ppszLocation = psDInfo->pachUHLRecord + 28; + *pnLength = 4; + break; + + case DTEDMD_SECURITYCODE_UHL: + *ppszLocation = psDInfo->pachUHLRecord + 32; + *pnLength = 3; + break; + + case DTEDMD_UNIQUEREF_UHL: + *ppszLocation = psDInfo->pachUHLRecord + 35; + *pnLength = 12; + break; + + case DTEDMD_DATA_EDITION: + *ppszLocation = psDInfo->pachDSIRecord + 87; + *pnLength = 2; + break; + + case DTEDMD_MATCHMERGE_VERSION: + *ppszLocation = psDInfo->pachDSIRecord + 89; + *pnLength = 1; + break; + + case DTEDMD_MAINT_DATE: + *ppszLocation = psDInfo->pachDSIRecord + 90; + *pnLength = 4; + break; + + case DTEDMD_MATCHMERGE_DATE: + *ppszLocation = psDInfo->pachDSIRecord + 94; + *pnLength = 4; + break; + + case DTEDMD_MAINT_DESCRIPTION: + *ppszLocation = psDInfo->pachDSIRecord + 98; + *pnLength = 4; + break; + + case DTEDMD_PRODUCER: + *ppszLocation = psDInfo->pachDSIRecord + 102; + *pnLength = 8; + break; + + case DTEDMD_VERTDATUM: + *ppszLocation = psDInfo->pachDSIRecord + 141; + *pnLength = 3; + break; + + case DTEDMD_DIGITIZING_SYS: + *ppszLocation = psDInfo->pachDSIRecord + 149; + *pnLength = 10; + break; + + case DTEDMD_COMPILATION_DATE: + *ppszLocation = psDInfo->pachDSIRecord + 159; + *pnLength = 4; + break; + + case DTEDMD_HORIZACCURACY: + *ppszLocation = psDInfo->pachACCRecord + 3; + *pnLength = 4; + break; + + case DTEDMD_REL_HORIZACCURACY: + *ppszLocation = psDInfo->pachACCRecord + 11; + *pnLength = 4; + break; + + case DTEDMD_REL_VERTACCURACY: + *ppszLocation = psDInfo->pachACCRecord + 15; + *pnLength = 4; + break; + + case DTEDMD_VERTACCURACY_ACC: + *ppszLocation = psDInfo->pachACCRecord + 7; + *pnLength = 4; + break; + + case DTEDMD_SECURITYCODE_DSI: + *ppszLocation = psDInfo->pachDSIRecord + 3; + *pnLength = 1; + break; + + case DTEDMD_UNIQUEREF_DSI: + *ppszLocation = psDInfo->pachDSIRecord + 64; + *pnLength = 15; + break; + + default: + *ppszLocation = NULL; + *pnLength = 0; + } +} + +/************************************************************************/ +/* DTEDGetMetadata() */ +/************************************************************************/ + +char *DTEDGetMetadata( DTEDInfo *psDInfo, DTEDMetaDataCode eCode ) + +{ + int nFieldLen; + char *pszFieldSrc; + char *pszResult; + + DTEDGetMetadataLocation( psDInfo, eCode, &pszFieldSrc, &nFieldLen ); + if( pszFieldSrc == NULL ) + return VSIStrdup( "" ); + + pszResult = (char *) malloc(nFieldLen+1); + strncpy( pszResult, pszFieldSrc, nFieldLen ); + pszResult[nFieldLen] = '\0'; + + return pszResult; +} + +/************************************************************************/ +/* DTEDSetMetadata() */ +/************************************************************************/ + +int DTEDSetMetadata( DTEDInfo *psDInfo, DTEDMetaDataCode eCode, + const char *pszNewValue ) + +{ + int nFieldLen; + char *pszFieldSrc; + + if( !psDInfo->bUpdate ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Get the location in the headers to update. */ +/* -------------------------------------------------------------------- */ + DTEDGetMetadataLocation( psDInfo, eCode, &pszFieldSrc, &nFieldLen ); + if( pszFieldSrc == NULL ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Update it, padding with spaces. */ +/* -------------------------------------------------------------------- */ + memset( pszFieldSrc, ' ', nFieldLen ); + strncpy( pszFieldSrc, pszNewValue, + MIN(strlen(pszFieldSrc),strlen(pszNewValue)) ); + +/* -------------------------------------------------------------------- */ +/* Write all headers back to disk. */ +/* -------------------------------------------------------------------- */ + VSIFSeek( psDInfo->fp, psDInfo->nUHLOffset, SEEK_SET ); + VSIFWrite( psDInfo->pachUHLRecord, 1, DTED_UHL_SIZE, psDInfo->fp ); + + VSIFSeek( psDInfo->fp, psDInfo->nDSIOffset, SEEK_SET ); + VSIFWrite( psDInfo->pachDSIRecord, 1, DTED_DSI_SIZE, psDInfo->fp ); + + VSIFSeek( psDInfo->fp, psDInfo->nACCOffset, SEEK_SET ); + VSIFWrite( psDInfo->pachACCRecord, 1, DTED_ACC_SIZE, psDInfo->fp ); + + return TRUE; +} + +/************************************************************************/ +/* DTEDClose() */ +/************************************************************************/ + +void DTEDClose( DTEDInfo * psDInfo ) + +{ + VSIFClose( psDInfo->fp ); + + CPLFree( psDInfo->pachUHLRecord ); + CPLFree( psDInfo->pachDSIRecord ); + CPLFree( psDInfo->pachACCRecord ); + + CPLFree( psDInfo ); +} diff --git a/Utilities/GDAL/frmts/dted/dted_api.h b/Utilities/GDAL/frmts/dted/dted_api.h new file mode 100644 index 0000000000..b1cbb7e8b9 --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dted_api.h @@ -0,0 +1,211 @@ +/****************************************************************************** + * $Id$ + * + * Project: DTED Translator + * Purpose: Public (C callable) interface for DTED/CDED reading. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: dted_api.h,v $ + * Revision 1.11 2006/04/04 01:00:44 fwarmerdam + * updated contact info + * + * Revision 1.10 2004/04/14 19:47:29 warmerda + * added better boundary support, and trimming + * + * Revision 1.9 2004/01/29 23:35:22 gwalter + * Add a few more metadata fields, make sure that + * nodata value is recognized. + * + * Revision 1.8 2002/03/05 14:26:01 warmerda + * expanded tabs + * + * Revision 1.7 2002/01/28 18:18:07 warmerda + * Added DTEDPtStreamSetMetadata + * + * Revision 1.6 2002/01/26 05:51:40 warmerda + * added metadata read/write support + * + * Revision 1.5 2001/11/23 16:43:47 warmerda + * added nodata constant + * + * Revision 1.4 2001/11/21 19:55:49 warmerda + * added pt stream api + * + * Revision 1.3 2001/11/13 15:43:41 warmerda + * preliminary dted creation working + * + * Revision 1.2 2000/07/07 14:20:57 warmerda + * fixed AVOID_CPL support + * + * Revision 1.1 1999/12/07 18:01:28 warmerda + * New + * + */ + +#ifndef _DTED_API_H_INCLUDED +#define _DTED_API_H_INCLUDED + +/* -------------------------------------------------------------------- */ +/* To avoid dependence on CPL, just define AVOID_CPL when */ +/* compiling. */ +/* -------------------------------------------------------------------- */ +#ifndef AVOID_CPL +# include "cpl_conv.h" +#else + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#define CPL_C_START +#define CPL_C_END + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + +#ifndef EQUAL +#if defined(WIN32) || defined(_WIN32) || defined(_WINDOWS) +# define EQUALN(a,b,n) (strnicmp(a,b,n)==0) +# define EQUAL(a,b) (stricmp(a,b)==0) +#else +# define EQUALN(a,b,n) (strncasecmp(a,b,n)==0) +# define EQUAL(a,b) (strcasecmp(a,b)==0) +#endif +#endif + +#define VSIFTell ftell +#define VSIFOpen fopen +#define VSIFClose fclose +#define VSIFRead fread +#define CPLMalloc malloc +#define CPLCalloc calloc +#define CPLFree free +#define GInt16 short +#define GByte unsigned char +#define VSIFSeek fseek +#define CPLAssert assert + +#endif + +/* -------------------------------------------------------------------- */ +/* DTED information structure. All of this can be considered */ +/* public information. */ +/* -------------------------------------------------------------------- */ +CPL_C_START + +#define DTED_UHL_SIZE 80 +#define DTED_DSI_SIZE 648 +#define DTED_ACC_SIZE 2700 + +#define DTED_NODATA_VALUE -32767 + +typedef struct { + FILE *fp; + int bUpdate; + + int nXSize; + int nYSize; + + double dfULCornerX; /* in long/lat degrees */ + double dfULCornerY; + double dfPixelSizeX; + double dfPixelSizeY; + + int nUHLOffset; + char *pachUHLRecord; + + int nDSIOffset; + char *pachDSIRecord; + + int nACCOffset; + char *pachACCRecord; + + int nDataOffset; + +} DTEDInfo; + +/* -------------------------------------------------------------------- */ +/* DTED access API. Get info directly from the structure */ +/* (DTEDInfo). */ +/* -------------------------------------------------------------------- */ +DTEDInfo *DTEDOpen( const char * pszFilename, const char * pszAccess, + int bTestOpen ); + +int DTEDReadProfile( DTEDInfo * psDInfo, int nColumnOffset, + GInt16 * panData ); +int DTEDWriteProfile( DTEDInfo *psDInfo, int nColumnOffset, GInt16 *panData); + +void DTEDClose( DTEDInfo * ); + +const char *DTEDCreate( const char *pszFilename, + int nLevel, int nLLOriginLat, int nLLOriginLong ); + +/* -------------------------------------------------------------------- */ +/* Metadata support. */ +/* -------------------------------------------------------------------- */ +typedef enum { + DTEDMD_VERTACCURACY_UHL = 1, /* UHL 29+4, ACC 8+4 */ + DTEDMD_VERTACCURACY_ACC = 2, + DTEDMD_SECURITYCODE_UHL = 3, /* UHL 33+3, DSI 4+1 */ + DTEDMD_SECURITYCODE_DSI = 4, + DTEDMD_UNIQUEREF_UHL = 5, /* UHL 36+12, DSI 65+15*/ + DTEDMD_UNIQUEREF_DSI = 6, + DTEDMD_DATA_EDITION = 7, /* DSI 88+2 */ + DTEDMD_MATCHMERGE_VERSION = 8, /* DSI 90+1 */ + DTEDMD_MAINT_DATE = 9, /* DSI 91+4 */ + DTEDMD_MATCHMERGE_DATE = 10, /* DSI 95+4 */ + DTEDMD_MAINT_DESCRIPTION = 11, /* DSI 99+4 */ + DTEDMD_PRODUCER = 12, /* DSI 103+8 */ + DTEDMD_VERTDATUM = 13, /* DSI 142+3 */ + DTEDMD_DIGITIZING_SYS = 14, /* DSI 150+10 */ + DTEDMD_COMPILATION_DATE = 15, /* DSI 160+4 */ + DTEDMD_HORIZACCURACY = 16, /* ACC 4+4 */ + DTEDMD_REL_HORIZACCURACY = 17, /* ACC 12+4 */ + DTEDMD_REL_VERTACCURACY = 18, /* ACC 16+4 */ + DTEDMD_MAX = 18 +} DTEDMetaDataCode; + + +char *DTEDGetMetadata( DTEDInfo *, DTEDMetaDataCode ); +int DTEDSetMetadata( DTEDInfo *, DTEDMetaDataCode, const char *); + +/* -------------------------------------------------------------------- */ +/* Point stream writer API. */ +/* -------------------------------------------------------------------- */ +void *DTEDCreatePtStream( const char *pszPath, int nLevel ); +int DTEDWritePt( void *hStream, double dfLong, double dfLat, double dfElev ); +void DTEDFillPtStream( void *hStream, int nPixelSearchDist ); +void DTEDPtStreamSetMetadata( void *hStream, DTEDMetaDataCode, const char *); +void DTEDClosePtStream( void *hStream ); +void DTEDPtStreamTrimEdgeOnlyTiles( void *hStream ); + +CPL_C_END + +#endif /* ndef _DTED_API_H_INCLUDED */ + + diff --git a/Utilities/GDAL/frmts/dted/dted_create.c b/Utilities/GDAL/frmts/dted/dted_create.c new file mode 100644 index 0000000000..dd62a94c0c --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dted_create.c @@ -0,0 +1,328 @@ +/****************************************************************************** + * $Id$ + * + * Project: DTED Translator + * Purpose: Implementation of DTEDCreate() portion of DTED API. + * Author: Frank Warmerdam, warmerdamm@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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: dted_create.c,v $ + * Revision 1.12 2006/04/04 01:00:44 fwarmerdam + * updated contact info + * + * Revision 1.11 2004/05/13 00:28:57 gwalter + * Fix latitude/longitude mixup in header. + * + * Revision 1.10 2004/01/30 18:27:25 gwalter + * Fixed bug in tile sizing. + * + * Revision 1.9 2004/01/29 23:35:22 gwalter + * Add a few more metadata fields, make sure that + * nodata value is recognized. + * + * Revision 1.8 2003/05/30 16:17:21 warmerda + * fix warnings with casting and unused parameters + * + * Revision 1.7 2003/05/30 16:08:07 warmerda + * fixed setting of SE corner in DSI record + * + * Revision 1.6 2002/10/10 17:00:16 warmerda + * fixed bug in formatting some latitudes in DSI record + * + * Revision 1.5 2002/03/05 14:26:01 warmerda + * expanded tabs + * + * Revision 1.4 2002/01/28 18:19:42 warmerda + * fix setting of metadata fields + * + * Revision 1.3 2001/11/21 19:55:01 warmerda + * initialize data portion of new records + * + * Revision 1.2 2001/11/13 15:43:41 warmerda + * preliminary dted creation working + * + * Revision 1.1 2001/11/13 03:34:59 warmerda + * New + * + */ + +#include "dted_api.h" +#include <assert.h> + +CPL_CVSID("$Id$"); + +#define DTED_ABS_VERT_ACC "NA " +#define DTED_SECURITY "U" +#define DTED_EDITION 1 + +/************************************************************************/ +/* DTEDFormatDMS() */ +/************************************************************************/ + +static void DTEDFormatDMS( unsigned char *achField, double dfAngle, + const char *pszLatLong, const char *pszFormat ) + +{ + char chHemisphere; + char szWork[128]; + int nDegrees, nMinutes, nSeconds; + double dfRemainder; + + if( pszFormat == NULL ) + pszFormat = "%03d%02d%02d%c"; + + assert( EQUAL(pszLatLong,"LAT") || EQUAL(pszLatLong,"LONG") ); + + if( EQUAL(pszLatLong,"LAT") ) + { + if( dfAngle < 0.0 ) + chHemisphere = 'S'; + else + chHemisphere = 'N'; + } + else + { + if( dfAngle < 0.0 ) + chHemisphere = 'W'; + else + chHemisphere = 'E'; + } + + dfAngle = ABS(dfAngle); + + nDegrees = (int) floor(dfAngle + 0.5/3600.0); + dfRemainder = dfAngle - nDegrees; + nMinutes = (int) floor(dfRemainder*60.0 + 0.5/60.0); + dfRemainder = dfRemainder - nMinutes / 60.0; + nSeconds = (int) floor(dfRemainder * 3600.0 + 0.5); + + sprintf( szWork, pszFormat, + nDegrees, nMinutes, nSeconds, chHemisphere ); + + strncpy( (char *) achField, szWork, strlen(szWork) ); +} + +/************************************************************************/ +/* DTEDFormat() */ +/************************************************************************/ + +static void DTEDFormat( unsigned char *pszTarget, const char *pszFormat, ... ) + +{ + va_list args; + char szWork[512]; + + va_start(args, pszFormat); + vsprintf( szWork, pszFormat, args ); + va_end(args); + + strncpy( (char *) pszTarget, szWork, strlen(szWork) ); +} + +/************************************************************************/ +/* DTEDCreate() */ +/************************************************************************/ + +const char *DTEDCreate( const char *pszFilename, int nLevel, + int nLLOriginLat, int nLLOriginLong ) + +{ + FILE *fp; + unsigned char achRecord[3601*2 + 12]; + int nXSize, nYSize, iProfile; + static char szError[512]; + +/* -------------------------------------------------------------------- */ +/* Establish resolution. */ +/* -------------------------------------------------------------------- */ + if( nLevel == 0 ) + { + nXSize = 121; + nYSize = 121; + } + else if( nLevel == 1 ) + { + nXSize = 1201; + nYSize = 1201; + } + else if( nLevel == 2 ) + { + nXSize = 3601; + nYSize = 3601; + } + else + { + sprintf( szError, "Illegal DTED Level value %d, only 0-2 allowed.", + nLevel ); + return szError; + } + + if( ABS(nLLOriginLat) >= 80 ) + nXSize = (nXSize - 1) / 6 + 1; + else if( ABS(nLLOriginLat) >= 75 ) + nXSize = (nXSize - 1) / 4 + 1; + else if( ABS(nLLOriginLat) >= 70 ) + nXSize = (nXSize - 1) / 3 + 1; + else if( ABS(nLLOriginLat) >= 50 ) + nXSize = (nXSize - 1) / 2 + 1; + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpen( pszFilename, "wb" ); + + if( fp == NULL ) + { + sprintf( szError, "Unable to create file `%s'.", pszFilename ); + return szError; + } + +/* -------------------------------------------------------------------- */ +/* Format and write the UHL record. */ +/* -------------------------------------------------------------------- */ + memset( achRecord, ' ', DTED_UHL_SIZE ); + + DTEDFormat( achRecord + 0, "UHL1" ); + + DTEDFormatDMS( achRecord + 4, nLLOriginLong, "LONG", NULL ); + DTEDFormatDMS( achRecord + 12, nLLOriginLat, "LAT", NULL ); + + DTEDFormat( achRecord + 20, "%04d", (3600 / (nXSize-1)) * 10 ); + DTEDFormat( achRecord + 24, "%04d", (3600 / (nYSize-1)) * 10 ); + + DTEDFormat( achRecord + 28, "%4s", DTED_ABS_VERT_ACC ); + DTEDFormat( achRecord + 32, "%-3s", DTED_SECURITY ); + DTEDFormat( achRecord + 47, "%04d", nXSize ); + DTEDFormat( achRecord + 51, "%04d", nYSize ); + DTEDFormat( achRecord + 55, "%c", '0' ); + + if( VSIFWrite( achRecord, DTED_UHL_SIZE, 1, fp ) != 1 ) + return "UHL record write failed."; + +/* -------------------------------------------------------------------- */ +/* Format and write the DSI record. */ +/* -------------------------------------------------------------------- */ + memset( achRecord, ' ', DTED_DSI_SIZE ); + + DTEDFormat( achRecord + 0, "DSI" ); + DTEDFormat( achRecord + 3, "%1s", DTED_SECURITY ); + + DTEDFormat( achRecord + 59, "DTED%d", nLevel ); + DTEDFormat( achRecord + 64, "%015d", 0 ); + DTEDFormat( achRecord + 87, "%02d", DTED_EDITION ); + DTEDFormat( achRecord + 89, "%c", 'A' ); + DTEDFormat( achRecord + 90, "%04d", 0 ); + DTEDFormat( achRecord + 94, "%04d", 0 ); + DTEDFormat( achRecord + 98, "%04d", 0 ); + DTEDFormat( achRecord + 126, "PRF89020B"); + DTEDFormat( achRecord + 135, "00"); + DTEDFormat( achRecord + 137, "0005"); + DTEDFormat( achRecord + 141, "MSL" ); + DTEDFormat( achRecord + 144, "WGS84" ); + + /* origin */ + DTEDFormatDMS( achRecord + 185, nLLOriginLat, "LAT", + "%02d%02d%02d.0%c" ); + DTEDFormatDMS( achRecord + 194, nLLOriginLong, "LONG", + "%03d%02d%02d.0%c" ); + + /* SW */ + DTEDFormatDMS( achRecord + 204, nLLOriginLat, "LAT", "%02d%02d%02d%c" ); + DTEDFormatDMS( achRecord + 211, nLLOriginLong, "LONG", NULL ); + + /* NW */ + DTEDFormatDMS( achRecord + 219, nLLOriginLat+1, "LAT", "%02d%02d%02d%c" ); + DTEDFormatDMS( achRecord + 226, nLLOriginLong, "LONG", NULL ); + + /* NE */ + DTEDFormatDMS( achRecord + 234, nLLOriginLat+1, "LAT", "%02d%02d%02d%c" ); + DTEDFormatDMS( achRecord + 241, nLLOriginLong+1, "LONG", NULL ); + + /* SE */ + DTEDFormatDMS( achRecord + 249, nLLOriginLat, "LAT", "%02d%02d%02d%c" ); + DTEDFormatDMS( achRecord + 256, nLLOriginLong+1, "LONG", NULL ); + + DTEDFormat( achRecord + 264, "0000000.0" ); + DTEDFormat( achRecord + 264, "0000000.0" ); + + DTEDFormat( achRecord + 273, "%04d", (3600 / (nYSize-1)) * 10 ); + DTEDFormat( achRecord + 277, "%04d", (3600 / (nXSize-1)) * 10 ); + + DTEDFormat( achRecord + 281, "%04d", nYSize ); + DTEDFormat( achRecord + 285, "%04d", nXSize ); + DTEDFormat( achRecord + 289, "%02d", 0 ); + + if( VSIFWrite( achRecord, DTED_DSI_SIZE, 1, fp ) != 1 ) + return "DSI record write failed."; + +/* -------------------------------------------------------------------- */ +/* Create and write ACC record. */ +/* -------------------------------------------------------------------- */ + memset( achRecord, ' ', DTED_ACC_SIZE ); + + DTEDFormat( achRecord + 0, "ACC" ); + + DTEDFormat( achRecord + 3, "NA" ); + DTEDFormat( achRecord + 7, "NA" ); + DTEDFormat( achRecord + 11, "NA" ); + DTEDFormat( achRecord + 15, "NA" ); + + DTEDFormat( achRecord + 55, "00" ); + + if( VSIFWrite( achRecord, DTED_ACC_SIZE, 1, fp ) != 1 ) + return "ACC record write failed."; + +/* -------------------------------------------------------------------- */ +/* Write blank template profile data records. */ +/* -------------------------------------------------------------------- */ + memset( achRecord, 0, nYSize*2 + 12 ); + memset( achRecord + 8, 0xff, nYSize*2 ); + + achRecord[0] = 0252; + + for( iProfile = 0; iProfile < nXSize; iProfile++ ) + { + achRecord[1] = 0; + achRecord[2] = (GByte) (iProfile / 256); + achRecord[3] = (GByte) (iProfile % 256); + + achRecord[4] = (GByte) (iProfile / 256); + achRecord[5] = (GByte) (iProfile % 256); + + if( VSIFWrite( achRecord, nYSize*2 + 12, 1, fp ) != 1 ) + return "Data record write failed."; + } + +/* -------------------------------------------------------------------- */ +/* Write EOF. */ +/* -------------------------------------------------------------------- */ + DTEDFormat( achRecord, "EOF1" ); + + if( VSIFWrite( achRecord, 4, 1, fp ) != 1 ) + return "EOF record write failed."; + + VSIFClose( fp ); + + return NULL; +} diff --git a/Utilities/GDAL/frmts/dted/dted_ptstream.c b/Utilities/GDAL/frmts/dted/dted_ptstream.c new file mode 100644 index 0000000000..c4da0551ed --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dted_ptstream.c @@ -0,0 +1,655 @@ +/****************************************************************************** + * $Id$ + * + * Project: DTED Translator + * Purpose: DTED Point Stream Writer. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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: dted_ptstream.c,v $ + * Revision 1.8 2004/04/14 19:47:29 warmerda + * added better boundary support, and trimming + * + * Revision 1.7 2003/05/30 16:17:21 warmerda + * fix warnings with casting and unused parameters + * + * Revision 1.6 2002/03/05 14:26:01 warmerda + * expanded tabs + * + * Revision 1.5 2002/02/15 18:26:44 warmerda + * create output directory if necessary + * + * Revision 1.4 2002/01/28 19:11:34 warmerda + * avoid warning + * + * Revision 1.3 2002/01/28 18:18:48 warmerda + * Added DTEDPtStreamSetMetadata + * + * Revision 1.2 2001/11/23 16:43:34 warmerda + * rough interpolate implementation + * + * Revision 1.1 2001/11/21 19:51:34 warmerda + * New + * + */ + +#include "dted_api.h" + +CPL_CVSID("$Id$"); + +typedef struct { + char *pszFilename; + DTEDInfo *psInfo; + + GInt16 **papanProfiles; + + int nLLLong; + int nLLLat; +} DTEDCachedFile; + +typedef struct { + int nLevel; + char *pszPath; + + double dfPixelSize; + + int nOpenFiles; + DTEDCachedFile *pasCF; + + int nLastFile; + + char *apszMetadata[DTEDMD_MAX+1]; +} DTEDPtStream; + +/************************************************************************/ +/* DTEDCreatePtStream() */ +/************************************************************************/ + +void *DTEDCreatePtStream( const char *pszPath, int nLevel ) + +{ + DTEDPtStream *psStream; + int i; + VSIStatBuf sStat; + +/* -------------------------------------------------------------------- */ +/* Does the target directory already exist? If not try to */ +/* create it. */ +/* -------------------------------------------------------------------- */ + if( CPLStat( pszPath, &sStat ) != 0 ) + { + if( VSIMkdir( pszPath, 0755 ) != 0 ) + { +#ifndef AVOID_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to find, or create directory `%s'.", + pszPath ); +#endif + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Create the stream and initialize it. */ +/* -------------------------------------------------------------------- */ + + psStream = (DTEDPtStream *) CPLCalloc( sizeof(DTEDPtStream), 1 ); + psStream->nLevel = nLevel; + psStream->pszPath = CPLStrdup( pszPath ); + psStream->nOpenFiles = 0; + psStream->pasCF = NULL; + psStream->nLastFile = -1; + + for( i = 0; i < DTEDMD_MAX+1; i++ ) + psStream->apszMetadata[i] = NULL; + + if( nLevel == 0 ) + psStream->dfPixelSize = 1.0 / 120.0; + else if( nLevel == 1 ) + psStream->dfPixelSize = 1.0 / 1200.0; + else if( nLevel == 2 ) + psStream->dfPixelSize = 1.0 / 3600.0; + else + psStream->dfPixelSize = 1.0 / 3600.0; + + return (void *) psStream; +} + +/************************************************************************/ +/* DTEDPtStreamNewTile() */ +/* */ +/* Create a new DTED file file, add it to our list, and make it */ +/* "current". */ +/************************************************************************/ + +static int DTEDPtStreamNewTile( DTEDPtStream *psStream, + int nCrLong, int nCrLat ) + +{ + DTEDInfo *psInfo; + char szFile[128]; + char chNSHemi, chEWHemi; + char *pszFullFilename; + const char *pszError; + + /* work out filename */ + if( nCrLat < 0 ) + chNSHemi = 's'; + else + chNSHemi = 'n'; + + if( nCrLong < 0 ) + chEWHemi = 'w'; + else + chEWHemi = 'e'; + + sprintf( szFile, "%c%03d%c%03d.dt%d", + chEWHemi, ABS(nCrLong), chNSHemi, ABS(nCrLat), + psStream->nLevel ); + + pszFullFilename = + CPLStrdup(CPLFormFilename( psStream->pszPath, szFile, NULL )); + + /* create the dted file */ + pszError = DTEDCreate( pszFullFilename, psStream->nLevel, + nCrLat, nCrLong ); + if( pszError != NULL ) + { +#ifndef AVOID_CPL + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to create DTED file `%s'.\n%s", + pszFullFilename, pszError ); +#endif + return FALSE; + } + + psInfo = DTEDOpen( pszFullFilename, "rb+", FALSE ); + + if( psInfo == NULL ) + { + CPLFree( pszFullFilename ); + return FALSE; + } + + /* add cached file to stream */ + psStream->nOpenFiles++; + psStream->pasCF = + CPLRealloc(psStream->pasCF, + sizeof(DTEDCachedFile)*psStream->nOpenFiles); + + psStream->pasCF[psStream->nOpenFiles-1].psInfo = psInfo; + psStream->pasCF[psStream->nOpenFiles-1].papanProfiles = + CPLCalloc(sizeof(GInt16*),psInfo->nXSize); + psStream->pasCF[psStream->nOpenFiles-1].pszFilename = pszFullFilename; + psStream->pasCF[psStream->nOpenFiles-1].nLLLat = nCrLat; + psStream->pasCF[psStream->nOpenFiles-1].nLLLong = nCrLong; + + psStream->nLastFile = psStream->nOpenFiles-1; + + return TRUE; +} + +/************************************************************************/ +/* DTEDWritePtLL() */ +/************************************************************************/ + +static int DTEDWritePtLL( DTEDPtStream *psStream, + DTEDCachedFile *psCF, + double dfLong, double dfLat, double dfElev ) + +{ +/* -------------------------------------------------------------------- */ +/* Determine what profile this belongs in, and initialize the */ +/* profile if it doesn't already exist. */ +/* -------------------------------------------------------------------- */ + DTEDInfo *psInfo = psCF->psInfo; + int iProfile, i, iRow; + + iProfile = (int) ((dfLong - psInfo->dfULCornerX) / psInfo->dfPixelSizeX); + iProfile = MAX(0,MIN(psInfo->nXSize-1,iProfile)); + + if( psCF->papanProfiles[iProfile] == NULL ) + { + psCF->papanProfiles[iProfile] = + CPLMalloc(sizeof(GInt16) * psInfo->nYSize); + + for( i = 0; i < psInfo->nYSize; i++ ) + psCF->papanProfiles[iProfile][i] = DTED_NODATA_VALUE; + } + +/* -------------------------------------------------------------------- */ +/* Establish where we fit in the profile. */ +/* -------------------------------------------------------------------- */ + iRow = (int) ((psInfo->dfULCornerY-dfLat) / psInfo->dfPixelSizeY); + iRow = MAX(0,MIN(psInfo->nYSize-1,iRow)); + + psCF->papanProfiles[iProfile][iRow] = (GInt16) floor(dfElev+0.5); + + return TRUE; +} + +/************************************************************************/ +/* DTEDWritePt() */ +/* */ +/* Write a single point out, creating a new file if necessary */ +/* to hold it. */ +/************************************************************************/ + +int DTEDWritePt( void *hStream, double dfLong, double dfLat, double dfElev ) + +{ + DTEDPtStream *psStream = (DTEDPtStream *) hStream; + int i; + DTEDInfo *psInfo; + int bOnBoundary = FALSE; + +/* -------------------------------------------------------------------- */ +/* Determine if we are in a boundary region ... that is in the */ +/* area of the edge "pixel" that is shared with adjacent */ +/* tiles. */ +/* -------------------------------------------------------------------- */ + if( (floor(dfLong - 0.5*psStream->dfPixelSize) + != floor(dfLong + 0.5*psStream->dfPixelSize)) + || (floor(dfLat - 0.5*psStream->dfPixelSize) + != floor(dfLat + 0.5*psStream->dfPixelSize)) ) + { + bOnBoundary = TRUE; + psStream->nLastFile = -1; + } + +/* ==================================================================== */ +/* Handle case where the tile is not on a boundary. We only */ +/* need one output tile. */ +/* ==================================================================== */ +/* -------------------------------------------------------------------- */ +/* Is the last file used still applicable? */ +/* -------------------------------------------------------------------- */ + if( !bOnBoundary ) + { + if( psStream->nLastFile != -1 ) + { + psInfo = psStream->pasCF[psStream->nLastFile].psInfo; + + if( dfLat > psInfo->dfULCornerY + || dfLat < psInfo->dfULCornerY - 1.0 - psInfo->dfPixelSizeY + || dfLong < psInfo->dfULCornerX + || dfLong > psInfo->dfULCornerX + 1.0 + psInfo->dfPixelSizeX ) + psStream->nLastFile = -1; + } + +/* -------------------------------------------------------------------- */ +/* Search for the file to write to. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psStream->nOpenFiles && psStream->nLastFile == -1; i++ ) + { + psInfo = psStream->pasCF[i].psInfo; + + if( !(dfLat > psInfo->dfULCornerY + || dfLat < psInfo->dfULCornerY - 1.0 - psInfo->dfPixelSizeY + || dfLong < psInfo->dfULCornerX + || dfLong > psInfo->dfULCornerX + 1.0 + psInfo->dfPixelSizeX) ) + { + psStream->nLastFile = i; + } + } + +/* -------------------------------------------------------------------- */ +/* If none found, create a new file. */ +/* -------------------------------------------------------------------- */ + if( psStream->nLastFile == -1 ) + { + int nCrLong, nCrLat; + + nCrLong = (int) floor(dfLong); + nCrLat = (int) floor(dfLat); + + if( !DTEDPtStreamNewTile( psStream, nCrLong, nCrLat ) ) + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Write data out to selected tile. */ +/* -------------------------------------------------------------------- */ + return DTEDWritePtLL( psStream, psStream->pasCF + psStream->nLastFile, + dfLong, dfLat, dfElev ); + } + +/* ==================================================================== */ +/* Handle case where we are on a boundary. We may be writing */ +/* the value to as many as four tiles. */ +/* ==================================================================== */ + else + { + int nLatMin, nLatMax, nLongMin, nLongMax; + int nCrLong, nCrLat; + + nLongMin = (int) floor( dfLong - 0.5*psStream->dfPixelSize ); + nLongMax = (int) floor( dfLong + 0.5*psStream->dfPixelSize ); + nLatMin = (int) floor( dfLat - 0.5*psStream->dfPixelSize ); + nLatMax = (int) floor( dfLat + 0.5*psStream->dfPixelSize ); + + for( nCrLong = nLongMin; nCrLong <= nLongMax; nCrLong++ ) + { + for( nCrLat = nLatMin; nCrLat <= nLatMax; nCrLat++ ) + { + psStream->nLastFile = -1; + +/* -------------------------------------------------------------------- */ +/* Find this tile in our existing list. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psStream->nOpenFiles; i++ ) + { + if( psStream->pasCF[i].nLLLong == nCrLong + && psStream->pasCF[i].nLLLat == nCrLat ) + { + psStream->nLastFile = i; + break; + } + } + +/* -------------------------------------------------------------------- */ +/* Create the tile if not found. */ +/* -------------------------------------------------------------------- */ + if( psStream->nLastFile == -1 ) + { + if( !DTEDPtStreamNewTile( psStream, nCrLong, nCrLat ) ) + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Write to the tile. */ +/* -------------------------------------------------------------------- */ + if( !DTEDWritePtLL( psStream, + psStream->pasCF + psStream->nLastFile, + dfLong, dfLat, dfElev ) ) + return FALSE; + } + } + } + + return TRUE; +} + +/************************************************************************/ +/* DTEDClosePtStream() */ +/************************************************************************/ + +void DTEDClosePtStream( void *hStream ) + +{ + DTEDPtStream *psStream = (DTEDPtStream *) hStream; + int iFile, iMD; + +/* -------------------------------------------------------------------- */ +/* Flush all DTED files. */ +/* -------------------------------------------------------------------- */ + for( iFile = 0; iFile < psStream->nOpenFiles; iFile++ ) + { + int iProfile; + DTEDCachedFile *psCF = psStream->pasCF + iFile; + + for( iProfile = 0; iProfile < psCF->psInfo->nXSize; iProfile++ ) + { + if( psCF->papanProfiles[iProfile] != NULL ) + { + DTEDWriteProfile( psCF->psInfo, iProfile, + psCF->papanProfiles[iProfile] ); + CPLFree( psCF->papanProfiles[iProfile] ); + } + } + + CPLFree( psCF->papanProfiles ); + + for( iMD = 0; iMD < DTEDMD_MAX+1; iMD++ ) + { + if( psStream->apszMetadata[iMD] != NULL ) + DTEDSetMetadata( psCF->psInfo, iMD, + psStream->apszMetadata[iMD] ); + } + + DTEDClose( psCF->psInfo ); + } + +/* -------------------------------------------------------------------- */ +/* Final cleanup. */ +/* -------------------------------------------------------------------- */ + + for( iMD = 0; iMD < DTEDMD_MAX+1; iMD++ ) + CPLFree( psStream->apszMetadata[iMD] ); + + CPLFree( psStream->pasCF ); + CPLFree( psStream->pszPath ); + CPLFree( psStream ); +} + +/************************************************************************/ +/* DTEDFillPixel() */ +/************************************************************************/ + +void DTEDFillPixel( DTEDInfo *psInfo, GInt16 **papanProfiles, + GInt16 **papanDstProfiles, int iX, int iY, + int nPixelSearchDist, float *pafKernel ) + +{ + int nKernelWidth = 2 * nPixelSearchDist + 1; + int nXMin, nXMax, nYMin, nYMax; + double dfCoefSum = 0.0, dfValueSum = 0.0; + int iXS, iYS; + + nXMin = MAX(0,iX - nPixelSearchDist); + nXMax = MIN(psInfo->nXSize-1,iX + nPixelSearchDist); + nYMin = MAX(0,iY - nPixelSearchDist); + nYMax = MIN(psInfo->nYSize-1,iY + nPixelSearchDist); + + for( iXS = nXMin; iXS <= nXMax; iXS++ ) + { + GInt16 *panThisProfile = papanProfiles[iXS]; + + if( panThisProfile == NULL ) + continue; + + for( iYS = nYMin; iYS <= nYMax; iYS++ ) + { + if( panThisProfile[iYS] != DTED_NODATA_VALUE ) + { + int iXK, iYK; + float fKernelCoef; + + iXK = iXS - iX + nPixelSearchDist; + iYK = iYS - iY + nPixelSearchDist; + + fKernelCoef = pafKernel[iXK + iYK * nKernelWidth]; + dfCoefSum += fKernelCoef; + dfValueSum += fKernelCoef * panThisProfile[iYS]; + } + } + } + + if( dfCoefSum == 0.0 ) + papanDstProfiles[iX][iY] = DTED_NODATA_VALUE; + else + papanDstProfiles[iX][iY] = + (GInt16) floor(dfValueSum / dfCoefSum + 0.5); +} + +/************************************************************************/ +/* DTEDFillPtStream() */ +/* */ +/* Apply simple inverse distance interpolator to all no-data */ +/* pixels based on available values within the indicated search */ +/* distance (rectangular). */ +/************************************************************************/ + +void DTEDFillPtStream( void *hStream, int nPixelSearchDist ) + +{ + DTEDPtStream *psStream = (DTEDPtStream *) hStream; + int iFile, nKernelWidth; + float *pafKernel; + int iX, iY; + +/* -------------------------------------------------------------------- */ +/* Setup inverse distance weighting kernel. */ +/* -------------------------------------------------------------------- */ + nKernelWidth = 2 * nPixelSearchDist + 1; + pafKernel = (float *) CPLMalloc(nKernelWidth*nKernelWidth*sizeof(float)); + + for( iX = 0; iX < nKernelWidth; iX++ ) + { + for( iY = 0; iY < nKernelWidth; iY++ ) + { + pafKernel[iX + iY * nKernelWidth] = (float) (1.0 / + sqrt( (nPixelSearchDist-iX) * (nPixelSearchDist-iX) + + (nPixelSearchDist-iY) * (nPixelSearchDist-iY) )); + } + } + +/* ==================================================================== */ +/* Process each cached file. */ +/* ==================================================================== */ + for( iFile = 0; iFile < psStream->nOpenFiles; iFile++ ) + { + DTEDInfo *psInfo = psStream->pasCF[iFile].psInfo; + GInt16 **papanProfiles = psStream->pasCF[iFile].papanProfiles; + GInt16 **papanDstProfiles; + + papanDstProfiles = (GInt16 **) + CPLCalloc(sizeof(GInt16*),psInfo->nXSize); + +/* -------------------------------------------------------------------- */ +/* Setup output image. */ +/* -------------------------------------------------------------------- */ + for( iX = 0; iX < psInfo->nXSize; iX++ ) + { + papanDstProfiles[iX] = (GInt16 *) + CPLMalloc(sizeof(GInt16) * psInfo->nYSize); + } + +/* -------------------------------------------------------------------- */ +/* Interpolate all missing values, and copy over available values. */ +/* -------------------------------------------------------------------- */ + for( iX = 0; iX < psInfo->nXSize; iX++ ) + { + for( iY = 0; iY < psInfo->nYSize; iY++ ) + { + if( papanProfiles[iX] == NULL + || papanProfiles[iX][iY] == DTED_NODATA_VALUE ) + { + DTEDFillPixel( psInfo, papanProfiles, papanDstProfiles, + iX, iY, nPixelSearchDist, pafKernel ); + } + else + { + papanDstProfiles[iX][iY] = papanProfiles[iX][iY]; + } + } + } +/* -------------------------------------------------------------------- */ +/* Push new values back into cache. */ +/* -------------------------------------------------------------------- */ + for( iX = 0; iX < psInfo->nXSize; iX++ ) + { + CPLFree( papanProfiles[iX] ); + papanProfiles[iX] = papanDstProfiles[iX]; + } + + CPLFree( papanDstProfiles ); + } + + CPLFree( pafKernel ); +} + +/************************************************************************/ +/* DTEDPtStreamSetMetadata() */ +/************************************************************************/ + +void DTEDPtStreamSetMetadata( void *hStream, DTEDMetaDataCode eCode, + const char *pszValue ) + +{ + DTEDPtStream *psStream = (DTEDPtStream *) hStream; + + if( eCode >= 0 && eCode < DTEDMD_MAX+1 ) + { + CPLFree( psStream->apszMetadata[eCode] ); + psStream->apszMetadata[eCode] = CPLStrdup( pszValue ); + } +} + +/************************************************************************/ +/* DTEDPtStreamTrimEdgeOnlyTiles() */ +/* */ +/* Erase all tiles that only have boundary values set. */ +/************************************************************************/ + +void DTEDPtStreamTrimEdgeOnlyTiles( void *hStream ) + +{ + DTEDPtStream *psStream = (DTEDPtStream *) hStream; + int iFile; + + for( iFile = psStream->nOpenFiles-1; iFile >= 0; iFile-- ) + { + DTEDInfo *psInfo = psStream->pasCF[iFile].psInfo; + GInt16 **papanProfiles = psStream->pasCF[iFile].papanProfiles; + int iProfile, iPixel, bGotNonEdgeData = FALSE; + + for( iProfile = 1; iProfile < psInfo->nXSize-1; iProfile++ ) + { + if( papanProfiles[iProfile] == NULL ) + continue; + + for( iPixel = 1; iPixel < psInfo->nYSize-1; iPixel++ ) + { + if( papanProfiles[iProfile][iPixel] != DTED_NODATA_VALUE ) + { + bGotNonEdgeData = TRUE; + break; + } + } + } + + if( bGotNonEdgeData ) + continue; + + /* Remove this tile */ + + for( iProfile = 0; iProfile < psInfo->nXSize; iProfile++ ) + { + if( papanProfiles[iProfile] != NULL ) + CPLFree( papanProfiles[iProfile] ); + } + CPLFree( papanProfiles ); + + DTEDClose( psInfo ); + + VSIUnlink( psStream->pasCF[iFile].pszFilename ); + CPLFree( psStream->pasCF[iFile].pszFilename ); + + memmove( psStream->pasCF + iFile, + psStream->pasCF + iFile + 1, + sizeof(DTEDCachedFile) * (psStream->nOpenFiles-iFile-1) ); + psStream->nOpenFiles--; + } +} diff --git a/Utilities/GDAL/frmts/dted/dted_test.c b/Utilities/GDAL/frmts/dted/dted_test.c new file mode 100644 index 0000000000..44748a50f4 --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dted_test.c @@ -0,0 +1,145 @@ +/****************************************************************************** + * $Id$ + * + * Project: DTED Translator + * Purpose: Test mainline for DTED writer. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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. + *****************************************************************************/ + +#include "gdal.h" +#include "dted_api.h" + +/************************************************************************/ +/* Usage() */ +/************************************************************************/ + +static void Usage() + +{ + printf( "Usage: dted_test [-trim] [-fill n] [-level n] <in_file> [<out_level>]\n" ); + exit(0); +} + +/************************************************************************/ +/* main() */ +/************************************************************************/ +int main( int argc, char ** argv ) + +{ + GDALDatasetH hSrcDS; + int iY, iX, nOutLevel=0, nXSize, nYSize, iArg, nFillDist=0; + void *pStream; + GInt16 *panData; + const char *pszFilename = NULL; + GDALRasterBandH hSrcBand; + double adfGeoTransform[6]; + int bEnableTrim = FALSE; + +/* -------------------------------------------------------------------- */ +/* Identify arguments. */ +/* -------------------------------------------------------------------- */ + + for( iArg = 1; iArg < argc; iArg++ ) + { + if( EQUAL(argv[iArg],"-trim") ) + bEnableTrim = TRUE; + + else if( EQUAL(argv[iArg],"-fill") ) + nFillDist = atoi(argv[++iArg]); + + else if( EQUAL(argv[iArg],"-level") ) + nOutLevel = atoi(argv[++iArg]); + else + { + if( pszFilename != NULL ) + Usage(); + pszFilename = argv[iArg]; + } + } + + if( pszFilename == NULL ) + Usage(); + +/* -------------------------------------------------------------------- */ +/* Open input file. */ +/* -------------------------------------------------------------------- */ + GDALAllRegister(); + hSrcDS = GDALOpen( pszFilename, GA_ReadOnly ); + if( hSrcDS == NULL ) + exit(1); + + hSrcBand = GDALGetRasterBand( hSrcDS, 1 ); + + nXSize = GDALGetRasterXSize( hSrcDS ); + nYSize = GDALGetRasterYSize( hSrcDS ); + + GDALGetGeoTransform( hSrcDS, adfGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Create output stream. */ +/* -------------------------------------------------------------------- */ + pStream = DTEDCreatePtStream( ".", nOutLevel ); + + if( pStream == NULL ) + exit( 1 ); + +/* -------------------------------------------------------------------- */ +/* Process all the profiles. */ +/* -------------------------------------------------------------------- */ + panData = (GInt16 *) malloc(sizeof(GInt16) * nXSize); + + for( iY = 0; iY < nYSize; iY++ ) + { + GDALRasterIO( hSrcBand, GF_Read, 0, iY, nXSize, 1, + panData, nXSize, 1, GDT_Int16, 0, 0 ); + + for( iX = 0; iX < nXSize; iX++ ) + { + DTEDWritePt( pStream, + adfGeoTransform[0] + + adfGeoTransform[1] * (iX + 0.5) + + adfGeoTransform[2] * (iY + 0.5), + adfGeoTransform[3] + + adfGeoTransform[4] * (iX + 0.5) + + adfGeoTransform[5] * (iY + 0.5), + panData[iX] ); + } + } + + free( panData ); + +/* -------------------------------------------------------------------- */ +/* Cleanup. */ +/* -------------------------------------------------------------------- */ + if( bEnableTrim ) + DTEDPtStreamTrimEdgeOnlyTiles( pStream ); + + if( nFillDist > 0 ) + DTEDFillPtStream( pStream, nFillDist ); + + DTEDClosePtStream( pStream ); + GDALClose( hSrcDS ); + + exit( 0 ); +} diff --git a/Utilities/GDAL/frmts/dted/dteddataset.cpp b/Utilities/GDAL/frmts/dted/dteddataset.cpp new file mode 100644 index 0000000000..ee96926a42 --- /dev/null +++ b/Utilities/GDAL/frmts/dted/dteddataset.cpp @@ -0,0 +1,626 @@ +/****************************************************************************** + * $Id: dteddataset.cpp,v 1.18 2006/04/04 01:00:44 fwarmerdam Exp $ + * + * Project: DTED Translator + * Purpose: GDALDataset driver for DTED translator. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: dteddataset.cpp,v $ + * Revision 1.18 2006/04/04 01:00:44 fwarmerdam + * updated contact info + * + * Revision 1.17 2006/03/27 14:52:46 fwarmerdam + * Added overview support. + * + * Revision 1.16 2005/05/05 14:01:36 fwarmerdam + * PAM Enable + * + * Revision 1.15 2005/04/15 19:28:57 fwarmerdam + * added AREA_OR_POINT=Point metadata + * + * Revision 1.14 2004/01/30 18:27:25 gwalter + * Fixed bug in tile sizing. + * + * Revision 1.13 2004/01/29 23:35:22 gwalter + * Add a few more metadata fields, make sure that + * nodata value is recognized. + * + * Revision 1.12 2003/05/30 16:17:21 warmerda + * fix warnings with casting and unused parameters + * + * Revision 1.11 2002/11/23 18:54:17 warmerda + * added CREATIONDATATYPES metadata for drivers + * + * Revision 1.10 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.9 2002/06/12 21:12:24 warmerda + * update to metadata based driver info + * + * Revision 1.8 2002/03/05 14:26:01 warmerda + * expanded tabs + * + * Revision 1.7 2002/01/26 05:51:40 warmerda + * added metadata read/write support + * + * Revision 1.6 2001/11/13 15:43:41 warmerda + * preliminary dted creation working + * + * Revision 1.5 2001/11/11 23:50:59 warmerda + * added required class keyword to friend declarations + * + * Revision 1.4 2001/07/18 04:51:56 warmerda + * added CPL_CVSID + * + * Revision 1.3 2000/02/28 16:32:20 warmerda + * use SetBand method + * + * Revision 1.2 2000/01/12 19:43:17 warmerda + * Don't open dataset twice in Open(). + * + * Revision 1.1 1999/12/07 18:01:28 warmerda + * New + * + */ + +#include "dted_api.h" +#include "gdal_pam.h" + +CPL_CVSID("$Id: dteddataset.cpp,v 1.18 2006/04/04 01:00:44 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_DTED(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* DTEDDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class DTEDRasterBand; + +class DTEDDataset : public GDALPamDataset +{ + friend class DTEDRasterBand; + + DTEDInfo *psDTED; + + public: + virtual ~DTEDDataset(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr GetGeoTransform( double * ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* DTEDRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class DTEDRasterBand : public GDALPamRasterBand +{ + friend class DTEDDataset; + + int bNoDataSet; + double dfNoDataValue; + + public: + + DTEDRasterBand( DTEDDataset *, int ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); +}; + + +/************************************************************************/ +/* DTEDRasterBand() */ +/************************************************************************/ + +DTEDRasterBand::DTEDRasterBand( DTEDDataset *poDS, int nBand ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + eDataType = GDT_Int16; + + bNoDataSet = TRUE; + dfNoDataValue = (double) DTED_NODATA_VALUE; + + nBlockXSize = 1; + nBlockYSize = poDS->GetRasterYSize();; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr DTEDRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + DTEDDataset *poDTED_DS = (DTEDDataset *) poDS; + int nYSize = poDTED_DS->psDTED->nYSize; + GInt16 *panData; + + (void) nBlockXOff; + CPLAssert( nBlockYOff == 0 ); + +/* -------------------------------------------------------------------- */ +/* Read the data. */ +/* -------------------------------------------------------------------- */ + panData = (GInt16 *) pImage; + if( !DTEDReadProfile( poDTED_DS->psDTED, nBlockXOff, panData ) ) + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Flip line to orient it top to bottom instead of bottom to */ +/* top. */ +/* -------------------------------------------------------------------- */ + for( int i = nYSize/2; i >= 0; i-- ) + { + GInt16 nTemp; + + nTemp = panData[i]; + panData[i] = panData[nYSize - i - 1]; + panData[nYSize - i - 1] = nTemp; + } + + return CE_None; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double DTEDRasterBand::GetNoDataValue( int * pbSuccess ) + +{ + if( pbSuccess ) + *pbSuccess = bNoDataSet; + + return dfNoDataValue; +} + +/************************************************************************/ +/* ~DTEDDataset() */ +/************************************************************************/ + +DTEDDataset::~DTEDDataset() + +{ + FlushCache(); + if( psDTED != NULL ) + DTEDClose( psDTED ); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *DTEDDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i; + DTEDInfo *psDTED; + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + psDTED = DTEDOpen( poOpenInfo->pszFilename, "rb", TRUE ); + + if( psDTED == NULL ) + return( NULL ); + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + DTEDDataset *poDS; + + poDS = new DTEDDataset(); + + poDS->psDTED = psDTED; + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = psDTED->nXSize; + poDS->nRasterYSize = psDTED->nYSize; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = 1;; + for( i = 0; i < poDS->nBands; i++ ) + poDS->SetBand( i+1, new DTEDRasterBand( poDS, i+1 ) ); + +/* -------------------------------------------------------------------- */ +/* Collect any metadata available. */ +/* -------------------------------------------------------------------- */ + char *pszValue; + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTACCURACY_UHL ); + poDS->SetMetadataItem( "DTED_VerticalAccuracy_UHL", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTACCURACY_ACC ); + poDS->SetMetadataItem( "DTED_VerticalAccuracy_ACC", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_SECURITYCODE_UHL ); + poDS->SetMetadataItem( "DTED_SecurityCode_UHL", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_SECURITYCODE_DSI ); + poDS->SetMetadataItem( "DTED_SecurityCode_DSI", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_UNIQUEREF_UHL ); + poDS->SetMetadataItem( "DTED_UniqueRef_UHL", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_UNIQUEREF_DSI ); + poDS->SetMetadataItem( "DTED_UniqueRef_DSI", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_DATA_EDITION ); + poDS->SetMetadataItem( "DTED_DataEdition", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_VERSION ); + poDS->SetMetadataItem( "DTED_MatchMergeVersion", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DATE ); + poDS->SetMetadataItem( "DTED_MaintenanceDate", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_DATE ); + poDS->SetMetadataItem( "DTED_MatchMergeDate", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DESCRIPTION ); + poDS->SetMetadataItem( "DTED_MaintenanceDescription", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_PRODUCER ); + poDS->SetMetadataItem( "DTED_Producer", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTDATUM ); + poDS->SetMetadataItem( "DTED_VerticalDatum", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_DIGITIZING_SYS ); + poDS->SetMetadataItem( "DTED_DigitizingSystem", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_COMPILATION_DATE ); + poDS->SetMetadataItem( "DTED_CompilationDate", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_HORIZACCURACY ); + poDS->SetMetadataItem( "DTED_HorizontalAccuracy", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_HORIZACCURACY ); + poDS->SetMetadataItem( "DTED_RelHorizontalAccuracy", pszValue ); + CPLFree( pszValue ); + + pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_VERTACCURACY ); + poDS->SetMetadataItem( "DTED_RelVerticalAccuracy", pszValue ); + CPLFree( pszValue ); + + poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT ); + +/* -------------------------------------------------------------------- */ +/* Support overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + + return( poDS ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr DTEDDataset::GetGeoTransform( double * padfTransform ) + +{ + padfTransform[0] = psDTED->dfULCornerX; + padfTransform[1] = psDTED->dfPixelSizeX; + padfTransform[2] = 0.0; + padfTransform[3] = psDTED->dfULCornerY; + padfTransform[4] = 0.0; + padfTransform[5] = psDTED->dfPixelSizeY * -1; + + return( CE_None ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *DTEDDataset::GetProjectionRef() + +{ + return( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" ); +} + +/************************************************************************/ +/* DTEDCreateCopy() */ +/* */ +/* For now we will assume the input is exactly one proper */ +/* cell. */ +/************************************************************************/ + +static GDALDataset * +DTEDCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + (void) pProgressData; + (void) pfnProgress; + (void) papszOptions; + (void) bStrict; + +/* -------------------------------------------------------------------- */ +/* Work out the level. */ +/* -------------------------------------------------------------------- */ + int nLevel; + + if( poSrcDS->GetRasterYSize() == 121 ) + nLevel = 0; + else if( poSrcDS->GetRasterYSize() == 1201 ) + nLevel = 1; + else if( poSrcDS->GetRasterYSize() == 3601 ) + nLevel = 2; + else + { + CPLError( CE_Warning, CPLE_AppDefined, + "The source does not appear to be a properly formatted cell." ); + nLevel = 1; + } + +/* -------------------------------------------------------------------- */ +/* Work out the LL origin. */ +/* -------------------------------------------------------------------- */ + int nLLOriginLat, nLLOriginLong; + double adfGeoTransform[6]; + + poSrcDS->GetGeoTransform( adfGeoTransform ); + + nLLOriginLat = (int) + floor(adfGeoTransform[3] + + poSrcDS->GetRasterYSize() * adfGeoTransform[5] + 0.5); + + nLLOriginLong = (int) floor(adfGeoTransform[0] + 0.5); + +/* -------------------------------------------------------------------- */ +/* Create the output dted file. */ +/* -------------------------------------------------------------------- */ + const char *pszError; + + pszError = DTEDCreate( pszFilename, nLevel, nLLOriginLat, nLLOriginLong ); + + if( pszError != NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s", pszError ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Open the DTED file so we can output the data to it. */ +/* -------------------------------------------------------------------- */ + DTEDInfo *psDTED; + + psDTED = DTEDOpen( pszFilename, "rb+", FALSE ); + if( psDTED == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Read all the data in one dollup. */ +/* -------------------------------------------------------------------- */ + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( 1 ); + GInt16 *panData; + + panData = (GInt16 *) + CPLMalloc(sizeof(GInt16) * psDTED->nXSize * psDTED->nYSize); + + poSrcBand->RasterIO( GF_Read, 0, 0, psDTED->nXSize, psDTED->nYSize, + (void *) panData, psDTED->nXSize, psDTED->nYSize, + GDT_Int16, 0, 0 ); + +/* -------------------------------------------------------------------- */ +/* Write all the profiles. */ +/* -------------------------------------------------------------------- */ + GInt16 anProfData[3601]; + double dfNodataCount=0.0; + GByte iPartialCell; + + for( int iProfile = 0; iProfile < psDTED->nXSize; iProfile++ ) + { + for( int iY = 0; iY < psDTED->nYSize; iY++ ) + { + anProfData[iY] = panData[iProfile + iY * psDTED->nXSize]; + if ( anProfData[iY] == DTED_NODATA_VALUE ) + dfNodataCount = dfNodataCount+1.0; + } + DTEDWriteProfile( psDTED, iProfile, anProfData ); + } + CPLFree( panData ); + +/* -------------------------------------------------------------------- */ +/* Partial cell indicator: 0 for complete coverage; 1-99 for incomplete */ +/* -------------------------------------------------------------------- */ + char pszPartialCell[2]; + + if ( dfNodataCount < 0.5 ) + iPartialCell = 0; + else + { + iPartialCell = int(floor(100.0 - + (dfNodataCount*100.0/(psDTED->nXSize * psDTED->nYSize)))); + if (iPartialCell < 1) + iPartialCell=1; + } + sprintf(pszPartialCell,"%02d",iPartialCell); + strncpy((char *) (psDTED->pachDSIRecord+289), pszPartialCell, 2 ); + +/* -------------------------------------------------------------------- */ +/* Try to copy any matching available metadata. */ +/* -------------------------------------------------------------------- */ + if( poSrcDS->GetMetadataItem( "DTED_VerticalAccuracy_UHL" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_VERTACCURACY_UHL, + poSrcDS->GetMetadataItem( "DTED_VerticalAccuracy_UHL" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_VerticalAccuracy_ACC" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_VERTACCURACY_ACC, + poSrcDS->GetMetadataItem( "DTED_VerticalAccuracy_ACC" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_SecurityCode_UHL" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_SECURITYCODE_UHL, + poSrcDS->GetMetadataItem( "DTED_SecurityCode_UHL" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_SecurityCode_DSI" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_SECURITYCODE_DSI, + poSrcDS->GetMetadataItem( "DTED_SecurityCode_DSI" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_UniqueRef_UHL" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_UNIQUEREF_UHL, + poSrcDS->GetMetadataItem( "DTED_UniqueRef_UHL" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_UniqueRef_DSI" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_UNIQUEREF_DSI, + poSrcDS->GetMetadataItem( "DTED_UniqueRef_DSI" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_DataEdition" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_DATA_EDITION, + poSrcDS->GetMetadataItem( "DTED_DataEdition" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_MatchMergeVersion" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_MATCHMERGE_VERSION, + poSrcDS->GetMetadataItem( "DTED_MatchMergeVersion" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_MaintenanceDate" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_MAINT_DATE, + poSrcDS->GetMetadataItem( "DTED_MaintenanceDate" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_MatchMergeDate" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_MATCHMERGE_DATE, + poSrcDS->GetMetadataItem( "DTED_MatchMergeDate" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_MaintenanceDescription" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_MAINT_DESCRIPTION, + poSrcDS->GetMetadataItem( "DTED_MaintenanceDescription" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_Producer" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_PRODUCER, + poSrcDS->GetMetadataItem( "DTED_Producer" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_VerticalDatum" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_VERTDATUM, + poSrcDS->GetMetadataItem( "DTED_VerticalDatum" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_DigitizingSystem" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_DIGITIZING_SYS, + poSrcDS->GetMetadataItem( "DTED_DigitizingSystem" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_CompilationDate" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_COMPILATION_DATE, + poSrcDS->GetMetadataItem( "DTED_CompilationDate" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_HorizontalAccuracy" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_HORIZACCURACY, + poSrcDS->GetMetadataItem( "DTED_HorizontalAccuracy" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_RelHorizontalAccuracy" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_REL_HORIZACCURACY, + poSrcDS->GetMetadataItem( "DTED_RelHorizontalAccuracy" ) ); + + if( poSrcDS->GetMetadataItem( "DTED_RelVerticalAccuracy" ) != NULL ) + DTEDSetMetadata( psDTED, DTEDMD_REL_VERTACCURACY, + poSrcDS->GetMetadataItem( "DTED_RelVerticalAccuracy" ) ); + +/* -------------------------------------------------------------------- */ +/* Try to open the resulting DTED file. */ +/* -------------------------------------------------------------------- */ + DTEDClose( psDTED ); + +/* -------------------------------------------------------------------- */ +/* Reopen and copy missing information into a PAM file. */ +/* -------------------------------------------------------------------- */ + GDALPamDataset *poDS = (GDALPamDataset *) + GDALOpen( pszFilename, GA_ReadOnly ); + + if( poDS ) + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + +/************************************************************************/ +/* GDALRegister_DTED() */ +/************************************************************************/ + +void GDALRegister_DTED() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "DTED" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "DTED" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "DTED Elevation Raster" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#DTED" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16" ); + + poDriver->pfnOpen = DTEDDataset::Open; + poDriver->pfnCreateCopy = DTEDCreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/dted/frmt_dted.html b/Utilities/GDAL/frmts/dted/frmt_dted.html new file mode 100644 index 0000000000..b5653bccbf --- /dev/null +++ b/Utilities/GDAL/frmts/dted/frmt_dted.html @@ -0,0 +1,30 @@ +<html> +<head> +<title>DTED -- Military Elevation Data</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>DTED -- Military Elevation Data</h1> + +GDAL supports DTED Levels 0, 1, and 2 elevation data for read access. +Elevation data is returned as 16 bit signed integer. Appropriate +projection (always WGS84) and georeferencing information is also returned. +A variety of header fields are returned dataset level metadata. +<p> + +<h2>Creation Issues</h2> + +The DTED driver does support creating new files, but the input data +must be exactly formatted as a Level 0, 1 or 2 cell. That is the size, +and bounds must be appropriate for a cell.<P> + +<h2>See Also:</h2> + +<ul> +<li> Implemented as <tt>gdal/frmts/dted/dteddataset.cpp</tt>.<p> + +</ul> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/dted/makefile.vc b/Utilities/GDAL/frmts/dted/makefile.vc new file mode 100644 index 0000000000..26790f3c12 --- /dev/null +++ b/Utilities/GDAL/frmts/dted/makefile.vc @@ -0,0 +1,18 @@ + +OBJ = dted_api.obj dteddataset.obj dted_create.obj dted_create.obj \ + dted_ptstream.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + +dted_test.exe: dted_test.obj $(OBJ) + cl dted_test.obj dted_api.obj dted_create.obj dted_ptstream.obj \ + ..\..\port\cpl.lib + diff --git a/Utilities/GDAL/frmts/formats_list.html b/Utilities/GDAL/frmts/formats_list.html new file mode 100644 index 0000000000..0f30f18137 --- /dev/null +++ b/Utilities/GDAL/frmts/formats_list.html @@ -0,0 +1,441 @@ +<html> +<head> +<title>GDAL Raster Formats</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>GDAL Raster Formats</h1> + +<table border> + +<tr> +<th>Long Format Name</th> +<th>Code</th> +<th>Creation</th> +<th>Georeferencing</th> +<th>Maximum file size<sup><a href="#footnote1">1</a></sup></th> +</tr> + +<tr><td> <a href="frmt_various.html#AAIGrid">Arc/Info ASCII Grid</a> +</td><td> AAIGrid +</td><td> Yes +</td><td> Yes +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_various.html#AIG">Arc/Info Binary Grid (.adf)</a> +</td><td> AIG +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_airsar.html">AIRSAR Polarimetric</a> +</td><td> AIRSAR +</td><td> No +</td><td> No +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_bmp.html">Microsoft Windows Device Independent Bitmap (.bmp)</a> +</td><td> BMP +</td><td> Yes +</td><td> Yes +</td><td> 4GiB +</td></tr> + +<tr><td> <a href="frmt_various.html#BSB">BSB Nautical Chart Format (.kap)</a> +</td><td> BSB +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#BT">VTP Binary Terrain Format (.bt)</a> +</td><td> BT +</td><td> Yes +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#CEOS">CEOS (Spot for instance)</a> +</td><td> CEOS +</td><td> No +</td><td> No +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#DOQ1">First Generation USGS DOQ (.doq)</a> +</td><td> DOQ1 +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_dods.html">DODS / OPeNDAP</a> +</td><td> DODS +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#DOQ2">New Labelled USGS DOQ (.doq)</a> +</td><td> DOQ2 +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_dted.html">Military Elevation Data (.dt0, .dt1)</a> +</td><td> DTED +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_ecw.html">ERMapper Compressed Wavelets (.ecw)</a> +</td><td> ECW +</td><td> Yes +</td><td> Yes +</td><td> +</td></tr> + +<tr><td> <a href="frmt_various.html#EHdr">ESRI .hdr Labelled</a> +</td><td> EHdr +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_various.html#ENVI">ENVI .hdr Labelled Raster</a> +</td><td> ENVI +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_various.html#Envisat">Envisat Image Product (.n1)</a> +</td><td> Envisat +</td><td> No +</td><td> No +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_fast.html">EOSAT FAST Format</a> +</td><td> FAST +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#FITS">FITS (.fits)</a> +</td><td> FITS +</td><td> Yes +</td><td> No +</td><td> +</td></tr> + +<tr><td> <a href="frmt_gif.html">Graphics Interchange Format (.gif)</a> +</td><td> GIF +</td><td> Yes +</td><td> No +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_various.html#GMT">GMT Compatible netCDF</a> +</td><td> GMT +</td><td> No +</td><td> Yes +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_grass.html">GRASS Rasters</a> +</td><td> GRASS +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_gtiff.html">TIFF / GeoTIFF (.tif)</a> +</td><td> GTiff +</td><td> Yes +</td><td> Yes +</td><td> 4GiB +</td></tr> + +<tr><td> <a href="frmt_hdf4.html">Hierarchical Data Format Release 4 (HDF4)</a> +</td><td> HDF4 +</td><td> Yes +</td><td> Yes +</td><td> 2GiB +</td></tr> + +<tr><td> <a href="frmt_hdf4.html">Hierarchical Data Format Release 5 (HDF5)</a> +</td><td> HDF5 +</td><td> Yes +</td><td> Yes +</td><td> 2GiB +</td></tr> + +<tr><td> <a href="frmt_hfa.html">Erdas Imagine (.img)</a> +</td><td> HFA +</td><td> Yes +</td><td> Yes +</td><td> No limits<sup><a href="#footnote2">2</a></sup> +</td></tr> + +<tr><td> <a href="frmt_mff2.html">Vexcel MFF2</a> +</td><td> HKV +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_Idrisi.html">Idrisi Raster</a> +</td><td> RST +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_various.html#IDA">Image Display and Analysis (WinDisp)</a> +</td><td> IDA +</td><td> Yes +</td><td> Yes +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_various.html#ILWIS">ILWIS Raster Map (.mpr,.mpl)</a> +</td><td> ILWIS +</td><td> Yes +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#JDEM">Japanese DEM (.mem)</a> +</td><td> JDEM +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_jpeg.html">JPEG JFIF (.jpg)</a> +</td><td> JPEG +</td><td> Yes +</td><td> Yes +</td><td> 4GiB (max dimentions 65500x65500) +</td></tr> + +<tr><td> <a href="frmt_jpeg2000.html">JPEG2000 (.jp2, .j2k)</a> +</td><td> JPEG2000 +</td><td> Yes +</td><td> Yes +</td><td> 2GiB +</td></tr> + +<tr><td> <a href="frmt_jp2kak.html">JPEG2000 (.jp2, .j2k)</a> +</td><td> JP2KAK +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_jp2ecw.html">JPEG2000 (.jp2, .j2k)</a> +</td><td> JP2ECW +</td><td> Yes +</td><td> Yes +</td><td> 500MB +</td></tr> + +<tr><td> <a href="frmt_jp2mrsid.html">JPEG2000 (.jp2, .j2k)</a> +</td><td> JP2MrSID +</td><td> Yes +</td><td> Yes +</td><td> +</td></tr> + +<tr><td> <a href="frmt_l1b.html">NOAA Polar Orbiter Level 1b Data Set (AVHRR)</a> +</td><td> L1B +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#LAN">Erdas 7.x .LAN and .GIS</a> +</td><td> LAN +</td><td> No +</td><td> Yes +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_leveller.html">Daylon Leveller Heightfield</a> +</td><td> Leveller +</td><td> Yes +</td><td> No +</td><td> +</td></tr> + +<tr><td> <a href="frmt_mem.html">In Memory Raster</a> +</td><td> MEM +</td><td> Yes +</td><td> Yes +</td><td> 2GiB +</td></tr> + +<tr><td> <a href="frmt_various.html#MFF">Vexcel MFF</a> +</td><td> MFF +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_mrsid.html">Multi-resolution Seamless Image Database</a> +</td><td> MrSID +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_msg.html">Meteosat Second Generation</a> +</td><td> MSG +</td><td> No +</td><td> Yes +</td><td> +</td></tr> + +<tr><td> <a href="frmt_various.html#NDF">NDF</a> +</td><td> NLAPS Data Format +</td><td> No +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_nitf.html">NITF</a> +</td><td> NITF +</td><td> Yes +</td><td> Yes +</td><td> 4GB +</td></tr> + +<tr><td> <a href="frmt_various.html#netCDF">NetCDF</a> +</td><td> netCDF +</td><td> No +</td><td> Yes +</td><td> 2GB +</td></tr> + +<tr><td> <a href="frmt_ogdi.html">OGDI Bridge</a> +</td><td> OGDI +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#PAux">PCI .aux Labelled</a> +</td><td> PAux +</td><td> Yes +</td><td> No +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_pcidsk.html">PCI Geomatics Database File</a> +</td><td> PCIDSK +</td><td> Yes +</td><td> Yes +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_various.html#PNG">Portable Network Graphics (.png)</a> +</td><td> PNG +</td><td> Yes +</td><td> No +</td><td> +</td></tr> + +<tr><td> <a href="frmt_various.html#PCRaster">PCRaster (.map)</a> +</td><td> PCRaster +</td><td> Yes +</td><td> Yes +</td><td> +</td></tr> + +<tr><td> <a href="frmt_various.html#PNM">Netpbm (.ppm,.pgm)</a> +</td><td> PNM +</td><td> Yes +</td><td> No +</td><td> No limits +</td></tr> + +<tr><td> <a href="frmt_rik.html">Swedish Grid RIK (.rik)</a> +</td><td> RIK +</td><td> No +</td><td> Yes +</td><td> 4GB +</td></tr> + +<tr><td> <a href="frmt_rs2.html">RadarSat2 XML (product.xml)</a> +</td><td> RS2 +</td><td> No +</td><td> Yes +</td><td> 4GB +</td></tr> + +<tr><td> <a href="frmt_various.html#SDTS">USGS SDTS DEM (*CATD.DDF)</a> +</td><td> SDTS +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_rmf.html">Raster Matrix Format (*.rsw, .mtw)</a> +</td><td> RMF +</td><td> Yes +</td><td> Yes +</td><td> 4GB +</td></tr> + +<tr><td> <a href="frmt_various.html#SAR_CEOS">SAR CEOS</a> +</td><td> SAR_CEOS +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#SGI">SGI Image Format</a> +</td><td> SGI +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_usgsdem.html">USGS ASCII DEM (.dem)</a> +</td><td> USGSDEM +</td><td> No +</td><td> Yes +</td><td> -- +</td></tr> + +<tr><td> <a href="frmt_various.html#XPM">X11 Pixmap (.xpm)</a> +</td><td> XPM +</td><td> Yes +</td><td> No +</td><td> +</td></tr> + +</table> + +<p> +<a name="#footnote1"><sup>1</sup>Maximum file size does not only determined by + the file format itself, but operating system/file system capabilities + as well. Look <a href="gdal_building.html#gdal_building_lfs">here</a> + for details.</a> +<p> +<a name="#footnote2"><sup>2</sup>ERDAS Imagine has different file format for + large files, where 32-bit pointers cannot be used. Look for details + <a href="frmt_hfa.html">here</a>. + +</body> +</html> + + diff --git a/Utilities/GDAL/frmts/hdf4/GNUmakefile b/Utilities/GDAL/frmts/hdf4/GNUmakefile new file mode 100644 index 0000000000..f75356873d --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/GNUmakefile @@ -0,0 +1,26 @@ + +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/hdf4/frmt_hdf4.html b/Utilities/GDAL/frmts/hdf4/frmt_hdf4.html new file mode 100644 index 0000000000..48c44b691a --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/frmt_hdf4.html @@ -0,0 +1,272 @@ +<!-- $Id: frmt_hdf4.html,v 1.11 2004/12/26 15:55:38 fwarmerdam Exp $ --> + +<html> +<head> +<title>HDF4 --- Hierarchical Data Format Release 4 (HDF4)</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>HDF4 --- Hierarchical Data Format Release 4 (HDF4)</h1> + +There are two HDF formats, HDF4 (4.x and previous releases) and HDF5. +These formats are completely different and NOT compatible. This driver +intended for HDF4 file formats importing. NASA's Earth Observing System (EOS) +maintains its own HDF modification called HDF-EOS. This modification is +suited for use with remote sensing data and fully compatible with +underlying HDF. This driver can import HDF4-EOS files. Currently EOS use +HDF4-EOS for data storing (telemetry form `Terra' and `Aqua' satellites). In +the future they will switch to HDF5-EOS format, which will be used for +telemetry from `Aura' satellite.<p> + +<h2>Multiple Image Handling (Subdatasets)</h2> + +Hierarchical Data Format is a container for several different datasets. +For data storing Scientific Datasets (SDS) used most often. SDS is a +multidimensional array filled by data. One HDF file may contain several +different SDS arrays. They may differ in size, number of dimensions and may +represent data for different regions.<p> + +If the file contains only one SDS that appears to be an image, it may be +accessed normally, but if it contains multiple images it may be necessary to +import the file via a two step process. The first step is to get a report +of the components images (SDS arrays) in the file using <b>gdalinfo</b>, and +then to import the desired images using gdal_translate. + +The <b>gdalinfo</b> utility lists all multidimensional subdatasets from the +input HDF file. The name of individual images (subdatasets) are assigned to +the <b>SUBDATASET_n_NAME</b> metadata item. The description for each image is +found in the <b>SUBDATASET_n_DESC</b> metadata item. For HDF4 images the +subdataset names will be formatted like this:<p> + +<i>HDF4_SDS:subdataset_type:file_name:subdataset_index</i><p> + +where <i>subdataset_type</i> shows predefined names for some of the well +known HDF datasets, <i>file_name</i> is the name of the input file, and +<i>subdataset_index</i> is the index of the image to use (for internal use in +GDAL).<p> + +On the second step you should provide this name for <b>gdalinfo</b> or +<b>gdal_translate</b> for actual reading of the data.<p> + +For example, we want to read data from the MODIS Level 1B dataset:<p> +<pre> +$ gdalinfo GSUB1.A2001124.0855.003.200219309451.hdf +Driver: HDF4/Hierarchical Data Format Release 4 +Size is 512, 512 +Coordinate System is `' +Metadata: + HDFEOSVersion=HDFEOS_V2.7 + Number of Scans=204 + Number of Day mode scans=204 + Number of Night mode scans=0 + Incomplete Scans=0 +</pre> +...a lot of metadata output skipped...<p> +<pre> +Subdatasets: + SUBDATASET_1_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:0 + SUBDATASET_1_DESC=[408x271] Latitude (32-bit floating-point) + SUBDATASET_2_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:1 + SUBDATASET_2_DESC=[408x271] Longitude (32-bit floating-point) + SUBDATASET_3_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:2 + SUBDATASET_3_DESC=[12x2040x1354] EV_1KM_RefSB (16-bit unsigned integer) + SUBDATASET_4_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:3 + SUBDATASET_4_DESC=[12x2040x1354] EV_1KM_RefSB_Uncert_Indexes (8-bit unsigned integer) + SUBDATASET_5_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:4 + SUBDATASET_5_DESC=[408x271] Height (16-bit integer) + SUBDATASET_6_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:5 + SUBDATASET_6_DESC=[408x271] SensorZenith (16-bit integer) + SUBDATASET_7_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:6 + SUBDATASET_7_DESC=[408x271] SensorAzimuth (16-bit integer) + SUBDATASET_8_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:7 + SUBDATASET_8_DESC=[408x271] Range (16-bit unsigned integer) + SUBDATASET_9_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:8 + SUBDATASET_9_DESC=[408x271] SolarZenith (16-bit integer) + SUBDATASET_10_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:9 + SUBDATASET_10_DESC=[408x271] SolarAzimuth (16-bit integer) + SUBDATASET_11_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:10 + SUBDATASET_11_DESC=[408x271] gflags (8-bit unsigned integer) + SUBDATASET_12_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:12 + SUBDATASET_12_DESC=[16x10] Noise in Thermal Detectors (8-bit unsigned integer) + SUBDATASET_13_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:13 + SUBDATASET_13_DESC=[16x10] Change in relative responses of thermal detectors (8-bit unsigned integer) + SUBDATASET_14_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:14 + SUBDATASET_14_DESC=[204x16x10] DC Restore Change for Thermal Bands (8-bit integer) + SUBDATASET_15_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:15 + SUBDATASET_15_DESC=[204x2x40] DC Restore Change for Reflective 250m Bands (8-bit integer) + SUBDATASET_16_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:16 + SUBDATASET_16_DESC=[204x5x20] DC Restore Change for Reflective 500m Bands (8-bit integer) + SUBDATASET_17_NAME=HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:17 + SUBDATASET_17_DESC=[204x15x10] DC Restore Change for Reflective 1km Bands (8-bit integer) +Corner Coordinates: +Upper Left ( 0.0, 0.0) +Lower Left ( 0.0, 512.0) +Upper Right ( 512.0, 0.0) +Lower Right ( 512.0, 512.0) +Center ( 256.0, 256.0) +</pre> + +Now select one of the subdatasets, described as +<tt>[12x2040x1354] EV_1KM_RefSB (16-bit unsigned integer)</tt>:<p> +<pre> +$ gdalinfo HDF4_SDS:MODIS_L1B:GSUB1.A2001124.0855.003.200219309451.hdf:2 +Driver: HDF4Image/HDF4 Internal Dataset +Size is 1354, 2040 +Coordinate System is `' +Metadata: + long_name=Earth View 1KM Reflective Solar Bands Scaled Integers +</pre> +...metadata skipped...<p> +<pre> +Corner Coordinates: +Upper Left ( 0.0, 0.0) +Lower Left ( 0.0, 2040.0) +Upper Right ( 1354.0, 0.0) +Lower Right ( 1354.0, 2040.0) +Center ( 677.0, 1020.0) +Band 1 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 2 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 3 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 4 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 5 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 6 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 7 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 8 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 9 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 10 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 11 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +Band 12 Block=1354x2040 Type=UInt16, ColorInterp=Undefined +</pre> + +Or you may use <b>gdal_translate</b> for reading image bands from this +dataset.<p> + +Note that you should provide exactly the contents of the line marked +<b>SUBDATASET_n_NAME</b> to GDAL, including the <b>HDF4_SDS:</b> prefix.<p> + +This driver is intended only for importing remote sensing and geospatial +datasets in form of raster images. If you want explore all data contained in +HDF file you should use another tools (you can find information about +different HDF tools using links at end of this page). + +<h2>Georeference</h2> + +There is no universal way of storing georeferencing in HDF files. However, +some product types have mechanisms for saving georeferencing, and some of +these are supported by GDAL. Currently supported are (<i>subdataset_type</i> +shown in parenthesis):<p> + +<ul> + <li> HDF4 files created by GDAL (<B>GDAL_HDF4</B>) + + <li> ASTER Level 1A (<B>ASTER_L1A</B>) + + <li> ASTER Level 1B (<B>ASTER_L1B</B>) + + <li> ASTER Level 2 (<B>ASTER_L2</B>) + + <li> ASTER DEM (<B>AST14DEM</B>) + + <li> MODIS Level 1B Earth View products (<B>MODIS_L1B</B>) + + <li> MODIS Level 3 products (<B>MODIS_L3</B>) + + <li> SeaWiFS Level 3 Standard Mapped Image Products (<B>SEAWIFS_L3</B>) +</ul> + +<h2>Creation Issues</h2> + +This driver supports creation of the HDF4 Scientific Datasets. You may create +set of 2D datasets (one per each input band) or single 3D dataset where the third +dimension represents band numbers. All metadata and band descriptions from +the input dataset are stored as HDF4 attributes. Projection information (if it +exists) and affine transformation coefficients also stored in form of +attributes. +Files, created by GDAL have the special attribute:<p> + +"Signature=Created with GDAL (http://www.remotesensing.org/gdal/)"<p> + +and are automatically recognised when read, so the projection info and +transformation matrix restored back.<p> + +Creation Options:<p> + +<ul> + <li> <b>RANK=n</b>: Create <b>n</b>-dimensional SDS. Currently only 2D + and 3D datasets supported. By default a 3-dimensional dataset will be + created.<p> + + <!--li> <b>COMPRESS=[RLE/HUFFMAN/DEFLATE/NONE]</b>: Set the compression + to use. <b>RLE</b> is Run-length encoding, <b>HUFFMAN</b> is adaptive + Huffman, <b>DEFLATE</b> is GZIP "deflation" (Lempel/Ziv-77 dictionary + coder). <b>NONE</b> is the default.<p--> + +</ul> + +<h2>Metadata</h2> + +All HDF4 attributes are transparently translated as GDAL metadata. In the HDF +file attributes may be assigned assigned to the whole file as well as to +particular subdatasets. + +<h2>Driver building</h2> + +This driver builded on top of NCSA HDF library, so you need one to compile +GDAL with HDF4 support. You may search your operating system distribution for +the precompiled binaries or download source code or binaries from the NCSA HDF +Home Page (see links below).<p> + +Please note, that NCSA HDF library compiled with several defaults which is +defined in <i>hlimits.h</i> file. For example, <i>hlimits.h</i> defines +the maximum number of opened files: + +<pre> +# define MAX_FILE 32 +</pre> + +If you need open more HDF4 files simultaneously you should change this value +and rebuild HDF4 library (and relink GDAL if using static HDF libraries).<p> + +<h2>See Also:</h2> + +<ul> +<li> Implemented as <tt>gdal/frmts/hdf4/hdf4dataset.cpp</tt> +and <tt>gdal/frmts/hdf4/hdf4imagedataset.cpp</tt>.<p> + +<li> <a href="http://hdf.ncsa.uiuc.edu/">The NCSA HDF Home Page</a> +at the +<a href="http://www.ncsa.uiuc.edu/"> +National Center for Supercomputing Applications +</a>.<p> + +<li> <a href="http://hdfeos.gsfc.nasa.gov/hdfeos/index.cfm"> +HDF-EOS tools and information center</a> +<p> + +<li> Sources of the data in HDF4 and HDF4-EOS formats: <p> +<a href="http://edcimswww.cr.usgs.gov/pub/imswelcome/"> +Earth Observing System Data Gateway</a> +</ul> + +Documentation to individual products, supported by this driver:<p> + +<ul> + +<li> <a href="http://edcdaac.usgs.gov/aster/ASTER_GeoRef_FINAL.pdf"> +Geo-Referencing ASTER L1B Data</a> + +<li> <a href= +"http://asterweb.jpl.nasa.gov/documents/ASTERHigherLevelUserGuideVer2May01.pdf"> +ASTER Standard Data Product Specifications Document</a> + +<li> <a href="http://www.mcst.ssai.biz/mcstweb/L1B/product.html"> +MODIS Level 1B Product Information and Status</a> + +<li> <a href="http://modis-ocean.gsfc.nasa.gov/userguide.html"> +MODIS Ocean User's Guide</a> + +</ul> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/EHapi.c b/Utilities/GDAL/frmts/hdf4/hdf-eos/EHapi.c new file mode 100644 index 0000000000..b8c7fcf840 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/EHapi.c @@ -0,0 +1,3543 @@ +/* +Copyright (C) 1996 Hughes and Applied Research Corporation + +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation. +*/ +#ifdef WIN32 +#include <windows.h> //bwf +#include <winbase.h> //bwf +#define sleep Sleep +#endif + +#include <errno.h> +#include "mfhdf.h" +#include "HdfEosDef.h" + +/* Set maximun number of HDF-EOS files to HDF limit (MAX_FILE) */ +/* #define NEOSHDF MAX_FILE */ +#define NEOSHDF 200 +uint8 EHXtypeTable[NEOSHDF]; +uint8 EHXacsTable[NEOSHDF]; +int32 EHXfidTable[NEOSHDF]; +int32 EHXsdTable[NEOSHDF]; + +/* define a macro for the string size of the utility strings and some dimension + list strings. The value in previous versions of this code may not be + enough in some cases. The length now is 512 which seems to be more than + enough to hold larger strings. */ + +#define UTLSTR_MAX_SIZE 512 +#define UTLSTRSIZE 32000 + +#define EHIDOFFSET 524288 + +#define HDFEOSVERSION 2.12 +#define HDFEOSVERSION1 "2.12" +#include <HDFEOSVersion.h> + +#define MAX_RETRIES 10 + +#define INT32 INT +#define INT32V INTV +#define PINT32 PINT + +/* Function Prototypes */ +intn EHmetalist(char *, char *); + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHopen | +| | +| DESCRIPTION: Opens HDF-EOS file and returns file handle | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| fid int32 HDF-EOS file ID | +| | +| INPUTS: | +| filename char Filename | +| access intn HDF access code | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales Add file id offset EHIDOFFSET | +| Aug 96 Joel Gales Add "END" statment to structural metadata | +| Sep 96 Joel Gales Reverse order of Hopen ane SDstart statements | +| for RDWR and READ access | +| Oct 96 Joel Gales Trap CREATE & RDWR (no write permission) | +| access errors | +| Apr 97 Joel Gales Fix problem with RDWR open when file previously | +| open for READONLY access | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHopen(char *filename, intn access) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn dum; /* Dummy variable */ + + int32 HDFfid; /* HDF file ID */ + int32 fid = -1; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 nfileopen = 0; /* # of HDF files open */ + int32 attrIndex; /* Structural Metadata attribute index */ + + uint8 acs; /* Read (0) / Write (1) access code */ + + char *testname; /* Test filename */ + char errbuf[256];/* Error report buffer */ + char *metabuf; /* Pointer to structural metadata buffer */ + char hdfeosVersion[32]; /* HDFEOS version string */ + + intn retryCount; + + + /* Determine number of files currently opened */ + /* ------------------------------------------ */ + for (i = 0; i < NEOSHDF; i++) + { + nfileopen += EHXtypeTable[i]; + } + + + + /* Setup file interface */ + /* -------------------- */ + if (nfileopen < NEOSHDF) + { + + /* + * Check that file has not been previously opened for write access if + * current open request is not READONLY + */ + if (access != DFACC_READ) + { + /* Loop through all files */ + /* ---------------------- */ + for (i = 0; i < NEOSHDF; i++) + { + /* if entry is active file opened for write access ... */ + /* --------------------------------------------------- */ + if (EHXtypeTable[i] != 0 && EHXacsTable[i] == 1) + { + /* Get filename (testname) */ + /* ----------------------- */ + Hfidinquire(EHXfidTable[i], &testname, &dum, &dum); + + + /* if same as filename then report error */ + /* ------------------------------------- */ + if (strcmp(testname, filename) == 0) + { + status = -1; + fid = -1; + HEpush(DFE_ALROPEN, "EHopen", __FILE__, __LINE__); + HEreport("\"%s\" already open.\n", filename); + break; + } + } + } + } + if (status == 0) + { + /* Create HDF-EOS file */ + /* ------------------- */ + switch (access) + { + case DFACC_CREATE: + + /* Get SDS interface ID */ + /* -------------------- */ + sdInterfaceID = SDstart(filename, DFACC_CREATE); + + /* If SDstart successful ... */ + /* ------------------------- */ + if (sdInterfaceID != -1) + { + /* Set HDFEOS version number in file */ + /* --------------------------------- */ + sprintf(hdfeosVersion, "%s%s", "HDFEOS_V", + HDFEOSVERSION1); + SDsetattr(sdInterfaceID, "HDFEOSVersion", DFNT_CHAR8, + strlen(hdfeosVersion), hdfeosVersion); + + + /* Get HDF file ID */ + /* --------------- */ + HDFfid = Hopen(filename, DFACC_RDWR, 0); + + /* Set open access to write */ + /* ------------------------ */ + acs = 1; + + /* Setup structural metadata */ + /* ------------------------- */ + metabuf = (char *) calloc(32000, 1); + if(metabuf == NULL) + { + HEpush(DFE_NOSPACE,"EHopen", __FILE__, __LINE__); + return(-1); + } + + strcpy(metabuf, "GROUP=SwathStructure\n"); + strcat(metabuf, "END_GROUP=SwathStructure\n"); + strcat(metabuf, "GROUP=GridStructure\n"); + strcat(metabuf, "END_GROUP=GridStructure\n"); + strcat(metabuf, "GROUP=PointStructure\n"); + strcat(metabuf, "END_GROUP=PointStructure\n"); + strcat(metabuf, "END\n"); + + /* Write Structural metadata */ + /* ------------------------- */ + SDsetattr(sdInterfaceID, "StructMetadata.0", + DFNT_CHAR8, 32000, metabuf); + free(metabuf); + } else + { + /* If error in SDstart then report */ + /* ------------------------------- */ + fid = -1; + status = -1; + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "%s%s%s", "\"", filename, + "\" cannot be created."); + HEreport("%s\n", errbuf); + } + + break; + + /* Open existing HDF-EOS file for read/write access */ + /* ------------------------------------------------ */ + case DFACC_RDWR: + + /* Get HDF file ID */ + /* --------------- */ +#ifndef _PGS_OLDNFS +/* The following loop around the function Hopen is intended to deal with the NFS cache + problem when opening file fails with errno = 150 or 151. When NFS cache is updated, + this part of change is no longer neccessary. 10/18/1999 */ + retryCount = 0; + HDFfid = -1; + while ((HDFfid == -1) && (retryCount < MAX_RETRIES)) + { + HDFfid = Hopen(filename, DFACC_RDWR, 0); + if((HDFfid == -1) && (errno == 150 || errno == 151)) + { + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "\"%s\" cannot be opened for READ/WRITE access, will retry %d times.", filename, (MAX_RETRIES - retryCount - 1)); + HEreport("%s\n", errbuf); + + sleep(1); + } + retryCount++; + } +#else + HDFfid = Hopen(filename, DFACC_RDWR, 0); +#endif + + /* If Hopen successful ... */ + /* ----------------------- */ + if (HDFfid != -1) + { + /* Get SDS interface ID */ + /* -------------------- */ + sdInterfaceID = SDstart(filename, DFACC_RDWR); + + /* If SDstart successful ... */ + /* ------------------------- */ + if (sdInterfaceID != -1) + { + /* Set HDFEOS version number in file */ + /* --------------------------------- */ + + attrIndex = SDfindattr(sdInterfaceID, "HDFEOSVersion"); + if (attrIndex == -1) + { + sprintf(hdfeosVersion, "%s%s", "HDFEOS_V", + HDFEOSVERSION1); + SDsetattr(sdInterfaceID, "HDFEOSVersion", DFNT_CHAR8, + strlen(hdfeosVersion), hdfeosVersion); + } + /* Set open access to write */ + /* ------------------------ */ + acs = 1; + + /* Get structural metadata attribute ID */ + /* ------------------------------------ */ + attrIndex = SDfindattr(sdInterfaceID, "StructMetadata.0"); + + /* Write structural metadata if it doesn't exist */ + /* --------------------------------------------- */ + if (attrIndex == -1) + { + metabuf = (char *) calloc(32000, 1); + if(metabuf == NULL) + { + HEpush(DFE_NOSPACE,"EHopen", __FILE__, __LINE__); + return(-1); + } + + strcpy(metabuf, "GROUP=SwathStructure\n"); + strcat(metabuf, "END_GROUP=SwathStructure\n"); + strcat(metabuf, "GROUP=GridStructure\n"); + strcat(metabuf, "END_GROUP=GridStructure\n"); + strcat(metabuf, "GROUP=PointStructure\n"); + strcat(metabuf, "END_GROUP=PointStructure\n"); + strcat(metabuf, "END\n"); + + SDsetattr(sdInterfaceID, "StructMetadata.0", + DFNT_CHAR8, 32000, metabuf); + free(metabuf); + } + } else + { + /* If error in SDstart then report */ + /* ------------------------------- */ + fid = -1; + status = -1; + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "%s%s%s", "\"", filename, + "\" cannot be opened for read/write access."); + HEreport("%s\n", errbuf); + } + } else + { + /* If error in Hopen then report */ + /* ----------------------------- */ + fid = -1; + status = -1; + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "%s%s%s", "\"", filename, + "\" cannot be opened for RDWR access."); + HEreport("%s\n", errbuf); + } + + break; + + + /* Open existing HDF-EOS file for read-only access */ + /* ----------------------------------------------- */ + case DFACC_READ: + + /* Get HDF file ID */ + /* --------------- */ +#ifndef _PGS_OLDNFS +/* The following loop around the function Hopen is intended to deal with the NFS cache + problem when opening file fails with errno = 150 or 151. When NFS cache is updated, + this part of change is no longer neccessary. 10/18/1999 */ + retryCount = 0; + HDFfid = -1; + while ((HDFfid == -1) && (retryCount < MAX_RETRIES)) + { + HDFfid = Hopen(filename, DFACC_READ, 0); + if((HDFfid == -1) && (errno == 150 || errno == 151)) + { + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "\"%s\" cannot be opened for READONLY access, will retry %d times.", filename, (MAX_RETRIES - retryCount - 1)); + HEreport("%s\n", errbuf); + + sleep(1); + } + retryCount++; + } +#else + HDFfid = Hopen(filename, DFACC_READ, 0); +#endif + + /* If file does not exist report error */ + /* ----------------------------------- */ + if (HDFfid == -1) + { + fid = -1; + status = -1; + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + strcpy(errbuf, "\""); + strcat(errbuf, filename); + strcat(errbuf, "\" (opened for READONLY access)"); + strcat(errbuf, " does not exist."); + HEreport("%s\n", errbuf); + } else + { + /* If file exists then get SD interface ID */ + /* --------------------------------------- */ + sdInterfaceID = SDstart(filename, DFACC_RDONLY); + + /* If SDstart successful ... */ + /* ------------------------- */ + if (sdInterfaceID != -1) + { + + /* Set open access to read-only */ + /* ---------------------------- */ + acs = 0; + } else + { + /* If error in SDstart then report */ + /* ------------------------------- */ + fid = -1; + status = -1; + HEpush(DFE_FNF, "EHopen", __FILE__, __LINE__); + sprintf(errbuf, "%s%s%s", "\"", filename, + "\" cannot be opened for read access."); + HEreport("%s\n", errbuf); + } + } + + break; + + default: + /* Invalid Access Code */ + /* ------------------- */ + fid = -1; + status = -1; + HEpush(DFE_BADACC, "EHopen", __FILE__, __LINE__); + HEreport("Access Code: %d (%s).\n", access, filename); + } + + } + } else + { + /* Too many files opened */ + /* --------------------- */ + status = -1; + fid = -1; + HEpush(DFE_TOOMANY, "EHopen", __FILE__, __LINE__); + HEreport("No more than %d files may be open simultaneously (%s).\n", + NEOSHDF, filename); + } + + + + + if (status == 0) + { + /* Initialize Vgroup Access */ + /* ------------------------ */ + Vstart(HDFfid); + + + /* Assign HDFEOS fid # & Load HDF fid and sdInterfaceID tables */ + /* ----------------------------------------------------------- */ + for (i = 0; i < NEOSHDF; i++) + { + if (EHXtypeTable[i] == 0) + { + fid = i + EHIDOFFSET; + EHXacsTable[i] = acs; + EHXtypeTable[i] = 1; + EHXfidTable[i] = HDFfid; + EHXsdTable[i] = sdInterfaceID; + break; + } + } + + } + return (fid); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHchkfid | +| | +| DESCRIPTION: Checks for valid file id and returns HDF file ID and | +| SD interface ID | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| name char Structure name | +| | +| OUTPUTS: | +| HDFfid int32 HDF File ID | +| sdInterfaceID int32 SDS interface ID | +| access uint8 access code | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales set status=-1 if failure | +| Jul 96 Joel Gales Add file id offset EHIDOFFSET | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHchkfid(int32 fid, char *name, int32 * HDFfid, int32 * sdInterfaceID, + uint8 * access) + +{ + intn status = 0; /* routine return status variable */ + intn fid0; /* HDFEOS file ID - Offset */ + + + /* Check for valid HDFEOS file ID range */ + /* ------------------------------------ */ + if (fid < EHIDOFFSET || fid > NEOSHDF + EHIDOFFSET) + { + status = -1; + HEpush(DFE_RANGE, "EHchkfid", __FILE__, __LINE__); + HEreport("Invalid file id: %d. ID must be >= %d and < %d (%s).\n", + fid, EHIDOFFSET, NEOSHDF + EHIDOFFSET, name); + } else + { + /* Compute "reduced" file ID */ + /* ------------------------- */ + fid0 = fid % EHIDOFFSET; + + + /* Check that HDFEOS file ID is active */ + /* ----------------------------------- */ + if (EHXtypeTable[fid0] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "EHchkfid", __FILE__, __LINE__); + HEreport("File id %d not active (%s).\n", fid, name); + } else + { + /* + * Get HDF file ID, SD interface ID and file access from external + * arrays + */ + *HDFfid = EHXfidTable[fid0]; + *sdInterfaceID = EHXsdTable[fid0]; + *access = EHXacsTable[fid0]; + } + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHidinfo | +| | +| DESCRIPTION: Gets Hopen and SD intereface IDs from HDF-EOS id | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| | +| OUTPUTS: | +| HDFfid int32 HDF File ID | +| sdInterfaceID int32 SDS interface ID | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jul 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHidinfo(int32 fid, int32 * HDFfid, int32 * sdInterfaceID) + +{ + intn status = 0; /* routine return status variable */ + uint8 dum; /* Dummy variable */ + + /* Call EHchkfid to get HDF and SD interface IDs */ + /* --------------------------------------------- */ + status = EHchkfid(fid, "EHidinfo", HDFfid, sdInterfaceID, &dum); + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHfilename | +| | +| DESCRIPTION: Returns HDF filename | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file id | +| | +| OUTPUTS: | +| filename char HDF-EOS file name | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHfilename(int32 fid, char *filename) +{ + intn status = 0; /* routine return status variable */ + intn dum; /* Dummy variable */ + + char *fname; /* Pointer to filename */ + + /* Get point to filename from Hfidinquire */ + /* -------------------------------------- */ + Hfidinquire(EHXfidTable[fid % EHIDOFFSET], &fname, &dum, &dum); + strcpy(filename, fname); + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHgetversion | +| | +| DESCRIPTION: Returns HDF-EOS version string | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file id | +| | +| OUTPUTS: | +| version char HDF-EOS version string | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Mar 97 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHgetversion(int32 fid, char *version) +{ + intn status = 0; /* routine return status variable */ + + uint8 access; /* Access code */ + int32 dum; /* Dummy variable */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 attrIndex; /* HDFEOS version attribute index */ + int32 count; /* Version string size */ + + char attrname[16]; /* Attribute name */ + + + /* Get SDS interface ID */ + /* -------------------- */ + status = EHchkfid(fid, "EHgetversion", &dum, &sdInterfaceID, &access); + + + /* Get attribute index number */ + /* -------------------------- */ + attrIndex = SDfindattr(sdInterfaceID, "HDFEOSVersion"); + + /* No such attribute */ + /* ----------------- */ + if (attrIndex < 0) + return (-1); + + /* Get attribute size */ + /* ------------------ */ + status = SDattrinfo(sdInterfaceID, attrIndex, attrname, &dum, &count); + + /* Check return status */ + /* ------------------- */ + if (status < 0) + return (-1); + + /* Read version attribute */ + /* ---------------------- */ + status = SDreadattr(sdInterfaceID, attrIndex, (VOIDP) version); + + + /* Place string terminator on version string */ + /* ----------------------------------------- */ + version[count] = 0; + + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHconvAng | +| | +| DESCRIPTION: Angle conversion Utility | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| outAngle float64 Output Angle value | +| | +| INPUTS: | +| inAngle float64 Input Angle value | +| code intn Conversion code | +! HDFE_RAD_DEG (0) | +| HDFE_DEG_RAD (1) | +| HDFE_DMS_DEG (2) | +| HDFE_DEG_DMS (3) | +| HDFE_RAD_DMS (4) | +| HDFE_DMS_RAD (5) | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Feb 97 Joel Gales Correct "60" min & "60" sec in _DMS conversion | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +float64 +EHconvAng(float64 inAngle, intn code) +{ + int32 min; /* Truncated Minutes */ + int32 deg; /* Truncated Degrees */ + + float64 sec; /* Seconds */ + float64 outAngle = 0.0; /* Angle in desired units */ + float64 pi = 3.14159265358979324; /* Pi */ + float64 r2d = 180 / pi; /* Radians to degrees conversion */ + float64 d2r = 1 / r2d; /* Degrees to radians conversion */ + + + switch (code) + { + + /* Convert radians to degrees */ + /* -------------------------- */ + case HDFE_RAD_DEG: + outAngle = inAngle * r2d; + break; + + + /* Convert degrees to radians */ + /* -------------------------- */ + case HDFE_DEG_RAD: + outAngle = inAngle * d2r; + break; + + + /* Convert packed degrees to degrees */ + /* --------------------------------- */ + case HDFE_DMS_DEG: + deg = inAngle / 1000000; + min = (inAngle - deg * 1000000) / 1000; + sec = (inAngle - deg * 1000000 - min * 1000); + outAngle = deg + min / 60.0 + sec / 3600.0; + break; + + + /* Convert degrees to packed degrees */ + /* --------------------------------- */ + case HDFE_DEG_DMS: + deg = inAngle; + min = (inAngle - deg) * 60; + sec = (inAngle - deg - min / 60.0) * 3600; + + if ((intn) sec == 60) + { + sec = sec - 60; + min = min + 1; + } + if (min == 60) + { + min = min - 60; + deg = deg + 1; + } + outAngle = deg * 1000000 + min * 1000 + sec; + break; + + + /* Convert radians to packed degrees */ + /* --------------------------------- */ + case HDFE_RAD_DMS: + inAngle = inAngle * r2d; + deg = inAngle; + min = (inAngle - deg) * 60; + sec = (inAngle - deg - min / 60.0) * 3600; + + if ((intn) sec == 60) + { + sec = sec - 60; + min = min + 1; + } + if (min == 60) + { + min = min - 60; + deg = deg + 1; + } + outAngle = deg * 1000000 + min * 1000 + sec; + break; + + + /* Convert packed degrees to radians */ + /* --------------------------------- */ + case HDFE_DMS_RAD: + deg = inAngle / 1000000; + min = (inAngle - deg * 1000000) / 1000; + sec = (inAngle - deg * 1000000 - min * 1000); + outAngle = deg + min / 60.0 + sec / 3600.0; + outAngle = outAngle * d2r; + break; + } + return (outAngle); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHparsestr | +| | +| DESCRIPTION: String Parser Utility | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| count int32 Number of string entries | +| | +| INPUTS: | +| instring char Input string | +| delim char string delimitor | +| | +| OUTPUTS: | +| pntr char * Pointer array to beginning of each | +| string entry | +| len int32 Array of string entry lengths | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales NULL pointer array returns count only | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHparsestr(char *instring, char delim, char *pntr[], int32 len[]) +{ + int32 i; /* Loop index */ + int32 prevDelimPos = 0; /* Previous delimitor position */ + int32 count; /* Number of elements in string list */ + int32 slen; /* String length */ + + char *delimitor; /* Pointer to delimitor */ + + + /* Get length of input string list & Point to first delimitor */ + /* ---------------------------------------------------------- */ + slen = strlen(instring); + delimitor = strchr(instring, delim); + + /* If NULL string set count to zero otherwise set to 1 */ + /* --------------------------------------------------- */ + count = (slen == 0) ? 0 : 1; + + + /* if string pointers are requested set first one to beginning of string */ + /* --------------------------------------------------------------------- */ + if (&pntr[0] != NULL) + { + pntr[0] = instring; + } + /* If delimitor not found ... */ + /* -------------------------- */ + if (delimitor == NULL) + { + /* if string length requested then set to input string length */ + /* ---------------------------------------------------------- */ + if (len != NULL) + { + len[0] = slen; + } + } else + /* Delimitors Found */ + /* ---------------- */ + { + /* Loop through all characters in string */ + /* ------------------------------------- */ + for (i = 1; i < slen; i++) + { + /* If character is a delimitor ... */ + /* ------------------------------- */ + if (instring[i] == delim) + { + + /* If string pointer requested */ + /* --------------------------- */ + if (&pntr[0] != NULL) + { + /* if requested then compute string length of entry */ + /* ------------------------------------------------ */ + if (len != NULL) + { + len[count - 1] = i - prevDelimPos; + } + /* Point to beginning of string entry */ + /* ---------------------------------- */ + pntr[count] = instring + i + 1; + } + /* Reset previous delimitor position and increment counter */ + /* ------------------------------------------------------- */ + prevDelimPos = i + 1; + count++; + } + } + + /* Compute string length of last entry */ + /* ----------------------------------- */ + if (&pntr[0] != NULL && len != NULL) + { + len[count - 1] = i - prevDelimPos; + } + } + + return (count); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHstrwithin | +| | +| DESCRIPTION: Searchs for string within target string | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| indx int32 Element index (0 - based) | +| | +| INPUTS: | +| target char Target string | +| search char Search string | +| delim char Delimitor | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Change ptr & slen to dynamic arrays | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHstrwithin(char *target, char *search, char delim) +{ + intn found = 0; /* Target string found flag */ + + int32 indx; /* Loop index */ + int32 nentries; /* Number of entries in search string */ + int32 *slen; /* Pointer to string length array */ + + char **ptr; /* Pointer to string pointer array */ + char buffer[128];/* Buffer to hold "test" string entry */ + + + /* Count number of entries in search string list */ + /* --------------------------------------------- */ + nentries = EHparsestr(search, delim, NULL, NULL); + + + /* Allocate string pointer and length arrays */ + /* ----------------------------------------- */ + ptr = (char **) calloc(nentries, sizeof(char *)); + if(ptr == NULL) + { + HEpush(DFE_NOSPACE,"EHstrwithin", __FILE__, __LINE__); + return(-1); + } + slen = (int32 *) calloc(nentries, sizeof(int32)); + if(slen == NULL) + { + HEpush(DFE_NOSPACE,"EHstrwithin", __FILE__, __LINE__); + free(ptr); + return(-1); + } + + + /* Parse search string */ + /* ------------------- */ + nentries = EHparsestr(search, delim, ptr, slen); + + + /* Loop through all elements in search string list */ + /* ----------------------------------------------- */ + for (indx = 0; indx < nentries; indx++) + { + /* Copy string entry into buffer */ + /* ----------------------------- */ + memcpy(buffer, ptr[indx], slen[indx]); + buffer[slen[indx]] = 0; + + + /* Compare target string with string entry */ + /* --------------------------------------- */ + if (strcmp(target, buffer) == 0) + { + found = 1; + break; + } + } + + /* If not found set return to -1 */ + /* ----------------------------- */ + if (found == 0) + { + indx = -1; + } + free(slen); + free(ptr); + + return (indx); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHloadliststr | +| | +| DESCRIPTION: Builds list string from string array | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| ptr char String pointer array | +| nentries int32 Number of string array elements | +| delim char Delimitor | +| | +| OUTPUTS: | +| liststr char Output list string | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHloadliststr(char *ptr[], int32 nentries, char *liststr, char delim) +{ + intn status = 0; /* routine return status variable */ + + int32 i; /* Loop index */ + int32 slen; /* String entry length */ + int32 off = 0; /* Position of next entry along string list */ + char dstr[2]; /* string version of input variable "delim" */ + + dstr[0] = delim; + dstr[1] = '\0'; + + + /* Loop through all entries in string array */ + /* ---------------------------------------- */ + for (i = 0; i < nentries; i++) + { + /* Get string length of string array entry */ + /* --------------------------------------- */ + slen = strlen(ptr[i]); + + + /* Copy string entry to string list */ + /* -------------------------------- */ + memcpy(liststr + off, ptr[i], slen + 1); + + + /* Concatenate with delimitor */ + /* -------------------------- */ + if (i != nentries - 1) + { + strcat(liststr, dstr); + } + /* Get position of next entry for string list */ + /* ------------------------------------------ */ + off += slen + 1; + } + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHgetid | +| | +| DESCRIPTION: Get Vgroup/Vdata ID from name | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| outID int32 Output ID | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| vgid int32 Vgroup ID | +| objectname char object name | +| code intn object code (0 - Vgroup, 1 - Vdata) | +| access char access ("w/r") | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHgetid(int32 fid, int32 vgid, char *objectname, intn code, char *access) +{ + intn i; /* Loop index */ + + int32 nObjects; /* # of objects in Vgroup */ + int32 *tags; /* Pnt to Vgroup object tags array */ + int32 *refs; /* Pnt to Vgroup object refs array */ + int32 id; /* Object ID */ + int32 outID = -1; /* Desired object ID */ + + char name[128]; /* Object name */ + + + /* Get Number of objects */ + /* --------------------- */ + nObjects = Vntagrefs(vgid); + + /* If objects exist ... */ + /* -------------------- */ + if (nObjects != 0) + { + + /* Get tags and references of objects */ + /* ---------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * nObjects); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"EHgetid", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * nObjects); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"EHgetid", __FILE__, __LINE__); + free(tags); + return(-1); + } + + Vgettagrefs(vgid, tags, refs, nObjects); + + + /* Vgroup ID Section */ + /* ----------------- */ + if (code == 0) + { + /* Loop through objects */ + /* -------------------- */ + for (i = 0; i < nObjects; i++) + { + + /* If object is Vgroup ... */ + /* ----------------------- */ + if (*(tags + i) == DFTAG_VG) + { + + /* Get ID and name */ + /* --------------- */ + id = Vattach(fid, *(refs + i), access); + Vgetname(id, name); + + /* If name equals desired object name get ID */ + /* ----------------------------------------- */ + if (strcmp(name, objectname) == 0) + { + outID = id; + break; + } + /* If not desired object then detach */ + /* --------------------------------- */ + Vdetach(id); + } + } + } else if (code == 1) + { + + /* Loop through objects */ + /* -------------------- */ + for (i = 0; i < nObjects; i++) + { + + /* If object is Vdata ... */ + /* ---------------------- */ + if (*(tags + i) == DFTAG_VH) + { + + /* Get ID and name */ + /* --------------- */ + id = VSattach(fid, *(refs + i), access); + VSgetname(id, name); + + /* If name equals desired object name get ID */ + /* ----------------------------------------- */ + if (EHstrwithin(objectname, name, ',') != -1) + { + outID = id; + break; + } + /* If not desired object then detach */ + /* --------------------------------- */ + VSdetach(id); + } + } + } + free(tags); + free(refs); + } + return (outID); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHrevflds | +| | +| DESCRIPTION: Reverses elements in a string list | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| dimlist char Original dimension list | +| | +| OUTPUTS: | +| revdimlist char Reversed dimension list | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHrevflds(char *dimlist, char *revdimlist) +{ + intn status = 0; /* routine return status variable */ + + int32 indx; /* Loop index */ + int32 nentries; /* Number of entries in search string */ + int32 *slen; /* Pointer to string length array */ + + char **ptr; /* Pointer to string pointer array */ + char *tempPtr; /* Temporary string pointer */ + char *tempdimlist;/* Temporary dimension list */ + + + /* Copy dimlist into temp dimlist */ + /* ------------------------------ */ + tempdimlist = (char *) malloc(strlen(dimlist) + 1); + if(tempdimlist == NULL) + { + HEpush(DFE_NOSPACE,"EHrevflds", __FILE__, __LINE__); + return(-1); + } + strcpy(tempdimlist, dimlist); + + + /* Count number of entries in search string list */ + /* --------------------------------------------- */ + nentries = EHparsestr(tempdimlist, ',', NULL, NULL); + + + /* Allocate string pointer and length arrays */ + /* ----------------------------------------- */ + ptr = (char **) calloc(nentries, sizeof(char *)); + if(ptr == NULL) + { + HEpush(DFE_NOSPACE,"EHrevflds", __FILE__, __LINE__); + free(tempdimlist); + return(-1); + } + slen = (int32 *) calloc(nentries, sizeof(int32)); + if(slen == NULL) + { + HEpush(DFE_NOSPACE,"EHrevflds", __FILE__, __LINE__); + free(ptr); + free(tempdimlist); + return(-1); + } + + + /* Parse search string */ + /* ------------------- */ + nentries = EHparsestr(tempdimlist, ',', ptr, slen); + + + /* Reverse entries in string pointer array */ + /* --------------------------------------- */ + for (indx = 0; indx < nentries / 2; indx++) + { + tempPtr = ptr[indx]; + ptr[indx] = ptr[nentries - 1 - indx]; + ptr[nentries - 1 - indx] = tempPtr; + } + + + /* Replace comma delimitors by nulls */ + /* --------------------------------- */ + for (indx = 0; indx < nentries - 1; indx++) + { + *(ptr[indx] - 1) = 0; + } + + + /* Build new string list */ + /* --------------------- */ + status = EHloadliststr(ptr, nentries, revdimlist, ','); + + + free(slen); + free(ptr); + free(tempdimlist); + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHcntOBJECT | +| | +| DESCRIPTION: Determines number of OBJECTs in metadata GROUP | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| count int32 Number of OBJECTs in GROUP | +| | +| INPUTS: | +| metabur char Begin & end metadata pointer array | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHcntOBJECT(char *metabuf[]) +{ + int32 count = 0; /* Counter */ + + char *metaptr; /* Beginning of metadata section */ + char *endptr; /* End of metadata section */ + char *tempptr; /* Pointer within metadata section */ + + + /* Get Pointers to beginning and ending of metadata section */ + /* -------------------------------------------------------- */ + metaptr = metabuf[0]; + endptr = metabuf[1]; + + + /* Find number of "END_OBJECT" strings within section */ + /* -------------------------------------------------- */ + tempptr = metaptr; + while (tempptr < endptr && tempptr != NULL) + { + tempptr = strstr(tempptr + 1, "END_OBJECT"); + count++; + } + count--; + + return (count); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHcntGROUP | +| | +| DESCRIPTION: Determines number of GROUPs in metadata GROUP | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| count int32 Number of GROUPs in GROUP | +| | +| INPUTS: | +| metabur char Begin & end metadata pointer array | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHcntGROUP(char *metabuf[]) +{ + int32 count = 0; /* Counter */ + + char *metaptr; /* Beginning of metadata section */ + char *endptr; /* End of metadata section */ + char *tempptr; /* Pointer within metadata section */ + + + /* Get Pointers to beginning and ending of metadata section */ + /* -------------------------------------------------------- */ + metaptr = metabuf[0]; + endptr = metabuf[1]; + + + /* Find number of "END_GROUP" strings within section */ + /* ------------------------------------------------- */ + tempptr = metaptr; + while (tempptr < endptr && tempptr != NULL) + { + tempptr = strstr(tempptr + 1, "END_GROUP"); + count++; + } + count--; + + return (count); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHmetalist | +| | +| DESCRIPTION: Converts string list to metadata list | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| instring char Input string list | +| | +| OUTPUTS: | +| outstring char Output metadata string | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHmetalist(char *instring, char *outstring) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 nentries; /* Number of entries in search string */ + int32 listlen = 1;/* String list length */ + int32 *slen; /* Pointer to string length array */ + + char **ptr; /* Pointer to string pointer array */ + + + /* Count number of entries in search string list */ + /* --------------------------------------------- */ + nentries = EHparsestr(instring, ',', NULL, NULL); + + + /* Allocate string pointer and length arrays */ + /* ----------------------------------------- */ + ptr = (char **) calloc(nentries, sizeof(char *)); + if(ptr == NULL) + { + HEpush(DFE_NOSPACE,"EHmetalist", __FILE__, __LINE__); + return(-1); + } + slen = (int32 *) calloc(nentries, sizeof(int32)); + if(slen == NULL) + { + HEpush(DFE_NOSPACE,"EHmetalist", __FILE__, __LINE__); + free(ptr); + return(-1); + } + + + /* Parse input string */ + /* ------------------ */ + nentries = EHparsestr(instring, ',', ptr, slen); + + + /* Start output string with leading "(" */ + /* ------------------------------------ */ + strcpy(outstring, "("); + + + /* Loop through all entries */ + /* ------------------------ */ + for (i = 0; i < nentries; i++) + { + /* Add double quote (") to output string */ + /* ------------------------------------- */ + strcat(outstring, "\""); + listlen++; + + /* Add input string entry to output string */ + /* --------------------------------------- */ + memcpy(outstring + listlen, ptr[i], slen[i]); + listlen += slen[i]; + outstring[listlen] = 0; + + + /* Add closing double quote (") to output string */ + /* --------------------------------------------- */ + strcat(outstring, "\""); + listlen++; + outstring[listlen] = 0; + + + /* Add comma delimitor to output string */ + /* ------------------------------------ */ + if (i != (nentries - 1)) + { + strcat(outstring, ","); + listlen++; + } + /* Place null terminator in output string */ + /* -------------------------------------- */ + outstring[listlen] = 0; + } + + + /* End output string with trailing ")" */ + /* ----------------------------------- */ + strcat(outstring, ")"); + + free(ptr); + free(slen); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHinsertmeta | +| | +| DESCRIPTION: Writes metadata | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| sdInterfaceID int32 SDS interface ID | +| structname char HDF-EOS structure name | +| structcode char Structure code ("s/g/p") | +| metacode int32 Metadata code type | +| metastr char Metadata input string | +| metadata int32 Metadata utility array | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Sep 96 Joel Gales Allow new metadata object to be written in | +| old metadata. | +| Dec 96 Joel Gales Fix Point metadata problem | +| Oct 98 David Wynne Change utlstr/utlstr2 to dynamic allocation from | +| static | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHinsertmeta(int32 sdInterfaceID, char *structname, char *structcode, + int32 metacode, char *metastr, int32 metadata[]) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 attrIndex; /* Structural metadata attribute index */ + int32 slen[8]; /* String length array (for dim map parsing) */ + int32 nmeta; /* Number of 32000 byte metadata sections */ + int32 metalen; /* Length of structural metadata */ + int32 seglen; /* Length of metadata string to insert */ + int32 count; /* Objects/Groups counter */ + int32 offset; /* Offset insertion position of new metadata + * section within existing metadata */ + + char *metabuf; /* Pointer (handle) to structural metadata */ + char *begptr; /* Pointer to beginning of metadata section */ + char *metaptr; /* Metadata pointer */ + char *prevmetaptr;/* Previous position of metadata pointer */ + char *ptr[8]; /* String pointer array (for dim map parsing) */ + char type[32]; /* Number type descriptor string */ + char *metaArr[2]; /* Array of metadata positions */ + char *colon; /* Colon position */ + char *colon2; /* 2nd colon position */ + char *slash; /* Slash postion */ + char *utlstr; /* Utility string */ + char *utlstr2; /* Utility string 2 */ + + + /* Allocate space for utility strings */ + /* ---------------------------------- */ + utlstr = (char *) calloc(UTLSTRSIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"EHinsertmeta", __FILE__, __LINE__); + return(-1); + } + + utlstr2 = (char *) calloc(UTLSTRSIZE, sizeof(char)); + if(utlstr2 == NULL) + { + HEpush(DFE_NOSPACE,"EHinsertmeta", __FILE__, __LINE__); + free(utlstr); + return(-1); + } + + /* Determine number of structural metadata "sections" */ + /* -------------------------------------------------- */ + nmeta = 0; + while (1) + { + /* Search for "StructMetadata.x" attribute */ + /* --------------------------------------- */ + sprintf(utlstr, "%s%d", "StructMetadata.", (int)nmeta); + attrIndex = SDfindattr(sdInterfaceID, utlstr); + + + /* If found then increment metadata section counter else exit loop */ + /* --------------------------------------------------------------- */ + if (attrIndex != -1) + { + nmeta++; + } else + { + break; + } + } + + + /* Allocate space for metadata (in units of 32000 bytes) */ + /* ----------------------------------------------------- */ + metabuf = (char *) calloc(32000 * nmeta, 1); + if(metabuf == NULL) + { + HEpush(DFE_NOSPACE,"EHinsertmeta", __FILE__, __LINE__); + free(utlstr); + free(utlstr2); + return(-1); + } + + + /* Read structural metadata */ + /* ------------------------ */ + for (i = 0; i < nmeta; i++) + { + sprintf(utlstr, "%s%d", "StructMetadata.", i); + attrIndex = SDfindattr(sdInterfaceID, utlstr); + metalen = strlen(metabuf); + SDreadattr(sdInterfaceID, attrIndex, metabuf + metalen); + } + + /* Determine length (# of characters) of metadata */ + /* ---------------------------------------------- */ + metalen = strlen(metabuf); + + + + /* Find HDF-EOS structure "root" group in metadata */ + /* ----------------------------------------------- */ + + /* Setup proper search string */ + /* -------------------------- */ + if (strcmp(structcode, "s") == 0) + { + strcpy(utlstr, "GROUP=SwathStructure"); + } else if (strcmp(structcode, "g") == 0) + { + strcpy(utlstr, "GROUP=GridStructure"); + } else if (strcmp(structcode, "p") == 0) + { + strcpy(utlstr, "GROUP=PointStructure"); + } + /* Use string search routine (strstr) to move through metadata */ + /* ----------------------------------------------------------- */ + metaptr = strstr(metabuf, utlstr); + + + + /* Find specific (named) structure */ + /* ------------------------------- */ + if (metacode < 1000) + { + /* Save current metadata pointer */ + /* ----------------------------- */ + prevmetaptr = metaptr; + + + /* First loop for "old-style" (non-ODL) metadata string */ + /* ---------------------------------------------------- */ + if (strcmp(structcode, "s") == 0) + { + sprintf(utlstr, "%s%s", "SwathName=\"", structname); + } else if (strcmp(structcode, "g") == 0) + { + sprintf(utlstr, "%s%s", "GridName=\"", structname); + } else if (strcmp(structcode, "p") == 0) + { + sprintf(utlstr, "%s%s", "PointName=\"", structname); + } + /* Do string search */ + /* ---------------- */ + metaptr = strstr(metaptr, utlstr); + + + /* + * If not found then return to previous position in metadata and look + * for "new-style" (ODL) metadata string + */ + if (metaptr == NULL) + { + sprintf(utlstr, "%s%s", "GROUP=\"", structname); + metaptr = strstr(prevmetaptr, utlstr); + } + } + /* + * If searching for geo fields (3), data fields (4), or point fields (11) + * convert type code to string designator. + */ + if (metacode == 3 || metacode == 4 || metacode == 11) + { + switch (metadata[0]) + { + case 3: + strcpy(type, "DFNT_UCHAR8"); + break; + case 4: + strcpy(type, "DFNT_CHAR8"); + break; + case 5: + strcpy(type, "DFNT_FLOAT32"); + break; + case 6: + strcpy(type, "DFNT_FLOAT64"); + break; + case 20: + strcpy(type, "DFNT_INT8"); + break; + case 21: + strcpy(type, "DFNT_UINT8"); + break; + case 22: + strcpy(type, "DFNT_INT16"); + break; + case 23: + strcpy(type, "DFNT_UINT16"); + break; + case 24: + strcpy(type, "DFNT_INT32"); + break; + case 25: + strcpy(type, "DFNT_UINT32"); + break; + } + } + /* Metadata Section Switch */ + /* ----------------------- */ + switch (abs(metacode)) + { + + case 0: + /* Dimension Section */ + /* ----------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=Dimension"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=Dimension"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%d%s%d%s", + "\t\t\tOBJECT=Dimension_", (int)count, + "\n\t\t\t\tDimensionName=\"", &metastr[0], + "\"\n\t\t\t\tSize=", (int)metadata[0], + "\n\t\t\tEND_OBJECT=Dimension_", (int)count, "\n"); + break; + + + case 1: + /* Dimension Map Section */ + /* --------------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=DimensionMap"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=DimensionMap"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find slash within input mapping string and replace with NULL */ + /* ------------------------------------------------------------ */ + EHparsestr(metastr, '/', ptr, slen); + metastr[slen[0]] = 0; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%d%s%d%s%d%s", + "\t\t\tOBJECT=DimensionMap_", (int)count, + "\n\t\t\t\tGeoDimension=\"", &metastr[0], + "\"\n\t\t\t\tDataDimension=\"", &metastr[slen[0] + 1], + "\"\n\t\t\t\tOffset=", (int)metadata[0], + "\n\t\t\t\tIncrement=", (int)metadata[1], + "\n\t\t\tEND_OBJECT=DimensionMap_", (int)count, "\n"); + break; + + + case 2: + /* Index Dimension Map Section */ + /* --------------------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=IndexDimensionMap"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=IndexDimensionMap"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find slash within input mapping string and replace with NULL */ + /* ------------------------------------------------------------ */ + EHparsestr(metastr, '/', ptr, slen); + metastr[slen[0]] = 0; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%d%s", + "\t\t\tOBJECT=IndexDimensionMap_", (int)count, + "\n\t\t\t\tGeoDimension=\"", &metastr[0], + "\"\n\t\t\t\tDataDimension=\"", &metastr[slen[0] + 1], + "\"\n\t\t\tEND_OBJECT=IndexDimensionMap_", (int)count, "\n"); + break; + + + case 3: + /* Geolocation Field Section */ + /* ------------------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=GeoField"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=GeoField"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find colon (parse off field name) */ + /* --------------------------------- */ + colon = strchr(metastr, ':'); + *colon = 0; + + + /* Search for next colon (compression and/or tiling parameters) */ + /* ------------------------------------------------------------ */ + colon2 = strchr(colon + 1, ':'); + if (colon2 != NULL) + { + *colon2 = 0; + } + /* Make metadata string list for dimension list */ + /* -------------------------------------------- */ + EHmetalist(colon + 1, utlstr2); + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%s", + "\t\t\tOBJECT=GeoField_", (int)count, + "\n\t\t\t\tGeoFieldName=\"", metastr, + "\"\n\t\t\t\tDataType=", type, + "\n\t\t\t\tDimList=", utlstr2); + + + /* If compression and/or tiling parameters add to string */ + /* ----------------------------------------------------- */ + if (colon2 != NULL) + { + strcat(utlstr, colon2 + 1); + } + /* Add END_OBJECT terminator to metadata string */ + /* -------------------------------------------- */ + sprintf(utlstr2, "%s%d%s", + "\n\t\t\tEND_OBJECT=GeoField_", (int)count, "\n"); + strcat(utlstr, utlstr2); + + break; + + + case 4: + /* Data Field Section */ + /* ------------------ */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=DataField"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=DataField"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find colon (parse off field name) */ + /* --------------------------------- */ + colon = strchr(metastr, ':'); + *colon = 0; + + + /* Search for next colon (compression and/or tiling parameters) */ + /* ------------------------------------------------------------ */ + colon2 = strchr(colon + 1, ':'); + if (colon2 != NULL) + { + *colon2 = 0; + } + /* Make metadata string list from dimension list */ + /* --------------------------------------------- */ + EHmetalist(colon + 1, utlstr2); + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%s", + "\t\t\tOBJECT=DataField_", (int)count, + "\n\t\t\t\tDataFieldName=\"", metastr, + "\"\n\t\t\t\tDataType=", type, + "\n\t\t\t\tDimList=", utlstr2); + + + /* If compression and/or tiling parameters add to string */ + /* ----------------------------------------------------- */ + if (colon2 != NULL) + { + strcat(utlstr, colon2 + 1); + } + /* Add END_OBJECT terminator to metadata string */ + /* -------------------------------------------- */ + sprintf(utlstr2, "%s%d%s", + "\n\t\t\tEND_OBJECT=DataField_", (int)count, "\n"); + strcat(utlstr, utlstr2); + + break; + + + case 6: + /* Merged Field Section */ + /* -------------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=MergedFields"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=MergedFields"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find colon (parse off merged fieldname) */ + /* --------------------------------------- */ + colon = strchr(metastr, ':'); + + + /* Make metadata string list from field list */ + /* ----------------------------------------- */ + EHmetalist(colon + 1, utlstr2); + *colon = 0; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%s%d%s", + "\t\t\tOBJECT=MergedFields_", (int)count, + "\n\t\t\t\tMergedFieldName=\"", metastr, "\"", + "\n\t\t\t\tFieldList=", utlstr2, + "\n\t\t\tEND_OBJECT=MergedFields_", (int)count, "\n"); + break; + + + case 10: + /* Point Level Section */ + /* ------------------- */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=Level"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\n\t\tEND_GROUP=Level"); + metaptr = strstr(metaptr, utlstr) + 1; + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntGROUP(metaArr); + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%d%s", + "\t\t\tGROUP=Level_", (int)count, + "\n\t\t\t\tLevelName=\"", metastr, + "\"\n\t\t\tEND_GROUP=Level_", (int)count, "\n"); + break; + + + case 11: + /* Point Field Section */ + /* ------------------- */ + + /* Find colon (parse off point field name) */ + /* --------------------------------------- */ + colon = strchr(metastr, ':'); + *colon = 0; + + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\t\t\tLevelName=\""); + strcat(utlstr, colon + 1); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\t\tEND_GROUP=Level_"); + metaptr = strstr(begptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%d%s%d%s", + "\t\t\t\tOBJECT=PointField_", (int)count, + "\n\t\t\t\t\tPointFieldName=\"", metastr, + "\"\n\t\t\t\t\tDataType=", type, + "\n\t\t\t\t\tOrder=", (int)metadata[1], + "\n\t\t\t\tEND_OBJECT=PointField_", (int)count, "\n"); + break; + + + + case 12: + /* Level Link Section */ + /* ------------------ */ + + /* Find beginning and ending of metadata section */ + /* --------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=LevelLink"); + begptr = strstr(metaptr, utlstr); + + strcpy(utlstr, "\t\tEND_GROUP=LevelLink"); + metaptr = strstr(metaptr, utlstr); + + + /* Count number of existing entries and increment */ + /* ---------------------------------------------- */ + metaArr[0] = begptr; + metaArr[1] = metaptr; + count = EHcntOBJECT(metaArr) + 1; + + + /* Find colon (parse off parent/child level names from link field) */ + /* --------------------------------------------------------------- */ + colon = strchr(metastr, ':'); + *colon = 0; + + + /* Find slash (divide parent and child levels) */ + /* ------------------------------------------- */ + slash = strchr(metastr, '/'); + *slash = 0; + + + /* Build metadata entry string */ + /* --------------------------- */ + sprintf(utlstr, "%s%d%s%s%s%s%s%s%s%d%s", + "\t\t\tOBJECT=LevelLink_", (int)count, + "\n\t\t\t\tParent=\"", metastr, + "\"\n\t\t\t\tChild=\"", slash + 1, + "\"\n\t\t\t\tLinkField=\"", colon + 1, + "\"\n\t\t\tEND_OBJECT=LevelLink_", (int)count, "\n"); + + break; + + + case 101: + /* Position metadata pointer for Grid proj parms, pix reg, origin */ + /* -------------------------------------------------------------- */ + strcpy(utlstr, "\t\tGROUP=Dimension"); + metaptr = strstr(metaptr, utlstr); + strcpy(utlstr, metastr); + + break; + + + case 1001: + /* Position metadata pointer for new swath structure (SWcreate) */ + /* ------------------------------------------------------------ */ + strcpy(utlstr, "END_GROUP=SwathStructure"); + metaptr = strstr(metaptr, utlstr); + strcpy(utlstr, metastr); + break; + + + case 1002: + /* Position metadata pointer for new grid structure (GDcreate) */ + /* ----------------------------------------------------------- */ + strcpy(utlstr, "END_GROUP=GridStructure"); + metaptr = strstr(metaptr, utlstr); + strcpy(utlstr, metastr); + break; + + + case 1003: + /* Position metadata pointer for new point structure (PTcreate) */ + /* ------------------------------------------------------------ */ + strcpy(utlstr, "END_GROUP=PointStructure"); + metaptr = strstr(metaptr, utlstr); + strcpy(utlstr, metastr); + break; + } + + + + /* Get length of metadata string to insert */ + /* --------------------------------------- */ + seglen = strlen(utlstr); + + /* Get offset of entry postion within existing metadata */ + /* ---------------------------------------------------- */ + offset = metaptr - metabuf; + + + /* If end of new metadata string outside of current metadata buffer ... */ + /* -------------------------------------------------------------------- */ + if (metalen + seglen > 32000 * nmeta - 1) + { + /* Reallocate metadata buffer with additional 32000 bytes */ + /* ------------------------------------------------------ */ + metabuf = (char *) realloc((void *) metabuf, 32000 * (nmeta + 1)); + if(metabuf == NULL) + { + HEpush(DFE_NOSPACE,"EHinsertmeta", __FILE__, __LINE__); + free(utlstr); + free(utlstr2); + return(-1); + } + + /* Increment metadata section counter */ + /* ---------------------------------- */ + nmeta++; + + /* Reposition metadata pointer (entry position) */ + /* -------------------------------------------- */ + metaptr = metabuf + offset; + } + /* Move metadata following entry point to its new position */ + /* ------------------------------------------------------- */ + for (i = metalen - 1; i > offset - 1; i--) + { + *(metabuf + seglen + i) = *(metabuf + i); + } + + /* Copy new metadat string (utlstr) into metadata */ + /* ---------------------------------------------- */ + memcpy(metaptr, utlstr, seglen); + + /* set to null character remaining of the metabuf */ + + memset((metabuf + metalen + seglen), '\0', (nmeta*32000 -1 - (metalen + + seglen))); + /* Add new null string terminator */ + /* ------------------------------ */ + metabuf[metalen + seglen] = 0; + + + /* Write Back to Global Attribute(s) */ + /* --------------------------------- */ + for (i = 0; i < nmeta; i++) + { + sprintf(utlstr, "%s%d", "StructMetadata.", i); + SDsetattr(sdInterfaceID, utlstr, DFNT_CHAR8, + 32000, metabuf + i * 32000); + } + + + + free(metabuf); + free(utlstr); + free(utlstr2); + + return (status); + +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHgetmetavalue | +| | +| DESCRIPTION: Returns metadata value | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| metaptrs char Begin and end of metadata section | +| parameter char parameter to access | +| | +| OUTPUTS: | +| metaptr char Ptr to (updated) beginning of metadata | +| retstr char return string containing value | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check string pointer against end of meta section | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHgetmetavalue(char *metaptrs[], char *parameter, char *retstr) +{ + intn status = 0; /* routine return status variable */ + + int32 slen; /* String length */ + char *newline; /* Position of new line character */ + char *sptr; /* string pointer within metadata */ + + + /* Get string length of parameter string + 1 */ + /* ----------------------------------------- */ + slen = strlen(parameter) + 1; + + + /* Build search string (parameter string + "=") */ + /* -------------------------------------------- */ + strcpy(retstr, parameter); + strcat(retstr, "="); + + + /* Search for string within metadata (beginning at metaptrs[0]) */ + /* ------------------------------------------------------------ */ + sptr = strstr(metaptrs[0], retstr); + + + /* If string found within desired section ... */ + /* ------------------------------------------ */ + if (sptr != NULL && sptr < metaptrs[1]) + { + /* Store position of string within metadata */ + /* ---------------------------------------- */ + metaptrs[0] = sptr; + + /* Find newline "\n" character */ + /* --------------------------- */ + newline = strchr(metaptrs[0], '\n'); + + /* Copy from "=" to "\n" (exclusive) into return string */ + /* ---------------------------------------------------- */ + memcpy(retstr, metaptrs[0] + slen, newline - metaptrs[0] - slen); + + /* Terminate return string with null */ + /* --------------------------------- */ + retstr[newline - metaptrs[0] - slen] = 0; + } else + { + /* + * if parameter string not found within section, null return string + * and set status to -1. + */ + retstr[0] = 0; + status = -1; + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHmetagroup | +| | +| DESCRIPTION: Returns pointers to beginning and end of metadata group | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| metabuf char Pointer to HDF-EOS object in metadata | +| | +| INPUTS: | +| sdInterfaceID int32 SDS interface ID | +| structname char HDF-EOS structure name | +| structcode char Structure code ("s/g/p") | +| groupname char Metadata group name | +| | +| OUTPUTS: | +| metaptrs char pointers to begin and end of metadata | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +char * +EHmetagroup(int32 sdInterfaceID, char *structname, char *structcode, + char *groupname, char *metaptrs[]) +{ + intn i; /* Loop index */ + + int32 attrIndex; /* Structural metadata attribute index */ + int32 nmeta; /* Number of 32000 byte metadata sections */ + int32 metalen; /* Length of structural metadata */ + + char *metabuf; /* Pointer (handle) to structural metadata */ + char *endptr; /* Pointer to end of metadata section */ + char *metaptr; /* Metadata pointer */ + char *prevmetaptr;/* Previous position of metadata pointer */ + char *utlstr; /* Utility string */ + + + + /* Allocate memory for utility string */ + /* ---------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE,sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"EHEHmetagroup", __FILE__, __LINE__); + + return( NULL); + } + /* Determine number of structural metadata "sections" */ + /* -------------------------------------------------- */ + nmeta = 0; + while (1) + { + /* Search for "StructMetadata.x" attribute */ + /* --------------------------------------- */ + sprintf(utlstr, "%s%d", "StructMetadata.", (int)nmeta); + attrIndex = SDfindattr(sdInterfaceID, utlstr); + + + /* If found then increment metadata section counter else exit loop */ + /* --------------------------------------------------------------- */ + if (attrIndex != -1) + { + nmeta++; + } else + { + break; + } + } + + + /* Allocate space for metadata (in units of 32000 bytes) */ + /* ----------------------------------------------------- */ + metabuf = (char *) calloc(32000 * nmeta, 1); + + if(metabuf == NULL) + { + HEpush(DFE_NOSPACE,"EHmetagroup", __FILE__, __LINE__); + free(utlstr); + return(metabuf); + } + + + /* Read structural metadata */ + /* ------------------------ */ + for (i = 0; i < nmeta; i++) + { + sprintf(utlstr, "%s%d", "StructMetadata.", i); + attrIndex = SDfindattr(sdInterfaceID, utlstr); + metalen = strlen(metabuf); + SDreadattr(sdInterfaceID, attrIndex, metabuf + metalen); + } + + /* Determine length (# of characters) of metadata */ + /* ---------------------------------------------- */ + metalen = strlen(metabuf); + + + + /* Find HDF-EOS structure "root" group in metadata */ + /* ----------------------------------------------- */ + + /* Setup proper search string */ + /* -------------------------- */ + if (strcmp(structcode, "s") == 0) + { + strcpy(utlstr, "GROUP=SwathStructure"); + } else if (strcmp(structcode, "g") == 0) + { + strcpy(utlstr, "GROUP=GridStructure"); + } else if (strcmp(structcode, "p") == 0) + { + strcpy(utlstr, "GROUP=PointStructure"); + } + /* Use string search routine (strstr) to move through metadata */ + /* ----------------------------------------------------------- */ + metaptr = strstr(metabuf, utlstr); + + + + /* Save current metadata pointer */ + /* ----------------------------- */ + prevmetaptr = metaptr; + + + /* First loop for "old-style" (non-ODL) metadata string */ + /* ---------------------------------------------------- */ + if (strcmp(structcode, "s") == 0) + { + sprintf(utlstr, "%s%s", "SwathName=\"", structname); + } else if (strcmp(structcode, "g") == 0) + { + sprintf(utlstr, "%s%s", "GridName=\"", structname); + } else if (strcmp(structcode, "p") == 0) + { + sprintf(utlstr, "%s%s", "PointName=\"", structname); + } + /* Do string search */ + /* ---------------- */ + metaptr = strstr(metaptr, utlstr); + + + /* + * If not found then return to previous position in metadata and look for + * "new-style" (ODL) metadata string + */ + if (metaptr == NULL) + { + sprintf(utlstr, "%s%s", "GROUP=\"", structname); + metaptr = strstr(prevmetaptr, utlstr); + } + /* Find group within structure */ + /* --------------------------- */ + if (groupname != NULL) + { + sprintf(utlstr, "%s%s", "GROUP=", groupname); + metaptr = strstr(metaptr, utlstr); + + sprintf(utlstr, "%s%s", "\t\tEND_GROUP=", groupname); + endptr = strstr(metaptr, utlstr); + } else + { + /* If groupname == NULL then find end of structure in metadata */ + /* ----------------------------------------------------------- */ + sprintf(utlstr, "%s", "\n\tEND_GROUP="); + endptr = strstr(metaptr, utlstr); + } + + + /* Return beginning and ending pointers */ + /* ------------------------------------ */ + metaptrs[0] = metaptr; + metaptrs[1] = endptr; + + free(utlstr); + + return (metabuf); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHfillfld | +| | +| DESCRIPTION: Fills field with fill value | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| sdid int32 SD element ID | +| rank int32 Rank of field | +| truerank int32 True rank of field (merging) | +| size int32 size of fill element | +| off int32 Offset of field within merged field | +| dims int32 Dimensions of field | +| fillval void fill value | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHfillfld(int32 sdid, int32 rank, int32 truerank, int32 size, int32 off, + int32 dims[], VOIDP fillval) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 n; /* Max number of planes or rows in fill + * buffer */ + int32 start[3] = {0, 0, 0}; /* Start array (SDwritedata) */ + int32 edge[3]; /* Edge (count) array (SDwritedata) */ + int32 totN; /* Total number of elements in field */ + int32 planeN; /* Number of elements in plane */ + + char *fillbuf; /* Fill buffer */ + + + /* Get total number of elements in field */ + /* ------------------------------------- */ + totN = dims[0]; + for (i = 1; i < rank; i++) + { + totN *= dims[i]; + } + + + /* Get number of elements in a plane of the field */ + /* ---------------------------------------------- */ + planeN = dims[1] * dims[2]; + + + + /* Allocate & Write Fill buffer */ + /* ---------------------------- */ + if (totN * size < HDFE_MAXMEMBUF) + { + /* Entire field size (in bytes) smaller than max fill buffer */ + /* --------------------------------------------------------- */ + + + /* Allocate fill buffer */ + /* -------------------- */ + fillbuf = (char *) malloc(totN * size); + if(fillbuf == NULL) + { + HEpush(DFE_NOSPACE,"EHfillfld", __FILE__, __LINE__); + return(-1); + } + + + /* Fill buffer with fill value */ + /* --------------------------- */ + for (i = 0; i < totN; i++) + { + memcpy(fillbuf + i * size, fillval, size); + } + + + /* Write fill buffer to field */ + /* -------------------------- */ + start[0] = off; + edge[0] = dims[0]; + edge[1] = dims[1]; + edge[2] = dims[2]; + status = SDwritedata(sdid, start, NULL, edge, + (VOIDP) fillbuf); + + free(fillbuf); + + } else if (planeN * size < HDFE_MAXMEMBUF) + { + /* Single plane size (in bytes) smaller than max fill buffer */ + /* --------------------------------------------------------- */ + + + /* Compute number of planes that can be written at one time */ + /* -------------------------------------------------------- */ + n = HDFE_MAXMEMBUF / (planeN * size); + + + /* Allocate fill buffer */ + /* -------------------- */ + fillbuf = (char *) malloc(planeN * size * n); + if(fillbuf == NULL) + { + HEpush(DFE_NOSPACE,"EHfillfld", __FILE__, __LINE__); + return(-1); + } + + + /* Fill buffer with fill value */ + /* --------------------------- */ + for (i = 0; i < planeN * n; i++) + { + memcpy(fillbuf + i * size, fillval, size); + } + + + /* Write (full) fill buffer to field */ + /* --------------------------------- */ + for (i = 0; i < (dims[0] / n); i++) + { + start[0] = off + i * n; + edge[0] = n; + edge[1] = dims[1]; + edge[2] = dims[2]; + status = SDwritedata(sdid, start, NULL, edge, + (VOIDP) fillbuf); + } + + + /* Write (partial) last fill buffer to field (if necessary) */ + /* -------------------------------------------------------- */ + if (i * n != dims[0]) + { + start[0] = off + i * n; + edge[0] = dims[0] - i * n; + edge[1] = dims[1]; + edge[2] = dims[2]; + status = SDwritedata(sdid, start, NULL, edge, + (VOIDP) fillbuf); + } + free(fillbuf); + + } else + { + /* Single plane size (in bytes) greater than max fill buffer */ + /* --------------------------------------------------------- */ + + + /* Compute number of "rows" than can be written at one time */ + /* -------------------------------------------------------- */ + n = HDFE_MAXMEMBUF / (dims[rank - 1] * size); + + + /* Allocate fill buffer */ + /* -------------------- */ + fillbuf = (char *) malloc(dims[rank - 1] * size * n); + if(fillbuf == NULL) + { + HEpush(DFE_NOSPACE,"EHfillfld", __FILE__, __LINE__); + return(-1); + } + + + /* Fill buffer with fill value */ + /* --------------------------- */ + for (i = 0; i < dims[rank - 1] * n; i++) + { + memcpy(fillbuf + i * size, fillval, size); + } + + + /* For every plane in field ... */ + /* ---------------------------- */ + for (j = 0; j < dims[0]; j++) + { + + /* Write (full) fill buffer to field */ + /* --------------------------------- */ + for (i = 0; i < (dims[1] / n); i++) + { + start[0] = off + j; + start[1] = i * n; + edge[0] = 1; + edge[1] = n; + edge[2] = dims[2]; + status = SDwritedata(sdid, start, NULL, edge, + (VOIDP) fillbuf); + } + + + /* Write (partial) last fill buffer to field (if necessary) */ + /* -------------------------------------------------------- */ + if (i * n != dims[1]) + { + start[0] = off + j; + start[1] = i * n; + edge[0] = 1; + edge[1] = dims[1] - i * n; + edge[2] = dims[2]; + status = SDwritedata(sdid, start, NULL, edge, + (VOIDP) fillbuf); + } + } + + free(fillbuf); + + } + + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHbisect | +| | +| DESCRIPTION: Finds root of function using bisection | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| func() float64 Function to bisect | +| funcParms float64 Function parameters (fixed) | +| nParms int32 Number of function parameters | +| limLft float64 Lower limit of function arguement | +| limRgt float64 Upper limit of function arguement | +| convCrit float64 Convergence criterion | +| | +| OUTPUTS: | +| root float64 Function root | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHbisect(float64(*func) (float64[]), float64 funcParms[], int32 nParms, + float64 limLft, float64 limRgt, float64 convCrit, float64 * root) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + float64 midPnt; /* Mid-point value */ + float64 newmidPnt; /* New mid-point value */ + float64 funcLft; /* Function value at left-hand limit */ + float64 funcMid; /* Function value at mid-point */ + float64 funcRgt; /* Function value at right-hand limit */ + float64 *parms; /* Function parameters */ + + + /* Allocate space for function parameters */ + /* -------------------------------------- */ + parms = (float64 *) calloc(nParms + 1, sizeof(float64)); + if(parms == NULL) + { + HEpush(DFE_NOSPACE, "EHbisect", __FILE__, __LINE__); + return(-1); + } + + + /* Copy (fixed) function parameters */ + /* -------------------------------- */ + for (i = 0; i < nParms; i++) + { + parms[i + 1] = funcParms[i]; + } + + + /* Copy left-hand limit to "floating" parameter */ + /* -------------------------------------------- */ + parms[0] = limLft; + + + /* Determine function value */ + /* ------------------------ */ + funcLft = (*func) (parms); + + + /* Copy right-hand limit to "floating" parameter */ + /* --------------------------------------------- */ + parms[0] = limRgt; + + + /* Determine function value */ + /* ------------------------ */ + funcRgt = (*func) (parms); + + + /* If left and right limits function values of same sign then no root */ + /* ------------------------------------------------------------------ */ + if (funcLft * funcRgt > 0) + { + free(parms); + return (-1); + } + /* Compute (initial) mid-point */ + /* --------------------------- */ + newmidPnt = 0.5 * (limLft + limRgt); + + + /* Bisection Loop */ + /* -------------- */ + while (1) + { + /* Compute function at new mid-point */ + /* --------------------------------- */ + midPnt = newmidPnt; + parms[0] = midPnt; + funcMid = (*func) (parms); + + + /* If left limit same sign as mid-point move it to mid-point */ + /* --------------------------------------------------------- */ + if (funcLft * funcMid > 0.0) + { + limLft = midPnt; + } else + { + /* Otherwise move over right-hand limit */ + /* ------------------------------------ */ + limRgt = midPnt; + } + + + /* Compute new mid-point */ + /* --------------------- */ + newmidPnt = 0.5 * (limLft + limRgt); + + + /* If relative change in midpoint < convergence crit then exit loop */ + /* ---------------------------------------------------------------- */ + if (fabs((newmidPnt - midPnt) / midPnt) < convCrit) + { + break; + } + } + + /* Save root */ + /* --------- */ + *root = newmidPnt; + + + free(parms); + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHattr | +| | +| DESCRIPTION: Reads/Writes attributes for HDF-EOS structures | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| attrVgrpID int32 Attribute Vgroup ID | +| attrname char attribute name | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| wrcode char Read/Write Code "w/r" | +| datbuf void I/O buffer | +| | +| | +| OUTPUTS: | +| datbuf void I/O buffer | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Pass Vgroup id as routine parameter | +| Oct 96 Joel Gales Remove Vdetach call | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHattr(int32 fid, int32 attrVgrpID, char *attrname, int32 numbertype, + int32 count, char *wrcode, VOIDP datbuf) + +{ + intn status = 0; /* routine return status variable */ + int32 vdataID; /* Attribute Vdata ID */ + + /* + * Attributes are stored as Vdatas with name given by the user, class: + * "Attr0.0" and fieldname: "AttrValues" + */ + + + /* Get Attribute Vdata ID and "open" with approriate I/O code */ + /* ---------------------------------------------------------- */ + vdataID = EHgetid(fid, attrVgrpID, attrname, 1, wrcode); + + /* Write Attribute Section */ + /* ----------------------- */ + if (strcmp(wrcode, "w") == 0) + { + /* Create Attribute Vdata (if it doesn't exist) */ + /* -------------------------------------------- */ + if (vdataID == -1) + { + vdataID = VSattach(fid, -1, "w"); + VSsetname(vdataID, attrname); + VSsetclass(vdataID, "Attr0.0"); + + VSfdefine(vdataID, "AttrValues", numbertype, count); + Vinsert(attrVgrpID, vdataID); + } + /* Write Attribute */ + /* --------------- */ + VSsetfields(vdataID, "AttrValues"); + (void) VSsizeof(vdataID, "AttrValues"); + VSwrite(vdataID, datbuf, 1, FULL_INTERLACE); + + VSdetach(vdataID); + } + /* Read Attribute Section */ + /* ---------------------- */ + if (strcmp(wrcode, "r") == 0) + { + /* If attribute doesn't exist report error */ + /* --------------------------------------- */ + if (vdataID == -1) + { + status = -1; + HEpush(DFE_GENAPP, "EHattr", __FILE__, __LINE__); + HEreport("Attribute %s not defined.\n", attrname); + } else + { + VSsetfields(vdataID, "AttrValues"); + (void) VSsizeof(vdataID, "AttrValues"); + VSread(vdataID, datbuf, 1, FULL_INTERLACE); + VSdetach(vdataID); + } + } + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHattrinfo | +| | +| DESCRIPTION: Returns numbertype and count of given HDF-EOS attribute | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| attrVgrpID int32 Attribute Vgroup ID | +| attrname char attribute name | +| | +| OUTPUTS: | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Pass Vgroup id as routine parameter | +| Oct 96 Joel Gales Remove Vdetach call | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHattrinfo(int32 fid, int32 attrVgrpID, char *attrname, int32 * numbertype, + int32 * count) + +{ + intn status = 0; /* routine return status variable */ + int32 vdataID; /* Attribute Vdata ID */ + + /* Get Attribute Vdata ID */ + /* ---------------------- */ + vdataID = EHgetid(fid, attrVgrpID, attrname, 1, "r"); + + /* If attribute not defined then report error */ + /* ------------------------------------------ */ + if (vdataID == -1) + { + status = -1; + HEpush(DFE_GENAPP, "EHattr", __FILE__, __LINE__); + HEreport("Attribute %s not defined.\n", attrname); + } else + { + /* Get attribute info */ + /* ------------------ */ + VSsetfields(vdataID, "AttrValues"); + *count = VSsizeof(vdataID, "AttrValues"); + *numbertype = VFfieldtype(vdataID, 0); + VSdetach(vdataID); + } + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHattrcat | +| | +| DESCRIPTION: Returns a listing of attributes within an HDF-EOS structure | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nattr int32 Number of attributes in swath struct | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| attrVgrpID int32 Attribute Vgroup ID | +| structcode char Structure Code ("s/g/p") | +| | +| OUTPUTS: | +| attrnames char Attribute names in swath struct | +| (Comma-separated list) | +| strbufsize int32 Attributes name list string length | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Pass Vgroup id as routine parameter | +| Oct 96 Joel Gales Remove Vdetach call | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHattrcat(int32 fid, int32 attrVgrpID, char *attrnames, int32 * strbufsize) +{ + intn i; /* Loop index */ + + int32 nObjects; /* # of objects in Vgroup */ + int32 *tags; /* Pnt to Vgroup object tags array */ + int32 *refs; /* Pnt to Vgroup object refs array */ + int32 vdataID; /* Attribute Vdata ID */ + + int32 nattr = 0; /* Number of attributes */ + int32 slen; /* String length */ + + char name[80]; /* Attribute name */ + char *indxstr = "INDXMAP:"; /* Index Mapping reserved + * string */ + char *fvstr = "_FV_"; /* Flag Value reserved string */ + char *bsom = "_BLKSOM:"; /* Block SOM Offset reserved string */ + + + /* Set string buffer size to 0 */ + /* --------------------------- */ + *strbufsize = 0; + + + /* Get number of attributes within Attribute Vgroup */ + /* ------------------------------------------------ */ + nObjects = Vntagrefs(attrVgrpID); + + + /* If attributes exist ... */ + /* ----------------------- */ + if (nObjects > 0) + { + /* Get tags and references of attribute Vdatas */ + /* ------------------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * nObjects); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"EHattrcat", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * nObjects); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"EHattrcat", __FILE__, __LINE__); + free(tags); + return(-1); + } + + Vgettagrefs(attrVgrpID, tags, refs, nObjects); + + /* Get attribute vdata IDs and names */ + /* --------------------------------- */ + for (i = 0; i < nObjects; i++) + { + vdataID = VSattach(fid, *(refs + i), "r"); + VSgetname(vdataID, name); + + /* + * Don't return fill value, index mapping & block SOM attributes + */ + if (memcmp(name, indxstr, strlen(indxstr)) != 0 && + memcmp(name, fvstr, strlen(fvstr)) != 0 && + memcmp(name, bsom, strlen(bsom)) != 0) + { + /* Increment attribute counter and add name to list */ + /* ------------------------------------------------ */ + nattr++; + if (attrnames != NULL) + { + if (nattr == 1) + { + strcpy(attrnames, name); + } else + { + strcat(attrnames, ","); + strcat(attrnames, name); + } + } + /* Increment attribute names string length */ + /* --------------------------------------- */ + slen = (nattr == 1) ? strlen(name) : strlen(name) + 1; + *strbufsize += slen; + } + VSdetach(vdataID); + } + free(tags); + free(refs); + } + return (nattr); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHinquire | +| | +| DESCRIPTION: Returns number and names of HDF-EOS structures in file | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nobj int32 Number of HDF-EOS structures in file | +| | +| INPUTS: | +| filename char HDF-EOS filename | +| type char Object Type ("SWATH/GRID/POINT") | +| | +| OUTPUTS: | +| objectlist char List of object names (comma-separated) | +| strbufsize int32 Length of objectlist | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +EHinquire(char *filename, char *type, char *objectlist, int32 * strbufsize) +{ + int32 HDFfid; /* HDF file ID */ + int32 vgRef; /* Vgroup reference number */ + int32 vGrpID; /* Vgroup ID */ + int32 nobj = 0; /* Number of HDFEOS objects in file */ + int32 slen; /* String length */ + + char name[80]; /* Object name */ + char class[80]; /* Object class */ + + + /* Open HDFEOS file of read-only access */ + /* ------------------------------------ */ + HDFfid = Hopen(filename, DFACC_READ, 0); + + + /* Start Vgroup Interface */ + /* ---------------------- */ + Vstart(HDFfid); + + + /* If string buffer size is requested then zero out counter */ + /* -------------------------------------------------------- */ + if (strbufsize != NULL) + { + *strbufsize = 0; + } + /* Search for objects from begining of HDF file */ + /* -------------------------------------------- */ + vgRef = -1; + + /* Loop through all objects */ + /* ------------------------ */ + while (1) + { + /* Get Vgroup reference number */ + /* --------------------------- */ + vgRef = Vgetid(HDFfid, vgRef); + + /* If no more then exist search loop */ + /* --------------------------------- */ + if (vgRef == -1) + { + break; + } + /* Get Vgroup ID, name, and class */ + /* ------------------------------ */ + vGrpID = Vattach(HDFfid, vgRef, "r"); + Vgetname(vGrpID, name); + Vgetclass(vGrpID, class); + + + /* If object of desired type (SWATH, POINT, GRID) ... */ + /* -------------------------------------------------- */ + if (strcmp(class, type) == 0) + { + + /* Increment counter */ + /* ----------------- */ + nobj++; + + + /* If object list requested add name to list */ + /* ----------------------------------------- */ + if (objectlist != NULL) + { + if (nobj == 1) + { + strcpy(objectlist, name); + } else + { + strcat(objectlist, ","); + strcat(objectlist, name); + } + } + /* Compute string length of object entry */ + /* ------------------------------------- */ + slen = (nobj == 1) ? strlen(name) : strlen(name) + 1; + + + /* If string buffer size is requested then increment buffer size */ + /* ------------------------------------------------------------- */ + if (strbufsize != NULL) + { + *strbufsize += slen; + } + } + /* Detach Vgroup */ + /* ------------- */ + Vdetach(vGrpID); + } + + /* "Close" Vgroup interface and HDFEOS file */ + /* ---------------------------------------- */ + Vend(HDFfid); + Hclose(HDFfid); + + return (nobj); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: EHclose | +| | +| DESCRIPTION: Closes HDF-EOS file | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS File ID | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales Add file id offset EHIDOFFSET | +| Aug 96 Joel Gales Add HE error report if file id out of bounds | +| Nov 96 Joel Gales Add EHXacsTable array to "garbage collection" | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +EHclose(int32 fid) +{ + intn status = 0; /* routine return status variable */ + + int32 HDFfid; /* HDF file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 fid0; /* HDF EOS file id - offset */ + + + /* Check for valid HDFEOS file ID range */ + /* ------------------------------------ */ + if (fid >= EHIDOFFSET && fid < NEOSHDF + EHIDOFFSET) + { + /* Compute "reduced" file ID */ + /* ------------------------- */ + fid0 = fid % EHIDOFFSET; + + + /* Get HDF file ID and SD interface ID */ + /* ----------------------------------- */ + HDFfid = EHXfidTable[fid0]; + sdInterfaceID = EHXsdTable[fid0]; + + /* "Close" SD interface, Vgroup interface, and HDF file */ + /* ---------------------------------------------------- */ + status = SDend(sdInterfaceID); + status = Vend(HDFfid); + status = Hclose(HDFfid); + + /* Clear out external array entries */ + /* -------------------------------- */ + EHXtypeTable[fid0] = 0; + EHXacsTable[fid0] = 0; + EHXfidTable[fid0] = 0; + EHXsdTable[fid0] = 0; + } else + { + status = -1; + HEpush(DFE_RANGE, "EHclose", __FILE__, __LINE__); + HEreport("Invalid file id: %d. ID must be >= %d and < %d.\n", + fid, EHIDOFFSET, NEOSHDF + EHIDOFFSET); + } + + return (status); +} diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/GDapi.c b/Utilities/GDAL/frmts/hdf4/hdf-eos/GDapi.c new file mode 100644 index 0000000000..7998140d98 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/GDapi.c @@ -0,0 +1,12180 @@ +/* +Copyright (C) 1996 Hughes and Applied Research Corporation + +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation. +*/ +/***************************************************************************** +REVISIONS: + +Aug 31, 1999 Abe Taaheri Changed memory allocation for utility strings to + the size of UTLSTR_MAX_SIZE. + Added error check for memory unavailibilty in + several functions. + Added check for NULL metabuf returned from + EHmeta... functions. NULL pointer retruned from + EHmeta... functions indicate that memory could not + be allocated for metabuf. +Jun 27, 2000 Abe Taaheri Added support for EASE grid that uses + Behrmann Cylinderical Equal Area (BCEA) projection +Oct 23, 2000 Abe Taaheri Updated for ISINUS projection, so that both codes + 31 and 99 can be used for this projection. +Jan 15, 2003 Abe Taaheri Modified for generalization of EASE Grid. + +Jun 05, 2003 Bruce Beaumont / Abe Taaheri + + Fixed SQUARE definition. + Added static projection number/name translation + Added projection table lookup in GDdefproj. + Removed projection table from GDdefproj + Added projection table lookup in GDprojinfo + Removed projection table from GDprojinfo + Added cast for compcode in call to SDsetcompress + in GDdeffield to avoid compiler errors + Removed declaration for unused variable endptr + in GDSDfldsrch + Removed initialization code for unused variables + in GDSDfldsrch + Removed declarations for unused variables + BCEA_scale, r0, s0, xMtr0, xMtr1, yMtr0, + and yMtr1 in GDll2ij + Removed initialization code for unused variables + in GDll2ij + Added code in GEO projection handling to allow + map to span dateline in GDll2ij + Changed "for each point" loop in GDll2ij to + return -2147483648.0 for xVal and yVal if + for_trans returned an error instead of + returning an error to the caller + (Note: MAXLONG is defined as 2147483647.0 in + function cproj.c of GCTP) + Added code in GDij2ll to use for_trans to + translate the BCEA corner points from packed + degrees to meters + Removed declarations for unused variables + BCEA_scale, r0, s0, xMtr, yMtr, epsilon, + beta, qp_cea, kz_cea, eccen, eccen_sq, + phi1, sinphi1, cosphi1, lon, lat, xcor, + ycor, and nlatlon from GDij2ll + Removed initialization code for unused variables + in GDij2ll + Added declarations for xMtr0, yMtr0, xMtr1, and + yMtr1 in GDij2ll + Added special-case code for BCEA + Changed "for each point" loop in GDij2ll to + return PGSd_GCT_IN_ERROR (1.0e51) for + longitude and latitude values if inv_trans + returned an error instead of return an error + to the caller + Removed declaration for unused variable ii in + GDgetpixvalues + Removed declaration for unused variable + numTileDims in GDtileinfo + Added error message and error return at the + end of GDll2mm_cea + Added return statement to GDll2mm_cea +******************************************************************************/ +#include "stdio.h" +#include "mfhdf.h" +#include "hcomp.h" +#include <math.h> +#include "HdfEosDef.h" + +extern void for_init(int32, int32, float64 *, int32, char *, char *, int32 *, + int32 (*for_trans[])()); +extern void inv_init(int32, int32, float64 *, int32, char *, char *, int32 *, + int32 (*inv_trans[])()); + +#define GDIDOFFSET 4194304 +#define SQUARE(x) ((x) * (x)) /* x**2 */ +#define M_PI1 3.14159265358979323846 + +int32 GDXSDcomb[512*5]; +char GDXSDname[HDFE_NAMBUFSIZE]; +char GDXSDdims[HDFE_DIMBUFSIZE]; + + +#define NGRID 200 +/* Grid Structure External Arrays */ +struct gridStructure +{ + int32 active; + int32 IDTable; + int32 VIDTable[2]; + int32 fid; + int32 nSDS; + int32 *sdsID; + int32 compcode; + intn compparm[5]; + int32 tilecode; + int32 tilerank; + int32 tiledims[8]; +}; +struct gridStructure GDXGrid[NGRID]; + + + +#define NGRIDREGN 256 +struct gridRegion +{ + int32 fid; + int32 gridID; + int32 xStart; + int32 xCount; + int32 yStart; + int32 yCount; + int32 somStart; + int32 somCount; + float64 upleftpt[2]; + float64 lowrightpt[2]; + int32 StartVertical[8]; + int32 StopVertical[8]; + char *DimNamePtr[8]; +}; +struct gridRegion *GDXRegion[NGRIDREGN]; + +/* define a macro for the string size of the utility strings and some dimension + list strings. The value of 80 in the previous version of this code + may not be enough in some cases. The length now is 512 which seems to + be more than enough to hold larger strings. */ + +#define UTLSTR_MAX_SIZE 512 + +/* Static projection table */ +static struct { + int32 projcode; + char *projname; +} Projections[] = { + {GCTP_GEO, "GCTP_GEO"}, + {GCTP_UTM, "GCTP_UTM"}, + {GCTP_SPCS, "GCTP_SPCS"}, + {GCTP_ALBERS, "GCTP_ALBERS"}, + {GCTP_LAMCC, "GCTP_LAMCC"}, + {GCTP_MERCAT, "GCTP_MERCAT"}, + {GCTP_PS, "GCTP_PS"}, + {GCTP_POLYC, "GCTP_POLYC"}, + {GCTP_EQUIDC, "GCTP_EQUIDC"}, + {GCTP_TM, "GCTP_TM"}, + {GCTP_STEREO, "GCTP_STEREO"}, + {GCTP_LAMAZ, "GCTP_LAMAZ"}, + {GCTP_AZMEQD, "GCTP_AZMEQD"}, + {GCTP_GNOMON, "GCTP_GNOMON"}, + {GCTP_ORTHO, "GCTP_ORTHO"}, + {GCTP_GVNSP, "GCTP_GVNSP"}, + {GCTP_SNSOID, "GCTP_SNSOID"}, + {GCTP_EQRECT, "GCTP_EQRECT"}, + {GCTP_MILLER, "GCTP_MILLER"}, + {GCTP_VGRINT, "GCTP_VGRINT"}, + {GCTP_HOM, "GCTP_HOM"}, + {GCTP_ROBIN, "GCTP_ROBIN"}, + {GCTP_SOM, "GCTP_SOM"}, + {GCTP_ALASKA, "GCTP_ALASKA"}, + {GCTP_GOOD, "GCTP_GOOD"}, + {GCTP_MOLL, "GCTP_MOLL"}, + {GCTP_IMOLL, "GCTP_IMOLL"}, + {GCTP_HAMMER, "GCTP_HAMMER"}, + {GCTP_WAGIV, "GCTP_WAGIV"}, + {GCTP_WAGVII, "GCTP_WAGVII"}, + {GCTP_OBLEQA, "GCTP_OBLEQA"}, + {GCTP_ISINUS1, "GCTP_ISINUS1"}, + {GCTP_CEA, "GCTP_CEA"}, + {GCTP_BCEA, "GCTP_BCEA"}, + {GCTP_ISINUS, "GCTP_ISINUS"}, + {-1, NULL} +}; + + +/* Grid Function Prototypes (internal routines) */ +intn GDchkgdid(int32, char *, int32 *, int32 *, int32 *); +intn GDfldinfo(int32, char *, int32 *, int32 [], int32 *, char *); +intn GDdeffld(int32, char *, char *, int32, int32); +intn GDwrmeta(int32, char *, char *, int32); +intn GDSDfldsrch(int32, int32, char *, int32 *, int32 *, + int32 *, int32 *, int32 [], int32 *); +intn GDwrrdfield(int32, char *, char *, + int32 [], int32 [], int32 [], VOIDP datbuf); +intn GDwrfld(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn GDrdfld(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn GDwrrdattr(int32, char *, int32, int32, char *, VOIDP); +intn GDll2ij(int32, int32, float64 [], int32, int32, int32, float64 [], + float64 [], int32, float64 [], float64 [], int32 [], int32 [], + float64 [], float64 []); +intn GDij2ll(int32, int32, float64 [], int32, int32, int32, + float64 [], float64 [], int32, int32 [], int32 [], + float64 [], float64 [], int32, int32); +intn GDreginfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *, + float64 [], float64 []); +intn GDgetdefaults(int32, int32, float64 [], int32, float64 [], float64 []); +int32 GDdefvrtreg(int32, int32, char *, float64 []); +intn GDgetpix(int32, int32, float64 [], float64 [], int32 [], int32 []); +int32 GDgetpixval(int32, int32, int32 [], int32 [], char *, VOIDP); +intn GDtangentpnts(int32, float64 [], float64 [], float64 [], float64 [], + float64 [], int32 *); +intn GDwrrdtile(int32, char *, char *, int32 [], VOIDP); +intn GDdeftle(int32, int32, int32, int32 []); +intn GDtleinfo(int32, char *, int32 *, int32 *, int32 []); +intn GDwrtle(int32, char *, int32 [], VOIDP); +intn GDrdtle(int32, char *, int32 [], VOIDP); +intn GDll2mm_cea(int32 projcode,int32 zonecode, int32 spherecode, + float64 projparm[], + int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], int32 npnts, + float64 lon[],float64 lat[], + float64 x[],float64 y[], float64 *scaleX,float64 *scaleY); + +intn GDmm2ll_cea(int32 projcode,int32 zonecode, int32 spherecode, + float64 projparm[], + int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], int32 npnts, + float64 x[], float64 y[], + float64 lon[], float64 lat[]); +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDopen | +| | +| DESCRIPTION: Opens or creates HDF file in order to create, read, or write | +| a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| fid int32 HDF-EOS file ID | +| | +| INPUTS: | +| filename char Filename | +| access intn HDF access code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDopen(char *filename, intn access) + +{ + int32 fid /* HDF-EOS file ID */ ; + + /* Call EHopen to perform file access */ + /* ---------------------------------- */ + fid = EHopen(filename, access); + + return (fid); + +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDcreate | +| | +| DESCRIPTION: Creates a grid within the file. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| gridID int32 Grid structure ID | +| | +| INPUTS: | +| fid int32 File ID | +| gridname char Grid structure name | +| xdimsize int32 Number of columns in grid | +| ydimsize int32 Number of rows in grid | +| upleftpt float64 Location (m/deg) of upper left corner | +| lowrightpt float64 Location (m/deg) of lower right corner | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Aug 96 Joel Gales Check grid name for ODL compliance | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDcreate(int32 fid, char *gridname, int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[]) +{ + intn i; /* Loop index */ + intn ngridopen = 0; /* # of grid structures open */ + intn status = 0; /* routine return status variable */ + + uint8 access; /* Read/Write file access code */ + + int32 HDFfid; /* HDF file id */ + int32 vgRef; /* Vgroup reference number */ + int32 vgid[3]; /* Vgroup ID array */ + int32 gridID = -1;/* HDF-EOS grid ID */ + + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 nGrid = 0; /* Grid counter */ + + char name[80]; /* Vgroup name */ + char class[80]; /* Vgroup class */ + char errbuf[256];/* Buffer for error message */ + char utlbuf[1024]; /* Utility buffer */ + char header[128];/* Structural metadata header string */ + char footer[256];/* Structural metadata footer string */ + char refstr1[128]; /* Upper left ref string (metadata) */ + char refstr2[128]; /* Lower right ref string (metadata) */ + + + /* + * Check HDF-EOS file ID, get back HDF file ID, SD interface ID and + * access code + */ + status = EHchkfid(fid, gridname, &HDFfid, &sdInterfaceID, &access); + + + /* Check gridname for length */ + /* ------------------------- */ + if ((intn) strlen(gridname) > VGNAMELENMAX) + { + status = -1; + HEpush(DFE_GENAPP, "GDcreate", __FILE__, __LINE__); + HEreport("Gridname \"%s\" must be less than %d characters.\n", + gridname, VGNAMELENMAX); + } + + + + if (status == 0) + { + /* Determine number of grids currently opened */ + /* ------------------------------------------- */ + for (i = 0; i < NGRID; i++) + { + ngridopen += GDXGrid[i].active; + } + + + /* Setup file interface */ + /* -------------------- */ + if (ngridopen < NGRID) + { + + /* Check that grid has not been previously opened */ + /* ----------------------------------------------- */ + vgRef = -1; + + while (1) + { + vgRef = Vgetid(HDFfid, vgRef); + + /* If no more Vgroups then exist while loop */ + /* ---------------------------------------- */ + if (vgRef == -1) + { + break; + } + + /* Get name and class of Vgroup */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, vgRef, "r"); + Vgetname(vgid[0], name); + Vgetclass(vgid[0], class); + Vdetach(vgid[0]); + + + /* If GRID then increment # grid counter */ + /* ------------------------------------- */ + if (strcmp(class, "GRID") == 0) + { + nGrid++; + } + + + /* If grid already exist, return error */ + /* ------------------------------------ */ + if (strcmp(name, gridname) == 0 && + strcmp(class, "GRID") == 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDcreate", __FILE__, __LINE__); + HEreport("\"%s\" already exists.\n", gridname); + break; + } + } + + + if (status == 0) + { + /* Create Root Vgroup for Grid */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, -1, "w"); + + + /* Set Name and Class (GRID) */ + /* -------------------------- */ + Vsetname(vgid[0], gridname); + Vsetclass(vgid[0], "GRID"); + + + + /* Create Data Fields Vgroup */ + /* ------------------------- */ + vgid[1] = Vattach(HDFfid, -1, "w"); + Vsetname(vgid[1], "Data Fields"); + Vsetclass(vgid[1], "GRID Vgroup"); + Vinsert(vgid[0], vgid[1]); + + + + /* Create Attributes Vgroup */ + /* ------------------------ */ + vgid[2] = Vattach(HDFfid, -1, "w"); + Vsetname(vgid[2], "Grid Attributes"); + Vsetclass(vgid[2], "GRID Vgroup"); + Vinsert(vgid[0], vgid[2]); + + + + /* Establish Grid in Structural MetaData Block */ + /* -------------------------------------------- */ + sprintf(header, "%s%d%s%s%s%s%d%s%s%d%s", + "\tGROUP=GRID_", (int)(nGrid + 1), + "\n\t\tGridName=\"", gridname, "\"\n", + "\t\tXDim=", (int)xdimsize, "\n", + "\t\tYDim=", (int)ydimsize, "\n"); + + + sprintf(footer, + "%s%s%s%s%s%s%s%d%s", + "\t\tGROUP=Dimension\n", + "\t\tEND_GROUP=Dimension\n", + "\t\tGROUP=DataField\n", + "\t\tEND_GROUP=DataField\n", + "\t\tGROUP=MergedFields\n", + "\t\tEND_GROUP=MergedFields\n", + "\tEND_GROUP=GRID_", (int)(nGrid + 1), "\n"); + + + + /* Build Ref point Col-Row strings */ + /* ------------------------------- */ + if (upleftpt == NULL || + (upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0)) + { + strcpy(refstr1, "DEFAULT"); + strcpy(refstr2, "DEFAULT"); + } + else + { + sprintf(refstr1, "%s%lf%s%lf%s", + "(", upleftpt[0], ",", upleftpt[1], ")"); + + sprintf(refstr2, "%s%lf%s%lf%s", + "(", lowrightpt[0], ",", lowrightpt[1], ")"); + } + + sprintf(utlbuf, + "%s%s%s%s%s%s%s%s", + header, + "\t\tUpperLeftPointMtrs=", refstr1, "\n", + "\t\tLowerRightMtrs=", refstr2, "\n", + footer); + + status = EHinsertmeta(sdInterfaceID, "", "g", 1002L, + utlbuf, NULL); + + } + } + else + { + /* Too many files opened */ + /* --------------------- */ + status = -1; + strcpy(errbuf, + "No more than %d grids may be open simutaneously"); + strcat(errbuf, " (%s)"); + HEpush(DFE_DENIED, "GDcreate", __FILE__, __LINE__); + HEreport(errbuf, NGRID, gridname); + } + + + /* Assign gridID # & Load grid and GDXGrid.fid table entries */ + /* --------------------------------------------------------- */ + if (status == 0) + { + + for (i = 0; i < NGRID; i++) + { + if (GDXGrid[i].active == 0) + { + gridID = i + idOffset; + GDXGrid[i].active = 1; + GDXGrid[i].IDTable = vgid[0]; + GDXGrid[i].VIDTable[0] = vgid[1]; + GDXGrid[i].VIDTable[1] = vgid[2]; + GDXGrid[i].fid = fid; + status = 0; + break; + } + } + + } + } + return (gridID); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDattach | +| | +| DESCRIPTION: Attaches to an existing grid within the file. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| gridID int32 grid structure ID | +| | +| INPUTS: | +| fid int32 HDF-EOS file id | +| gridname char grid sructure name | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Sep 99 Abe Taaheri Modified test for memory allocation check when no | +| SDSs are in the grid, NCR24147 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDattach(int32 fid, char *gridname) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn ngridopen = 0; /* # of grid structures open */ + intn status; /* routine return status variable */ + + uint8 acs; /* Read/Write file access code */ + + int32 HDFfid; /* HDF file id */ + int32 vgRef; /* Vgroup reference number */ + int32 vgid[3]; /* Vgroup ID array */ + int32 gridID = -1;/* HDF-EOS grid ID */ + int32 *tags; /* Pnt to Vgroup object tags array */ + int32 *refs; /* Pnt to Vgroup object refs array */ + int32 dum; /* dummy varible */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 nObjects; /* # of objects in Vgroup */ + int32 nSDS; /* SDS counter */ + int32 index; /* SDS index */ + int32 sdid; /* SDS object ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char name[80]; /* Vgroup name */ + char class[80]; /* Vgroup class */ + char errbuf[256];/* Buffer for error message */ + char acsCode[1]; /* Read/Write access char: "r/w" */ + + + /* Check HDF-EOS file ID, get back HDF file ID and access code */ + /* ----------------------------------------------------------- */ + status = EHchkfid(fid, gridname, &HDFfid, &dum, &acs); + + + if (status == 0) + { + /* Convert numeric access code to character */ + /* ---------------------------------------- */ + + acsCode[0] = (acs == 1) ? 'w' : 'r'; + + /* Determine number of grids currently opened */ + /* ------------------------------------------- */ + for (i = 0; i < NGRID; i++) + { + ngridopen += GDXGrid[i].active; + } + + + /* If room for more ... */ + /* -------------------- */ + if (ngridopen < NGRID) + { + + /* Search Vgroups for Grid */ + /* ------------------------ */ + vgRef = -1; + + while (1) + { + vgRef = Vgetid(HDFfid, vgRef); + + /* If no more Vgroups then exist while loop */ + /* ---------------------------------------- */ + if (vgRef == -1) + { + break; + } + + /* Get name and class of Vgroup */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, vgRef, "r"); + Vgetname(vgid[0], name); + Vgetclass(vgid[0], class); + + + /* + * If Vgroup with gridname and class GRID found, load tables + */ + + if (strcmp(name, gridname) == 0 && + strcmp(class, "GRID") == 0) + { + /* Attach to "Data Fields" and "Grid Attributes" Vgroups */ + /* ----------------------------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * 2); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * 2); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); + free(tags); + return(-1); + } + Vgettagrefs(vgid[0], tags, refs, 2); + vgid[1] = Vattach(HDFfid, refs[0], acsCode); + vgid[2] = Vattach(HDFfid, refs[1], acsCode); + free(tags); + free(refs); + + + /* Setup External Arrays */ + /* --------------------- */ + for (i = 0; i < NGRID; i++) + { + /* Find empty entry in array */ + /* ------------------------- */ + if (GDXGrid[i].active == 0) + { + /* + * Set gridID, Set grid entry active, Store root + * Vgroup ID, Store sub Vgroup IDs, Store HDF-EOS + * file ID + */ + gridID = i + idOffset; + GDXGrid[i].active = 1; + GDXGrid[i].IDTable = vgid[0]; + GDXGrid[i].VIDTable[0] = vgid[1]; + GDXGrid[i].VIDTable[1] = vgid[2]; + GDXGrid[i].fid = fid; + break; + } + } + + /* Get SDS interface ID */ + /* -------------------- */ + status = GDchkgdid(gridID, "GDattach", &dum, + &sdInterfaceID, &dum); + + + /* Get # of entries within Data Vgroup & search for SDS */ + /* ---------------------------------------------------- */ + nObjects = Vntagrefs(vgid[1]); + + if (nObjects > 0) + { + /* Get tag and ref # for Data Vgroup objects */ + /* ----------------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * nObjects); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * nObjects); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); + free(tags); + return(-1); + } + Vgettagrefs(vgid[1], tags, refs, nObjects); + + /* Count number of SDS & allocate SDS ID array */ + /* ------------------------------------------- */ + nSDS = 0; + for (j = 0; j < nObjects; j++) + { + if (tags[j] == DFTAG_NDG) + { + nSDS++; + } + } + GDXGrid[i].sdsID = (int32 *) calloc(nSDS, 4); + if(GDXGrid[i].sdsID == NULL && nSDS != 0) + { + HEpush(DFE_NOSPACE,"GDattach", __FILE__, __LINE__); + free(tags); + free(refs); + return(-1); + } + nSDS = 0; + + + + /* Fill SDS ID array */ + /* ----------------- */ + for (j = 0; j < nObjects; j++) + { + /* If object is SDS then get id */ + /* ---------------------------- */ + if (tags[j] == DFTAG_NDG) + { + index = SDreftoindex(sdInterfaceID, refs[j]); + sdid = SDselect(sdInterfaceID, index); + GDXGrid[i].sdsID[nSDS] = sdid; + nSDS++; + GDXGrid[i].nSDS++; + } + } + free(tags); + free(refs); + } + break; + } + + /* Detach Vgroup if not desired Grid */ + /* --------------------------------- */ + Vdetach(vgid[0]); + } + + /* If Grid not found then set up error message */ + /* ------------------------------------------- */ + if (gridID == -1) + { + HEpush(DFE_RANGE, "GDattach", __FILE__, __LINE__); + HEreport("Grid: \"%s\" does not exist within HDF file.\n", + gridname); + } + } + else + { + /* Too many files opened */ + /* --------------------- */ + gridID = -1; + strcpy(errbuf, + "No more than %d grids may be open simutaneously"); + strcat(errbuf, " (%s)"); + HEpush(DFE_DENIED, "GDattach", __FILE__, __LINE__); + HEreport(errbuf, NGRID, gridname); + } + + } + return (gridID); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDchkgdid | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| routname char Name of routine calling GDchkgdid | +| | +| OUTPUTS: | +| fid int32 File ID | +| sdInterfaceID int32 SDS interface ID | +| gdVgrpID int32 grid Vgroup ID | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDchkgdid(int32 gridID, char *routname, + int32 * fid, int32 * sdInterfaceID, int32 * gdVgrpID) +{ + intn status = 0; /* routine return status variable */ + uint8 access; /* Read/Write access code */ + int32 gID; /* Grid ID - offset */ + + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char message1[] = + "Invalid grid id: %d in routine \"%s\". ID must be >= %d and < %d.\n"; + char message2[] = + "Grid id %d in routine \"%s\" not active.\n"; + + + + /* Check for valid grid id */ + + if (gridID < idOffset || gridID >= NGRID + idOffset) + { + status = -1; + HEpush(DFE_RANGE, "GDchkgdid", __FILE__, __LINE__); + HEreport(message1, gridID, routname, idOffset, NGRID + idOffset); + } + else + { + + /* Compute "reduced" ID */ + /* -------------------- */ + gID = gridID % idOffset; + + + /* Check for active grid ID */ + /* ------------------------ */ + if (GDXGrid[gID].active == 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDchkgdid", __FILE__, __LINE__); + HEreport(message2, gridID, routname); + } + else + { + + /* Get file & SDS ids and Grid key */ + /* -------------------------------- */ + status = EHchkfid(GDXGrid[gID].fid, " ", + fid, sdInterfaceID, &access); + *gdVgrpID = GDXGrid[gID].IDTable; + } + } + return (status); + +} + + + + + + + + + + + + + + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefdim | +| | +| DESCRIPTION: Defines a new dimension within the grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| dimname char Dimension name to define | +| dim int32 Dimemsion value | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdefdim(int32 gridID, char *dimname, int32 dim) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file id */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char gridname[80] /* Grid name */ ; + + + /* Check for valid grid id */ + status = GDchkgdid(gridID, "GDdefinedim", + &fid, &sdInterfaceID, &gdVgrpID); + + + /* Make sure dimension >= 0 */ + /* ------------------------ */ + if (dim < 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefdim", __FILE__, __LINE__); + HEreport("Dimension value for \"%s\" less than zero: %d.\n", + dimname, dim); + } + + + /* Write Dimension to Structural MetaData */ + /* -------------------------------------- */ + if (status == 0) + { + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + status = EHinsertmeta(sdInterfaceID, gridname, "g", 0L, + dimname, &dim); + } + return (status); + +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefproj | +| | +| DESCRIPTION: Defines projection of grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| spherecode int32 GCTP spheriod code | +| projparm float64 Projection parameters | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdefproj(int32 gridID, int32 projcode, int32 zonecode, int32 spherecode, + float64 projparm[]) +{ + intn i; /* Loop index */ + intn projx; /* Projection table index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 slen; /* String length */ + float64 EHconvAng(); + char utlbuf[1024]; /* Utility Buffer */ + char projparmbuf[512]; /* Projection parameter metadata + * string */ + char gridname[80]; /* Grid Name */ + + + /* Check for valid grid id */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDdefproj", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* + * If projection not GEO, UTM, or State Code build projection + * parameter string + */ + if (projcode != GCTP_GEO && + projcode != GCTP_UTM && + projcode != GCTP_SPCS) + { + + /* Begin projection parameter list with "(" */ + strcpy(projparmbuf, "("); + + for (i = 0; i < 13; i++) + { + /* If projparm[i] = 0 ... */ + if (projparm[i] == 0.0) + { + strcpy(utlbuf, "0,"); + } + else + { + /* if projparm[i] is integer ... */ + if ((int32) projparm[i] == projparm[i]) + { + sprintf(utlbuf, "%d%s", + (int) projparm[i], ","); + } + /* else projparm[i] is non-zero floating point ... */ + else + { + sprintf(utlbuf, "%lf%s", + projparm[i], ","); + } + } + strcat(projparmbuf, utlbuf); + } + slen = strlen(projparmbuf); + + /* Add trailing ")" */ + projparmbuf[slen - 1] = ')'; + } + + for (projx = 0; Projections[projx].projcode != -1; projx++) + { + if (projcode == Projections[projx].projcode) + { + break; + } + } + + + /* Build metadata string */ + /* --------------------- */ + if ((projcode == GCTP_GEO)) + { + sprintf(utlbuf, + "%s%s%s", + "\t\tProjection=", Projections[projx].projname, "\n"); + } + else if (projcode == GCTP_UTM || projcode == GCTP_SPCS) + { + sprintf(utlbuf, + "%s%s%s%s%d%s%s%d%s", + "\t\tProjection=", Projections[projx].projname, "\n", + "\t\tZoneCode=", (int)zonecode, "\n", + "\t\tSphereCode=", (int)spherecode, "\n"); + } + else + { + sprintf(utlbuf, + "%s%s%s%s%s%s%s%d%s", + "\t\tProjection=", Projections[projx].projname, "\n", + "\t\tProjParams=", projparmbuf, "\n", + "\t\tSphereCode=", (int)spherecode, "\n"); + } + + + /* Insert in structural metadata */ + /* ----------------------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + status = EHinsertmeta(sdInterfaceID, gridname, "g", 101L, + utlbuf, NULL); + } + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDblkSOMoffset | +| | +| DESCRIPTION: Writes Block SOM offset values | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| offset float32 Offset values | +| count int32 Number of offset values | +| code char w/r code (w/r) | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| Mar 99 David Wynne Changed data type of offset array from int32 to | +| float32, NCR 21197 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDblkSOMoffset(int32 gridID, float32 offset[], int32 count, char *code) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 projcode; /* GCTP projection code */ + + float64 projparm[13]; /* Projection parameters */ + + char utlbuf[128];/* Utility Buffer */ + char gridname[80]; /* Grid Name */ + + /* Check for valid grid id */ + status = GDchkgdid(gridID, "GDblkSOMoffset", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get projection parameters */ + status = GDprojinfo(gridID, &projcode, NULL, NULL, projparm); + + /* If SOM projection with projparm[11] non-zero ... */ + if (projcode == GCTP_SOM && projparm[11] != 0) + { + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + sprintf(utlbuf, "%s%s", "_BLKSOM:", gridname); + + /* Write offset values as attribute */ + if (strcmp(code, "w") == 0) + { + status = GDwriteattr(gridID, utlbuf, DFNT_FLOAT32, + count, offset); + } + /* Read offset values from attribute */ + else if (strcmp(code, "r") == 0) + { + status = GDreadattr(gridID, utlbuf, offset); + } + } + } + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefcomp | +| | +| DESCRIPTION: Defines compression type and parameters | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| compcode int32 compression code | +| compparm intn compression parameters | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdefcomp(int32 gridID, int32 compcode, intn compparm[]) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file id */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 gID; /* gridID - offset */ + + /* Check for valid grid id */ + status = GDchkgdid(gridID, "GDdefcomp", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + gID = gridID % idOffset; + + /* Set compression code in compression exteral array */ + GDXGrid[gID].compcode = compcode; + + switch (compcode) + { + /* Set NBIT compression parameters in compression external array */ + case HDFE_COMP_NBIT: + + GDXGrid[gID].compparm[0] = compparm[0]; + GDXGrid[gID].compparm[1] = compparm[1]; + GDXGrid[gID].compparm[2] = compparm[2]; + GDXGrid[gID].compparm[3] = compparm[3]; + + break; + + /* Set GZIP compression parameter in compression external array */ + case HDFE_COMP_DEFLATE: + + GDXGrid[gID].compparm[0] = compparm[0]; + + break; + + } + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeftile | +| | +| DESCRIPTION: Defines tiling parameters | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| tilecode int32 tile code | +| tilerank int32 number of tiling dimensions | +| tiledims int32 tiling dimensions | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jan 97 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdeftile(int32 gridID, int32 tilecode, int32 tilerank, int32 tiledims[]) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file id */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 gID; /* gridID - offset */ + + /* Check for valid grid id */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDdeftile", &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + gID = gridID % idOffset; + + for (i = 0; i < 8; i++) + { + GDXGrid[gID].tiledims[i] = 0; + } + + GDXGrid[gID].tilecode = tilecode; + + switch (tilecode) + { + case HDFE_NOTILE: + + GDXGrid[gID].tilerank = 0; + + break; + + + case HDFE_TILE: + + GDXGrid[gID].tilerank = tilerank; + + for (i = 0; i < tilerank; i++) + { + GDXGrid[gID].tiledims[i] = tiledims[i]; + + if (GDXGrid[gID].tiledims[i] == 0) + { + GDXGrid[gID].tiledims[i] = 1; + } + } + + break; + + } + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeftle | +| | +| DESCRIPTION: FORTRAN wrapper around GDdetfile | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| tilecode int32 tile code | +| tilerank int32 number of tiling dimensions | +| forttiledims int32 tiling dimensions (FORTRAN order) | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Mar 97 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdeftle(int32 gridID, int32 tilecode, int32 tilerank, int32 forttiledims[]) +{ + intn j, status; + int32 dims[8]; + + + /* Reverse order of dimensions (FORTRAN -> C) */ + /* ------------------------------------------ */ + for (j = 0; j < tilerank; j++) + { + dims[j] = forttiledims[tilerank - 1 - j];; + } + + + /* Call GDdeftile routine to define tile */ + /* ------------------------------------- */ + status = GDdeftile(gridID, tilecode, tilerank, dims); + + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeforigin | +| | +| DESCRIPTION: Defines the origin of the grid data. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| origincode int32 origin code | +| HDFE_GD_UL (0) | +| HDFE_GD_UR (1) | +| HDFE_GD_LL (2) | +| HDFE_GD_LR (3) | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdeforigin(int32 gridID, int32 origincode) +{ + /* + * intn status = 0; + * + * int32 fid, gdkey; int32 sdInterfaceID, idOffset = + * GDIDOFFSET; + * + * char utlbuf[64]; char gridname[80]; + */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char utlbuf[64]; /* Utility buffer */ + char gridname[80]; /* Grid name */ + + char *originNames[] = {"HDFE_GD_UL", "HDFE_GD_UR", + "HDFE_GD_LL", "HDFE_GD_LR"}; + /* Origin Codes */ + + + /* Check for valid grid id */ + status = GDchkgdid(gridID, "GDdeforigin", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* If proper origin code then write to structural metadata */ + /* ------------------------------------------------------- */ + if (origincode >= 0 && origincode <= 3) + { + sprintf(utlbuf, "%s%s%s", + "\t\tGridOrigin=", originNames[origincode], "\n"); + + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + status = EHinsertmeta(sdInterfaceID, gridname, "g", 101L, + utlbuf, NULL); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDdeforigin", __FILE__, __LINE__); + HEreport("Improper Grid Origin code: %d\n", origincode); + } + } + + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefpixreg | +| | +| DESCRIPTION: Defines pixel registration within grid cell. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| pixregcode int32 Pixel registration code | +| HDFE_CENTER (0) | +| HDFE_CORNER (1) | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdefpixreg(int32 gridID, int32 pixregcode) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char utlbuf[64]; /* Utility buffer */ + char gridname[80]; /* Grid name */ + + char *pixregNames[] = {"HDFE_CENTER", "HDFE_CORNER"}; + /* Pixel Registration Codes */ + + /* Check for valid grid id */ + status = GDchkgdid(gridID, "GDdefpixreg", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* If proper pix reg code then write to structural metadata */ + /* -------------------------------------------------------- */ + if (pixregcode >= 0 && pixregcode <= 1) + { + sprintf(utlbuf, "%s%s%s", + "\t\tPixelRegistration=", pixregNames[pixregcode], "\n"); + + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + status = EHinsertmeta(sdInterfaceID, gridname, "g", 101L, + utlbuf, NULL); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDdefpixreg", __FILE__, __LINE__); + HEreport("Improper Pixel Registration code: %d\n", pixregcode); + } + } + + return (status); + +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdiminfo | +| | +| DESCRIPTION: Retrieve size of specified dimension. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| size int32 Size of dimension | +| | +| INPUTS: | +| gridID int32 grid structure id | +| dimname char Dimension name | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDdiminfo(int32 gridID, char *dimname) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 size; /* Dimension size */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDdiminfo", __FILE__, __LINE__); + return(-1); + } + /* Initialize return value */ + /* ----------------------- */ + size = -1; + + + /* Check Grid ID */ + /* ------------- */ + status = GDchkgdid(gridID, "GDdiminfo", &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to "Dimension" section within SM */ + /* --------------------------------------------- */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "Dimension", metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + /* Search for dimension name (surrounded by quotes) */ + /* ------------------------------------------------ */ + sprintf(utlstr, "%s%s%s", "\"", dimname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* + * If dimension found within grid structure then get dimension value + */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Set endptr at end of dimension definition entry */ + /* ----------------------------------------------- */ + metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT"); + + status = EHgetmetavalue(metaptrs, "Size", utlstr); + + if (status == 0) + { + size = atol(utlstr); + } + else + { + HEpush(DFE_GENAPP, "GDdiminfo", __FILE__, __LINE__); + HEreport("\"Size\" string not found in metadata.\n"); + } + } + else + { + HEpush(DFE_GENAPP, "GDdiminfo", __FILE__, __LINE__); + HEreport("Dimension \"%s\" not found.\n", dimname); + } + + free(metabuf); + } + free(utlstr); + return (size); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgridinfo | +| | +| DESCRIPTION: Returns xdim, ydim and location of upper left and lower | +| right corners, in meters. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 File ID | +| gridname char Grid structure name | +| | +| OUTPUTS: | +| xdimsize int32 Number of columns in grid | +| ydimsize int32 Number of rows in grid | +| upleftpt float64 Location (m/deg) of upper left corner | +| lowrightpt float64 Location (m/deg) of lower right corner | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDgridinfo(int32 gridID, int32 * xdimsize, int32 * ydimsize, + float64 upleftpt[], float64 lowrightpt[]) + +{ + intn status = 0; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDgridinfo", __FILE__, __LINE__); + return(-1); + } + /* Check Grid ID */ + /* ------------- */ + status = GDchkgdid(gridID, "GDgridinfo", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to grid structure section within SM */ + /* ------------------------------------------------ */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + NULL, metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* Get xdimsize if requested */ + /* ------------------------- */ + if (xdimsize != NULL) + { + statmeta = EHgetmetavalue(metaptrs, "XDim", utlstr); + if (statmeta == 0) + { + *xdimsize = atol(utlstr); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDgridinfo", __FILE__, __LINE__); + HEreport("\"XDim\" string not found in metadata.\n"); + } + } + + + /* Get ydimsize if requested */ + /* ------------------------- */ + if (ydimsize != NULL) + { + statmeta = EHgetmetavalue(metaptrs, "YDim", utlstr); + if (statmeta == 0) + { + *ydimsize = atol(utlstr); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDgridinfo", __FILE__, __LINE__); + HEreport("\"YDim\" string not found in metadata.\n"); + } + } + + + /* Get upleftpt if requested */ + /* ------------------------- */ + if (upleftpt != NULL) + { + statmeta = EHgetmetavalue(metaptrs, "UpperLeftPointMtrs", utlstr); + if (statmeta == 0) + { + /* If value is "DEFAULT" then return zeros */ + /* --------------------------------------- */ + if (strcmp(utlstr, "DEFAULT") == 0) + { + upleftpt[0] = 0; + upleftpt[1] = 0; + } + else + { + sscanf(utlstr, "(%lf,%lf)", + &upleftpt[0], &upleftpt[1]); + } + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDgridinfo", __FILE__, __LINE__); + HEreport( + "\"UpperLeftPointMtrs\" string not found in metadata.\n"); + } + + } + + /* Get lowrightpt if requested */ + /* --------------------------- */ + if (lowrightpt != NULL) + { + statmeta = EHgetmetavalue(metaptrs, "LowerRightMtrs", utlstr); + if (statmeta == 0) + { + /* If value is "DEFAULT" then return zeros */ + if (strcmp(utlstr, "DEFAULT") == 0) + { + lowrightpt[0] = 0; + lowrightpt[1] = 0; + } + else + { + sscanf(utlstr, "(%lf,%lf)", + &lowrightpt[0], &lowrightpt[1]); + } + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDgridinfo", __FILE__, __LINE__); + HEreport( + "\"LowerRightMtrs\" string not found in metadata.\n"); + } + } + + free(metabuf); + } + free(utlstr); + return (status); +} + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDprojinfo | +| | +| DESCRIPTION: Returns GCTP projection code, zone code, spheroid code | +| and projection parameters. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| | +| OUTPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| spherecode int32 GCTP spheriod code | +| projparm float64 Projection parameters | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Add check for no projection code | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDprojinfo(int32 gridID, int32 * projcode, int32 * zonecode, + int32 * spherecode, float64 projparm[]) + +{ + intn i; /* Loop index */ + intn projx; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + char fmt[96]; /* Format String */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDprojinfo", __FILE__, __LINE__); + return(-1); + } + + /* Check Grid ID */ + /* ------------- */ + status = GDchkgdid(gridID, "GDprojinfo", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to grid structure section within SM */ + /* ------------------------------------------------ */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + NULL, metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* Get projcode if requested */ + /* ------------------------- */ + if (projcode != NULL) + { + *projcode = -1; + + statmeta = EHgetmetavalue(metaptrs, "Projection", utlstr); + if (statmeta == 0) + { + /* Loop through projection codes until found */ + /* ----------------------------------------- */ + for (projx = 0; Projections[projx].projcode != -1; projx++) + if (strcmp(utlstr, Projections[projx].projname) == 0) + break; + if (Projections[projx].projname != NULL) + *projcode = Projections[projx].projcode; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDprojinfo", __FILE__, __LINE__); + HEreport("Projection Code not defined for \"%s\".\n", + gridname); + + if (projparm != NULL) + { + for (i = 0; i < 13; i++) + { + projparm[i] = -1; + } + } + } + } + + + /* Get zonecode if requested */ + /* ------------------------- */ + if (zonecode != NULL) + { + *zonecode = -1; + + + /* Zone code only relevant for UTM and State Code projections */ + /* ---------------------------------------------------------- */ + if (*projcode == GCTP_UTM || *projcode == GCTP_SPCS) + { + statmeta = EHgetmetavalue(metaptrs, "ZoneCode", utlstr); + if (statmeta == 0) + { + *zonecode = atol(utlstr); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDprojinfo", __FILE__, __LINE__); + HEreport("Zone Code not defined for \"%s\".\n", + gridname); + } + } + } + + + /* Get projection parameters if requested */ + /* -------------------------------------- */ + if (projparm != NULL) + { + + /* + * Note: No projection parameters for GEO, UTM, and State Code + * projections + */ + if (*projcode == GCTP_GEO || *projcode == GCTP_UTM || + *projcode == GCTP_SPCS) + { + for (i = 0; i < 13; i++) + { + projparm[i] = 0.0; + } + + } + else + { + statmeta = EHgetmetavalue(metaptrs, "ProjParams", utlstr); + + if (statmeta == 0) + { + + /* Build format string to read projection parameters */ + /* ------------------------------------------------- */ + strcpy(fmt, "%lf,"); + for (i = 1; i <= 11; i++) + strcat(fmt, "%lf,"); + strcat(fmt, "%lf"); + + + /* Read parameters from numeric list */ + /* --------------------------------- */ + sscanf(&utlstr[1], fmt, + &projparm[0], &projparm[1], + &projparm[2], &projparm[3], + &projparm[4], &projparm[5], + &projparm[6], &projparm[7], + &projparm[8], &projparm[9], + &projparm[10], &projparm[11], + &projparm[12]); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDprojinfo", __FILE__, __LINE__); + HEreport("Projection parameters not defined for \"%s\".\n", + gridname); + + } + } + } + + + /* Get spherecode if requested */ + /* --------------------------- */ + if (spherecode != NULL) + { + *spherecode = 0; + + /* Note: Spherecode not defined for GEO projection */ + /* ----------------------------------------------- */ + if ((*projcode != GCTP_GEO)) + { + EHgetmetavalue(metaptrs, "SphereCode", utlstr); + if (statmeta == 0) + { + *spherecode = atol(utlstr); + } + } + } + free(metabuf); + + } + free(utlstr); + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDorigininfo | +| | +| DESCRIPTION: Returns origin code | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| | +| | +| OUTPUTS: | +| origincode int32 grid origin code | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDorigininfo(int32 gridID, int32 * origincode) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + + char *originNames[] = {"HDFE_GD_UL", "HDFE_GD_UR", + "HDFE_GD_LL", "HDFE_GD_LR"};/* Origin Codes */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDorigininfo", __FILE__, __LINE__); + return(-1); + } + /* Check Grid ID */ + /* ------------- */ + status = GDchkgdid(gridID, "GDorigininfo", + &fid, &sdInterfaceID, &gdVgrpID); + + + /* Initialize pixreg code to -1 (in case of error) */ + /* ----------------------------------------------- */ + *origincode = -1; + + if (status == 0) + { + /* Set default origin code */ + /* ----------------------- */ + *origincode = 0; + + + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to grid structure section within SM */ + /* ------------------------------------------------ */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + NULL, metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + statmeta = EHgetmetavalue(metaptrs, "GridOrigin", utlstr); + + if (statmeta == 0) + { + /* + * If "GridOrigin" string found in metadata then convert to + * numeric origin code (fixed added: Jan 97) + */ + for (i = 0; i < 4; i++) + { + if (strcmp(utlstr, originNames[i]) == 0) + { + *origincode = i; + break; + } + } + } + + free(metabuf); + } + free(utlstr); + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDpixreginfo | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| | +| | +| OUTPUTS: | +| pixregcode int32 Pixel registration code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDpixreginfo(int32 gridID, int32 * pixregcode) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + + char *pixregNames[] = {"HDFE_CENTER", "HDFE_CORNER"}; + /* Pixel Registration Codes */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDpixreginfo", __FILE__, __LINE__); + return(-1); + } + /* Check Grid ID */ + status = GDchkgdid(gridID, "GDpixreginfo", + &fid, &sdInterfaceID, &gdVgrpID); + + /* Initialize pixreg code to -1 (in case of error) */ + *pixregcode = -1; + + if (status == 0) + { + /* Set default pixreg code */ + *pixregcode = 0; + + /* Get grid name */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + /* Get pointers to grid structure section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + NULL, metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + statmeta = EHgetmetavalue(metaptrs, "PixelRegistration", utlstr); + + if (statmeta == 0) + { + /* + * If "PixelRegistration" string found in metadata then convert + * to numeric origin code (fixed added: Jan 97) + */ + + for (i = 0; i < 2; i++) + { + if (strcmp(utlstr, pixregNames[i]) == 0) + { + *pixregcode = i; + break; + } + } + } + free(metabuf); + } + free(utlstr); + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDcompinfo | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn | +| | +| INPUTS: | +| gridID int32 | +| compcode int32 | +| compparm intn | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDcompinfo(int32 gridID, char *fieldname, int32 * compcode, intn compparm[]) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr;/* Utility string */ + + + char *HDFcomp[5] = {"HDFE_COMP_NONE", "HDFE_COMP_RLE", + "HDFE_COMP_NBIT", "HDFE_COMP_SKPHUFF", + "HDFE_COMP_DEFLATE"}; /* Compression Codes */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDcompinfo", __FILE__, __LINE__); + return(-1); + } + /* Check Grid ID */ + status = GDchkgdid(gridID, "GDcompinfo", &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + /* Get grid name */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + /* Get pointers to "DataField" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* Search for field */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + + /* If field found and user wants compression code ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + if (compcode != NULL) + { + /* Set endptr at end of field's definition entry */ + metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT"); + + /* Get compression type */ + statmeta = EHgetmetavalue(metaptrs, "CompressionType", utlstr); + + /* + * Default is no compression if "CompressionType" string not + * in metadata + */ + *compcode = HDFE_COMP_NONE; + + /* If compression code is found ... */ + if (statmeta == 0) + { + /* Loop through compression types until match */ + for (i = 0; i < 5; i++) + { + if (strcmp(utlstr, HDFcomp[i]) == 0) + { + *compcode = i; + break; + } + } + } + } + + /* If user wants compression parameters ... */ + if (compparm != NULL && compcode != NULL) + { + /* Initialize to zero */ + for (i = 0; i < 4; i++) + { + compparm[i] = 0.0; + } + + /* + * Get compression parameters if NBIT or DEFLATE compression + */ + if (*compcode == HDFE_COMP_NBIT) + { + statmeta = + EHgetmetavalue(metaptrs, "CompressionParams", utlstr); + if (statmeta == 0) + { + sscanf(utlstr, "(%d,%d,%d,%d)", + &compparm[0], &compparm[1], + &compparm[2], &compparm[3]); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDcompinfo", __FILE__, __LINE__); + HEreport( + "\"CompressionParams\" string not found in metadata.\n"); + } + } + else if (*compcode == HDFE_COMP_DEFLATE) + { + statmeta = + EHgetmetavalue(metaptrs, "DeflateLevel", utlstr); + if (statmeta == 0) + { + sscanf(utlstr, "%d", &compparm[0]); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDcompinfo", __FILE__, __LINE__); + HEreport( + "\"DeflateLevel\" string not found in metadata.\n"); + } + } + } + } + else + { + HEpush(DFE_GENAPP, "GDcompinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + + free(metabuf); + + } + free(utlstr); + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDfieldinfo | +| | +| DESCRIPTION: Retrieve information about a specific geolocation or data | +| field in the grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure id | +| fieldname char name of field | +| | +| | +| OUTPUTS: | +| rank int32 rank of field (# of dims) | +| dims int32 field dimensions | +| numbertype int32 field number type | +| dimlist char field dimension list | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| Feb 99 Abe Taaheri Changed memcpy to memmove to avoid overlapping | +| problem when copying strings | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDfieldinfo(int32 gridID, char *fieldname, int32 * rank, int32 dims[], + int32 * numbertype, char *dimlist) + +{ + intn i; /* Loop index */ + intn status; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 ndims; /* Number of dimensions */ + int32 slen[8]; /* Length of each entry in parsed string */ + int32 dum; /* Dummy variable */ + int32 xdim; /* X dim size */ + int32 ydim; /* Y dim size */ + int32 sdid; /* SDS id */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr; /* Utility string */ + char *ptr[8]; /* String pointers for parsed string */ + char dimstr[64]; /* Individual dimension entry string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDfieldinfo", __FILE__, __LINE__); + return(-1); + } + *rank = -1; + *numbertype = -1; + + status = GDchkgdid(gridID, "GDfieldinfo", &fid, &sdInterfaceID, &dum); + + if (status == 0) + { + + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* Search for field */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* If field found ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + + /* Set endptr at end of dimension definition entry */ + metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT"); + + /* Get DataType string */ + statmeta = EHgetmetavalue(metaptrs, "DataType", utlstr); + + /* Convert to numbertype code */ + if (statmeta == 0) + { + if (strcmp(utlstr, "DFNT_UCHAR8") == 0) + *numbertype = 3; + else if (strcmp(utlstr, "DFNT_CHAR8") == 0) + *numbertype = 4; + else if (strcmp(utlstr, "DFNT_FLOAT32") == 0) + *numbertype = 5; + else if (strcmp(utlstr, "DFNT_FLOAT64") == 0) + *numbertype = 6; + else if (strcmp(utlstr, "DFNT_INT8") == 0) + *numbertype = 20; + else if (strcmp(utlstr, "DFNT_UINT8") == 0) + *numbertype = 21; + else if (strcmp(utlstr, "DFNT_INT16") == 0) + *numbertype = 22; + else if (strcmp(utlstr, "DFNT_UINT16") == 0) + *numbertype = 23; + else if (strcmp(utlstr, "DFNT_INT32") == 0) + *numbertype = 24; + else if (strcmp(utlstr, "DFNT_UINT32") == 0) + *numbertype = 25; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDfieldinfo", __FILE__, __LINE__); + HEreport( + "\"DataType\" string not found in metadata.\n"); + } + + /* + * Get DimList string and trim off leading and trailing parens + * "()" + */ + statmeta = EHgetmetavalue(metaptrs, "DimList", utlstr); + + if (statmeta == 0) + { + memmove(utlstr, utlstr + 1, strlen(utlstr) - 2); + utlstr[strlen(utlstr) - 2] = 0; + + /* Parse trimmed DimList string and get rank */ + ndims = EHparsestr(utlstr, ',', ptr, slen); + *rank = ndims; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDfieldinfo", __FILE__, __LINE__); + HEreport( + "\"DimList\" string not found in metadata.\n"); + } + + + if (status == 0) + { + status = GDgridinfo(gridID, &xdim, &ydim, NULL, NULL); + + for (i = 0; i < ndims; i++) + { + memcpy(dimstr, ptr[i] + 1, slen[i] - 2); + dimstr[slen[i] - 2] = 0; + + if (strcmp(dimstr, "XDim") == 0) + { + dims[i] = xdim; + } + else if (strcmp(dimstr, "YDim") == 0) + { + dims[i] = ydim; + } + else + { + dims[i] = GDdiminfo(gridID, dimstr); + } + + + if (dimlist != NULL) + { + if (i == 0) + { + dimlist[0] = 0; + } + + if (i > 0) + { + strcat(dimlist, ","); + } + strcat(dimlist, dimstr); + } + } + + + if (dims[0] == 0) + { + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, + &sdid, &dum, &dum, &dum, dims, + &dum); + } + } + } + + free(metabuf); + } + + if (*rank == -1) + { + status = -1; + + HEpush(DFE_GENAPP, "GDfieldinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + free(utlstr); + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDfldinfo | +| | +| DESCRIPTION: FORTRAN wrapper around GDfieldinfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure id | +| fieldname char name of field | +| | +| | +| OUTPUTS: | +| rank int32 rank of field (# of dims) | +| dims int32 field dimensions | +| numbertype int32 field number type | +| fortdimlist char field dimension list (FORTRAN order) | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales Perform swap only if GDfieldinfo succesful | +| May 00 Abe Taaheri modified dynamic memoery allocation for dimlist to | +| static Allocation(NCR ECSed26831) +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDfldinfo(int32 gridID, char *fieldname, int32 * rank, int32 dims[], + int32 * numbertype, char *fortdimlist) +{ + + intn j, status; + int32 swap; + char dimlist[UTLSTR_MAX_SIZE]; + + + /* Call GDfieldinfo to get C dimensions */ + /* ------------------------------------ */ + status = GDfieldinfo(gridID, fieldname, rank, dims, + numbertype, dimlist); + + + /* Convert to FORTRAN dimension order */ + /* ---------------------------------- */ + if (status == 0) + { + for (j = 0; j < *rank / 2; j++) + { + swap = dims[*rank - 1 - j]; + dims[*rank - 1 - j] = dims[j]; + dims[j] = swap; + } + + + /* Convert dimlist to FORTRAN order */ + /* -------------------------------- */ + EHrevflds(dimlist, fortdimlist); + } + return (status); + +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeffield | +| | +| DESCRIPTION: Defines a new data field within the grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| merge int32 merge code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Check name for ODL compliance | +| Sep 96 Joel Gales Make string array "dimbuf" dynamic | +| Sep 96 Joel Gales Add support for Block SOM (MISR) | +| Jan 97 Joel Gales Add support for tiling | +| Feb 99 Abe Taaheri Changed strcpy to memmove to avoid overlapping | +| problem when copying strings | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdeffield(int32 gridID, char *fieldname, char *dimlist, + int32 numbertype, int32 merge) + +{ + intn i; /* Loop index */ + intn status; /* routine return status variable */ + intn found; /* utility found flag */ + intn foundNT = 0;/* found number type flag */ + intn foundAllDim = 1; /* found all dimensions flag */ + intn first = 1; /* first entry flag */ + + int32 fid; /* HDF-EOS file ID */ + int32 vgid; /* Geo/Data field Vgroup ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS object ID */ + int32 dimid; /* SDS dimension ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 dims[8]; /* Dimension size array */ + int32 dimsize; /* Dimension size */ + int32 rank = 0; /* Field rank */ + int32 slen[32]; /* String length array */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 compcode; /* Compression code */ + int32 tilecode; /* Tiling code */ + int32 chunkFlag; /* Chunking (Tiling) flag */ + int32 gID; /* GridID - offset */ + int32 xdim; /* Grid X dimension */ + int32 ydim; /* Grid Y dimension */ + int32 projcode; /* Projection Code */ + + float64 projparm[13]; /* Projection Parameters */ + + char *dimbuf; /* Dimension buffer */ + char *dimlist0; /* Auxilliary dimension list */ + char *comma; /* Pointer to comma */ + char *dimcheck; /* Dimension check buffer */ + char utlbuf[512];/* Utility buffer */ + char utlbuf2[256]; /* Utility buffer 1 */ + char *ptr[32]; /* String pointer array */ + char gridname[80]; /* Grid name */ + char parmbuf[128]; /* Parameter string buffer */ + char errbuf1[128]; /* Error buffer 1 */ + char errbuf2[128]; /* Error buffer 2 */ + char *errmsg1 = "Dimension: %d (size: %d) not divisible by "; + /* Tiling error message part 1 */ + char *errmsg2 = "tile dimension (size: %d).\n"; + /* Tiling error message part 2 */ + char errmsg[128];/* Tiling error message */ + + char *HDFcomp[5] = {"HDFE_COMP_NONE", "HDFE_COMP_RLE", + "HDFE_COMP_NBIT", "HDFE_COMP_SKPHUFF", + "HDFE_COMP_DEFLATE"}; + /* Compression code names */ + + uint16 good_number[10] = {3, 4, 5, 6, 20, 21, 22, 23, 24, 25}; + /* Valid number types */ + + comp_info c_info; /* Compression parameter structure */ + + HDF_CHUNK_DEF chunkDef; /* Tiling structure */ + + + + /* Setup error message strings */ + /* --------------------------- */ + strcpy(errbuf1, "GDXSDname array too small.\nPlease increase "); + strcat(errbuf1, "size of HDFE_NAMBUFSIZE in \"HdfEosDef.h\".\n"); + strcpy(errbuf2, "GDXSDdims array too small.\nPlease increase "); + strcat(errbuf2, "size of HDFE_DIMBUFSIZE in \"HdfEosDef.h\".\n"); + + + /* Build tiling dimension error message */ + /* ------------------------------------ */ + strcpy(errmsg, errmsg1); + strcat(errmsg, errmsg2); + + /* + * Check for proper grid ID and return HDF-EOS file ID, SDinterface ID, + * and grid root Vgroup ID + */ + status = GDchkgdid(gridID, "GDdefinefield", + &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + /* Remove offset from grid ID & get gridname */ + gID = gridID % idOffset; + Vgetname(GDXGrid[gID].IDTable, gridname); + + + /* Allocate space for dimension buffer and auxilliary dimension list */ + /* ----------------------------------------------------------------- */ + dimbuf = (char *) calloc(strlen(dimlist) + 64, 1); + if(dimbuf == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffield", __FILE__, __LINE__); + return(-1); + } + dimlist0 = (char *) calloc(strlen(dimlist) + 64, 1); + if(dimlist0 == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffield", __FILE__, __LINE__); + free(dimbuf); + return(-1); + } + + + /* Get Grid and Projection info */ + /* ---------------------------- */ + status = GDgridinfo(gridID, &xdim, &ydim, NULL, NULL); + status = GDprojinfo(gridID, &projcode, NULL, NULL, projparm); + + + /* Setup Block Dimension if "Blocked" SOM projection */ + /* ------------------------------------------------- */ + if (projcode == GCTP_SOM && (int32) projparm[11] != 0) + { + dimsize = GDdiminfo(gridID, "SOMBlockDim"); + + /* If "SOMBlockDim" not yet defined then do it */ + if (dimsize == -1) + { + GDdefdim(gridID, "SOMBlockDim", (int32) projparm[11]); + } + + /* If not 1D field then prepend to dimension list */ + if (strchr(dimlist, ',') != NULL) + { + strcpy(dimbuf, "SOMBlockDim,"); + strcat(dimbuf, dimlist); + } + else + { + strcpy(dimbuf, dimlist); + } + } + else + { + /* If not "Blocked" SOM then just copy dim list to dim buffer */ + strcpy(dimbuf, dimlist); + } + + /* + * Copy dimension buffer to auxilliary dimlist and Append comma to + * end of dimension list + */ + strcpy(dimlist0, dimbuf); + strcat(dimbuf, ","); + + + /* Find comma */ + /* ---------- */ + comma = strchr(dimbuf, ','); + + + /* + * Loop through entries in dimension list to make sure they are + * defined in grid + */ + while (comma != NULL) + { + /* Copy dimension list entry to dimcheck */ + /* ------------------------------------- */ + dimcheck = (char *) calloc(comma - dimbuf + 1, 1); + if(dimcheck == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffield", __FILE__, __LINE__); + free(dimbuf); + free(dimlist0); + return(-1); + } + memcpy(dimcheck, dimbuf, comma - dimbuf); + + + /* Get Dimension Size */ + /* ------------------ */ + if (strcmp(dimcheck, "XDim") == 0) + { + /* If "XDim" then use xdim value for grid definition */ + /* ------------------------------------------------- */ + dimsize = xdim; + found = 1; + dims[rank] = dimsize; + rank++; + } + else if (strcmp(dimcheck, "YDim") == 0) + { + /* If "YDim" then use ydim value for grid definition */ + /* ------------------------------------------------- */ + dimsize = ydim; + found = 1; + dims[rank] = dimsize; + rank++; + } + else + { + /* "Regular" Dimension */ + /* ------------------- */ + dimsize = GDdiminfo(gridID, dimcheck); + if (dimsize != -1) + { + found = 1; + dims[rank] = dimsize; + rank++; + } + else + { + found = 0; + } + } + + + /* + * If dimension list entry not found - set error return status, + * append name to utility buffer for error report + */ + if (found == 0) + { + status = -1; + foundAllDim = 0; + if (first == 1) + { + strcpy(utlbuf, dimcheck); + } + else + { + strcat(utlbuf, ","); + strcat(utlbuf, dimcheck); + } + first = 0; + } + + /* + * Go to next dimension entry, find next comma, & free up + * dimcheck buffer + */ + memmove(dimbuf, comma + 1, strlen(comma)-1); + dimbuf[strlen(comma)-1]= 0; + comma = strchr(dimbuf, ','); + free(dimcheck); + } + free(dimbuf); + + + + /* Check fieldname length */ + /* ---------------------- */ + if (status == 0) + { +/* if ((intn) strlen(fieldname) > MAX_NC_NAME - 7) +** this was changed because HDF4.1r3 made a change in the +** hlimits.h file. We have notidfied NCSA and asked to have +** it made the same as in previous versions of HDF +** see ncr 26314. DaW Apr 2000 +*/ + if((intn) strlen(fieldname) > (256 - 7)) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefinefield", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" too long.\n", fieldname); + } + } + + + + /* Check for valid numbertype */ + /* -------------------------- */ + if (status == 0) + { + for (i = 0; i < 10; i++) + { + if (numbertype == good_number[i]) + { + foundNT = 1; + break; + } + } + + if (foundNT == 0) + { + HEpush(DFE_BADNUMTYPE, "GDdeffield", __FILE__, __LINE__); + HEreport("Invalid number type: %d (%s).\n", + numbertype, fieldname); + status = -1; + } + } + + + /* Define Field */ + /* ------------ */ + if (status == 0) + { + /* Get Field Vgroup id, compresion code, & tiling code */ + /* -------------------------------------------------- */ + vgid = GDXGrid[gID].VIDTable[0]; + compcode = GDXGrid[gID].compcode; + tilecode = GDXGrid[gID].tilecode; + + + /* SDS Interface (Multi-dim fields) */ + /* -------------------------------- */ + + + /* + * If rank is less than or equal to 3 (and greater than 1) and + * AUTOMERGE is set and the first dimension is not appendable and + * the compression code is set to none then ... + */ + if (rank >= 2 && rank <= 3 && merge == HDFE_AUTOMERGE && + dims[0] != 0 && compcode == HDFE_COMP_NONE && + tilecode == HDFE_NOTILE) + { + + /* Find first empty slot in external combination array */ + /* --------------------------------------------------- */ + i = 0; + while (GDXSDcomb[5 * i] != 0) + { + i++; + } + + /* + * Store dimensions, grid root Vgroup ID, and number type in + * external combination array "GDXSDcomb" + */ + if (rank == 2) + { + /* If 2-dim field then set lowest dimension to 1 */ + /* --------------------------------------------- */ + GDXSDcomb[5 * i] = 1; + GDXSDcomb[5 * i + 1] = dims[0]; + GDXSDcomb[5 * i + 2] = dims[1]; + } + else + { + GDXSDcomb[5 * i] = dims[0]; + GDXSDcomb[5 * i + 1] = dims[1]; + GDXSDcomb[5 * i + 2] = dims[2]; + } + + GDXSDcomb[5 * i + 3] = gdVgrpID; + GDXSDcomb[5 * i + 4] = numbertype; + + + /* Concatanate fieldname with combined name string */ + /* ----------------------------------------------- */ + if ((intn) strlen(GDXSDname) + + (intn) strlen(fieldname) + 2 < HDFE_NAMBUFSIZE) + { + strcat(GDXSDname, fieldname); + strcat(GDXSDname, ","); + } + else + { + /* GDXSDname array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "GDdefinefield", + __FILE__, __LINE__); + HEreport(errbuf1); + status = -1; + free(dimlist0); + return (status); + } + + + /* + * If 2-dim field then set lowest dimension (in 3-dim array) + * to "ONE" + */ + if (rank == 2) + { + if ((intn) strlen(GDXSDdims) + 5 < HDFE_DIMBUFSIZE) + { + strcat(GDXSDdims, "ONE,"); + } + else + { + /* GDXSDdims array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "GDdefinefield", + __FILE__, __LINE__); + HEreport(errbuf2); + status = -1; + free(dimlist0); + return (status); + } + } + + + /* + * Concatanate field dimlist to merged dimlist and separate + * fields with semi-colon + */ + if ((intn) strlen(GDXSDdims) + + (intn) strlen(dimlist0) + 2 < HDFE_DIMBUFSIZE) + { + strcat(GDXSDdims, dimlist0); + strcat(GDXSDdims, ";"); + } + else + { + /* GDXSDdims array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "GDdefinefield", + __FILE__, __LINE__); + HEreport(errbuf2); + status = -1; + free(dimlist0); + return (status); + } + + } /* End Multi-Dim Merge Section */ + else + { + + /* Multi-Dim No Merge Section */ + /* ========================== */ + + + /* Check that field dims are divisible by tile dims */ + /* ------------------------------------------------ */ + if (tilecode == HDFE_TILE) + { + for (i = 0; i < GDXGrid[gID].tilerank; i++) + { + if ((dims[i] % GDXGrid[gID].tiledims[i]) != 0) + { + HEpush(DFE_GENAPP, "GDdeffield", + __FILE__, __LINE__); + HEreport(errmsg, + i, dims[i], GDXGrid[gID].tiledims[0]); + status = -1; + } + } + + if (status == -1) + { + free(dimlist0); + return (status); + } + } + + + /* Create SDS dataset */ + /* ------------------ */ + sdid = SDcreate(sdInterfaceID, fieldname, + numbertype, rank, dims); + + + /* Store Dimension Names in SDS */ + /* ---------------------------- */ + rank = EHparsestr(dimlist0, ',', ptr, slen); + for (i = 0; i < rank; i++) + { + /* Dimension name = Swathname:Dimname */ + /* ---------------------------------- */ + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + strcat(utlbuf, ":"); + strcat(utlbuf, gridname); + + dimid = SDgetdimid(sdid, i); + SDsetdimname(dimid, utlbuf); + } + + + /* Setup Compression */ + /* ----------------- */ + if (compcode == HDFE_COMP_NBIT) + { + c_info.nbit.nt = numbertype; + c_info.nbit.sign_ext = GDXGrid[gID].compparm[0]; + c_info.nbit.fill_one = GDXGrid[gID].compparm[1]; + c_info.nbit.start_bit = GDXGrid[gID].compparm[2]; + c_info.nbit.bit_len = GDXGrid[gID].compparm[3]; + } + else if (compcode == HDFE_COMP_SKPHUFF) + { + c_info.skphuff.skp_size = (intn) DFKNTsize(numbertype); + } + else if (compcode == HDFE_COMP_DEFLATE) + { + c_info.deflate.level = GDXGrid[gID].compparm[0]; + } + + + /* If field is compressed w/o tiling then call SDsetcompress */ + /* --------------------------------------------------------- */ + if (compcode != HDFE_COMP_NONE && tilecode == HDFE_NOTILE) + { + status = SDsetcompress(sdid, (comp_coder_t) compcode, &c_info); + } + + + /* Setup Tiling */ + /* ------------ */ + if (tilecode == HDFE_TILE) + { + /* Tiling without Compression */ + /* -------------------------- */ + if (compcode == HDFE_COMP_NONE) + { + + /* Setup chunk lengths */ + /* ------------------- */ + for (i = 0; i < GDXGrid[gID].tilerank; i++) + { + chunkDef.chunk_lengths[i] = + GDXGrid[gID].tiledims[i]; + } + + chunkFlag = HDF_CHUNK; + } + + /* Tiling with Compression */ + /* ----------------------- */ + else + { + /* Setup chunk lengths */ + /* ------------------- */ + for (i = 0; i < GDXGrid[gID].tilerank; i++) + { + chunkDef.comp.chunk_lengths[i] = + GDXGrid[gID].tiledims[i]; + } + + + /* Setup chunk flag & chunk compression type */ + /* ----------------------------------------- */ + chunkFlag = HDF_CHUNK | HDF_COMP; + chunkDef.comp.comp_type = compcode; + + + /* Setup chunk compression parameters */ + /* ---------------------------------- */ + if (compcode == HDFE_COMP_SKPHUFF) + { + chunkDef.comp.cinfo.skphuff.skp_size = + c_info.skphuff.skp_size; + } + else if (compcode == HDFE_COMP_DEFLATE) + { + chunkDef.comp.cinfo.deflate.level = + c_info.deflate.level; + } + } + + /* Call SDsetchunk routine */ + /* ----------------------- */ + status = SDsetchunk(sdid, chunkDef, chunkFlag); + } + + + /* Attach to Vgroup */ + /* ---------------- */ + Vaddtagref(vgid, DFTAG_NDG, SDidtoref(sdid)); + + + /* Store SDS dataset IDs */ + /* --------------------- */ + + /* Allocate space for the SDS ID array */ + /* ----------------------------------- */ + if (GDXGrid[gID].nSDS > 0) + { + /* Array already exists therefore reallocate */ + /* ----------------------------------------- */ + GDXGrid[gID].sdsID = (int32 *) + realloc((void *) GDXGrid[gID].sdsID, + (GDXGrid[gID].nSDS + 1) * 4); + if(GDXGrid[gID].sdsID == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffield", __FILE__, __LINE__); + free(dimlist0); + return(-1); + } + } + else + { + /* Array does not exist */ + /* -------------------- */ + GDXGrid[gID].sdsID = (int32 *) calloc(1, 4); + if(GDXGrid[gID].sdsID == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffield", __FILE__, __LINE__); + free(dimlist0); + return(-1); + } + } + + /* Store SDS ID in array & increment count */ + /* --------------------------------------- */ + GDXGrid[gID].sdsID[GDXGrid[gID].nSDS] = sdid; + GDXGrid[gID].nSDS++; + + } + + + /* Setup metadata string */ + /* --------------------- */ + sprintf(utlbuf, "%s%s%s", fieldname, ":", dimlist0); + + + /* Setup compression metadata */ + /* -------------------------- */ + if (compcode != HDFE_COMP_NONE) + { + sprintf(utlbuf2, + "%s%s", + ":\n\t\t\t\tCompressionType=", HDFcomp[compcode]); + + switch (compcode) + { + case HDFE_COMP_NBIT: + + sprintf(parmbuf, + "%s%d,%d,%d,%d%s", + "\n\t\t\t\tCompressionParams=(", + GDXGrid[gID].compparm[0], + GDXGrid[gID].compparm[1], + GDXGrid[gID].compparm[2], + GDXGrid[gID].compparm[3], ")"); + strcat(utlbuf2, parmbuf); + break; + + + case HDFE_COMP_DEFLATE: + + sprintf(parmbuf, + "%s%d", + "\n\t\t\t\tDeflateLevel=", + GDXGrid[gID].compparm[0]); + strcat(utlbuf2, parmbuf); + break; + } + strcat(utlbuf, utlbuf2); + } + + + + + /* Setup tiling metadata */ + /* --------------------- */ + if (tilecode == HDFE_TILE) + { + if (compcode == HDFE_COMP_NONE) + { + sprintf(utlbuf2, "%s%d", + ":\n\t\t\t\tTilingDimensions=(", + (int)GDXGrid[gID].tiledims[0]); + } + else + { + sprintf(utlbuf2, "%s%d", + "\n\t\t\t\tTilingDimensions=(", + (int)GDXGrid[gID].tiledims[0]); + } + + for (i = 1; i < GDXGrid[gID].tilerank; i++) + { + sprintf(parmbuf, ",%d", (int)GDXGrid[gID].tiledims[i]); + strcat(utlbuf2, parmbuf); + } + strcat(utlbuf2, ")"); + strcat(utlbuf, utlbuf2); + } + + + /* Insert field metadata within File Structural Metadata */ + /* ----------------------------------------------------- */ + status = EHinsertmeta(sdInterfaceID, gridname, "g", 4L, + utlbuf, &numbertype); + + } + free(dimlist0); + + } + + /* If all dimensions not found then report error */ + /* --------------------------------------------- */ + if (foundAllDim == 0) + { + HEpush(DFE_GENAPP, "GDdeffield", __FILE__, __LINE__); + HEreport("Dimension(s): \"%s\" not found (%s).\n", + utlbuf, fieldname); + status = -1; + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwritefieldmeta | +| | +| DESCRIPTION: Writes field meta data for an existing grid field not | +| defined within the grid API routine "GDdeffield". | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwritefieldmeta(int32 gridID, char *fieldname, char *dimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 dum; /* dummy variable */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + char utlbuf[256];/* Utility buffer */ + char gridname[80]; /* Grid name */ + + + status = GDchkgdid(gridID, "GDwritefieldmeta", &dum, &sdInterfaceID, + &dum); + + if (status == 0) + { + sprintf(utlbuf, "%s%s%s", fieldname, ":", dimlist); + + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + status = EHinsertmeta(sdInterfaceID, gridname, "g", 4L, + utlbuf, &numbertype); + } + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeffld | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| merge int32 merge code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdeffld(int32 gridID, char *fieldname, char *fortdimlist, + int32 numbertype, int32 merge) + +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"GDdeffld", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + + /* Call Define Field routine */ + /* ------------------------- */ + status = GDdeffield(gridID, fieldname, dimlist, numbertype, merge); + + free(dimlist); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwrmeta | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwrmeta(int32 gridID, char *fieldname, char *fortdimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"GDwrmeta", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + + /* Call Write Metadata routine */ + /* --------------------------- */ + status = GDwritefieldmeta(gridID, fieldname, dimlist, numbertype); + + + free(dimlist); + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDSDfldsrch | +| | +| DESCRIPTION: Retrieves information from SDS fields | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| sdInterfaceID int32 SD interface ID | +| fieldname char field name | +| | +| | +| OUTPUTS: | +| sdid int32 SD element ID | +| rankSDS int32 Rank of SDS | +| rankFld int32 True rank of field (merging) | +| offset int32 Offset of field within merged field | +| dims int32 Dimensions of field | +| solo int32 Solo field flag | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDSDfldsrch(int32 gridID, int32 sdInterfaceID, char *fieldname, int32 * sdid, + int32 * rankSDS, int32 * rankFld, int32 * offset, int32 dims[], + int32 * solo) +{ + intn i; /* Loop index */ + intn status = -1;/* routine return status variable */ + + int32 gID; /* GridID - offset */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 dum; /* Dummy variable */ + int32 dums[128]; /* Dummy array */ + int32 attrIndex; /* Attribute index */ + + char name[2048]; /* Merged-Field Names */ + char gridname[80]; /* Grid Name */ + char *utlstr;/* Utility string */ + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char *oldmetaptr; /* Pointer within SM section */ + char *metaptr; /* Pointer within SM section */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDSDfldsrch", __FILE__, __LINE__); + return(-1); + } + /* Set solo flag to 0 (no) */ + /* ----------------------- */ + *solo = 0; + + + /* Compute "reduced" grid ID */ + /* ------------------------- */ + gID = gridID % idOffset; + + + /* Loop through all SDSs in grid */ + /* ----------------------------- */ + for (i = 0; i < GDXGrid[gID].nSDS; i++) + { + /* If active SDS ... */ + /* ----------------- */ + if (GDXGrid[gID].sdsID[i] != 0) + { + /* Get SDS ID, name, rankSDS, and dimensions */ + /* ----------------------------------------- */ + *sdid = GDXGrid[gID].sdsID[i]; + SDgetinfo(*sdid, name, rankSDS, dims, &dum, &dum); + *rankFld = *rankSDS; + + + /* If merged field ... */ + /* ------------------- */ + if (strstr(name, "MRGFLD_") == &name[0]) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gID].IDTable, gridname); + + + /* Get pointers to "MergedFields" section within SM */ + /* ------------------------------------------------ */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "MergedFields", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* Initialize metaptr to beg. of section */ + /* ------------------------------------- */ + metaptr = metaptrs[0]; + + + /* Store metaptr in order to recover */ + /* --------------------------------- */ + oldmetaptr = metaptr; + + + /* Search for Merged field name */ + /* ---------------------------- */ + sprintf(utlstr, "%s%s%s", "MergedFieldName=\"", + name, "\"\n"); + metaptr = strstr(metaptr, utlstr); + + + /* If not found check for old metadata */ + /* ----------------------------------- */ + if (metaptr == NULL) + { + sprintf(utlstr, "%s%s%s", "OBJECT=\"", name, "\"\n"); + metaptr = strstr(oldmetaptr, utlstr); + } + + + /* Get field list and strip off leading and trailing quotes */ + /* -------------------------------------------------------- */ + EHgetmetavalue(metaptrs, "FieldList", name); + memmove(name, name + 1, strlen(name) - 2); + name[strlen(name) - 2] = 0; + + + /* Search for desired field within merged field list */ + /* ------------------------------------------------- */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\""); + dum = EHstrwithin(utlstr, name, ','); + + free(metabuf); + } + else + { + /* If solo (unmerged) check if SDS name matches fieldname */ + /* ------------------------------------------------------ */ + dum = EHstrwithin(fieldname, name, ','); + if (dum != -1) + { + *solo = 1; + *offset = 0; + } + } + + + + /* If field found ... */ + /* ------------------ */ + if (dum != -1) + { + status = 0; + + /* If merged field ... */ + /* ------------------- */ + if (*solo == 0) + { + /* Get "Field Offsets" SDS attribute index */ + /* --------------------------------------- */ + attrIndex = SDfindattr(*sdid, "Field Offsets"); + + /* + * If attribute exists then get offset of desired field + * within merged field + */ + if (attrIndex != -1) + { + SDreadattr(*sdid, attrIndex, (VOIDP) dums); + *offset = dums[dum]; + } + + + /* Get "Field Dims" SDS attribute index */ + /* ------------------------------------ */ + attrIndex = SDfindattr(*sdid, "Field Dims"); + + /* + * If attribute exists then get 0th dimension of desired + * field within merged field + */ + if (attrIndex != -1) + { + SDreadattr(*sdid, attrIndex, (VOIDP) dums); + dims[0] = dums[dum]; + + /* If this dimension = 1 then field is really 2 dim */ + /* ------------------------------------------------ */ + if (dums[dum] == 1) + { + *rankFld = 2; + } + } + } + + + /* Break out of SDS loop */ + /* --------------------- */ + break; + } /* End of found field section */ + } + else + { + /* First non-active SDS signifies no more, break out of SDS loop */ + /* ------------------------------------------------------------- */ + break; + } + } + free(utlstr); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwrrdfield | +| | +| DESCRIPTION: Writes/Reads fields | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| code char Write/Read code (w/r) | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| datbuf void data buffer for read | +| | +| | +| OUTPUTS: | +| datbuf void data buffer for write | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Feb 97 Joel Gales Stride = 1 HDF compression workaround | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwrrdfield(int32 gridID, char *fieldname, char *code, + int32 start[], int32 stride[], int32 edge[], VOIDP datbuf) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS ID */ + int32 dum; /* Dummy variable */ + int32 rankSDS; /* Rank of SDS */ + int32 rankFld; /* Rank of field */ + + int32 offset[8]; /* I/O offset (start) */ + int32 incr[8]; /* I/O increment (stride) */ + int32 count[8]; /* I/O count (edge) */ + int32 dims[8]; /* Field/SDS dimensions */ + int32 mrgOffset; /* Merged field offset */ + int32 strideOne; /* Strides = 1 flag */ + + + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDwrrdfield", &fid, &sdInterfaceID, &dum); + + + if (status == 0) + { + /* Check that field exists */ + /* ----------------------- */ + status = GDfieldinfo(gridID, fieldname, &rankSDS, dims, &dum, NULL); + + + if (status != 0) + { + HEpush(DFE_GENAPP, "GDwrrdfield", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + + } + + + if (status == 0) + { + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, &sdid, + &rankSDS, &rankFld, &mrgOffset, dims, &dum); + + + /* Set I/O offset Section */ + /* ---------------------- */ + + /* + * If start == NULL (default) set I/O offset of 0th field to + * offset within merged field (if any) and the rest to 0 + */ + if (start == NULL) + { + for (i = 0; i < rankSDS; i++) + { + offset[i] = 0; + } + offset[0] = mrgOffset; + } + else + { + /* + * ... otherwise set I/O offset to user values, adjusting the + * 0th field with the merged field offset (if any) + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + offset[i] = start[i]; + } + offset[0] += mrgOffset; + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field offset to merge offset and then next two to + * the user values + */ + for (i = 0; i < rankFld; i++) + { + offset[i + 1] = start[i]; + } + offset[0] = mrgOffset; + } + } + + + + /* Set I/O stride Section */ + /* ---------------------- */ + + /* + * If stride == NULL (default) set I/O stride to 1 + */ + if (stride == NULL) + { + for (i = 0; i < rankSDS; i++) + { + incr[i] = 1; + } + } + else + { + /* + * ... otherwise set I/O stride to user values + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + incr[i] = stride[i]; + } + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field stride to 1 and then next two to the user + * values. + */ + for (i = 0; i < rankFld; i++) + { + incr[i + 1] = stride[i]; + } + incr[0] = 1; + } + } + + + + /* Set I/O count Section */ + /* --------------------- */ + + /* + * If edge == NULL (default) set I/O count to number of remaining + * entries (dims - start) / increment. Note that 0th field + * offset corrected for merged field offset (if any). + */ + if (edge == NULL) + { + for (i = 1; i < rankSDS; i++) + { + count[i] = (dims[i] - offset[i]) / incr[i]; + } + count[0] = (dims[0] - (offset[0] - mrgOffset)) / incr[0]; + } + else + { + /* + * ... otherwise set I/O count to user values + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + count[i] = edge[i]; + } + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field count to 1 and then next two to the user + * values. + */ + for (i = 0; i < rankFld; i++) + { + count[i + 1] = edge[i]; + } + count[0] = 1; + } + } + + + /* Perform I/O with relevant HDF I/O routine */ + /* ----------------------------------------- */ + if (strcmp(code, "w") == 0) + { + /* Set strideOne to true (1) */ + /* ------------------------- */ + strideOne = 1; + + + /* If incr[i] != 1 set strideOne to false (0) */ + /* ------------------------------------------ */ + for (i = 0; i < rankSDS; i++) + { + if (incr[i] != 1) + { + strideOne = 0; + break; + } + } + + + /* + * If strideOne is true use NULL paramater for stride. This + * is a work-around to HDF compression problem + */ + if (strideOne == 1) + { + status = SDwritedata(sdid, offset, NULL, count, + (VOIDP) datbuf); + } + else + { + status = SDwritedata(sdid, offset, incr, count, + (VOIDP) datbuf); + } + } + else + { + status = SDreaddata(sdid, offset, incr, count, + (VOIDP) datbuf); + } + } + } + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwritefield | +| | +| DESCRIPTION: Writes data to a grid field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| | +| | +| OUTPUTS: | +| data void data buffer for write | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwritefield(int32 gridID, char *fieldname, + int32 start[], int32 stride[], int32 edge[], VOIDP data) + +{ + intn status = 0; /* routine return status variable */ + + status = GDwrrdfield(gridID, fieldname, "w", start, stride, edge, + data); + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDreadfield | +| | +| DESCRIPTION: Reads data from a grid field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| buffer void data buffer for read | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDreadfield(int32 gridID, char *fieldname, + int32 start[], int32 stride[], int32 edge[], VOIDP buffer) + +{ + intn status = 0; /* routine return status variable */ + + status = GDwrrdfield(gridID, fieldname, "r", start, stride, edge, + buffer); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwrfld | +| | +| DESCRIPTION: Writes data to field (FORTRAN wrapper around GDwritefield) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| fortstart int32 start array | +| fortstride int32 stride array | +| fortedge int32 edge array | +| | +| | +| OUTPUTS: | +| data void data buffer for write | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwrfld(int32 gridID, char *fieldname, + int32 fortstart[], int32 fortstride[], int32 fortedge[], VOIDP data) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *start; /* Pointer to start array (C order) */ + int32 *stride; /* Pointer to stride array (C order) */ + int32 *edge; /* Pointer to edge array (C order) */ + + + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, NULL); + + if (status == 0) + { + start = (int32 *) malloc(4 * rank); + if(start == NULL) + { + HEpush(DFE_NOSPACE,"GDwrfld", __FILE__, __LINE__); + return(-1); + } + stride = (int32 *) malloc(4 * rank); + if(stride == NULL) + { + HEpush(DFE_NOSPACE,"GDwrfld", __FILE__, __LINE__); + free(start); + return(-1); + } + edge = (int32 *) malloc(4 * rank); + if(edge == NULL) + { + HEpush(DFE_NOSPACE,"GDwrfld", __FILE__, __LINE__); + free(start); + free(stride); + return(-1); + } + + /* Reverse order of dimensions (FORTRAN -> C) */ + /* ------------------------------------------ */ + for (i = 0; i < rank; i++) + { + start[i] = fortstart[rank - 1 - i]; + stride[i] = fortstride[rank - 1 - i]; + edge[i] = fortedge[rank - 1 - i]; + } + + status = GDwrrdfield(gridID, fieldname, "w", start, stride, edge, + data); + + free(start); + free(stride); + free(edge); + } + else + { + HEpush(DFE_GENAPP, "GDwrfld", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + } + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDrdfld | +| | +| DESCRIPTION: Reads data from field (FORTRAN wrapper around GDreadfield) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char fieldname | +| fortstart int32 start array | +| fortstride int32 stride array | +| fortedge int32 edge array | +| buffer void data buffer for read | +| | +| | +| OUTPUTS: | +| None | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDrdfld(int32 gridID, char *fieldname, int32 fortstart[], + int32 fortstride[], int32 fortedge[], VOIDP buffer) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *start; /* Pointer to start array (C order) */ + int32 *stride; /* Pointer to stride array (C order) */ + int32 *edge; /* Pointer to edge array (C order) */ + + + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, NULL); + + if (status == 0) + { + start = (int32 *) malloc(4 * rank); + if(start == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + return(-1); + } + stride = (int32 *) malloc(4 * rank); + if(stride == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + free(start); + return(-1); + } + edge = (int32 *) malloc(4 * rank); + if(edge == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + free(start); + free(stride); + return(-1); + } + + /* Reverse order of dimensions (FORTRAN -> C) */ + /* ------------------------------------------ */ + for (i = 0; i < rank; i++) + { + start[i] = fortstart[rank - 1 - i]; + stride[i] = fortstride[rank - 1 - i]; + edge[i] = fortedge[rank - 1 - i]; + } + + + status = GDwrrdfield(gridID, fieldname, "r", start, stride, edge, + buffer); + + free(start); + free(stride); + free(edge); + } + else + { + HEpush(DFE_GENAPP, "GDrdfld", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwrrdattr | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| attrname char attribute name | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| wrcode char Read/Write Code "w/r" | +| datbuf void I/O buffer | +| | +| OUTPUTS: | +| datbuf | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwrrdattr(int32 gridID, char *attrname, int32 numbertype, int32 count, + char *wrcode, VOIDP datbuf) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Grid attribute ID */ + int32 dum; /* dummy variable */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + /* Check Grid id */ + status = GDchkgdid(gridID, "GDwrrdattr", &fid, &dum, &dum); + + if (status == 0) + { + /* Perform Attribute I/O */ + /* --------------------- */ + attrVgrpID = GDXGrid[gridID % idOffset].VIDTable[1]; + status = EHattr(fid, attrVgrpID, attrname, numbertype, count, + wrcode, datbuf); + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDwriteattr | +| | +| DESCRIPTION: Writes/updates attribute in a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| attrname char attribute name | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| datbuf void I/O buffer | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDwriteattr(int32 gridID, char *attrname, int32 numbertype, int32 count, + VOIDP datbuf) +{ + intn status = 0; /* routine return status variable */ + + /* Call GDwrrdattr routine to write attribute */ + /* ------------------------------------------ */ + status = GDwrrdattr(gridID, attrname, numbertype, count, "w", datbuf); + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDreadattr | +| | +| DESCRIPTION: Reads attribute from a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| attrname char attribute name | +| | +| OUTPUTS: | +| datbuf void I/O buffer | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDreadattr(int32 gridID, char *attrname, VOIDP datbuf) +{ + intn status = 0; /* routine return status variable */ + int32 dum = 0; /* dummy variable */ + + /* Call GDwrrdattr routine to read attribute */ + /* ----------------------------------------- */ + status = GDwrrdattr(gridID, attrname, dum, dum, "r", datbuf); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDattrinfo | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| attrname char attribute name | +| | +| OUTPUTS: | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDattrinfo(int32 gridID, char *attrname, int32 * numbertype, int32 * count) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Grid attribute ID */ + int32 dum; /* dummy variable */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + status = GDchkgdid(gridID, "GDattrinfo", &fid, &dum, &dum); + + attrVgrpID = GDXGrid[gridID % idOffset].VIDTable[1]; + + status = EHattrinfo(fid, attrVgrpID, attrname, numbertype, + count); + + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDinqattrs | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nattr int32 Number of attributes in swath struct | +| | +| INPUTS: | +| grid ID int32 grid structure ID | +| | +| OUTPUTS: | +| attrnames char Attribute names in swath struct | +| (Comma-separated list) | +| strbufsize int32 Attributes name list string length | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Initialize nattr | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDinqattrs(int32 gridID, char *attrnames, int32 * strbufsize) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Grid attribute ID */ + int32 dum; /* dummy variable */ + int32 nattr = 0; /* Number of attributes */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + + + /* Check Grid id */ + status = GDchkgdid(gridID, "GDinqattrs", &fid, &dum, &dum); + + if (status == 0) + { + attrVgrpID = GDXGrid[gridID % idOffset].VIDTable[1]; + nattr = EHattrcat(fid, attrVgrpID, attrnames, strbufsize); + } + + return (nattr); +} + + + + + + +#define REMQUOTE \ +\ +memmove(utlstr, utlstr + 1, strlen(utlstr) - 2); \ +utlstr[strlen(utlstr) - 2] = 0; + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDinqdims | +| | +| DESCRIPTION: Retrieve information about all dimensions defined in a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nDim int32 Number of defined dimensions | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| | +| OUTPUTS: | +| dimnames char Dimension names (comma-separated) | +| dims int32 Dimension values | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nDim to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDinqdims(int32 gridID, char *dimnames, int32 dims[]) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 size; /* Dimension size */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 nDim = 0; /* Number of dimensions */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr;/* Utility string */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDinqdims", __FILE__, __LINE__); + return(-1); + } + /* Check for valid grid id */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDinqdims", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* If dimension names or sizes are requested */ + /* ----------------------------------------- */ + if (dimnames != NULL || dims != NULL) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to "Dimension" section within SM */ + /* --------------------------------------------- */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "Dimension", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* If dimension names are requested then "clear" name buffer */ + /* --------------------------------------------------------- */ + if (dimnames != NULL) + { + dimnames[0] = 0; + } + + while (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + strcpy(utlstr, "\t\tOBJECT="); + metaptrs[0] = strstr(metaptrs[0], utlstr); + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Dimension Name */ + /* ------------------ */ + if (dimnames != NULL) + { + /* Check 1st for old meta data then new */ + /* ------------------------------------ */ + EHgetmetavalue(metaptrs, "OBJECT", utlstr); + if (utlstr[0] != '"') + { + metaptrs[0] = + strstr(metaptrs[0], "\t\t\t\tDimensionName="); + EHgetmetavalue(metaptrs, "DimensionName", utlstr); + } + + /* Strip off double quotes */ + /* ----------------------- */ + memmove(utlstr, utlstr + 1, strlen(utlstr) - 2); + utlstr[strlen(utlstr) - 2] = 0; + + if (nDim > 0) + { + strcat(dimnames, ","); + } + strcat(dimnames, utlstr); + } + + /* Get Dimension Size */ + /* ------------------ */ + if (dims != NULL) + { + EHgetmetavalue(metaptrs, "Size", utlstr); + size = atol(utlstr); + dims[nDim] = size; + } + nDim++; + } + } + free(metabuf); + + } + } + + + /* Set nDim to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nDim = -1; + } + free(utlstr); + return (nDim); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDinqfields | +| | +| DESCRIPTION: Retrieve information about all data fields defined in a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nFld int32 Number of fields in swath | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| | +| | +| OUTPUTS: | +| fieldlist char Field names (comma-separated) | +| rank int32 Array of ranks | +| numbertype int32 Array of HDF number types | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nFld to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDinqfields(int32 gridID, char *fieldlist, int32 rank[], + int32 numbertype[]) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 nFld = 0; /* Number of mappings */ + int32 slen[8]; /* String length array */ + int32 ntype = 0; /* Data Type */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr;/* Utility string */ + char *ptr[8]; /* String pointer array */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDinqfields", __FILE__, __LINE__); + return(-1); + } + /* Check for valid grid id */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDinqfields", &fid, &sdInterfaceID, &gdVgrpID); + if (status == 0) + { + + /* If field names, ranks, or number types desired ... */ + /* --------------------------------------------------- */ + if (fieldlist != NULL || rank != NULL || numbertype != NULL) + { + /* Get grid name */ + /* ------------- */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + + /* Get pointers to "DataField" section within SM */ + /* --------------------------------------------- */ + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + + /* If field names are desired then "clear" name buffer */ + /* --------------------------------------------------- */ + if (fieldlist != NULL) + { + fieldlist[0] = 0; + } + + + /* Begin loop through mapping entries in metadata */ + /* ---------------------------------------------- */ + while (1) + { + /* Search for OBJECT string */ + /* ------------------------ */ + metaptrs[0] = strstr(metaptrs[0], "\t\tOBJECT="); + + + /* If found within "Data" Field metadata section .. */ + /* ------------------------------------------------ */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Fieldnames (if desired) */ + /* --------------------------- */ + if (fieldlist != NULL) + { + /* Check 1st for old meta data then new */ + /* ------------------------------------ */ + EHgetmetavalue(metaptrs, "OBJECT", utlstr); + + /* + * If OBJECT value begins with double quote then old + * metadata, field name is OBJECT value. Otherwise + * search for "DataFieldName" string + */ + + if (utlstr[0] != '"') + { + strcpy(utlstr, "\t\t\t\t"); + strcat(utlstr, "DataFieldName"); + strcat(utlstr, "="); + metaptrs[0] = strstr(metaptrs[0], utlstr); + EHgetmetavalue(metaptrs, "DataFieldName", utlstr); + } + + /* Strip off double quotes */ + /* ----------------------- */ + REMQUOTE + + + /* Add to fieldlist */ + /* ---------------- */ + if (nFld > 0) + { + strcat(fieldlist, ","); + } + strcat(fieldlist, utlstr); + + } + /* Get Numbertype */ + if (numbertype != NULL) + { + EHgetmetavalue(metaptrs, "DataType", utlstr); + + if (strcmp(utlstr, "DFNT_UCHAR8") == 0) + ntype = 3; + else if (strcmp(utlstr, "DFNT_CHAR8") == 0) + ntype = 4; + else if (strcmp(utlstr, "DFNT_FLOAT32") == 0) + ntype = 5; + else if (strcmp(utlstr, "DFNT_FLOAT64") == 0) + ntype = 6; + else if (strcmp(utlstr, "DFNT_INT8") == 0) + ntype = 20; + else if (strcmp(utlstr, "DFNT_UINT8") == 0) + ntype = 21; + else if (strcmp(utlstr, "DFNT_INT16") == 0) + ntype = 22; + else if (strcmp(utlstr, "DFNT_UINT16") == 0) + ntype = 23; + else if (strcmp(utlstr, "DFNT_INT32") == 0) + ntype = 24; + else if (strcmp(utlstr, "DFNT_UINT32") == 0) + ntype = 25; + + numbertype[nFld] = ntype; + } + /* + * Get Rank (if desired) by counting # of dimensions in + * "DimList" string + */ + if (rank != NULL) + { + EHgetmetavalue(metaptrs, "DimList", utlstr); + rank[nFld] = EHparsestr(utlstr, ',', ptr, slen); + } + /* Increment number of fields */ + nFld++; + } + else + /* No more fields found */ + { + break; + } + } + free(metabuf); + } + } + + /* Set nFld to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nFld = -1; + } + free(utlstr); + return (nFld); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDnentries | +| | +| DESCRIPTION: Returns number of entries and descriptive string buffer | +| size for a specified entity. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nEntries int32 Number of entries | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| entrycode int32 Entry code | +| HDFE_NENTDIM (0) | +| HDFE_NENTDFLD (4) | +| | +| | +| OUTPUTS: | +| strbufsize int32 Length of comma-separated list | +| (Does not include null-terminator | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nEntries to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDnentries(int32 gridID, int32 entrycode, int32 * strbufsize) + +{ + intn status; /* routine return status variable */ + intn i; /* Loop index */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 nEntries = 0; /* Number of entries */ + int32 metaflag; /* Old (0), New (1) metadata flag) */ + int32 nVal = 0; /* Number of strings to search for */ + + char *metabuf = NULL; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char gridname[80]; /* Grid Name */ + char *utlstr;/* Utility string */ + char valName[2][32]; /* Strings to search for */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"GDnentries", __FILE__, __LINE__); + return(-1); + } + status = GDchkgdid(gridID, "GDnentries", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get grid name */ + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + + /* Zero out string buffer size */ + *strbufsize = 0; + + + /* + * Get pointer to relevant section within SM and Get names of + * metadata strings to inquire about + */ + switch (entrycode) + { + case HDFE_NENTDIM: + { + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "Dimension", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + nVal = 1; + strcpy(&valName[0][0], "DimensionName"); + } + break; + + case HDFE_NENTDFLD: + { + metabuf = (char *) EHmetagroup(sdInterfaceID, gridname, "g", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + nVal = 1; + strcpy(&valName[0][0], "DataFieldName"); + } + break; + } + + + /* + * Check for presence of 'GROUP="' string If found then old metadata, + * search on OBJECT string + */ + metaflag = (strstr(metabuf, "GROUP=\"") == NULL) ? 1 : 0; + if (metaflag == 0) + { + nVal = 1; + strcpy(&valName[0][0], "\t\tOBJECT"); + } + + + /* Begin loop through entries in metadata */ + /* -------------------------------------- */ + while (1) + { + /* Search for first string */ + strcpy(utlstr, &valName[0][0]); + strcat(utlstr, "="); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* If found within relevant metadata section ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + for (i = 0; i < nVal; i++) + { + /* + * Get all string values Don't count quotes + */ + EHgetmetavalue(metaptrs, &valName[i][0], utlstr); + *strbufsize += strlen(utlstr) - 2; + } + /* Increment number of entries */ + nEntries++; + + /* Go to end of OBJECT */ + metaptrs[0] = strstr(metaptrs[0], "END_OBJECT"); + } + else + /* No more entries found */ + { + break; + } + } + free(metabuf); + + + /* Count comma separators & slashes (if mappings) */ + /* ---------------------------------------------- */ + if (nEntries > 0) + { + *strbufsize += nEntries - 1; + *strbufsize += (nVal - 1) * nEntries; + } + } + + + /* Set nEntries to -1 if error status exists */ + /* ----------------------------------------- */ + if (status == -1) + { + nEntries = -1; + } + + free(utlstr); + return (nEntries); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDinqgrid | +| | +| DESCRIPTION: Returns number and names of grid structures in file | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nGrid int32 Number of grid structures in file | +| | +| INPUTS: | +| filename char HDF-EOS filename | +| | +| OUTPUTS: | +| gridlist char List of grid names (comma-separated) | +| strbufsize int32 Length of gridlist | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDinqgrid(char *filename, char *gridlist, int32 * strbufsize) +{ + int32 nGrid; /* Number of grid structures in file */ + + /* Call "EHinquire" routine */ + /* ------------------------ */ + nGrid = EHinquire(filename, "GRID", gridlist, strbufsize); + + return (nGrid); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDsetfillvalue | +| | +| DESCRIPTION: Sets fill value for the specified field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char field name | +| fillval void fill value | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDsetfillvalue(int32 gridID, char *fieldname, VOIDP fillval) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 sdid; /* SDS id */ + int32 nt; /* Number type */ + int32 dims[8]; /* Dimensions array */ + int32 dum; /* Dummy variable */ + int32 solo; /* "Solo" (non-merged) field flag */ + + char name[80]; /* Fill value "attribute" name */ + + /* Check for valid grid ID and get SDS interface ID */ + status = GDchkgdid(gridID, "GDsetfillvalue", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &dum, dims, &nt, NULL); + + if (status == 0) + { + /* Get SDS ID and solo flag */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, + &sdid, &dum, &dum, &dum, + dims, &solo); + + /* If unmerged field then call HDF set field routine */ + if (solo == 1) + { + status = SDsetfillvalue(sdid, fillval); + } + + /* + * Store fill value in attribute. Name is given by fieldname + * prepended with "_FV_" + */ + strcpy(name, "_FV_"); + strcat(name, fieldname); + status = GDwriteattr(gridID, name, nt, 1, fillval); + + + } + else + { + HEpush(DFE_GENAPP, "GDsetfillvalue", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + } + return (status); +} + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetfillvalue | +| | +| DESCRIPTION: Retrieves fill value for a specified field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char field name | +| | +| OUTPUTS: | +| fillval void fill value | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDgetfillvalue(int32 gridID, char *fieldname, VOIDP fillval) +{ + intn status; /* routine return status variable */ + + int32 nt; /* Number type */ + int32 dims[8]; /* Dimensions array */ + int32 dum; /* Dummy variable */ + + char name[80]; /* Fill value "attribute" name */ + + status = GDchkgdid(gridID, "GDgetfillvalue", &dum, &dum, &dum); + + /* Check for valid grid ID */ + if (status == 0) + { + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &dum, dims, &nt, NULL); + + if (status == 0) + { + /* Read fill value attribute */ + strcpy(name, "_FV_"); + strcat(name, fieldname); + status = GDreadattr(gridID, name, fillval); + } + else + { + HEpush(DFE_GENAPP, "GDgetfillvalue", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdetach | +| | +| DESCRIPTION: Detaches from grid interface and performs file housekeeping. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Sep 96 Joel Gales Setup dim names for SDsetdimname in dimbuf1 rather | +| that utlstr | +| Oct 96 Joel Gales Detach Grid Vgroups | +| Oct 96 Joel Gales "Detach" from SDS | +| Nov 96 Joel Gales Call GDchkgdid to check for proper grid ID | +| Dec 96 Joel Gales Add multiple vertical subsetting garbage collection | +| Oct 98 Abe Taaheri Added GDXRegion[k]->DimNamePtr[i] =0; after freeing | +| memory | +| Sep 99 Abe Taaheri Changed memcpy to memmove because of overlapping | +| source and destination for GDXSDcomb, nameptr, and | +| dimptr. memcpy may cause unexpected results. | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDdetach(int32 gridID) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statusFill = 0; /* return status from GDgetfillvalue */ + + int32 *namelen; /* Pointer to name string length array */ + int32 *dimlen; /* Pointer to dim string length array */ + int32 slen1[3]; /* String length array 1 */ + int32 slen2[3]; /* String length array 2 */ + int32 nflds; /* Number of fields */ + int32 match[5]; /* Merged field match array */ + int32 cmbfldcnt; /* Number of fields combined */ + int32 sdid; /* SDS ID */ + int32 vgid; /* Vgroup ID */ + int32 dims[3]; /* Dimension array */ + int32 *offset; /* Pointer to merged field offset array */ + int32 *indvdims; /* Pointer to merged field size array */ + int32 sdInterfaceID; /* SDS interface ID */ + int32 gID; /* Grid ID - offset */ + int32 nflds0; /* Number of fields */ + int32 *namelen0; /* Pointer to name string length array */ + int32 rank; /* Rank of merged field */ + int32 truerank; /* True rank of merged field */ + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + int32 dum; /* Dummy variable */ + + char *nambuf; /* Pointer to name buffer */ + char **nameptr; /* Pointer to name string pointer array */ + char **dimptr; /* Pointer to dim string pointer array */ + char **nameptr0; /* Pointer to name string pointer array */ + char *ptr1[3]; /* String pointer array */ + char *ptr2[3]; /* String pointer array */ + char dimbuf1[128]; /* Dimension buffer 1 */ + char dimbuf2[128]; /* Dimension buffer 2 */ + char gridname[VGNAMELENMAX + 1]; /* Grid name */ + char *utlbuf; /* Utility buffer */ + char fillval[32];/* Fill value buffer */ + + + + status = GDchkgdid(gridID, "GDdetach", &dum, &sdInterfaceID, &dum); + + if (status == 0) + { + gID = gridID % idOffset; + Vgetname(GDXGrid[gID].IDTable, gridname); + + /* SDS combined fields */ + /* ------------------- */ + if (strlen(GDXSDname) == 0) + { + nflds = 0; + + /* Allocate "dummy" arrays so free() doesn't bomb later */ + /* ---------------------------------------------------- */ + nameptr = (char **) calloc(1, sizeof(char *)); + if(nameptr == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + return(-1); + } + namelen = (int32 *) calloc(1, sizeof(int32)); + if(namelen == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + return(-1); + } + nameptr0 = (char **) calloc(1, sizeof(char *)); + if(nameptr0 == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + return(-1); + } + namelen0 = (int32 *) calloc(1, sizeof(int32)); + if(namelen0 == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + return(-1); + } + dimptr = (char **) calloc(1, sizeof(char *)); + if(dimptr == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + return(-1); + } + dimlen = (int32 *) calloc(1, sizeof(int32)); + if(dimlen == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + return(-1); + } + offset = (int32 *) calloc(1, sizeof(int32)); + if(offset == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + return(-1); + } + indvdims = (int32 *) calloc(1, sizeof(int32)); + if(indvdims == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + } + else + { + /* + * "Trim Off" trailing "," and ";" in GDXSDname & GDXSDdims + * respectively + */ + GDXSDname[strlen(GDXSDname) - 1] = 0; + GDXSDdims[strlen(GDXSDdims) - 1] = 0; + + + /* Get number of fields from GDXSDname string */ + /* ------------------------------------------ */ + nflds = EHparsestr(GDXSDname, ',', NULL, NULL); + + /* Allocate space for various dynamic arrays */ + /* ----------------------------------------- */ + nameptr = (char **) calloc(nflds, sizeof(char *)); + if(nameptr == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + return(-1); + } + namelen = (int32 *) calloc(nflds, sizeof(int32)); + if(namelen == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + return(-1); + } + nameptr0 = (char **) calloc(nflds, sizeof(char *)); + if(nameptr0 == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + return(-1); + } + namelen0 = (int32 *) calloc(nflds, sizeof(int32)); + if(namelen0 == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + return(-1); + } + dimptr = (char **) calloc(nflds, sizeof(char *)); + if(dimptr == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + return(-1); + } + dimlen = (int32 *) calloc(nflds, sizeof(int32)); + if(dimlen == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + return(-1); + } + offset = (int32 *) calloc(nflds, sizeof(int32)); + if(offset == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + return(-1); + } + indvdims = (int32 *) calloc(nflds, sizeof(int32)); + if(indvdims == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + + /* Parse GDXSDname and GDXSDdims strings */ + /* ------------------------------------- */ + nflds = EHparsestr(GDXSDname, ',', nameptr, namelen); + nflds = EHparsestr(GDXSDdims, ';', dimptr, dimlen); + } + + + for (i = 0; i < nflds; i++) + { + if (GDXSDcomb[5 * i] != 0 && + GDXSDcomb[5 * i + 3] == GDXGrid[gID].IDTable) + { + nambuf = (char *) calloc(strlen(GDXSDname) + 1, 1); + if(nambuf == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + utlbuf = (char *) calloc(strlen(GDXSDname) * 2 + 7, 1); + if(utlbuf == NULL) + { + HEpush(DFE_NOSPACE,"GDdetach", __FILE__, __LINE__); + free(nambuf); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + + for (k = 0; k < sizeof(dimbuf1); k++) + dimbuf1[k] = 0; + + + /* Load array to match, name & parse dims */ + /* -------------------------------------- */ + memcpy(match, &GDXSDcomb[5 * i], 20); + memcpy(nambuf, nameptr[i], namelen[i]); + + memcpy(dimbuf1, dimptr[i], dimlen[i]); + dum = EHparsestr(dimbuf1, ',', ptr1, slen1); + + + /* Separate combined dimension from others */ + /* --------------------------------------- */ + dimbuf1[slen1[0]] = 0; + + offset[0] = 0; + indvdims[0] = abs(match[0]); + + for (j = i + 1, cmbfldcnt = 0; j < nflds; j++) + { + for (k = 0; k < sizeof(dimbuf2); k++) + dimbuf2[k] = 0; + memcpy(dimbuf2, dimptr[j], dimlen[j]); + dum = EHparsestr(dimbuf2, ',', ptr2, slen2); + dimbuf2[slen2[0]] = 0; + + + if (GDXSDcomb[5 * j] != 0 && + strcmp(dimbuf1 + slen1[0], + dimbuf2 + slen2[0]) == 0 && + match[1] == GDXSDcomb[5 * j + 1] && + match[2] == GDXSDcomb[5 * j + 2] && + match[3] == GDXSDcomb[5 * j + 3] && + match[4] == GDXSDcomb[5 * j + 4]) + { + /* Add to combined dimension size */ + match[0] += GDXSDcomb[5 * j]; + + /* Concatanate name */ + strcat(nambuf, ","); + memcpy(nambuf + strlen(nambuf), + nameptr[j], namelen[j]); + + /* Store individual dims and dim offsets */ + cmbfldcnt++; + indvdims[cmbfldcnt] = abs(GDXSDcomb[5 * j]); + offset[cmbfldcnt] = + offset[cmbfldcnt - 1] + indvdims[cmbfldcnt - 1]; + + GDXSDcomb[5 * j] = 0; + } + } + + + /* Create SDS */ + /* ---------- */ + nflds0 = EHparsestr(nambuf, ',', nameptr0, namelen0); + + if (abs(match[0]) == 1) + { + for (k = 0; k < 2; k++) + dims[k] = abs(match[k + 1]); + + rank = 2; + + sdid = SDcreate(sdInterfaceID, nambuf, + GDXSDcomb[5 * i + 4], 2, dims); + } + else + { + for (k = 0; k < 3; k++) + dims[k] = abs(match[k]); + + rank = 3; + + if (cmbfldcnt > 0) + { + strcpy(utlbuf, "MRGFLD_"); + memcpy(utlbuf + 7, nameptr0[0], namelen0[0]); + utlbuf[7 + namelen0[0]] = 0; + strcat(utlbuf, ":"); + strcat(utlbuf, nambuf); + + status = EHinsertmeta(sdInterfaceID, gridname, "g", + 6L, utlbuf, NULL); + } + else + { + strcpy(utlbuf, nambuf); + } + + sdid = SDcreate(sdInterfaceID, utlbuf, + GDXSDcomb[5 * i + 4], 3, dims); + + + if (cmbfldcnt > 0) + { + SDsetattr(sdid, "Field Dims", DFNT_INT32, + cmbfldcnt + 1, (VOIDP) indvdims); + + SDsetattr(sdid, "Field Offsets", DFNT_INT32, + cmbfldcnt + 1, (VOIDP) offset); + } + + } + + + + /* Register Dimensions in SDS */ + /* -------------------------- */ + for (k = 0; k < rank; k++) + { + if (rank == 2) + { + memcpy(dimbuf2, ptr1[k + 1], slen1[k + 1]); + dimbuf2[slen1[k + 1]] = 0; + } + else + { + memcpy(dimbuf2, ptr1[k], slen1[k]); + dimbuf2[slen1[k]] = 0; + } + + + if (k == 0 && rank > 2 && cmbfldcnt > 0) + { + sprintf(dimbuf2, "%s%s_%d", "MRGDIM:", + gridname, (int)dims[0]); + } + else + { + strcat(dimbuf2, ":"); + strcat(dimbuf2, gridname); + } + SDsetdimname(SDgetdimid(sdid, k), (char *) dimbuf2); + } + + + + /* Write Fill Value */ + /* ---------------- */ + for (k = 0; k < nflds0; k++) + { + memcpy(utlbuf, nameptr0[k], namelen0[k]); + utlbuf[namelen[k]] = 0; + statusFill = GDgetfillvalue(gridID, utlbuf, fillval); + + if (statusFill == 0) + { + if (cmbfldcnt > 0) + { + dims[0] = indvdims[k]; + truerank = (dims[0] == 1) ? 2 : 3; + EHfillfld(sdid, rank, truerank, + DFKNTsize(match[4]), offset[k], + dims, fillval); + } + else + { + status = SDsetfillvalue(sdid, fillval); + } + } + } + + + vgid = GDXGrid[gID].VIDTable[0]; + Vaddtagref(vgid, DFTAG_NDG, SDidtoref(sdid)); + SDendaccess(sdid); + + free(nambuf); + free(utlbuf); + + } + } + + + for (i = 0; i < nflds; i++) + { + if (GDXSDcomb[5 * i + 3] == GDXGrid[gID].IDTable) + { + if (i == (nflds - 1)) + { + GDXSDcomb[5 * i] = 0; + *(nameptr[i] - (nflds != 1)) = 0; + *(dimptr[i] - (nflds != 1)) = 0; + } + else + { + /* memcpy(&GDXSDcomb[5 * i], + &GDXSDcomb[5 * (i + 1)], + (512 - i - 1) * 5 * 4);*/ + memmove(&GDXSDcomb[5 * i], + &GDXSDcomb[5 * (i + 1)], + (512 - i - 1) * 5 * 4); + /* memcpy(nameptr[i], + nameptr[i + 1], + nameptr[0] + 2048 - nameptr[i + 1] - 1);*/ + memmove(nameptr[i], + nameptr[i + 1], + nameptr[0] + 2048 - nameptr[i + 1] - 1); + /* memcpy(dimptr[i], + dimptr[i + 1], + dimptr[0] + 2048 * 2 - dimptr[i + 1] - 1);*/ + memmove(dimptr[i], + dimptr[i + 1], + dimptr[0] + 2048 * 2 - dimptr[i + 1] - 1); + } + + i--; + nflds = EHparsestr(GDXSDname, ',', nameptr, namelen); + nflds = EHparsestr(GDXSDdims, ';', dimptr, dimlen); + } + } + + if (nflds != 0) + { + strcat(GDXSDname, ","); + strcat(GDXSDdims, ";"); + } + + + + /* Free up a bunch of dynamically allocated arrays */ + /* ----------------------------------------------- */ + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + free(indvdims); + + + + /* "Detach" from previously attached SDSs */ + /* -------------------------------------- */ + for (k = 0; k < GDXGrid[gID].nSDS; k++) + { + SDendaccess(GDXGrid[gID].sdsID[k]); + } + free(GDXGrid[gID].sdsID); + GDXGrid[gID].sdsID = 0; + GDXGrid[gID].nSDS = 0; + + + + /* Detach Grid Vgroups */ + /* ------------------- */ + Vdetach(GDXGrid[gID].VIDTable[0]); + Vdetach(GDXGrid[gID].VIDTable[1]); + Vdetach(GDXGrid[gID].IDTable); + + GDXGrid[gID].active = 0; + GDXGrid[gID].VIDTable[0] = 0; + GDXGrid[gID].VIDTable[1] = 0; + GDXGrid[gID].IDTable = 0; + GDXGrid[gID].fid = 0; + + + + + /* Free Region Pointers */ + /* -------------------- */ + for (k = 0; k < NGRIDREGN; k++) + { + if (GDXRegion[k] != 0 && + GDXRegion[k]->gridID == gridID) + { + for (i = 0; i < 8; i++) + { + if (GDXRegion[k]->DimNamePtr[i] != 0) + { + free(GDXRegion[k]->DimNamePtr[i]); + GDXRegion[k]->DimNamePtr[i] = 0; + } + } + + free(GDXRegion[k]); + GDXRegion[k] = 0; + } + } + } + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDclose | +| | +| DESCRIPTION: Closes file. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 File ID | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDclose(int32 fid) + +{ + intn status = 0; /* routine return status variable */ + + /* Call EHclose to perform file close */ + /* ---------------------------------- */ + status = EHclose(fid); + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetdefaults | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| projparm float64 Projection parameters | +| spherecode int32 GCTP spheriod code | +| upleftpt float64 upper left corner coordinates | +| lowrightpt float64 lower right corner coordinates | +| | +| | +| OUTPUTS: | +| upleftpt float64 upper left corner coordinates | +| lowrightpt float64 lower right corner coordinates | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Sep 96 Raj Gejjaga Fixed bugs in Polar Stereographic and Goode | | Homolosine default calculations. | +| Sep 96 Raj Gejjaga Added code to compute default boundary points | +| for Lambert Azimuthal Polar and Equitorial | +| projections. | +| Feb 97 Raj Gejjaga Added code to compute default boundary points | +| for Integerized Sinusoidal Grid. Added error | +| handling code. | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDgetdefaults(int32 projcode, int32 zonecode, float64 projparm[], + int32 spherecode, float64 upleftpt[], float64 lowrightpt[]) +{ + int32 errorcode = 0, status = 0; + int32(*for_trans[100]) (); + + float64 lon, lat, plat, x, y; + float64 plon, tlon, llon, rlon, pplon, LLon, LLat, RLon, RLat; + + + /* invoke GCTP initialization routine */ + /* ---------------------------------- */ + for_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, for_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Compute Default Boundary Points for EASE Grid */ + /* Use Global coverage */ + /* ------------------------------------------------------ */ + if (projcode == GCTP_BCEA && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + upleftpt[0] = EHconvAng(EASE_GRID_DEFAULT_UPLEFT_LON, HDFE_DEG_DMS); + upleftpt[1] = EHconvAng(EASE_GRID_DEFAULT_UPLEFT_LAT, HDFE_DEG_DMS); + lowrightpt[0] = EHconvAng(EASE_GRID_DEFAULT_LOWRGT_LON, HDFE_DEG_DMS); + lowrightpt[1] = EHconvAng(EASE_GRID_DEFAULT_LOWRGT_LAT, HDFE_DEG_DMS); + } + +/* Compute Default Boundary Points for CEA */ + /* --------------------------------------------*/ + if (projcode == GCTP_CEA && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + LLon = EHconvAng(EASE_GRID_DEFAULT_UPLEFT_LON, HDFE_DEG_RAD); + LLat = EHconvAng(EASE_GRID_DEFAULT_UPLEFT_LAT, HDFE_DEG_RAD); + RLon = EHconvAng(EASE_GRID_DEFAULT_LOWRGT_LON, HDFE_DEG_RAD); + RLat = EHconvAng(EASE_GRID_DEFAULT_LOWRGT_LAT, HDFE_DEG_RAD); + + errorcode = for_trans[projcode] (LLon, LLat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + upleftpt[0] = x; + upleftpt[1] = y; + + errorcode = for_trans[projcode] (RLon, RLat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + lowrightpt[0] = x; + lowrightpt[1] = y; + + } + + + /* Compute Default Boundary Points for Polar Sterographic */ + /* ------------------------------------------------------ */ + if (projcode == GCTP_PS && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + /* + * Convert the longitude and latitude from the DMS to decimal degree + * format. + */ + plon = EHconvAng(projparm[4], HDFE_DMS_DEG); + plat = EHconvAng(projparm[5], HDFE_DMS_DEG); + + /* + * Compute the longitudes at 90, 180 and 270 degrees from the central + * longitude. + */ + + if (plon <= 0.0) + { + tlon = 180.0 + plon; + pplon = plon + 360.0; + } + else + { + tlon = plon - 180.0; + pplon = plon; + } + + rlon = pplon + 90.0; + if (rlon > 360.0) + rlon = rlon - 360; + + if (rlon > 180.0) + rlon = rlon - 360.0; + + if (rlon <= 0.0) + llon = 180.0 + rlon; + else + llon = rlon - 180.0; + + + /* Convert all four longitudes from decimal degrees to radians */ + plon = EHconvAng(plon, HDFE_DEG_RAD); + tlon = EHconvAng(tlon, HDFE_DEG_RAD); + llon = EHconvAng(llon, HDFE_DEG_RAD); + rlon = EHconvAng(rlon, HDFE_DEG_RAD); + + errorcode = for_trans[projcode] (llon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[0] = x; + + errorcode = for_trans[projcode] (rlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[0] = x; + + /* + * Compute the upperleft and lowright y values based on the south or + * north polar projection + */ + + if (plat < 0.0) + { + errorcode = for_trans[projcode] (plon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + errorcode = for_trans[projcode] (tlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + + } + else + { + errorcode = for_trans[projcode] (tlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + errorcode = for_trans[projcode] (plon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + + } + } + + + /* Compute Default Boundary Points for Goode Homolosine */ + /* ---------------------------------------------------- */ + if (projcode == GCTP_GOOD && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + lon = EHconvAng(-180, HDFE_DEG_RAD); + lat = 0.0; + + errorcode = for_trans[projcode] (lon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[0] = -fabs(x); + lowrightpt[0] = +fabs(x); + + lat = EHconvAng(90, HDFE_DEG_RAD); + + errorcode = for_trans[projcode] (lon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = +fabs(y); + lowrightpt[1] = -fabs(y); + } + + /* Compute Default Boundary Points for Lambert Azimuthal */ + /* ----------------------------------------------------- */ + if (projcode == GCTP_LAMAZ && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + /* + * Convert the longitude and latitude from the DMS to decimal degree + * format. + */ + plon = EHconvAng(projparm[4], HDFE_DMS_DEG); + plat = EHconvAng(projparm[5], HDFE_DMS_DEG); + + /* + * Compute the longitudes at 90, 180 and 270 degrees from the central + * longitude. + */ + + if (plon <= 0.0) + { + tlon = 180.0 + plon; + pplon = plon + 360.0; + } + else + { + tlon = plon - 180.0; + pplon = plon; + } + + rlon = pplon + 90.0; + if (rlon > 360.0) + rlon = rlon - 360; + + if (rlon > 180.0) + rlon = rlon - 360.0; + + if (rlon <= 0.0) + llon = 180.0 + rlon; + else + llon = rlon - 180.0; + + /* Convert all four longitudes from decimal degrees to radians */ + plon = EHconvAng(plon, HDFE_DEG_RAD); + tlon = EHconvAng(tlon, HDFE_DEG_RAD); + llon = EHconvAng(llon, HDFE_DEG_RAD); + rlon = EHconvAng(rlon, HDFE_DEG_RAD); + + errorcode = for_trans[projcode] (llon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[0] = x; + + errorcode = for_trans[projcode] (rlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[0] = x; + + /* + * Compute upperleft and lowerright values based on whether the + * projection is south polar, north polar or equitorial + */ + + if (plat == -90.0) + { + errorcode = for_trans[projcode] (plon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + errorcode = for_trans[projcode] (tlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + } + else if (plat == 90.0) + { + errorcode = for_trans[projcode] (tlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + errorcode = for_trans[projcode] (plon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + } + else + { + lat = EHconvAng(90, HDFE_DEG_RAD); + errorcode = for_trans[projcode] (plon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + lat = EHconvAng(-90, HDFE_DEG_RAD); + errorcode = for_trans[projcode] (plon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + } + } + + /* Compute Default Boundary Points for Integerized Sinusoidal Grid */ + /* --------------------------------------------------------------- */ + if (((projcode == GCTP_ISINUS) || (projcode == GCTP_ISINUS1)) && + upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + /* + * Convert the longitude and latitude from the DMS to decimal degree + * format. + */ + plon = EHconvAng(projparm[4], HDFE_DMS_DEG); + plat = EHconvAng(projparm[5], HDFE_DMS_DEG); + + /* + * Compute the longitudes at 90, 180 and 270 degrees from the central + * longitude. + */ + + if (plon <= 0.0) + { + tlon = 180.0 + plon; + pplon = plon + 360.0; + } + else + { + tlon = plon - 180.0; + pplon = plon; + } + + rlon = pplon + 90.0; + if (rlon > 360.0) + rlon = rlon - 360; + + if (rlon > 180.0) + rlon = rlon - 360.0; + + if (rlon <= 0.0) + llon = 180.0 + rlon; + else + llon = rlon - 180.0; + + /* Convert all four longitudes from decimal degrees to radians */ + plon = EHconvAng(plon, HDFE_DEG_RAD); + tlon = EHconvAng(tlon, HDFE_DEG_RAD); + llon = EHconvAng(llon, HDFE_DEG_RAD); + rlon = EHconvAng(rlon, HDFE_DEG_RAD); + + errorcode = for_trans[projcode] (llon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[0] = x; + + errorcode = for_trans[projcode] (rlon, 0.0, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[0] = x; + + lat = EHconvAng(90, HDFE_DEG_RAD); + errorcode = for_trans[projcode] (plon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + upleftpt[1] = y; + + lat = EHconvAng(-90, HDFE_DEG_RAD); + errorcode = for_trans[projcode] (plon, lat, &x, &y); + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetdefaults", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + lowrightpt[1] = y; + } + return (errorcode); +} + + + + + +#if !defined(HP9000) && !defined(DEC_ALPHA) +void +sincos(double val, double *sin_val, double *cos_val) +{ + *sin_val = sin(val); + *cos_val = cos(val); + return; +} +#endif + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDll2ij | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| projparm float64 Projection parameters | +| spherecode int32 GCTP spheriod code | +| xdimsize int32 xdimsize from GDcreate | +| ydimsize int32 ydimsize from GDcreate | +| upleftpt float64 upper left corner coordinates | +| lowrightpt float64 lower right corner coordinates | +| npnts int32 number of lon-lat points | +| longitude float64 longitude array (radians) | +| latitude float64 latitude array (radians) | +| | +| OUTPUTS: | +| row int32 Row array | +| col int32 Column array | +| xval float64 X value array | +| yval float64 Y value array | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Return x and y values if requested | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDll2ij(int32 projcode, int32 zonecode, float64 projparm[], + int32 spherecode, int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], + int32 npnts, float64 longitude[], float64 latitude[], + int32 row[], int32 col[], float64 xval[], float64 yval[]) + + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 errorcode = 0; /* GCTP error code */ + int32(*for_trans[100]) (); /* GCTP function pointer */ + + float64 xVal; /* Scaled x distance */ + float64 yVal; /* Scaled y distance */ + float64 xMtr; /* X value in meters from GCTP */ + float64 yMtr; /* Y value in meters from GCTP */ + float64 lonrad0; /* Longitude in radians of upleft point */ + float64 latrad0; /* Latitude in radians of upleft point */ + float64 lonrad; /* Longitude in radians of point */ + float64 latrad; /* Latitude in radians of point */ + float64 scaleX; /* X scale factor */ + float64 scaleY; /* Y scale factor */ + float64 EHconvAng();/* Angle conversion routine */ + float64 xMtr0, xMtr1, yMtr0, yMtr1; + float64 lonrad1; /* Longitude in radians of lowright point */ + + /* If projection not GEO call GCTP initialization routine */ + /* ------------------------------------------------------ */ + if (projcode != GCTP_GEO) + { + for_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, for_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDll2ij", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + } + } + + + if (status == 0) + { + /* GEO projection */ + /* -------------- */ + if (projcode == GCTP_GEO) + { + /* Convert upleft and lowright X coords from DMS to radians */ + /* -------------------------------------------------------- */ + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + + /* Compute x scale factor */ + /* ---------------------- */ + scaleX = (lonrad - lonrad0) / xdimsize; + + + /* Convert upleft and lowright Y coords from DMS to radians */ + /* -------------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_RAD); + latrad = EHconvAng(lowrightpt[1], HDFE_DMS_RAD); + + + /* Compute y scale factor */ + /* ---------------------- */ + scaleY = (latrad - latrad0) / ydimsize; + } + + /* BCEA projection */ + /* -------------- */ + else if ( projcode == GCTP_BCEA) + { + /* Convert upleft and lowright X coords from DMS to radians */ + /* -------------------------------------------------------- */ + + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + + /* Convert upleft and lowright Y coords from DMS to radians */ + /* -------------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_RAD); + latrad = EHconvAng(lowrightpt[1], HDFE_DMS_RAD); + + /* Convert from lon/lat to meters(or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0); + + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDll2ij", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Convert from lon/lat to meters(or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1); + + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDll2ij", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Compute x scale factor */ + /* ---------------------- */ + scaleX = (xMtr1 - xMtr0) / xdimsize; + + /* Compute y scale factor */ + /* ---------------------- */ + scaleY = (yMtr1 - yMtr0) / ydimsize; + } + else + { + /* Non-GEO, Non_BCEA projections */ + /* ---------------------------- */ + + /* Compute x & y scale factors */ + /* --------------------------- */ + scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize; + scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize; + } + + + + /* Loop through all points */ + /* ----------------------- */ + for (i = 0; i < npnts; i++) + { + /* Convert lon & lat from decimal degrees to radians */ + /* ------------------------------------------------- */ + lonrad = EHconvAng(longitude[i], HDFE_DEG_RAD); + latrad = EHconvAng(latitude[i], HDFE_DEG_RAD); + + + /* GEO projection */ + /* -------------- */ + if (projcode == GCTP_GEO) + { + /*allow map to span dateline */ + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad1 = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + /* if time-line is paased */ + if(lonrad < lonrad1) + { + if (lonrad < lonrad0) lonrad += 2.0 * M_PI1; + if (lonrad > lonrad1) lonrad -= 2.0 * M_PI1; + } + + /* Compute scaled distance to point from origin */ + /* -------------------------------------------- */ + xVal = (lonrad - lonrad0) / scaleX; + yVal = (latrad - latrad0) / scaleY; + } + else + { + /* Convert from lon/lat to meters using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad, latrad, &xMtr, &yMtr); + + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + /*status = -1; + HEpush(DFE_GENAPP, "GDll2ij", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); */ /* Bruce Beaumont */ + xVal = -2147483648.0; /* Bruce Beaumont */ + yVal = -2147483648.0; /* Bruce Beaumont */ + }/* (Note: MAXLONG is defined as 2147483647.0 in + function cproj.c of GCTP) */ + else { + /* if projection is BCEA normalize x and y by cell size and + measure it from the uperleft corner of the grid */ + + /* Compute scaled distance to point from origin */ + /* -------------------------------------------- */ + if( projcode == GCTP_BCEA) + { + xVal = (xMtr - xMtr0) / scaleX; + yVal = (yMtr - yMtr0) / scaleY; + } + else + { + xVal = (xMtr - upleftpt[0]) / scaleX; + yVal = (yMtr - upleftpt[1]) / scaleY; + } + } + } + + + /* Compute row and col from scaled distance */ + /* ---------------------------------------- */ + col[i] = (int32) xVal; + row[i] = (int32) yVal; + + /* Store scaled distances if requested */ + /* ----------------------------------- */ + if (xval != NULL) + { + xval[i] = xVal; + } + + if (yval != NULL) + { + yval[i] = yVal; + } + } + } + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDij2ll | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| projparm float64 Projection parameters | +| spherecode int32 GCTP spheriod code | +| xdimsize int32 xdimsize from GDcreate | +| ydimsize int32 ydimsize from GDcreate | +| upleftpt float64 upper left corner coordinates | +| lowrightpt float64 lower right corner coordinates | +| pixcen int32 pixel center code | +| npnts int32 number of lon-lat points | +| row int32 Row array | +| col int32 Column array | +| pixcen int32 Code from GDpixreginfo | +| pixcnr int32 Code from GDorigininfo | +| | +| | +| OUTPUTS: | +| longitude float64 longitude array (decimal degrees) | +| latitude float64 latitude array (decimal degrees) | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Add support for GEO (linear) projection | +| Feb 97 Joel Gales Add pixel adjustment support for UR, LL, LR | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDij2ll(int32 projcode, int32 zonecode, float64 projparm[], + int32 spherecode, int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], + int32 npnts, int32 row[], int32 col[], + float64 longitude[], float64 latitude[], int32 pixcen, int32 pixcnr) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 errorcode = 0; /* GCTP error code */ + int32(*inv_trans[100]) (); /* GCTP function pointer */ + int32(*for_trans[100]) (); /* GCTP function pointer */ + + float64 pixadjX; /* Pixel adjustment (x) */ + float64 pixadjY; /* Pixel adjustment (y) */ + float64 lonrad0; /* Longitude in radians of upleft point */ + float64 latrad0; /* Latitude in radians of upleft point */ + float64 scaleX; /* X scale factor */ + float64 scaleY; /* Y scale factor */ + float64 lonrad; /* Longitude in radians of point */ + float64 latrad; /* Latitude in radians of point */ + float64 EHconvAng();/* Angle conversion routine */ + float64 xMtr0, yMtr0, xMtr1, yMtr1; + + /* Compute adjustment of position within pixel */ + /* ------------------------------------------- */ + if (pixcen == HDFE_CENTER) + { + /* Pixel defined at center */ + /* ----------------------- */ + pixadjX = 0.5; + pixadjY = 0.5; + } + else + { + switch (pixcnr) + { + case HDFE_GD_UL: + { + /* Pixel defined at upper left corner */ + /* ---------------------------------- */ + pixadjX = 0.0; + pixadjY = 0.0; + break; + } + + case HDFE_GD_UR: + { + /* Pixel defined at upper right corner */ + /* ----------------------------------- */ + pixadjX = 1.0; + pixadjY = 0.0; + break; + } + + case HDFE_GD_LL: + { + /* Pixel defined at lower left corner */ + /* ---------------------------------- */ + pixadjX = 0.0; + pixadjY = 1.0; + break; + } + + case HDFE_GD_LR: + { + /* Pixel defined at lower right corner */ + /* ----------------------------------- */ + pixadjX = 1.0; + pixadjY = 1.0; + break; + } + + } + } + + /* If projection not GEO or BCEA call GCTP initialization routine */ + /* ------------------------------------------------------------- */ + if (projcode != GCTP_GEO && projcode != GCTP_BCEA) + { + scaleX = (lowrightpt[0] - upleftpt[0]) / xdimsize; + scaleY = (lowrightpt[1] - upleftpt[1]) / ydimsize; + + /* Initialize inverse transformation */ + /* --------------------------------- */ + inv_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, inv_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (-1); + } + + /* For each point ... */ + /* ------------------ */ + for (i = 0; i < npnts; i++) + { + /* Convert from meters (or any units that r_major and + r_minor has) to lon/lat (radians) using GCTP */ + /* --------------------------------------------------- */ + errorcode = inv_trans[projcode] ( + (col[i] + pixadjX) * scaleX + upleftpt[0], + (row[i] + pixadjY) * scaleY + upleftpt[1], + &lonrad, &latrad); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + /* status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); */ + longitude[i] = 1.0e51; /* PGSd_GCT_IN_ERROR */ + latitude[i] = 1.0e51; /* PGSd_GCT_IN_ERROR */ + } + else + { + /* Convert from radians to decimal degrees */ + /* --------------------------------------- */ + longitude[i] = EHconvAng(lonrad, HDFE_RAD_DEG); + latitude[i] = EHconvAng(latrad, HDFE_RAD_DEG); + } + } + } + else if (projcode == GCTP_BCEA) + { + /* BCEA projection */ + /* -------------- */ + + /* Note: upleftpt and lowrightpt are in packed degrees, so they + must be converted to meters for this projection */ + + /* Initialize forward transformation */ + /* --------------------------------- */ + for_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, for_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (-1); + } + + /* Convert upleft and lowright X coords from DMS to radians */ + /* -------------------------------------------------------- */ + + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + + /* Convert upleft and lowright Y coords from DMS to radians */ + /* -------------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_RAD); + latrad = EHconvAng(lowrightpt[1], HDFE_DMS_RAD); + + /* Convert form lon/lat to meters(or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0); + + /* Report error if any */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Convert from lon/lat to meters or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1); + + /* Report error if any */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Compute x scale factor */ + /* ---------------------- */ + scaleX = (xMtr1 - xMtr0) / xdimsize; + + /* Compute y scale factor */ + /* ---------------------- */ + scaleY = (yMtr1 - yMtr0) / ydimsize; + + /* Initialize inverse transformation */ + /* --------------------------------- */ + inv_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, inv_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (-1); + } + + /* For each point ... */ + /* ------------------ */ + for (i = 0; i < npnts; i++) + { + /* Convert from meters (or any units that r_major and + r_minor has) to lon/lat (radians) using GCTP */ + /* --------------------------------------------------- */ + errorcode = inv_trans[projcode] ( + (col[i] + pixadjX) * scaleX + xMtr0, + (row[i] + pixadjY) * scaleY + yMtr0, + &lonrad, &latrad); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + /* status = -1; + HEpush(DFE_GENAPP, "GDij2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); */ + longitude[i] = 1.0e51; /* PGSd_GCT_IN_ERROR */ + latitude[i] = 1.0e51; /* PGSd_GCT_IN_ERROR */ + } + + /* Convert from radians to decimal degrees */ + /* --------------------------------------- */ + longitude[i] = EHconvAng(lonrad, HDFE_RAD_DEG); + latitude[i] = EHconvAng(latrad, HDFE_RAD_DEG); + } + } + + else if (projcode == GCTP_GEO) + { + /* GEO projection */ + /* -------------- */ + + /* + * Note: lonrad, lonrad0, latrad, latrad0 are actually in degrees for + * the GEO projection case. + */ + + + /* Convert upleft and lowright X coords from DMS to degrees */ + /* -------------------------------------------------------- */ + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_DEG); + lonrad = EHconvAng(lowrightpt[0], HDFE_DMS_DEG); + + + /* Compute x scale factor */ + /* ---------------------- */ + scaleX = (lonrad - lonrad0) / xdimsize; + + + /* Convert upleft and lowright Y coords from DMS to degrees */ + /* -------------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_DEG); + latrad = EHconvAng(lowrightpt[1], HDFE_DMS_DEG); + + + /* Compute y scale factor */ + /* ---------------------- */ + scaleY = (latrad - latrad0) / ydimsize; + + + /* For each point ... */ + /* ------------------ */ + for (i = 0; i < npnts; i++) + { + /* Convert to lon/lat (decimal degrees) */ + /* ------------------------------------ */ + longitude[i] = (col[i] + pixadjX) * scaleX + lonrad0; + latitude[i] = (row[i] + pixadjY) * scaleY + latrad0; + } + } + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDrs2ll | +| | +| DESCRIPTION: Converts EASE grid's (r,s) coordinates to longitude and | +| latritude (in decimal degrees). | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| projparm float64 Projection parameters | +| xdimsize int32 xdimsize from GDcreate | +| ydimsize int32 ydimsize from GDcreate | +| pixcen int32 pixel center code | +| npnts int32 number of lon-lat points | +| s int32 s coordinate | +| r int32 r coordinate | +| pixcen int32 Code from GDpixreginfo | +| pixcnr int32 Code from GDorigininfo | +| upleft float64 upper left corner coordinates (DMS) | +| lowright float64 lower right corner coordinates (DMS) | +| | +| | +| OUTPUTS: | +| longitude float64 longitude array (decimal degrees) | +| latitude float64 latitude array (decimal degrees) | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jul 00 Abe Taaheri Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDrs2ll(int32 projcode, float64 projparm[], + int32 xdimsize, int32 ydimsize, + float64 upleft[], float64 lowright[], + int32 npnts, float64 r[], float64 s[], + float64 longitude[], float64 latitude[], int32 pixcen, int32 pixcnr) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 errorcode = 0; /* GCTP error code */ + int32(*inv_trans[100]) (); /* GCTP function pointer */ + + float64 pixadjX; /* Pixel adjustment (x) */ + float64 pixadjY; /* Pixel adjustment (y) */ + float64 lonrad; /* Longitude in radians of point */ + float64 latrad; /* Latitude in radians of point */ + float64 EHconvAng();/* Angle conversion routine */ + float64 xMtr; /* X value in meters from GCTP */ + float64 yMtr; /* Y value in meters from GCTP */ + float64 epsilon; + float64 beta; + float64 qp_cea; + float64 kz_cea; + float64 eccen, eccen_sq; + float64 phi1, sinphi1, cosphi1; + float64 scaleX, scaleY; + + int32 zonecode=0; + + int32 spherecode=0; + float64 lon[2],lat[2]; + float64 xcor[2], ycor[2]; + int32 nlatlon; + + /* If projection is BCEA define scale, r0 and s0 */ + if (projcode == GCTP_BCEA) + { + eccen_sq = 1.0 - SQUARE(projparm[1]/projparm[0]); + eccen = sqrt(eccen_sq); + if(eccen < 0.00001) + { + qp_cea = 2.0; + } + else + { + qp_cea = + (1.0 - eccen_sq)*((1.0/(1.0 - eccen_sq))-(1.0/(2.0*eccen))* + log((1.0 - eccen)/(1.0 + eccen))); + } + phi1 = EHconvAng(projparm[5],HDFE_DMS_RAD); + cosphi1 = cos(phi1); + sinphi1 = sin(phi1); + kz_cea = cosphi1/(sqrt(1.0 - (eccen_sq*sinphi1*sinphi1))); + } + + + + + /* Compute adjustment of position within pixel */ + /* ------------------------------------------- */ + if (pixcen == HDFE_CENTER) + { + /* Pixel defined at center */ + /* ----------------------- */ + pixadjX = 0.5; + pixadjY = 0.5; + } + else + { + switch (pixcnr) + { + case HDFE_GD_UL: + { + /* Pixel defined at upper left corner */ + /* ---------------------------------- */ + pixadjX = 0.0; + pixadjY = 0.0; + break; + } + + case HDFE_GD_UR: + { + /* Pixel defined at upper right corner */ + /* ----------------------------------- */ + pixadjX = 1.0; + pixadjY = 0.0; + break; + } + + case HDFE_GD_LL: + { + /* Pixel defined at lower left corner */ + /* ---------------------------------- */ + pixadjX = 0.0; + pixadjY = 1.0; + break; + } + + case HDFE_GD_LR: + { + /* Pixel defined at lower right corner */ + /* ----------------------------------- */ + pixadjX = 1.0; + pixadjY = 1.0; + break; + } + + } + } + + /* If projection is BCEA call GCTP initialization routine */ + /* ------------------------------------------------------ */ + if (projcode == GCTP_BCEA) + { + + inv_init(projcode, 0, projparm, 0, NULL, NULL, + &errorcode, inv_trans); + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDrs2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + } + else + { + /* For each point ... */ + /* ------------------ */ + for (i = 0; i < npnts; i++) + { + /* Convert from EASE grid's (r,s) to lon/lat (radians) + using GCTP */ + /* --------------------------------------------------- */ + nlatlon = 2; + lon[0] = upleft[0]; + lon[1] = lowright[0]; + lat[0] = upleft[1]; + lat[1] = lowright[1]; + status = + GDll2mm_cea(projcode,zonecode,spherecode,projparm, + xdimsize, ydimsize, + upleft, lowright, nlatlon, + lon, lat, + xcor, ycor, &scaleX, &scaleY); + + if (status == -1) + { + HEpush(DFE_GENAPP, "GDrs2ll", __FILE__, __LINE__); + return (status); + } + + xMtr = (r[i]/ scaleX + pixadjX - 0.5)* scaleX; + yMtr = - (s[i]/fabs(scaleY) + pixadjY - 0.5)* fabs(scaleY); + + + /* allow .5 cell tolerance in arcsin function + (used in bceainv function) so that grid + coordinates which are less than .5 cells + above 90.00N or below 90.00S are given lat of 90.00 + */ + + epsilon = 1 + 0.5 * (fabs(scaleY)/projparm[0]); + beta = 2.0 * (yMtr - projparm[7]) * kz_cea/(projparm[0] * qp_cea); + + if( fabs (beta) > epsilon) + { + status = -1; + HEpush(DFE_GENAPP, "GDrs2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %s %s %s\n", "grid coordinates", + "are more than .5 cells", + "above 90.00N or below 90.00S. "); + return (status); + } + else if( beta <= -1) + { + errorcode = inv_trans[projcode] (xMtr, 0.0, + &lonrad, &latrad); + latrad = - M_PI1/2; + } + else if( beta >= 1) + { + errorcode = inv_trans[projcode] (xMtr, 0.0, + &lonrad, &latrad); + latrad = M_PI1/2; + } + else + { + errorcode = inv_trans[projcode] (xMtr, yMtr, + &lonrad, &latrad); + } + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDrs2ll", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Convert from radians to decimal degrees */ + /* --------------------------------------- */ + longitude[i] = EHconvAng(lonrad, HDFE_RAD_DEG); + latitude[i] = EHconvAng(latrad, HDFE_RAD_DEG); + } + } + } + + + + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: lamaxDxDtheta | +| | +| DESCRIPTION: Partial derivative along longitude line for Lambert Azimuthal | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| float64 Dx/D(theta) for LAMAZ projection | +| | +| INPUTS: | +| parms float64 Parameters defining partial derivative | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +float64 +lamazDxDtheta(float64 parms[]) +{ + float64 snTheta, sn2Theta, snTheta1, csTheta1, csLamda; + + snTheta = sin(EHconvAng(parms[0], HDFE_DEG_RAD)); + sn2Theta = sin(2 * EHconvAng(parms[0], HDFE_DEG_RAD)); + snTheta1 = sin(EHconvAng(parms[1], HDFE_DEG_RAD)); + csTheta1 = cos(EHconvAng(parms[1], HDFE_DEG_RAD)); + csLamda = cos(EHconvAng(parms[2], HDFE_DEG_RAD) - + EHconvAng(parms[3], HDFE_DEG_RAD)); + + return (4 * snTheta + + (csTheta1 * csLamda * sn2Theta) + + (2 * snTheta1 * (1 + (snTheta * snTheta)))); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: lamaxDxDlamda | +| | +| DESCRIPTION: Partial derivative along latitude line for Lambert Azimuthal | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| float64 Dx/D(lamda) for LAMAZ projection | +| | +| INPUTS: | +| parms float64 Parameters defining partial derivative | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +float64 +lamazDxDlamda(float64 parms[]) +{ + float64 snTheta, csTheta, snTheta1, csTheta1, csLamda; + float64 cs, sn; + + snTheta = sin(EHconvAng(parms[2], HDFE_DEG_RAD)); + csTheta = cos(EHconvAng(parms[2], HDFE_DEG_RAD)); + snTheta1 = sin(EHconvAng(parms[1], HDFE_DEG_RAD)); + csTheta1 = cos(EHconvAng(parms[1], HDFE_DEG_RAD)); + csLamda = cos(EHconvAng(parms[0], HDFE_DEG_RAD) - + EHconvAng(parms[3], HDFE_DEG_RAD)); + + cs = csTheta * csTheta1; + sn = snTheta * snTheta1; + + return (cs + (2 * (1 + sn) + (cs * csLamda)) * csLamda); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: lamaxDyDtheta | +| | +| DESCRIPTION: Partial derivative along longitude line for Lambert Azimuthal | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| float64 Dy/D(theta) for LAMAZ projection | +| | +| INPUTS: | +| parms float64 Parameters defining partial derivative | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +float64 +lamazDyDtheta(float64 parms[]) +{ + float64 snTheta, csTheta, snTheta1, csTheta1, csLamda; + float64 sn2, cs2, sndiff; + + snTheta = sin(EHconvAng(parms[0], HDFE_DEG_RAD)); + csTheta = cos(EHconvAng(parms[0], HDFE_DEG_RAD)); + snTheta1 = sin(EHconvAng(parms[1], HDFE_DEG_RAD)); + csTheta1 = cos(EHconvAng(parms[1], HDFE_DEG_RAD)); + csLamda = cos(EHconvAng(parms[2], HDFE_DEG_RAD) - + EHconvAng(parms[3], HDFE_DEG_RAD)); + + sn2 = snTheta1 * snTheta; + cs2 = csTheta1 * csTheta; + sndiff = snTheta1 - snTheta; + + return (cs2 * (sn2 * (1 + (csLamda * csLamda)) + 2) + + csLamda * (2 * (1 + sn2 * sn2) - (sndiff * sndiff))); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: homDyDtheta | +| | +| DESCRIPTION: Partial derivative along longitude line for Oblique Mercator | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| float64 Dx/D(theta) for HOM projection | +| | +| INPUTS: | +| parms float64 Parameters defining partial derivative | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Mar 97 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +float64 +homDyDtheta(float64 parms[]) +{ + float64 tnTheta, tnTheta1, snLamda; + + tnTheta = tan(EHconvAng(parms[0], HDFE_DEG_RAD)); + tnTheta1 = tan(EHconvAng(parms[1], HDFE_DEG_RAD)); + snLamda = cos(EHconvAng(parms[2], HDFE_DEG_RAD) - + EHconvAng(parms[3], HDFE_DEG_RAD)); + + return (tnTheta * snLamda + tnTheta1); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDtangentpnts | +| | +| DESCRIPTION: Finds tangent points along lon/lat lines | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 Projection code | +| projparm float64 Projection parameters | +| cornerlon float64 dec deg Longitude of opposite corners of box | +| cornerlat float64 dec deg Latitude of opposite corners of box | +| longitude float64 dec deg Longitude of points to check | +| latitude float64 dec deg Latitude of points to check | +| | +| | +| OUTPUTS: | +| npnts int32 Number of points to check in subset | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 96 Joel Gales Original Programmer | +| Mar 97 Joel Gales Add support for LAMCC, POLYC, TM | +| Aug 99 Abe Taaheri Add support for ALBERS, and MERCAT projections. | +| Also changed misstyped bisectParm[2] to | +| bisectParm[3] for HOM projection. | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDtangentpnts(int32 projcode, float64 projparm[], float64 cornerlon[], + float64 cornerlat[], float64 longitude[], float64 latitude[], + int32 * npnts) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + float64 lonrad; /* Longitude (radians) */ + float64 latrad; /* Latitude (radians) */ + float64 cs[4]; /* Cosine array */ + float64 sn[4]; /* Sine array */ + float64 csTest; /* Cosine test value */ + float64 snTest; /* Sine test value */ + float64 crs01; /* Cross product */ + float64 crsTest[2]; /* Cross product array */ + float64 longPol; /* Longitude beneath pole */ + float64 minLat; /* Minimum latitude */ + float64 bisectParm[4]; /* Bisection parameters */ + float64 tanLat; /* Tangent latitude */ + float64 tanLon; /* Tangent lontitude */ + float64 dotPrd; /* Dot product */ + float64 centMerd; /* Central Meridian */ + float64 orgLat; /* Latitude of origin */ + float64 dpi; /* Double precision pi */ + + float64 lamazDxDtheta(); /* Lambert Azimuthal Dx/Dtheta */ + float64 lamazDxDlamda(); /* Lambert Azimuthal Dx/Dlamda */ + float64 lamazDyDtheta(); /* Lambert Azimuthal Dy/Dtheta */ + float64 homDyDtheta(); /* Oblique Mercator Dy/Dtheta */ + + + /* Conpute pi (double precsion) */ + /* ---------------------------- */ + dpi = atan(1.0) * 4; + + + switch (projcode) + { + case GCTP_MERCAT: + { + /* No need for tangent points, since MERCAT projection + is rectangular */ + } + break; + case GCTP_BCEA: + { + /* No need for tangent points, since BCEA projection + is rectangular */ + } + break; + case GCTP_CEA: + { + /* No need for tangent points, since CEA projection + is rectangular */ + } + break; + + case GCTP_PS: + { + /* Add "xy axis" points for Polar Stereographic if necessary */ + /* --------------------------------------------------------- */ + + + /* Get minimum of corner latitudes */ + /* ------------------------------- */ + minLat = (fabs(cornerlat[0]) <= fabs(cornerlat[1])) + ? cornerlat[0] : cornerlat[1]; + + + /* Compute sine and cosine of corner longitudes */ + /* -------------------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + + + /* Compute cross product */ + /* --------------------- */ + crs01 = cs[0] * sn[1] - cs[1] * sn[0]; + + + /* Convert longitude beneath pole from DMS to DEG */ + /* ---------------------------------------------- */ + longPol = EHconvAng(projparm[4], HDFE_DMS_RAD); + + + + for (i = 0; i < 4; i++) + { + csTest = cos(longPol); + snTest = sin(longPol); + + crsTest[0] = cs[0] * snTest - csTest * sn[0]; + crsTest[1] = cs[1] * snTest - csTest * sn[1]; + + if ((crs01 > 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] < 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] > 0)) + { + longitude[*npnts] = EHconvAng(longPol, HDFE_RAD_DEG); + latitude[*npnts] = minLat; + (*npnts)++; + } + longPol += 0.5 * dpi; + } + } + break; + + + case GCTP_LAMAZ: + { + if ((int32) projparm[5] == +90000000 || + (int32) projparm[5] == -90000000) + { + /* Add "xy axis" points for Polar Lambert Azimuthal */ + /* ------------------------------------------------ */ + minLat = (fabs(cornerlat[0]) <= fabs(cornerlat[1])) + ? cornerlat[0] : cornerlat[1]; + + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + crs01 = cs[0] * sn[1] - cs[1] * sn[0]; + + longPol = EHconvAng(projparm[4], HDFE_DMS_RAD); + for (i = 0; i < 4; i++) + { + csTest = cos(longPol); + snTest = sin(longPol); + + crsTest[0] = cs[0] * snTest - csTest * sn[0]; + crsTest[1] = cs[1] * snTest - csTest * sn[1]; + + if ((crs01 > 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] < 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] > 0)) + { + longitude[*npnts] = EHconvAng(longPol, HDFE_RAD_DEG); + latitude[*npnts] = minLat; + (*npnts)++; + } + longPol += 0.5 * dpi; + } + } + else if ((int32) projparm[5] == 0) + { + /* Add "Equator" points for Equatorial Lambert Azimuthal */ + /* ----------------------------------------------------- */ + if (cornerlat[0] * cornerlat[1] < 0) + { + longitude[4] = cornerlon[0]; + latitude[4] = 0; + + longitude[5] = cornerlon[1]; + latitude[5] = 0; + + *npnts = 6; + } + } + else + { + /* Add tangent points for Oblique Lambert Azimuthal */ + /* ------------------------------------------------ */ + bisectParm[0] = EHconvAng(projparm[5], HDFE_DMS_DEG); + bisectParm[2] = EHconvAng(projparm[4], HDFE_DMS_DEG); + + + /* Tangent to y-axis along longitude */ + /* --------------------------------- */ + for (i = 0; i < 2; i++) + { + bisectParm[1] = cornerlon[i]; + + if (EHbisect(lamazDxDtheta, bisectParm, 3, + cornerlat[0], cornerlat[1], + 0.0001, &tanLat) == 0) + { + longitude[*npnts] = cornerlon[i]; + latitude[*npnts] = tanLat; + (*npnts)++; + } + } + + /* Tangent to y-axis along latitude */ + /* -------------------------------- */ + for (i = 0; i < 2; i++) + { + bisectParm[1] = cornerlat[i]; + + if (EHbisect(lamazDxDlamda, bisectParm, 3, + cornerlon[0], cornerlon[1], + 0.0001, &tanLon) == 0) + { + longitude[*npnts] = tanLon; + latitude[*npnts] = cornerlat[i]; + (*npnts)++; + } + } + + + /* Tangent to x-axis along longitude */ + /* --------------------------------- */ + for (i = 0; i < 2; i++) + { + bisectParm[1] = cornerlon[i]; + + if (EHbisect(lamazDyDtheta, bisectParm, 3, + cornerlat[0], cornerlat[1], + 0.0001, &tanLat) == 0) + { + longitude[*npnts] = cornerlon[i]; + latitude[*npnts] = tanLat; + (*npnts)++; + } + } + + /* Tangent to x-axis along latitude */ + /* -------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + crs01 = cs[0] * sn[1] - cs[1] * sn[0]; + + longPol = EHconvAng(projparm[4], HDFE_DMS_RAD); + for (i = 0; i < 2; i++) + { + csTest = cos(longPol); + snTest = sin(longPol); + + crsTest[0] = cs[0] * snTest - csTest * sn[0]; + crsTest[1] = cs[1] * snTest - csTest * sn[1]; + + if ((crs01 > 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] < 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] < 0) || + (crs01 < 0 && crsTest[0] > 0 && crsTest[1] > 0)) + { + longitude[*npnts] = EHconvAng(longPol, HDFE_RAD_DEG); + latitude[*npnts] = cornerlat[0]; + (*npnts)++; + longitude[*npnts] = EHconvAng(longPol, HDFE_RAD_DEG); + latitude[*npnts] = cornerlat[1]; + (*npnts)++; + } + longPol += dpi; + } + } + } + break; + + + case GCTP_GOOD: + { + /* Add "Equator" points for Goode Homolosine if necessary */ + /* ------------------------------------------------------ */ + if (cornerlat[0] * cornerlat[1] < 0) + { + longitude[4] = cornerlon[0]; + latitude[4] = 0; + + longitude[5] = cornerlon[1]; + latitude[5] = 0; + + *npnts = 6; + } + } + break; + + + case GCTP_LAMCC: + { + /* Compute sine and cosine of corner longitudes */ + /* -------------------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + + + /* Compute dot product */ + /* ------------------- */ + dotPrd = cs[0] * cs[1] + sn[0] * sn[1]; + + + /* Convert central meridian (DMS to DEG) & compute sin & cos */ + /* --------------------------------------------------------- */ + centMerd = EHconvAng(projparm[4], HDFE_DMS_DEG); + lonrad = EHconvAng(centMerd, HDFE_DEG_RAD); + cs[1] = cos(lonrad); + sn[1] = sin(lonrad); + + + /* If box brackets central meridian ... */ + /* ------------------------------------ */ + if (cs[0] * cs[1] + sn[0] * sn[1] > dotPrd) + { + latitude[4] = cornerlat[0]; + longitude[4] = centMerd; + + latitude[5] = cornerlat[1]; + longitude[5] = centMerd; + + *npnts = 6; + } + } + break; + + + case GCTP_ALBERS: + { + /* Compute sine and cosine of corner longitudes */ + /* -------------------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + + + /* Compute dot product */ + /* ------------------- */ + dotPrd = cs[0] * cs[1] + sn[0] * sn[1]; + + + /* Convert central meridian (DMS to DEG) & compute sin & cos */ + /* --------------------------------------------------------- */ + centMerd = EHconvAng(projparm[4], HDFE_DMS_DEG); + lonrad = EHconvAng(centMerd, HDFE_DEG_RAD); + cs[1] = cos(lonrad); + sn[1] = sin(lonrad); + + + /* If box brackets central meridian ... */ + /* ------------------------------------ */ + if (cs[0] * cs[1] + sn[0] * sn[1] > dotPrd) + { + latitude[4] = cornerlat[0]; + longitude[4] = centMerd; + + latitude[5] = cornerlat[1]; + longitude[5] = centMerd; + + *npnts = 6; + } + } + break; + + + case GCTP_POLYC: + { + /* Compute sine and cosine of corner longitudes */ + /* -------------------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + + + /* Compute dot product */ + /* ------------------- */ + dotPrd = cs[0] * cs[1] + sn[0] * sn[1]; + + + /* Convert central meridian (DMS to DEG) & compute sin & cos */ + /* --------------------------------------------------------- */ + centMerd = EHconvAng(projparm[4], HDFE_DMS_DEG); + lonrad = EHconvAng(centMerd, HDFE_DEG_RAD); + cs[1] = cos(lonrad); + sn[1] = sin(lonrad); + + + /* If box brackets central meridian ... */ + /* ------------------------------------ */ + if (cs[0] * cs[1] + sn[0] * sn[1] > dotPrd) + { + latitude[4] = cornerlat[0]; + longitude[4] = centMerd; + + latitude[5] = cornerlat[1]; + longitude[5] = centMerd; + + *npnts = 6; + } + } + break; + + + case GCTP_TM: + { + /* Compute sine and cosine of corner longitudes */ + /* -------------------------------------------- */ + for (i = 0; i < 2; i++) + { + lonrad = EHconvAng(cornerlon[i], HDFE_DEG_RAD); + cs[i] = cos(lonrad); + sn[i] = sin(lonrad); + } + + + /* Compute dot product */ + /* ------------------- */ + dotPrd = cs[0] * cs[1] + sn[0] * sn[1]; + + + for (i = -1; i <= 1; i++) + { + centMerd = EHconvAng(projparm[4], HDFE_DMS_DEG); + lonrad = EHconvAng(centMerd + 90 * i, HDFE_DEG_RAD); + csTest = cos(lonrad); + snTest = sin(lonrad); + + + /* If box brackets meridian ... */ + /* ---------------------------- */ + if (csTest * cs[1] + snTest * sn[1] > dotPrd) + { + latitude[*npnts] = cornerlat[0]; + longitude[*npnts] = centMerd; + (*npnts)++; + + latitude[*npnts] = cornerlat[1]; + longitude[*npnts] = centMerd; + (*npnts)++; + } + } + + + + /* Compute sine and cosine of corner latitudes */ + /* ------------------------------------------- */ + for (i = 0; i < 2; i++) + { + latrad = EHconvAng(cornerlat[i], HDFE_DEG_RAD); + cs[i] = cos(latrad); + sn[i] = sin(latrad); + } + + + /* Compute dot product */ + /* ------------------- */ + dotPrd = cs[0] * cs[1] + sn[0] * sn[1]; + + + /* Convert origin latitude (DMS to DEG) & compute sin & cos */ + /* -------------------------------------------------------- */ + orgLat = EHconvAng(projparm[5], HDFE_DMS_DEG); + latrad = EHconvAng(orgLat, HDFE_DEG_RAD); + cs[1] = cos(latrad); + sn[1] = sin(latrad); + + + /* If box brackets origin latitude ... */ + /* ----------------------------------- */ + if (cs[0] * cs[1] + sn[0] * sn[1] > dotPrd) + { + latitude[*npnts] = orgLat; + longitude[*npnts] = cornerlon[0]; + (*npnts)++; + + latitude[*npnts] = orgLat; + longitude[*npnts] = cornerlon[1]; + (*npnts)++; + } + } + break; + + + case GCTP_HOM: + { + /* Tangent to y-axis along longitude */ + /* --------------------------------- */ + if (projparm[12] == 0) + { + cs[0] = cos(EHconvAng(projparm[8], HDFE_DMS_RAD)); + sn[0] = sin(EHconvAng(projparm[8], HDFE_DMS_RAD)); + cs[1] = cos(EHconvAng(projparm[9], HDFE_DMS_RAD)); + sn[1] = sin(EHconvAng(projparm[9], HDFE_DMS_RAD)); + cs[2] = cos(EHconvAng(projparm[10], HDFE_DMS_RAD)); + sn[2] = sin(EHconvAng(projparm[10], HDFE_DMS_RAD)); + cs[3] = cos(EHconvAng(projparm[11], HDFE_DMS_RAD)); + sn[3] = sin(EHconvAng(projparm[11], HDFE_DMS_RAD)); + + bisectParm[3] = atan2( + (cs[1] * sn[3] * cs[0] - sn[1] * cs[3] * cs[2]), + (sn[1] * cs[3] * sn[2] - cs[1] * sn[3] * sn[0])); + bisectParm[0] = atan( + (sin(bisectParm[3]) * sn[0] - cos(bisectParm[3]) * cs[0]) / + (sn[1] / cs[1])); + bisectParm[2] = bisectParm[3] + 0.5 * dpi; + } + else + { + cs[0] = cos(EHconvAng(projparm[3], HDFE_DMS_RAD)); + sn[0] = sin(EHconvAng(projparm[3], HDFE_DMS_RAD)); + cs[1] = cos(EHconvAng(projparm[4], HDFE_DMS_RAD)); + sn[1] = sin(EHconvAng(projparm[4], HDFE_DMS_RAD)); + + bisectParm[0] = asin(cs[1] * sn[0]); + bisectParm[2] = atan2(-cs[0], (-sn[1] * sn[0])) + 0.5 * dpi; + } + + for (i = 0; i < 2; i++) + { + bisectParm[1] = cornerlon[i]; + + if (EHbisect(homDyDtheta, bisectParm, 3, + cornerlat[0], cornerlat[1], + 0.0001, &tanLat) == 0) + { + longitude[*npnts] = cornerlon[i]; + latitude[*npnts] = tanLat; + (*npnts)++; + } + } + + } + break; + } + + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefboxregion | +| | +| DESCRIPTION: Defines region for subsetting in a grid. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| cornerlon float64 dec deg Longitude of opposite corners of box | +| cornerlat float64 dec deg Latitude of opposite corners of box | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales "Clamp" subset region around grid | +| Oct 96 Joel Gales Fix "outside region" check | +| Nov 96 Joel Gales Add check for "tangent" points (GDtangentpnts) | +| Dec 96 Joel Gales Trap if no projection code defined | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Mar 99 David Wynne Fix for NCR 21195, allow subsetting of MISR SOM | +| data sets | +| Jun 00 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDdefboxregion(int32 gridID, float64 cornerlon[], float64 cornerlat[]) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn n; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 regionID; /* Region ID */ + int32 xdimsize; /* XDim size */ + int32 ydimsize; /* YDim size */ + int32 projcode; /* Projection code */ + int32 zonecode; /* Zone code */ + int32 spherecode; /* Sphere code */ + int32 row[32]; /* Row array */ + int32 col[32]; /* Column array */ + int32 minCol; /* Minimun column value */ + int32 minRow; /* Minimun row value */ + int32 maxCol; /* Maximun column value */ + int32 maxRow; /* Maximun row value */ + int32 npnts; /* Number of boundary (edge & tangent) pnts */ + + float64 longitude[32]; /* Longitude array */ + float64 latitude[32]; /* Latitude array */ + float64 upleftpt[2]; /* Upper left pt coordinates */ + float64 lowrightpt[2]; /* Lower right pt coordinates */ + float64 somupleftpt[2]; /* temporary Upper left pt coordinates for SOM projection */ + float64 somlowrightpt[2]; /* temporary Lower right pt coordinates for SOM projection */ + float64 projparm[16]; /* Projection parameters */ + float64 xscale; /* X scale */ + float64 yscale; /* Y scale */ + float64 lonrad0; /* Longitude of upper left point (radians) */ + float64 latrad0; /* Latitude of upper left point (radians) */ + float64 lonrad2; /* Longitude of point (radians) */ + float64 latrad2; /* Latitude of point (radians) */ + + /* Used for SOM projection */ + char *utlbuf; + char *gridname; + int32 blockindexstart = -1; + int32 blockindexstop = -1; + float32 offset[180]; + float64 templeftpt[2]; + float64 temprightpt[2]; + int32 idOffset = GDIDOFFSET; /* Grid ID offset */ + float64 xmtr[2], ymtr[2]; + float64 lon[2],lat[2]; + float64 xcor[2], ycor[2]; + int32 nlatlon; + float64 upleftpt_m[2]; + + + utlbuf = (char *)calloc(128, sizeof(char)); + if(utlbuf == NULL) + { + HEpush(DFE_NOSPACE,"GDdefboxregion", __FILE__, __LINE__); + return(-1); + } + gridname = (char *)calloc(128, sizeof(char)); + if(gridname == NULL) + { + HEpush(DFE_NOSPACE,"GDdefboxregion", __FILE__, __LINE__); + free(utlbuf); + return(-1); + } + + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDdefboxregion", + &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + /* Get grid info */ + /* ------------- */ + status = GDgridinfo(gridID, &xdimsize, &ydimsize, + upleftpt, lowrightpt); + + + /* If error then bail */ + /* ------------------ */ + if (status != 0) + { + regionID = -1; + free(utlbuf); + free(gridname); + return (regionID); + } + + + /* Get proj info */ + /* ------------- */ + status = GDprojinfo(gridID, &projcode, &zonecode, + &spherecode, projparm); + + + /* If no projection code defined then bail */ + /* --------------------------------------- */ + if (projcode == -1) + { + regionID = -1; + free(utlbuf); + free(gridname); + return (regionID); + } + + + /* Get default values for upleft and lowright if necessary */ + /* ------------------------------------------------------- */ + if (upleftpt[0] == 0 && upleftpt[1] == 0 && + lowrightpt[0] == 0 && lowrightpt[1] == 0) + { + status = GDgetdefaults(projcode, zonecode, projparm, spherecode, + upleftpt, lowrightpt); + + /* If error then bail */ + /* ------------------ */ + if (status != 0) + { + regionID = -1; + free(utlbuf); + free(gridname); + return (regionID); + } + } + + + + /* Fill-up longitude and latitude arrays */ + /* ------------------------------------- */ + longitude[0] = cornerlon[0]; + latitude[0] = cornerlat[0]; + + longitude[1] = cornerlon[0]; + latitude[1] = cornerlat[1]; + + longitude[2] = cornerlon[1]; + latitude[2] = cornerlat[0]; + + longitude[3] = cornerlon[1]; + latitude[3] = cornerlat[1]; + + npnts = 4; + + + /* Find additional tangent points from GDtangentpnts */ + /* ------------------------------------------------- */ + status = GDtangentpnts(projcode, projparm, cornerlon, cornerlat, + longitude, latitude, &npnts); + + /* If SOM projection with projparm[11] non-zero ... */ + if (projcode == GCTP_SOM && projparm[11] != 0) + { + Vgetname(GDXGrid[gridID % idOffset].IDTable, gridname); + sprintf(utlbuf, "%s%s", "_BLKSOM:", gridname); + status = GDreadattr(gridID, utlbuf, offset); + + somupleftpt[0] = upleftpt[0]; + somupleftpt[1] = upleftpt[1]; + somlowrightpt[0]= lowrightpt[0]; + somlowrightpt[1] = lowrightpt[1]; + + k = 0; + n = 2; + + for (j = 0; j <= projparm[11] - 1; j++) + { + + /* Convert from lon/lat to row/col */ + /* ------------------------------- */ + status = GDll2ij(projcode, zonecode, projparm, spherecode, + xdimsize, ydimsize, somupleftpt, somlowrightpt, + npnts, longitude, latitude, row, col, NULL, NULL); + + + /* Find min/max values for row & col */ + /* --------------------------------- */ + minCol = col[0]; + minRow = row[0]; + maxCol = col[0]; + maxRow = row[0]; + for (i = 1; i < npnts; i++) + { + if (col[i] < minCol) + { + minCol = col[i]; + } + + if (col[i] > maxCol) + { + maxCol = col[i]; + } + + if (row[i] < minRow) + { + minRow = row[i]; + } + + if (row[i] > maxRow) + { + maxRow = row[i]; + } + } + + + + /* "Clamp" if outside Grid */ + /* ----------------------- */ + minCol = (minCol < 0) ? 0 : minCol; + minRow = (minRow < 0) ? 0 : minRow; + + maxCol = (maxCol >= xdimsize) ? xdimsize - 1 : maxCol; + maxRow = (maxRow >= ydimsize) ? ydimsize - 1 : maxRow; + + + /* Check whether subset region is outside grid region */ + /* -------------------------------------------------- */ + if (minCol >= xdimsize || minRow >= ydimsize || + maxCol < 0 || maxRow < 0) + { + if ( blockindexstart == -1 && (projparm[11]) == j) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefboxregion", __FILE__, __LINE__); + HEreport("Subset Region outside of Grid Region\n"); + regionID = -1; + } + } + else + { + if (k == 0) + { + blockindexstart = j; + blockindexstop = j; + k = 1; + } + else + { + blockindexstop = j; + } + } + templeftpt[0] = upleftpt[0] + ((offset[j]/xdimsize)*abs(upleftpt[0] - lowrightpt[0])) + abs((upleftpt[0] - lowrightpt[0]))*(n-1); + templeftpt[1] = upleftpt[1] + ((lowrightpt[1] - upleftpt[1]))*(n-1); + + temprightpt[0] = lowrightpt[0] + ((offset[j]/xdimsize)*abs(lowrightpt[0] - upleftpt[0])) + abs((lowrightpt[0] - upleftpt[0]))*(n-1); + temprightpt[1] = lowrightpt[1] + ((upleftpt[1] - lowrightpt[1]))*(n-1); + + somupleftpt[0] = templeftpt[0]; + somupleftpt[1] = templeftpt[1]; + + somlowrightpt[0] = temprightpt[0]; + somlowrightpt[1] = temprightpt[1]; + n++; + } + } + else + { + + /* Convert from lon/lat to row/col */ + /* ------------------------------- */ + + status = GDll2ij(projcode, zonecode, projparm, spherecode, + xdimsize, ydimsize, upleftpt, lowrightpt, + npnts, longitude, latitude, row, col, NULL, NULL); + + /* Find min/max values for row & col */ + /* --------------------------------- */ + minCol = col[0]; + minRow = row[0]; + maxCol = col[0]; + maxRow = row[0]; + for (i = 1; i < npnts; i++) + { + if (col[i] < minCol) + { + minCol = col[i]; + } + + if (col[i] > maxCol) + { + maxCol = col[i]; + } + + if (row[i] < minRow) + { + minRow = row[i]; + } + + if (row[i] > maxRow) + { + maxRow = row[i]; + } + } + + + + /* "Clamp" if outside Grid */ + /* ----------------------- */ + minCol = (minCol < 0) ? 0 : minCol; + minRow = (minRow < 0) ? 0 : minRow; + + maxCol = (maxCol >= xdimsize) ? xdimsize - 1 : maxCol; + maxRow = (maxRow >= ydimsize) ? ydimsize - 1 : maxRow; + + + /* Check whether subset region is outside grid region */ + /* -------------------------------------------------- */ + if (minCol >= xdimsize || minRow >= ydimsize || maxCol < 0 || maxRow < 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefboxregion", __FILE__, __LINE__); + HEreport("Subset Region outside of Grid Region\n"); + regionID = -1; + + } + } + if (status == 0) + { + /* Store grid region info */ + /* ---------------------- */ + for (i = 0; i < NGRIDREGN; i++) + { + /* Find first empty grid region */ + /* ---------------------------- */ + if (GDXRegion[i] == 0) + { + /* Allocate space for grid region entry */ + /* ------------------------------------ */ + GDXRegion[i] = (struct gridRegion *) + calloc(1, sizeof(struct gridRegion)); + if(GDXRegion[i] == NULL) + { + HEpush(DFE_NOSPACE,"GDdefboxregion", __FILE__, __LINE__); + free(utlbuf); + free(gridname); + return(-1); + } + + + /* Store file and grid ID */ + /* ---------------------- */ + GDXRegion[i]->fid = fid; + GDXRegion[i]->gridID = gridID; + + + /* Initialize vertical subset entries to -1 */ + /* ---------------------------------------- */ + for (j = 0; j < 8; j++) + { + GDXRegion[i]->StartVertical[j] = -1; + GDXRegion[i]->StopVertical[j] = -1; + } + + + /* Store start & count along x & y */ + /* ------------------------------- */ + GDXRegion[i]->xStart = minCol; + GDXRegion[i]->xCount = maxCol - minCol + 1; + GDXRegion[i]->yStart = minRow; + GDXRegion[i]->yCount = maxRow - minRow + 1; + + + /* Store upleft and lowright points of subset region */ + /* ------------------------------------------------- */ + if (projcode == GCTP_GEO ) + { + /* GEO projection */ + /* ------------------------ */ + + /* Convert upleft & lowright lon from DMS to radians */ + /* ------------------------------------------------- */ + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad2 = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + + /* Compute X scale */ + /* --------------- */ + xscale = (lonrad2 - lonrad0) / xdimsize; + + /* Convert upleft & lowright lat from DMS to radians */ + /* ------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_RAD); + latrad2 = EHconvAng(lowrightpt[1], HDFE_DMS_RAD); + + /* Compute Y scale */ + /* --------------- */ + yscale = (latrad2 - latrad0) / ydimsize; + + + /* MinCol -> radians -> DMS -> upleftpt[0] */ + /* --------------------------------------- */ + GDXRegion[i]->upleftpt[0] = + EHconvAng(lonrad0 + xscale * minCol, + HDFE_RAD_DMS); + + + /* MinRow -> radians -> DMS -> upleftpt[1] */ + /* --------------------------------------- */ + GDXRegion[i]->upleftpt[1] = + EHconvAng(latrad0 + yscale * minRow, + HDFE_RAD_DMS); + + + /* MinCol + 1 -> radians -> DMS -> lowrightpt[0] */ + /* --------------------------------------------- */ + GDXRegion[i]->lowrightpt[0] = + EHconvAng(lonrad0 + xscale * (maxCol + 1), + HDFE_RAD_DMS); + + + /* MinRow + 1 -> radians -> DMS -> lowrightpt[1] */ + /* --------------------------------------------- */ + GDXRegion[i]->lowrightpt[1] = + EHconvAng(latrad0 + yscale * (maxRow + 1), + HDFE_RAD_DMS); + } + else if (projcode == GCTP_BCEA) + { + /* BCEA projection */ + /* -------------- */ + nlatlon = 2; + lon[0] = upleftpt[0]; + lon[1] = lowrightpt[0]; + lat[0] = upleftpt[1]; + lat[1] = lowrightpt[1]; + status = + GDll2mm_cea(projcode,zonecode,spherecode,projparm, + xdimsize, ydimsize, + upleftpt, lowrightpt,nlatlon, + lon, lat, + xcor, ycor, &xscale, &yscale); + upleftpt_m[0] = xcor[0]; + upleftpt_m[1] = ycor[0]; + + + if (status == -1) + { + HEpush(DFE_GENAPP, "GDdefboxregion", __FILE__, __LINE__); + free(utlbuf); + free(gridname); + return (status); + } + + /* MinCol -> meters -> upleftpt[0] */ + /* ------------------------------- */ + xmtr[0] = upleftpt_m[0] + xscale * minCol; + + /* MinRow -> meters -> upleftpt[1] */ + /* ------------------------------- */ + ymtr[0] = upleftpt_m[1] + yscale * minRow; + + /* MinCol + 1 -> meters -> lowrightpt[0] */ + /* ------------------------------------- */ + xmtr[1] = upleftpt_m[0] + xscale * (maxCol + 1); + + /* MinRow + 1 -> meters -> lowrightpt[1] */ + /* ------------------------------------- */ + ymtr[1] = upleftpt_m[1] + yscale * (maxRow + 1); + + /* Convert upleft & lowright lon from DMS to radians */ + /* ------------------------------------------------- */ + npnts = 2; + status = GDmm2ll_cea(projcode, zonecode, spherecode, + projparm, xdimsize, ydimsize, + upleftpt, lowrightpt, npnts, + xmtr, ymtr, + longitude, latitude); + if (status == -1) + { + HEpush(DFE_GENAPP, "GDdefboxregion", __FILE__, __LINE__); + free(utlbuf); + free(gridname); + return (status); + } + GDXRegion[i]->upleftpt[0] = longitude[0]; + + GDXRegion[i]->upleftpt[1] = latitude[0]; + + GDXRegion[i]->lowrightpt[0] = longitude[1]; + + GDXRegion[i]->lowrightpt[1] = latitude[1]; + } + else if (projcode == GCTP_SOM) + { + /* Store start & count along x & y */ + /* ------------------------------- */ + GDXRegion[i]->xStart = 0; + GDXRegion[i]->xCount = xdimsize; + GDXRegion[i]->yStart = 0; + GDXRegion[i]->yCount = ydimsize; + + GDXRegion[i]->somStart = blockindexstart; + GDXRegion[i]->somCount = blockindexstop - blockindexstart + 1; + + /* Store upleft and lowright points of subset region */ + /* ------------------------------------------------- */ + if (blockindexstart == 0) + { + GDXRegion[i]->upleftpt[0] = upleftpt[0]; + GDXRegion[i]->upleftpt[1] = upleftpt[1]; + GDXRegion[i]->lowrightpt[0] = lowrightpt[0]; + GDXRegion[i]->lowrightpt[1] = lowrightpt[1]; + } + else + { + GDXRegion[i]->upleftpt[0] = + (lowrightpt[0] - upleftpt[0])* + (offset[blockindexstart-1]/xdimsize) + upleftpt[0]; + GDXRegion[i]->upleftpt[1] = + (lowrightpt[1] - upleftpt[1])* + (blockindexstart+1-1) + upleftpt[1]; + + GDXRegion[i]->lowrightpt[0] = + (lowrightpt[0] - upleftpt[0])* + (offset[blockindexstart-1]/xdimsize) + lowrightpt[0]; + GDXRegion[i]->lowrightpt[1] = + (lowrightpt[1] - upleftpt[1])* + (blockindexstart+1-1) + lowrightpt[1]; + + } + } + else + { + /* Non-GEO, Non-BCEA projections */ + /* ---------------------------- */ + + /* Compute X & Y scale */ + /* ------------------- */ + xscale = (lowrightpt[0] - upleftpt[0]) / xdimsize; + yscale = (lowrightpt[1] - upleftpt[1]) / ydimsize; + + + /* MinCol -> meters -> upleftpt[0] */ + /* ------------------------------- */ + GDXRegion[i]->upleftpt[0] = upleftpt[0] + + xscale * minCol; + + + /* MinRow -> meters -> upleftpt[1] */ + /* ------------------------------- */ + GDXRegion[i]->upleftpt[1] = upleftpt[1] + + yscale * minRow; + + + /* MinCol + 1 -> meters -> lowrightpt[0] */ + /* ------------------------------------- */ + GDXRegion[i]->lowrightpt[0] = upleftpt[0] + + xscale * (maxCol + 1); + + + /* MinRow + 1 -> meters -> lowrightpt[1] */ + /* ------------------------------------- */ + GDXRegion[i]->lowrightpt[1] = upleftpt[1] + + yscale * (maxRow + 1); + } + + /* Store region ID */ + /* --------------- */ + regionID = i; + break; + } + + } + } + + } + free(utlbuf); + free(gridname); + return (regionID); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDregioninfo | +| | +| DESCRIPTION: Retrieves size of region in bytes. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| size int32 size in bytes of field region | +| upleftpt float64 Upper left corner coord for region | +| lowrightpt float64 Lower right corner coord for region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Add vertical subsetting | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Apr 99 David Wynne Added support for MISR SOM projection, NCR 21195 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDregioninfo(int32 gridID, int32 regionID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size, + float64 upleftpt[], float64 lowrightpt[]) +{ + intn j; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 index; /* Dimension index */ + + char dimlist[256]; /* Dimension list */ + char *errMesg = "Vertical Dimension Not Found: \"%s\".\n"; + char *errM1 = "Both \"XDim\" and \"YDim\" must be present "; + char *errM2 = "in the dimension list for \"%s\".\n"; + char errbuf[256];/* Error buffer */ + + + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDregioninfo", &fid, &sdInterfaceID, + &gdVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NGRIDREGN) + { + status = -1; + HEpush(DFE_RANGE, "GDregioninfo", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + + + /* Check that region defined for this file */ + /* --------------------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID]->fid != fid) + { + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + HEreport("Region is not defined for this file.\n"); + } + } + + + /* Check that region defined for this grid */ + /* --------------------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID]->gridID != gridID) + { + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + HEreport("Region is not defined for this Grid.\n"); + } + } + + + + /* Check for valid fieldname */ + /* ------------------------- */ + if (status == 0) + { + status = GDfieldinfo(gridID, fieldname, rank, dims, ntype, dimlist); + + if (status != 0) + { + /* Fieldname not found in grid */ + /* --------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", + fieldname); + } + else if (*rank == 1) + { + /* Field is 1 dimensional */ + /* ---------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + HEreport( + "One-Dimesional fields \"%s\" may not be subsetted.\n", + fieldname); + } + else + { + /* "XDim" and/or "YDim" not found */ + /* ------------------------------ */ + if (EHstrwithin("XDim", dimlist, ',') == -1 || + EHstrwithin("YDim", dimlist, ',') == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDregioninfo", __FILE__, __LINE__); + sprintf(errbuf, "%s%s", errM1, errM2); + HEreport(errbuf, fieldname); + } + } + } + + + + /* If no problems ... */ + /* ------------------ */ + if (status == 0) + { + /* Check if SOM projection */ + /* ----------------------- */ + if (EHstrwithin("SOMBlockDim", dimlist, ',') == 0) + { + dims[EHstrwithin("SOMBlockDim", dimlist, ',')] = + GDXRegion[regionID]->somCount; + } + + /* Load XDim dimension from region entry */ + /* ------------------------------------- */ + if (GDXRegion[regionID]->xCount != 0) + { + dims[EHstrwithin("XDim", dimlist, ',')] = + GDXRegion[regionID]->xCount; + } + + /* Load YDim dimension from region entry */ + /* ------------------------------------- */ + if (GDXRegion[regionID]->yCount != 0) + { + dims[EHstrwithin("YDim", dimlist, ',')] = + GDXRegion[regionID]->yCount; + } + + + /* Vertical Subset */ + /* --------------- */ + for (j = 0; j < 8; j++) + { + + /* If active vertical subset ... */ + /* ----------------------------- */ + if (GDXRegion[regionID]->StartVertical[j] != -1) + { + /* Find vertical dimension within dimlist */ + /* -------------------------------------- */ + index = EHstrwithin(GDXRegion[regionID]->DimNamePtr[j], + dimlist, ','); + + /* If dimension found ... */ + /* ---------------------- */ + if (index != -1) + { + /* Compute dimension size */ + /* ---------------------- */ + dims[index] = + GDXRegion[regionID]->StopVertical[j] - + GDXRegion[regionID]->StartVertical[j] + 1; + } + else + { + /* Vertical dimension not found */ + /* ---------------------------- */ + status = -1; + *size = -1; + HEpush(DFE_GENAPP, "GDregioninfo", + __FILE__, __LINE__); + HEreport(errMesg, + GDXRegion[regionID]->DimNamePtr[j]); + } + } + } + + + if (status == 0) + { + /* Compute number of total elements */ + /* -------------------------------- */ + *size = dims[0]; + for (j = 1; j < *rank; j++) + { + *size *= dims[j]; + } + + /* Multiply by size in bytes of numbertype */ + /* --------------------------------------- */ + *size *= DFKNTsize(*ntype); + + + /* Return upper left and lower right subset values */ + /* ----------------------------------------------- */ + upleftpt[0] = GDXRegion[regionID]->upleftpt[0]; + upleftpt[1] = GDXRegion[regionID]->upleftpt[1]; + lowrightpt[0] = GDXRegion[regionID]->lowrightpt[0]; + lowrightpt[1] = GDXRegion[regionID]->lowrightpt[1]; + } + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDreginfo | +| | +| DESCRIPTION: FORTRAN wrapper around GDregioninfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| (FORTRAN order) | +| size int32 size in bytes of field region | +| upleftpt float64 Upper left corner coord for region | +| lowrightpt float64 Lower right corner coord for region | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDreginfo(int32 gridID, int32 regionID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size, + float64 upleftpt[], float64 lowrightpt[]) +{ + + intn j; /* Loop index */ + intn status; /* routine return status variable */ + + int32 swap; /* Temporary swap variable */ + + + /* Call GDregioninfo */ + /* ----------------- */ + status = GDregioninfo(gridID, regionID, fieldname, + ntype, rank, dims, size, upleftpt, lowrightpt); + + + /* Change dimensions to FORTRAN order */ + /* ---------------------------------- */ + for (j = 0; j < *rank / 2; j++) + { + swap = dims[*rank - 1 - j]; + dims[*rank - 1 - j] = dims[j]; + dims[j] = swap; + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDextractregion | +| | +| DESCRIPTION: Retrieves data from specified region. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| | +| OUTPUTS: | +| buffer void Data buffer containing subsetted region | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Add vertical subsetting | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Apr 99 David Wynne Add support for MISR SOM projection, NCR 21195 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDextractregion(int32 gridID, int32 regionID, char *fieldname, + VOIDP buffer) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 index; /* Dimension index */ + int32 start[8]; /* Start array for data read */ + int32 edge[8]; /* Edge array for data read */ + int32 dims[8]; /* Dimensions */ + int32 rank; /* Field rank */ + int32 ntype; /* Field number type */ + int32 origincode; /* Pixel origin code */ + + char dimlist[256]; /* Dimension list */ + char *errMesg = "Vertical Dimension Not Found: \"%s\".\n"; + char *errM1 = "Both \"XDim\" and \"YDim\" must be present "; + char *errM2 = "in the dimension list for \"%s\".\n"; + char errbuf[256];/* Error buffer */ + + + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDextractregion", &fid, &sdInterfaceID, + &gdVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NGRIDREGN) + { + status = -1; + HEpush(DFE_RANGE, "GDextractregion", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + + + /* Check that region defined for this file */ + /* --------------------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID]->fid != fid) + { + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport("Region is not defined for this file.\n"); + } + } + + + /* Check that region defined for this grid */ + /* --------------------------------------- */ + if (status == 0) + { + if (GDXRegion[regionID]->gridID != gridID) + { + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport("Region is not defined for this Grid.\n"); + } + } + + + + /* Check for valid fieldname */ + /* ------------------------- */ + if (status == 0) + { + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, dimlist); + + if (status != 0) + { + /* Fieldname not found in grid */ + /* --------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", + fieldname); + } + else if (rank == 1) + { + /* Field is 1 dimensional */ + /* ---------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport( + "One-Dimesional fields \"%s\" may not be subsetted.\n", + fieldname); + } + else + { + /* "XDim" and/or "YDim" not found */ + /* ------------------------------ */ + if (EHstrwithin("XDim", dimlist, ',') == -1 || + EHstrwithin("YDim", dimlist, ',') == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + sprintf(errbuf, "%s%s", errM1, errM2); + HEreport(errbuf, fieldname); + } + } + } + + + + if (status == 0) + { + + /* Get origin order info */ + /* --------------------- */ + status = GDorigininfo(gridID, &origincode); + + + /* Initialize start & edge arrays */ + /* ------------------------------ */ + for (i = 0; i < rank; i++) + { + start[i] = 0; + edge[i] = dims[i]; + } + + + /* if MISR SOM projection, set start */ + /* & edge arrays for SOMBlockDim */ + /* --------------------------------- */ + if (EHstrwithin("SOMBlockDim", dimlist, ',') == 0) + { + index = EHstrwithin("SOMBlockDim", dimlist, ','); + edge[index] = GDXRegion[regionID]->somCount; + start[index] = GDXRegion[regionID]->somStart; + } + + + /* Set start & edge arrays for XDim */ + /* -------------------------------- */ + index = EHstrwithin("XDim", dimlist, ','); + if (GDXRegion[regionID]->xCount != 0) + { + edge[index] = GDXRegion[regionID]->xCount; + start[index] = GDXRegion[regionID]->xStart; + } + + /* Adjust X-dim start if origin on right edge */ + /* ------------------------------------------ */ + if ((origincode & 1) == 1) + { + start[index] = dims[index] - (start[index] + edge[index]); + } + + + /* Set start & edge arrays for YDim */ + /* -------------------------------- */ + index = EHstrwithin("YDim", dimlist, ','); + if (GDXRegion[regionID]->yCount != 0) + { + start[index] = GDXRegion[regionID]->yStart; + edge[index] = GDXRegion[regionID]->yCount; + } + + /* Adjust Y-dim start if origin on lower edge */ + /* ------------------------------------------ */ + if ((origincode & 2) == 2) + { + start[index] = dims[index] - (start[index] + edge[index]); + } + + + + /* Vertical Subset */ + /* --------------- */ + for (j = 0; j < 8; j++) + { + /* If active vertical subset ... */ + /* ----------------------------- */ + if (GDXRegion[regionID]->StartVertical[j] != -1) + { + + /* Find vertical dimension within dimlist */ + /* -------------------------------------- */ + index = EHstrwithin(GDXRegion[regionID]->DimNamePtr[j], + dimlist, ','); + + /* If dimension found ... */ + /* ---------------------- */ + if (index != -1) + { + /* Compute start and edge for vertical dimension */ + /* --------------------------------------------- */ + start[index] = GDXRegion[regionID]->StartVertical[j]; + edge[index] = GDXRegion[regionID]->StopVertical[j] - + GDXRegion[regionID]->StartVertical[j] + 1; + } + else + { + /* Vertical dimension not found */ + /* ---------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDextractregion", __FILE__, __LINE__); + HEreport(errMesg, + GDXRegion[regionID]->DimNamePtr[j]); + } + } + } + + + /* Read into data buffer */ + /* --------------------- */ + if (status == 0) + { + status = GDreadfield(gridID, fieldname, start, NULL, edge, buffer); + } + } + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdupregion | +| | +| DESCRIPTION: Duplicates a region | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| newregionID int32 New region ID | +| | +| INPUTS: | +| oldregionID int32 Old region ID | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jan 97 Joel Gales Original Programmer | +| Oct 98 Abe Taaheri changed *GDXRegion[i] = *GDXRegion[oldregionID]; | +| to copy elements of structure one by one to avoid | +| copying pointer for DimNamePtr to another place that| +| causes "Freeing Unallocated Memory" in purify when | +| using GDdetach | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDdupregion(int32 oldregionID) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + int32 slendupregion; + int32 newregionID = -1; /* New region ID */ + + + /* Find first empty (inactive) region */ + /* ---------------------------------- */ + for (i = 0; i < NGRIDREGN; i++) + { + if (GDXRegion[i] == 0) + { + /* Allocate space for new grid region entry */ + /* ---------------------------------------- */ + GDXRegion[i] = (struct gridRegion *) + calloc(1, sizeof(struct gridRegion)); + if(GDXRegion[i] == NULL) + { + HEpush(DFE_NOSPACE,"GDdupregion", __FILE__, __LINE__); + return(-1); + } + + + /* Copy old region structure data to new region */ + /* -------------------------------------------- */ + + GDXRegion[i]->fid = GDXRegion[oldregionID]->fid; + GDXRegion[i]->gridID = GDXRegion[oldregionID]->gridID; + GDXRegion[i]->xStart = GDXRegion[oldregionID]->xStart; + GDXRegion[i]->xCount = GDXRegion[oldregionID]->xCount; + GDXRegion[i]->yStart = GDXRegion[oldregionID]->yStart; + GDXRegion[i]->yCount = GDXRegion[oldregionID]->yCount; + GDXRegion[i]->upleftpt[0] = GDXRegion[oldregionID]->upleftpt[0]; + GDXRegion[i]->upleftpt[1] = GDXRegion[oldregionID]->upleftpt[1]; + GDXRegion[i]->lowrightpt[0] = GDXRegion[oldregionID]->lowrightpt[0]; + GDXRegion[i]->lowrightpt[1] = GDXRegion[oldregionID]->lowrightpt[1]; + for (j = 0; j < 8; j++) + { + GDXRegion[i]->StartVertical[j] = GDXRegion[oldregionID]->StartVertical[j]; + GDXRegion[i]->StopVertical[j] = GDXRegion[oldregionID]->StopVertical[j]; + } + + for (j=0; j<8; j++) + { + if(GDXRegion[oldregionID]->DimNamePtr[j] != NULL) + { + slendupregion = strlen(GDXRegion[oldregionID]->DimNamePtr[j]); + GDXRegion[i]->DimNamePtr[j] = (char *) malloc(slendupregion + 1); + strcpy(GDXRegion[i]->DimNamePtr[j],GDXRegion[oldregionID]->DimNamePtr[j]); + } + } + + + /* Define new region ID */ + /* -------------------- */ + newregionID = i; + + break; + } + } + return (newregionID); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefvrtregion | +| | +| DESCRIPTION: Finds elements of a monotonic field within a vertical subset | +| region. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| regionID int32 Region ID | +| vertObj char Vertical object to subset | +| range float64 Vertical subsetting range | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Feb 97 Joel Gales Store XDim, YDim, upleftpt, lowrightpt in GDXRegion | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +#define SETGRIDREG \ +\ +status = GDgridinfo(gridID, &xdimsize, &ydimsize, upleftpt, lowrightpt); \ +for (k = 0; k < NGRIDREGN; k++) \ +{ \ + if (GDXRegion[k] == 0) \ + { \ + GDXRegion[k] = (struct gridRegion *) \ + calloc(1, sizeof(struct gridRegion)); \ + GDXRegion[k]->fid = fid; \ + GDXRegion[k]->gridID = gridID; \ + GDXRegion[k]->xStart = 0; \ + GDXRegion[k]->xCount = xdimsize; \ + GDXRegion[k]->yStart = 0; \ + GDXRegion[k]->yCount = ydimsize; \ + GDXRegion[k]->upleftpt[0] = upleftpt[0]; \ + GDXRegion[k]->upleftpt[1] = upleftpt[1]; \ + GDXRegion[k]->lowrightpt[0] = lowrightpt[0]; \ + GDXRegion[k]->lowrightpt[1] = lowrightpt[1]; \ + regionID = k; \ + for (j=0; j<8; j++) \ + { \ + GDXRegion[k]->StartVertical[j] = -1; \ + GDXRegion[k]->StopVertical[j] = -1; \ + } \ + break; \ + } \ +} + +#define FILLVERTREG \ +for (j=0; j<8; j++) \ +{ \ + if (GDXRegion[regionID]->StartVertical[j] == -1) \ + { \ + GDXRegion[regionID]->StartVertical[j] = i; \ + GDXRegion[regionID]->DimNamePtr[j] = \ + (char *) malloc(slen + 1); \ + memcpy(GDXRegion[regionID]->DimNamePtr[j], \ + dimlist, slen + 1); \ + break; \ + } \ +} \ + + + +int32 +GDdefvrtregion(int32 gridID, int32 regionID, char *vertObj, float64 range[]) +{ + intn i, j, k, status; + uint8 found = 0; + + int16 vertINT16; + + int32 fid, sdInterfaceID, slen; + int32 gdVgrpID, rank, nt, dims[8], size; + int32 vertINT32; + int32 xdimsize; + int32 ydimsize; + + float32 vertFLT32; + float64 vertFLT64; + float64 upleftpt[2]; + float64 lowrightpt[2]; + + char *vertArr; + char *dimlist; + + /* Allocate space for dimlist */ + /* --------------------------------- */ + dimlist = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"GDdefvrtregion", __FILE__, __LINE__); + return(-1); + } + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDdefvrtregion", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + memcpy(dimlist, vertObj, 4); + dimlist[4] = 0; + + if (strcmp(dimlist, "DIM:") == 0) + { + slen = strlen(vertObj) - 4; + if (regionID == -1) + { + SETGRIDREG; + } + for (j = 0; j < 8; j++) + { + if (GDXRegion[regionID]->StartVertical[j] == -1) + { + GDXRegion[regionID]->StartVertical[j] = (int32) range[0]; + GDXRegion[regionID]->StopVertical[j] = (int32) range[1]; + GDXRegion[regionID]->DimNamePtr[j] = + (char *) malloc(slen + 1); + if(GDXRegion[regionID]->DimNamePtr[j] == NULL) + { + HEpush(DFE_NOSPACE,"GDdefvrtregion", __FILE__, __LINE__); + free(dimlist); + return(-1); + } + memcpy(GDXRegion[regionID]->DimNamePtr[j], + vertObj + 4, slen + 1); + break; + } + } + } + else + { + status = GDfieldinfo(gridID, vertObj, &rank, dims, &nt, dimlist); + if (status != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefvrtregion", __FILE__, __LINE__); + HEreport("Vertical Field: \"%s\" not found.\n", vertObj); + } + else + { + if (rank != 1) + { + status = -1; + HEpush(DFE_GENAPP, "GDdefvrtregion", __FILE__, __LINE__); + HEreport("Vertical Field: \"%s\" must be 1-dim.\n", + vertObj); + } + else + { + slen = strlen(dimlist); + size = DFKNTsize(nt); + vertArr = (char *) calloc(dims[0], size); + if(vertArr == NULL) + { + HEpush(DFE_NOSPACE,"GDdefvrtregion", __FILE__, __LINE__); + free(dimlist); + return(-1); + } + + status = GDreadfield(gridID, vertObj, + NULL, NULL, NULL, vertArr); + + switch (nt) + { + case DFNT_INT16: + + for (i = 0; i < dims[0]; i++) + { + memcpy(&vertINT16, vertArr + i * size, size); + + if (vertINT16 >= range[0] && + vertINT16 <= range[1]) + { + found = 1; + if (regionID == -1) + { + SETGRIDREG; + } + FILLVERTREG; + + break; + } + } + + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + memcpy(&vertINT16, vertArr + i * size, size); + + if (vertINT16 >= range[0] && + vertINT16 <= range[1]) + { + GDXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + status = -1; + } + break; + + + case DFNT_INT32: + + for (i = 0; i < dims[0]; i++) + { + memcpy(&vertINT32, vertArr + i * size, size); + + if (vertINT32 >= range[0] && + vertINT32 <= range[1]) + { + found = 1; + if (regionID == -1) + { + SETGRIDREG; + } + FILLVERTREG; + + break; + } + } + + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + memcpy(&vertINT32, vertArr + i * size, size); + + if (vertINT32 >= range[0] && + vertINT32 <= range[1]) + { + GDXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + status = -1; + } + break; + + + case DFNT_FLOAT32: + + for (i = 0; i < dims[0]; i++) + { + memcpy(&vertFLT32, vertArr + i * size, size); + + if (vertFLT32 >= range[0] && + vertFLT32 <= range[1]) + { + found = 1; + if (regionID == -1) + { + SETGRIDREG; + } + FILLVERTREG; + + break; + } + } + + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + memcpy(&vertFLT32, vertArr + i * size, size); + + if (vertFLT32 >= range[0] && + vertFLT32 <= range[1]) + { + GDXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + status = -1; + } + break; + + + case DFNT_FLOAT64: + + for (i = 0; i < dims[0]; i++) + { + memcpy(&vertFLT64, vertArr + i * size, size); + + if (vertFLT64 >= range[0] && + vertFLT64 <= range[1]) + { + found = 1; + if (regionID == -1) + { + SETGRIDREG; + } + FILLVERTREG; + + break; + } + } + + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + memcpy(&vertFLT64, vertArr + i * size, size); + + if (vertFLT64 >= range[0] && + vertFLT64 <= range[1]) + { + GDXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + status = -1; + } + break; + + } + free(vertArr); + } + } + } + } + if (status == -1) + { + regionID = -1; + } + free(dimlist); + return (regionID); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdefvrtreg | +| | +| DESCRIPTION: FORTRAN wrapper arount GDdefvrtregion | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| regionID int32 Region ID | +| vertObj char Vertical object to subset | +| range float64 Vertical subsetting range | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDdefvrtreg(int32 gridID, int32 regionID, char *vertObj, float64 fortrange[]) +{ + float64 range[2]; + char utlbuf[16]; + + memcpy(utlbuf, vertObj, 4); + utlbuf[4] = 0; + + /* If subsetting on dimension elements convert FORTRAN indices to C */ + /* ---------------------------------------------------------------- */ + if (strcmp(utlbuf, "DIM:") == 0) + { + range[0] = fortrange[0] - 1; + range[1] = fortrange[1] - 1; + } + else + { + range[0] = fortrange[0]; + range[1] = fortrange[1]; + } + + + /* Call GDdefvrtregion routine */ + /* --------------------------- */ + regionID = GDdefvrtregion(gridID, regionID, vertObj, range); + + return (regionID); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDdeftimeperiod | +| | +| DESCRIPTION: Finds elements of the "Time" field within a given time | +| period. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| periodID int32 Period ID | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| periodID int32 Period ID | +| starttime float64 TAI sec Start of time period | +| stoptime float64 TAI sec Stop of time period | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDdeftimeperiod(int32 gridID, int32 periodID, float64 starttime, + float64 stoptime) +{ + float64 timerange[2]; + + timerange[0] = starttime; + timerange[1] = stoptime; + + periodID = GDdefvrtregion(gridID, periodID, "Time", timerange); + + return (periodID); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetpixels | +| | +| DESCRIPTION: Finds row and columns for specified lon/lat values | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| nLonLat int32 Number of lonlat values | +| lonVal float64 dec deg Longitude values | +| latVal float64 dec deg Latitude values | +| | +| | +| OUTPUTS: | +| pixRow int32 Pixel rows | +| pixCol int32 Pixel columns | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Set row/col to -1 if outside boundary | +| Mar 97 Joel Gales Adjust row/col for CORNER pixel registration | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDgetpixels(int32 gridID, int32 nLonLat, float64 lonVal[], float64 latVal[], + int32 pixRow[], int32 pixCol[]) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + + int32 xdimsize; /* Size of "XDim" */ + int32 ydimsize; /* Size of "YDim" */ + int32 projcode; /* GCTP projection code */ + int32 zonecode; /* Zone code */ + int32 spherecode; /* Sphere code */ + int32 origincode; /* Origin code */ + int32 pixregcode; /* Pixel registration code */ + + float64 upleftpt[2];/* Upper left point */ + float64 lowrightpt[2]; /* Lower right point */ + float64 projparm[16]; /* Projection parameters */ + float64 *xVal; /* Pointer to point x location values */ + float64 *yVal; /* Pointer to point y location values */ + + + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDgetpixels", &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get grid info */ + /* ------------- */ + status = GDgridinfo(gridID, &xdimsize, &ydimsize, + upleftpt, lowrightpt); + + + /* Get projection info */ + /* ------------------- */ + status = GDprojinfo(gridID, &projcode, &zonecode, + &spherecode, projparm); + + + /* Get explicit upleftpt & lowrightpt if defaults are used */ + /* ------------------------------------------------------- */ + status = GDgetdefaults(projcode, zonecode, projparm, spherecode, + upleftpt, lowrightpt); + + + /* Get pixel registration and origin info */ + /* -------------------------------------- */ + status = GDorigininfo(gridID, &origincode); + status = GDpixreginfo(gridID, &pixregcode); + + + /* Allocate space for x & y locations */ + /* ---------------------------------- */ + xVal = (float64 *) calloc(nLonLat, sizeof(float64)); + if(xVal == NULL) + { + HEpush(DFE_NOSPACE,"GDgetpixels", __FILE__, __LINE__); + return(-1); + } + yVal = (float64 *) calloc(nLonLat, sizeof(float64)); + if(yVal == NULL) + { + HEpush(DFE_NOSPACE,"GDgetpixels", __FILE__, __LINE__); + free(xVal); + return(-1); + } + + + /* Get pixRow, pixCol, xVal, & yVal */ + /* -------------------------------- */ + status = GDll2ij(projcode, zonecode, projparm, spherecode, + xdimsize, ydimsize, upleftpt, lowrightpt, + nLonLat, lonVal, latVal, pixRow, pixCol, + xVal, yVal); + + + + /* Loop through all lon/lat values */ + /* ------------------------------- */ + for (i = 0; i < nLonLat; i++) + { + /* Adjust columns & rows for "corner" registered grids */ + /* --------------------------------------------------- */ + if (pixregcode == HDFE_CORNER) + { + if (origincode == HDFE_GD_UL) + { + if (xVal[i] - pixCol[i] > 0.5) + { + ++pixCol[i]; + } + + if (yVal[i] - pixRow[i] > 0.5) + { + ++pixRow[i]; + } + } + else if (origincode == HDFE_GD_UR) + { + if (xVal[i] - pixCol[i] <= 0.5) + { + --pixCol[i]; + } + + if (yVal[i] - pixRow[i] > 0.5) + { + ++pixRow[i]; + } + } + else if (origincode == HDFE_GD_LL) + { + if (xVal[i] - pixCol[i] > 0.5) + { + ++pixCol[i]; + } + + if (yVal[i] - pixRow[i] <= 0.5) + { + --pixRow[i]; + } + } + else if (origincode == HDFE_GD_LR) + { + if (xVal[i] - pixCol[i] <= 0.5) + { + --pixCol[i]; + } + + if (yVal[i] - pixRow[i] <= 0.5) + { + --pixRow[i]; + } + } + } + + + /* If outside grid boundaries then set to -1 */ + /* ----------------------------------------- */ + if (pixCol[i] < 0 || pixCol[i] >= xdimsize || + pixRow[i] < 0 || pixRow[i] >= ydimsize) + { + pixCol[i] = -1; + pixRow[i] = -1; + } + } + free(xVal); + free(yVal); + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetpixvalues | +| | +| DESCRIPTION: Retrieves data from specified pixels. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| size*nPixels int32 Size of data buffer | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| nPixels int32 Number of pixels | +| pixRow int32 Pixel row numbers | +| pixCol int32 Pixel column numbers | +| fieldname char Fieldname | +| | +| OUTPUTS: | +| buffer void Data buffer | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Check for pixels outside boundaries (-1) | +| Mar 98 Abe Taaheri revised to reduce overhead for rechecking | +| for gridid, fieldname, etc in GDreadfield. | +| June 98 AT fixed bug with 2-dim field merged in 3-dim field | +| (for offset and count) | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDgetpixvalues(int32 gridID, int32 nPixels, int32 pixRow[], int32 pixCol[], + char *fieldname, VOIDP buffer) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + + int32 start[8]; /* GDreadfield start array */ + int32 edge[8]; /* GDreadfield edge array */ + int32 dims[8]; /* Field dimensions */ + int32 rank; /* Field rank */ + int32 xdum; /* Location of "XDim" within field list */ + int32 ydum; /* Location of "YDim" within field list */ + int32 ntype; /* Field number type */ + int32 origincode; /* Origin code */ + int32 bufOffset; /* Data buffer offset */ + int32 size; /* Size of returned data buffer for each + * value in bytes */ + int32 offset[8]; /* I/O offset (start) */ + int32 incr[8]; /* I/O increment (stride) */ + int32 count[8]; /* I/O count (edge) */ + int32 sdid; /* SDS ID */ + int32 rankSDS; /* Rank of SDS */ + int32 rankFld; /* Rank of field */ + int32 dum; /* Dummy variable */ + int32 mrgOffset; /* Merged field offset */ + + char *dimlist; /* Dimension list */ + + + + /* Allocate space for dimlist */ + /* --------------------------------- */ + dimlist = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"GDgetpixvalues", __FILE__, __LINE__); + return(-1); + } + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDgetpixvalues", + &fid, &sdInterfaceID, &gdVgrpID); + + + if (status == 0) + { + /* Get field list */ + /* -------------- */ + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, dimlist); + + + /* Check for "XDim" & "YDim" in dimension list */ + /* ------------------------------------------- */ + if (status == 0) + { + xdum = EHstrwithin("XDim", dimlist, ','); + ydum = EHstrwithin("YDim", dimlist, ','); + + if (xdum == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetpixvalues", __FILE__, __LINE__); + HEreport( + "\"XDim\" not present in dimlist for field: \"%s\".\n", + fieldname); + } + + + if (ydum == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDgetpixvalues", __FILE__, __LINE__); + HEreport( + "\"YDim\" not present in dimlist for field: \"%s\".\n", + fieldname); + } + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDgetpixvalues", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + + + if (status == 0) + { + + /* Get origin order info */ + /* --------------------- */ + status = GDorigininfo(gridID, &origincode); + + + /* Initialize start & edge arrays */ + /* ------------------------------ */ + for (i = 0; i < rank; i++) + { + start[i] = 0; + edge[i] = dims[i]; + } + + + /* Compute size of data buffer for each pixel */ + /* ------------------------------------------ */ + edge[xdum] = 1; + edge[ydum] = 1; + size = edge[0]; + for (j = 1; j < rank; j++) + { + size *= edge[j]; + } + size *= DFKNTsize(ntype); + + + + /* If data values are requested ... */ + /* -------------------------------- */ + if (buffer != NULL) + { + /* get sdid */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, &sdid, + &rankSDS, &rankFld, &mrgOffset, dims, &dum); + + /* Loop through all pixels */ + /* ----------------------- */ + for (i = 0; i < nPixels; i++) + { + /* Conmpute offset within returned data buffer */ + /* ------------------------------------------- */ + bufOffset = size * i; + + + /* If pixel row & column OK ... */ + /* ---------------------------- */ + if (pixCol[i] != -1 && pixRow[i] != -1) + { + start[xdum] = pixCol[i]; + start[ydum] = pixRow[i]; + + + /* Adjust X-dim start if origin on right edge */ + /* ------------------------------------------ */ + if ((origincode & 1) == 1) + { + start[xdum] = dims[xdum] - (start[xdum] + 1); + } + + + /* Adjust Y-dim start if origin on lower edge */ + /* ------------------------------------------ */ + if ((origincode & 2) == 2) + { + start[ydum] = dims[ydum] - (start[ydum] + 1); + } + + /* Set I/O offset and count Section */ + /* ---------------------- */ + + /* + * start and edge != NULL, set I/O offset and count to + * user values, adjusting the + * 0th field with the merged field offset (if any) + */ + if (rankFld == rankSDS) + { + for (j = 0; j < rankSDS; j++) + { + offset[j] = start[j]; + count[j] = edge[j]; + } + offset[0] += mrgOffset; + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field offset to merge offset and then next two to + * the user values + */ + for (j = 0; j < rankFld; j++) + { + offset[j + 1] = start[j]; + count[j + 1] = edge[j]; + } + offset[0] = mrgOffset; + count[0] = 1; + } + + + + /* Set I/O stride Section */ + /* ---------------------- */ + + /* In original code stride enetred as NULL. + Abe Taaheri June 12, 1998 */ + /* + * If stride == NULL (default) set I/O stride to 1 + */ + for (j = 0; j < rankSDS; j++) + { + incr[j] = 1; + } + + + /* Read into data buffer */ + /* --------------------- */ + status = SDreaddata(sdid, + offset, incr, count, + (VOIDP) ((uint8 *) buffer + bufOffset)); + } + } + } + } + } + + + /* If successful return size of returned data in bytes */ + /* --------------------------------------------------- */ + if (status == 0) + { + free(dimlist); + return (size * nPixels); + } + else + { + free(dimlist); + return ((int32) status); + } +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetpix | +| | +| DESCRIPTION: FORTRAN wrapper around GDgetpixels | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| nLonLat int32 Number of lonlat values | +| lonVal float64 dec deg Longitude values | +| latVal float64 dec deg Latitude values | +| | +| | +| OUTPUTS: | +| fortpixRow int32 Pixel rows (1 - based) | +| fortpixCol int32 Pixel columns (1 - based) | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDgetpix(int32 gridID, int32 nLonLat, float64 lonVal[], float64 latVal[], + int32 fortpixRow[], int32 fortpixCol[]) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + + /* Call GDgetpixels routine */ + /* ------------------------ */ + status = GDgetpixels(gridID, nLonLat, lonVal, latVal, + fortpixRow, fortpixCol); + + + /* Convert row & column to 1-based values */ + /* -------------------------------------- */ + for (i = 0; i < nLonLat; i++) + { + fortpixRow[i] = fortpixRow[i] + 1; + fortpixCol[i] = fortpixCol[i] + 1; + } + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDgetpixval | +| | +| DESCRIPTION: FORTRAN wrapper around GDgetpixvalues | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| nPixels int32 Number of pixels | +| fortpixRow int32 Pixel row numbers | +| fortpixCol int32 Pixel column numbers | +| fieldname char Fieldname | +| | +| OUTPUTS: | +| buffer void Data buffer | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDgetpixval(int32 gridID, int32 nPixels, int32 fortpixRow[], + int32 fortpixCol[], char *fieldname, VOIDP buffer) +{ + intn i; /* Loop index */ + + int32 *pixRow; /* Pointer to C row numbers */ + int32 *pixCol; /* Pointer to C column numbers */ + int32 bufsiz; /* Size for returned data buffer in bytes */ + + + /* Allocate space for C (0-based) row & column numbers */ + /* --------------------------------------------------- */ + pixRow = (int32 *) calloc(nPixels, 4); + if(pixRow == NULL) + { + HEpush(DFE_NOSPACE,"GDgetpixval", __FILE__, __LINE__); + return(-1); + } + pixCol = (int32 *) calloc(nPixels, 4); + if(pixCol == NULL) + { + HEpush(DFE_NOSPACE,"GDgetpixval", __FILE__, __LINE__); + free(pixRow); + return(-1); + } + + /* Convert row & column to 0-based values */ + /* -------------------------------------- */ + for (i = 0; i < nPixels; i++) + { + pixRow[i] = fortpixRow[i] - 1; + pixCol[i] = fortpixCol[i] - 1; + } + + + /* Call GDgetpixvalues routine */ + /* --------------------------- */ + bufsiz = GDgetpixvalues(gridID, nPixels, pixRow, pixCol, fieldname, buffer); + + free(pixRow); + free(pixCol); + + return (bufsiz); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDinterpolate | +| | +| DESCRIPTION: Performs bilinear interpolate on a set of xy values | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nRetn*nValues* int32 Size of data buffer | +| sizeof(float64) | +| | +| INPUTS: | +| gridID int32 Grid structure ID | +| nValues int32 Number of lon/lat points to interpolate | +| xyValues float64 XY values of points to interpolate | +| fieldname char Fieldname | +| | +| OUTPUTS: | +| interpVal float64 Interpolated Data Values | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Fix array index problem with interpVal write | +| Apr 97 Joel Gales Trap interpolation boundary out of bounds error | +| Jun 98 Abe Taaheri changed the return value so that the Return Value | +| is size in bytes for the data buffer which is | +| float64. +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +GDinterpolate(int32 gridID, int32 nValues, float64 lonVal[], float64 latVal[], + char *fieldname, float64 interpVal[]) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int32 xdimsize; /* XDim size */ + int32 ydimsize; /* YDim size */ + int32 projcode; /* Projection code */ + int32 zonecode; /* Zone code */ + int32 spherecode; /* Sphere code */ + int32 pixregcode; /* Pixel registration code */ + int32 origincode; /* Origin code */ + int32 dims[8]; /* Field dimensions */ + int32 numsize; /* Size in bytes of number type */ + int32 rank; /* Field rank */ + int32 xdum; /* Location of "XDim" within field list */ + int32 ydum; /* Location of "YDim" within field list */ + int32 ntype; /* Number type */ + int32 dum; /* Dummy variable */ + int32 size; /* Size of returned data buffer for each + * value in bytes */ + int32 pixCol[4]; /* Pixel columns for 4 nearest neighbors */ + int32 pixRow[4]; /* Pixel rows for 4 nearest neighbors */ + int32 tDen; /* Interpolation denominator value 1 */ + int32 uDen; /* Interpolation denominator value 2 */ + int32 nRetn; /* Number of data values returned */ + + float64 upleftpt[2];/* Upper left pt coordinates */ + float64 lowrightpt[2]; /* Lower right pt coordinates */ + float64 projparm[16]; /* Projection parameters */ + float64 xVal; /* "Exact" x location of interpolated point */ + float64 yVal; /* "Exact" y location of interpolated point */ + float64 tNum; /* Interpolation numerator value 1 */ + float64 uNum; /* Interpolation numerator value 2 */ + + int16 i16[4]; /* Working buffer (int16) */ + int32 i32[4]; /* Working buffer (int132) */ + float32 f32[4]; /* Working buffer (float32) */ + float64 f64[4]; /* Working buffer (float64) */ + + char *pixVal; /* Nearest neighbor values */ + char *dimlist; /* Dimension list */ + + /* Allocate space for dimlist */ + /* --------------------------------- */ + dimlist = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"GDinterpolate", __FILE__, __LINE__); + return(-1); + } + /* Check for valid grid ID */ + /* ----------------------- */ + status = GDchkgdid(gridID, "GDinterpolate", + &fid, &sdInterfaceID, &gdVgrpID); + + + /* If no problems ... */ + /* ------------------ */ + if (status == 0) + { + /* Get field information */ + /* --------------------- */ + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, dimlist); + + + /* Check for "XDim" & "YDim" in dimension list */ + /* ------------------------------------------- */ + if (status == 0) + { + xdum = EHstrwithin("XDim", dimlist, ','); + ydum = EHstrwithin("YDim", dimlist, ','); + + if (xdum == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDinterpolate", __FILE__, __LINE__); + HEreport( + "\"XDim\" not present in dimlist for field: \"%s\".\n", + fieldname); + } + + + if (ydum == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDinterpolate", __FILE__, __LINE__); + HEreport( + "\"YDim\" not present in dimlist for field: \"%s\".\n", + fieldname); + } + } + else + { + /* Fieldname not found in grid */ + /* --------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "GDinterpolate", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + + + /* If no problems ... */ + /* ------------------ */ + if (status == 0) + { + /* Compute size of data buffer for each interpolated value */ + /* ------------------------------------------------------- */ + dims[xdum] = 1; + dims[ydum] = 1; + size = dims[0]; + for (i = 1; i < rank; i++) + { + size *= dims[i]; + } + numsize = DFKNTsize(ntype); + size *= numsize; + + nRetn = size / numsize; + + + + /* If interpolated values are requested ... */ + /* ---------------------------------------- */ + if (interpVal != NULL) + { + /* Get grid info */ + /* ------------- */ + status = GDgridinfo(gridID, &xdimsize, &ydimsize, + upleftpt, lowrightpt); + + + /* Get projection info */ + /* ------------------- */ + status = GDprojinfo(gridID, &projcode, &zonecode, + &spherecode, projparm); + + + /* Get explicit upleftpt & lowrightpt if defaults are used */ + /* ------------------------------------------------------- */ + status = GDgetdefaults(projcode, zonecode, projparm, + spherecode, upleftpt, lowrightpt); + + + /* Get pixel registration and origin info */ + /* -------------------------------------- */ + status = GDpixreginfo(gridID, &pixregcode); + status = GDorigininfo(gridID, &origincode); + + + + /* Loop through all interpolated points */ + /* ------------------------------------ */ + for (i = 0; i < nValues; i++) + { + /* Get row & column of point pixel */ + /* ------------------------------- */ + status = GDll2ij(projcode, zonecode, projparm, spherecode, + xdimsize, ydimsize, upleftpt, lowrightpt, + 1, &lonVal[i], &latVal[i], + pixRow, pixCol, &xVal, &yVal); + + + /* Get diff of interp. point from pixel location */ + /* --------------------------------------------- */ + if (pixregcode == HDFE_CENTER) + { + tNum = xVal - (pixCol[0] + 0.5); + uNum = yVal - (pixRow[0] + 0.5); + } + else if (origincode == HDFE_GD_UL) + { + tNum = xVal - pixCol[0]; + uNum = yVal - pixRow[0]; + } + else if (origincode == HDFE_GD_UR) + { + tNum = xVal - (pixCol[0] + 1); + uNum = yVal - pixRow[0]; + } + else if (origincode == HDFE_GD_LL) + { + tNum = xVal - pixCol[0]; + uNum = yVal - (pixRow[0] + 1); + } + else if (origincode == HDFE_GD_LR) + { + tNum = xVal - (pixCol[0] + 1); + uNum = yVal - (pixRow[0] + 1); + } + + + /* Get rows and columns of other nearest neighbor pixels */ + /* ----------------------------------------------------- */ + pixCol[1] = pixCol[0]; + pixRow[3] = pixRow[0]; + + if (tNum >= 0) + { + pixCol[2] = pixCol[0] + 1; + pixCol[3] = pixCol[0] + 1; + } + + if (tNum < 0) + { + pixCol[2] = pixCol[0] - 1; + pixCol[3] = pixCol[0] - 1; + } + + if (uNum >= 0) + { + pixRow[2] = pixRow[0] + 1; + pixRow[1] = pixRow[0] + 1; + } + + if (uNum < 0) + { + pixRow[2] = pixRow[0] - 1; + pixRow[1] = pixRow[0] - 1; + } + + + /* Get values of nearest neighbors */ + /* -------------------------------- */ + pixVal = (char *) malloc(4 * size); + if(pixVal == NULL) + { + HEpush(DFE_NOSPACE,"GDinterpolate", __FILE__, __LINE__); + free(dimlist); + return(-1); + } + dum = GDgetpixvalues(gridID, 4, pixRow, pixCol, + fieldname, pixVal); + + + /* Trap interpolation boundary out of range error */ + /* ---------------------------------------------- */ + if (dum == -1) + { + status = -1; + HEpush(DFE_GENAPP, "GDinterpolate", __FILE__, __LINE__); + HEreport("Interpolation boundary outside of grid.\n"); + } + else + { + + /* + * Algorithm taken for Numerical Recipies in C, 2nd + * edition, Section 3.6 + */ + + /* Perform bilinear interpolation */ + /* ------------------------------ */ + tDen = pixCol[3] - pixCol[0]; + uDen = pixRow[1] - pixRow[0]; + + switch (ntype) + { + case DFNT_INT16: + + + /* Loop through all returned data values */ + /* ------------------------------------- */ + for (j = 0; j < nRetn; j++) + { + /* Copy 4 NN values into working array */ + /* ----------------------------------- */ + for (k = 0; k < 4; k++) + { + memcpy(&i16[k], + pixVal + j * numsize + k * size, + sizeof(int16)); + } + + /* Compute interpolated value */ + /* -------------------------- */ + interpVal[i * nRetn + j] = + (1 - tNum / tDen) * (1 - uNum / uDen) * + i16[0] + + (tNum / tDen) * (1 - uNum / uDen) * + i16[3] + + (tNum / tDen) * (uNum / uDen) * + i16[2] + + (1 - tNum / tDen) * (uNum / uDen) * + i16[1]; + } + break; + + + case DFNT_INT32: + + for (j = 0; j < nRetn; j++) + { + for (k = 0; k < 4; k++) + { + memcpy(&i32[k], + pixVal + j * numsize + k * size, + sizeof(int32)); + } + + interpVal[i * nRetn + j] = + (1 - tNum / tDen) * (1 - uNum / uDen) * + i32[0] + + (tNum / tDen) * (1 - uNum / uDen) * + i32[3] + + (tNum / tDen) * (uNum / uDen) * + i32[2] + + (1 - tNum / tDen) * (uNum / uDen) * + i32[1]; + } + break; + + + case DFNT_FLOAT32: + + for (j = 0; j < nRetn; j++) + { + for (k = 0; k < 4; k++) + { + memcpy(&f32[k], + pixVal + j * numsize + k * size, + sizeof(float32)); + } + + interpVal[i * nRetn + j] = + (1 - tNum / tDen) * (1 - uNum / uDen) * + f32[0] + + (tNum / tDen) * (1 - uNum / uDen) * + f32[3] + + (tNum / tDen) * (uNum / uDen) * + f32[2] + + (1 - tNum / tDen) * (uNum / uDen) * + f32[1]; + } + break; + + + case DFNT_FLOAT64: + + for (j = 0; j < nRetn; j++) + { + for (k = 0; k < 4; k++) + { + memcpy(&f64[k], + pixVal + j * numsize + k * size, + sizeof(float64)); + } + + interpVal[i * nRetn + j] = + (1 - tNum / tDen) * (1 - uNum / uDen) * + f64[0] + + (tNum / tDen) * (1 - uNum / uDen) * + f64[3] + + (tNum / tDen) * (uNum / uDen) * + f64[2] + + (1 - tNum / tDen) * (uNum / uDen) * + f64[1]; + } + break; + } + } + free(pixVal); + } + } + } + } + + + /* If successful return size of returned data in bytes */ + /* --------------------------------------------------- */ + if (status == 0) + { + /*always return size of float64 buffer */ + free(dimlist); + return (nRetn * nValues * sizeof(float64)); + } + else + { + free(dimlist); + return ((int32) status); + } + +} +/*********************************************** +GDwrrdtile -- + This function is the underlying function below GDwritetile and + GDreadtile. + + +Author-- +Alexis Zubrow + +********************************************************/ + +intn +GDwrrdtile(int32 gridID, char *fieldname, char *code, int32 start[], + VOIDP datbuf) +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS ID */ + + int32 dum; /* Dummy variable */ + int32 rankSDS; /* Rank of SDS/Field */ + + int32 dims[8]; /* Field/SDS dimensions */ + int32 tileFlags; /* flag to determine if field is tiled */ + int32 numTileDims;/* number of tiles spanning a dimension */ + HDF_CHUNK_DEF tileDef; /* union holding tiling info. */ + + + /* Get gridID */ + status = GDchkgdid(gridID, "GDwrrdtile", &fid, &sdInterfaceID, &dum); + if (status == 0) + { + + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &rankSDS, dims, &dum, NULL); + + if (status == 0) + { + + /* Check whether fieldname is in SDS (multi-dim field) */ + /* --------------------------------------------------- */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, &sdid, + &rankSDS, &dum, &dum, dims, &dum); + + + + /* + * Check for errors in parameters passed to GDwritetile or + * GDreadtile + */ + + /* Check if untiled field */ + status = SDgetchunkinfo(sdid, &tileDef, &tileFlags); + if (tileFlags == HDF_NONE) + { + HEpush(DFE_GENAPP, "GDwrrdtile", __FILE__, __LINE__); + HEreport("Field \"%s\" is not tiled.\n", fieldname); + status = -1; + return (status); + + } + + /* + * Check if rd/wr tilecoords are within the extent of the field + */ + for (i = 0; i < rankSDS; i++) + { + /* + * Calculate the number of tiles which span a dimension of + * the field + */ + numTileDims = dims[i] / tileDef.chunk_lengths[i]; + if ((start[i] >= numTileDims) || (start[i] < 0)) + { + /* + * ERROR INDICATING BEYOND EXTENT OF THAT DIMENSION OR + * NEGATIVE TILECOORDS + */ + HEpush(DFE_GENAPP, "GDwrrdtile", __FILE__, __LINE__); + HEreport("Tilecoords for dimension \"%d\" ...\n", i); + HEreport("is beyond the extent of dimension length\n"); + status = -1; + + } + } + + if (status == -1) + { + return (status); + } + + + /* Actually write/read to the field */ + + if (strcmp(code, "w") == 0) /* write tile */ + { + status = SDwritechunk(sdid, start, (VOIDP) datbuf); + } + else if (strcmp(code, "r") == 0) /* read tile */ + { + status = SDreadchunk(sdid, start, (VOIDP) datbuf); + } + + + } + + /* Non-existent fieldname */ + else + { + HEpush(DFE_GENAPP, "GDwrrdtile", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + } + + } + + return (status); +} + + +/*********************************************** +GDtileinfo -- + This function queries the field to determine if it is tiled. If it is + tile, one can retrieve some of the characteristics of the tiles. + +Author-- Alexis Zubrow + +********************************************************/ + + +intn +GDtileinfo(int32 gridID, char *fieldname, int32 * tilecode, int32 * tilerank, + int32 tiledims[]) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS ID */ + + int32 dum; /* Dummy variable */ + int32 rankSDS; /* Rank of SDS/Field/tile */ + + int32 dims[8]; /* Field/SDS dimensions */ + int32 tileFlags; /* flag to determine if field is tiled */ + HDF_CHUNK_DEF tileDef; /* union holding tiling info. */ + + + /* Check if improper gridID */ + status = GDchkgdid(gridID, "GDtileinfo", &fid, &sdInterfaceID, &dum); + if (status == 0) + { + + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &rankSDS, dims, &dum, NULL); + + if (status == 0) + { + + /* Check whether fieldname is in SDS (multi-dim field) */ + /* --------------------------------------------------- */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, &sdid, + &rankSDS, &dum, &dum, dims, &dum); + + + + /* Query field for tiling information */ + status = SDgetchunkinfo(sdid, &tileDef, &tileFlags); + + /* If field is untiled, return untiled flag */ + if (tileFlags == HDF_NONE) + { + *tilecode = HDFE_NOTILE; + return (status); + } + + /* IF field is tiled or tiled with compression */ + else if ((tileFlags == HDF_CHUNK) || + (tileFlags == (HDF_CHUNK | HDF_COMP))) + { + if (tilecode != NULL) + { + *tilecode = HDFE_TILE; + } + if (tilerank != NULL) + { + *tilerank = rankSDS; + } + if (tiledims != NULL) + { + /* Assign size of tile dimensions */ + for (i = 0; i < rankSDS; i++) + { + tiledims[i] = tileDef.chunk_lengths[i]; + } + } + } + } + + /* Non-existent fieldname */ + else + { + HEpush(DFE_GENAPP, "GDtileinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + } + + } + return (status); +} +/******************************************************* +GDtleinfo + +This function gets information on the tileing of a field (FORTRAN wrapper around +GDtileinfo) + + +Author-- +Alexis Zubrow + +Date-- +3/4/1997 +*******************************************************/ + +intn +GDtleinfo(int32 gridID, char *fieldname, int32 * tilecode, int32 * tilerank, + int32 forttiledims[]) +{ + + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *tiledims; /* Pointer dimension size array (C order) */ + + + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, NULL); + + if (status == 0) + { + tiledims = malloc(rank * sizeof(int32)); + if(tiledims == NULL) + { + HEpush(DFE_NOSPACE,"GDtleinfo", __FILE__, __LINE__); + return(-1); + } + + /* reverse order of dimensions, converting FORTRAN to C */ + for (i = 0; i < rank; i++) + { + tiledims[i] = forttiledims[rank - 1 - i]; + } + + /* call GDtileinfo with C ordered array */ + status = GDtileinfo(gridID, fieldname, tilecode, tilerank, tiledims); + + free(tiledims); + } + else + { + HEpush(DFE_GENAPP, "GDtleinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + + } + + return (status); +} +/*********************************************** +GDwritetile -- + This function writes one tile to a particular field. + + +Author-- +Alexis Zubrow + +********************************************************/ + +intn +GDwritetile(int32 gridID, char *fieldname, int32 tilecoords[], + VOIDP tileData) +{ + char code[] = "w"; /* write tile code */ + intn status = 0; /* routine return status variable */ + + status = GDwrrdtile(gridID, fieldname, code, tilecoords, tileData); + + return (status); +} +/*********************************************** +GDreadtile -- + This function reads one tile from a particular field. + + +Author-- +Alexis Zubrow + +********************************************************/ + +intn +GDreadtile(int32 gridID, char *fieldname, int32 tilecoords[], + VOIDP tileData) +{ + char code[] = "r"; /* read tile code */ + intn status = 0; /* routine return status variable */ + + status = GDwrrdtile(gridID, fieldname, code, tilecoords, tileData); + + return (status); +} +/******************************************************* +GDwrtle + +This function writes a tile to a field (FORTRAN wrapper around GDwritetile) + + +Author-- +Alexis Zubrow + +Date-- +3/4/1997 +*******************************************************/ + +intn +GDwrtle(int32 gridID, char *fieldname, int32 forttilecoords[], VOIDP data) +{ + + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *tilecoords; /* Pointer origin array (C order) */ + + + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, NULL); + + if (status == 0) + { + tilecoords = malloc(rank * sizeof(int32)); + if(tilecoords == NULL) + { + HEpush(DFE_NOSPACE,"GDwrtle", __FILE__, __LINE__); + return(-1); + } + + /* reverse order of dimensions, converting FORTRAN to C */ + for (i = 0; i < rank; i++) + { + tilecoords[i] = forttilecoords[rank - 1 - i]; + } + + /* call GDwritetile with C ordered array */ + status = GDwritetile(gridID, fieldname, tilecoords, data); + + free(tilecoords); + } + else + { + HEpush(DFE_GENAPP, "GDwrtle", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + + } + + return (status); +} +/******************************************************* +GDrdtle + +This function reads a tile from a field (FORTRAN wrapper around GDreadtile) + + +Author-- +Alexis Zubrow + +Date-- +3/4/1997 +*******************************************************/ + +intn +GDrdtle(int32 gridID, char *fieldname, int32 forttilecoords[], VOIDP data) +{ + + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *tilecoords; /* Pointer origin array (C order) */ + + + status = GDfieldinfo(gridID, fieldname, &rank, dims, &ntype, NULL); + + if (status == 0) + { + tilecoords = malloc(rank * sizeof(int32)); + if(tilecoords == NULL) + { + HEpush(DFE_NOSPACE,"GDrdtle", __FILE__, __LINE__); + return(-1); + } + + + /* reverse order of dimensions, converting FORTRAN to C */ + for (i = 0; i < rank; i++) + { + tilecoords[i] = forttilecoords[rank - 1 - i]; + } + + /* call GDreadtile with C ordered array */ + status = GDreadtile(gridID, fieldname, tilecoords, data); + + free(tilecoords); + } + else + { + HEpush(DFE_GENAPP, "GDrdtle", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + + } + + return (status); +} +/*********************************************** +GDsettilecache -- + This function sets the cache size for a tiled field. + + +Author-- +Alexis Zubrow + +********************************************************/ + +intn +GDsettilecache(int32 gridID, char *fieldname, int32 maxcache, int32 cachecode) +{ + + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS ID */ + + int32 dum; /* Dummy variable */ + + int32 dims[8]; /* Field/SDS dimensions */ + + + /* Check gridID */ + status = GDchkgdid(gridID, "GDwrrdtile", &fid, &sdInterfaceID, &dum); + if (status == 0) + { + + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &dum, dims, &dum, NULL); + + if (status == 0) + { + + /* Check whether fieldname is in SDS (multi-dim field) */ + /* --------------------------------------------------- */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, &sdid, + &dum, &dum, &dum, dims, &dum); + + + /* Check if maxcache is less than or equal to zero */ + if (maxcache <= 0) + { + HEpush(DFE_GENAPP, "GDsettilecache", __FILE__, __LINE__); + HEreport("Improper maxcache \"%d\"... \n", maxcache); + HEreport("maxcache must be greater than zero.\n"); + status = -1; + return (status); + } + + + /* Set the number of tiles to cache */ + /* Presently, the only cache flag allowed is 0 */ + status = SDsetchunkcache(sdid, maxcache, 0); + + + } + + /* Non-existent fieldname */ + else + { + HEpush(DFE_GENAPP, "GDwrrdtile", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + status = -1; + } + + } + + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDsettilecomp | +| | +| DESCRIPTION: Sets the tiling/compression parameters for the specified | +| field. This can be called after GDsetfillvalue and assumes | +| that the field was defined with no compression/tiling set | +| by GDdeftile or GDdefcomp. | +| | +| This function replaces the following sequence: | +| GDdefcomp | +| GDdeftile | +| GDdeffield | +| GDsetfillvalue | +| with: | +| GDdeffield | +| GDsetfillvalue | +| GDsettilecomp | +| so that fill values will work correctly. | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| gridID int32 grid structure ID | +| fieldname char field name | +| tilerank int32 number of tiling dimensions | +| tiledims int32 tiling dimensions | +| compcode int32 compression code | +| compparm intn compression parameters | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 98 MISR Used GDsetfillvalue as a template and copied | +| tiling/comp portions of GDdeffield.(NCR15866). | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +GDsettilecomp(int32 gridID, char *fieldname, int32 tilerank, int32* + tiledims, int32 compcode, intn* compparm) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 gdVgrpID; /* Grid root Vgroup ID */ + int i; /* Looping variable. */ + int32 sdid; /* SDS id */ + int32 nt; /* Number type */ + int32 dims[8]; /* Dimensions array */ + int32 dum; /* Dummy variable */ + int32 solo; /* "Solo" (non-merged) field flag */ + comp_info c_info; /* Compression parameter structure */ + HDF_CHUNK_DEF chunkDef; /* Tiling structure */ + int32 chunkFlag; /* Chunking (Tiling) flag */ + + /* Check for valid grid ID and get SDS interface ID */ + status = GDchkgdid(gridID, "GDsetfillvalue", + &fid, &sdInterfaceID, &gdVgrpID); + + if (status == 0) + { + /* Get field info */ + status = GDfieldinfo(gridID, fieldname, &dum, dims, &nt, NULL); + + if (status == 0) + { + /* Get SDS ID and solo flag */ + status = GDSDfldsrch(gridID, sdInterfaceID, fieldname, + &sdid, &dum, &dum, &dum, + dims, &solo); + if (status !=0) { + HEpush(DFE_GENAPP, "GDsettilecomp", __FILE__, __LINE__); + HEreport("GDSDfldsrch failed\n", fieldname); + return FAIL; + } + /* Tiling with Compression */ + /* ----------------------- */ + + + /* Setup Compression */ + /* ----------------- */ + if (compcode == HDFE_COMP_NBIT) + { + c_info.nbit.nt = nt; + c_info.nbit.sign_ext = compparm[0]; + c_info.nbit.fill_one = compparm[1]; + c_info.nbit.start_bit = compparm[2]; + c_info.nbit.bit_len = compparm[3]; + } + else if (compcode == HDFE_COMP_SKPHUFF) + { + c_info.skphuff.skp_size = (intn) DFKNTsize(nt); + } + else if (compcode == HDFE_COMP_DEFLATE) + { + c_info.deflate.level = compparm[0]; + } + + /* Setup chunk lengths */ + /* ------------------- */ + for (i = 0; i < tilerank; i++) + { + chunkDef.comp.chunk_lengths[i] = tiledims[i]; + } + + /* Setup chunk flag & chunk compression type */ + /* ----------------------------------------- */ + chunkFlag = HDF_CHUNK | HDF_COMP; + chunkDef.comp.comp_type = compcode; + + /* Setup chunk compression parameters */ + /* ---------------------------------- */ + if (compcode == HDFE_COMP_SKPHUFF) + { + chunkDef.comp.cinfo.skphuff.skp_size = + c_info.skphuff.skp_size; + } + else if (compcode == HDFE_COMP_DEFLATE) + { + chunkDef.comp.cinfo.deflate.level = + c_info.deflate.level; + } + /* Call SDsetchunk routine */ + /* ----------------------- */ + status = SDsetchunk(sdid, chunkDef, chunkFlag); + if (status ==FAIL) { + HEpush(DFE_GENAPP, "GDsettilecomp", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", + fieldname); + return status; + } + } + else + { + HEpush(DFE_GENAPP, "GDsettilecomp", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + } + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDll2mm_cea | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| projparm float64 Projection parameters | +| spherecode int32 GCTP spheriod code | +| xdimsize int32 xdimsize from GDcreate | +| ydimsize int32 ydimsize from GDcreate | +| upleftpt float64 upper left corner coordinates (DMS) | +| lowrightpt float64 lower right corner coordinates (DMS) | +| longitude float64 longitude array (DMS) | +| latitude float64 latitude array (DMS) | +| npnts int32 number of lon-lat points | +| | +| OUTPUTS: | +| x float64 X value array | +| y float64 Y value array | +| scaleX float64 X grid size | +| scaley float64 Y grid size | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 02 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn GDll2mm_cea(int32 projcode,int32 zonecode, int32 spherecode, + float64 projparm[], + int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], int32 npnts, + float64 lon[],float64 lat[], + float64 x[],float64 y[], float64 *scaleX,float64 *scaleY) +{ + intn status = 0; /* routine return status variable */ + int32 errorcode = 0; /* GCTP error code */ + float64 xMtr0, xMtr1, yMtr0, yMtr1; + float64 lonrad0; /* Longitude in radians of upleft point */ + float64 latrad0; /* Latitude in radians of upleft point */ + float64 lonrad; /* Longitude in radians of point */ + float64 latrad; /* Latitude in radians of point */ + int32(*for_trans[100]) (); /* GCTP function pointer */ + + if(npnts <= 0) + { + HEpush(DFE_GENAPP, " GDll2mm_cea", __FILE__, __LINE__); + HEreport("Improper npnts value\"%d\"... \n", npnts); + HEreport("npnts must be greater than zero.\n"); + status = -1; + return (status); + } + if ( projcode == GCTP_BCEA) + { + for_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, for_trans); + /* Convert upleft and lowright X coords from DMS to radians */ + /* -------------------------------------------------------- */ + + lonrad0 = EHconvAng(upleftpt[0], HDFE_DMS_RAD); + lonrad = EHconvAng(lowrightpt[0], HDFE_DMS_RAD); + + /* Convert upleft and lowright Y coords from DMS to radians */ + /* -------------------------------------------------------- */ + latrad0 = EHconvAng(upleftpt[1], HDFE_DMS_RAD); + latrad = EHconvAng(lowrightpt[1], HDFE_DMS_RAD); + + /* Convert from lon/lat to meters(or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad0, latrad0, &xMtr0, &yMtr0); + x[0] = xMtr0; + y[0] = yMtr0; + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDll2mm_cea", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Convert from lon/lat to meters(or whatever unit is, i.e unit + of r_major and r_minor) using GCTP */ + /* ----------------------------------------- */ + errorcode = for_trans[projcode] (lonrad, latrad, &xMtr1, &yMtr1); + x[1] = xMtr1; + y[1] = yMtr1; + + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDll2mm_cea", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + + /* Compute x scale factor */ + /* ---------------------- */ + *scaleX = (xMtr1 - xMtr0) / xdimsize; + + /* Compute y scale factor */ + /* ---------------------- */ + *scaleY = (yMtr1 - yMtr0) / ydimsize; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "GDll2mm_cea", __FILE__, __LINE__); + HEreport("Wrong projection code; this function is only for EASE grid"); + return (status); + } + return (0); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: GDmm2ll_cea | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| projcode int32 GCTP projection code | +| zonecode int32 UTM zone code | +| projparm float64 Projection parameters | +| spherecode int32 GCTP spheriod code | +| xdimsize int32 xdimsize from GDcreate | +| ydimsize int32 ydimsize from GDcreate | +| upleftpt float64 upper left corner coordinates (DMS) | +| lowrightpt float64 lower right corner coordinates (DMS) | +| x float64 X value array | +| y float64 Y value array | +| npnts int32 number of x-y points | +| | +| OUTPUTS: | +| longitude float64 longitude array (DMS) | +| latitude float64 latitude array (DMS) | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 02 Abe Taaheri Added support for EASE grid | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn GDmm2ll_cea(int32 projcode,int32 zonecode, int32 spherecode, + float64 projparm[], + int32 xdimsize, int32 ydimsize, + float64 upleftpt[], float64 lowrightpt[], int32 npnts, + float64 x[], float64 y[], + float64 longitude[], float64 latitude[]) +{ + intn status = 0; /* routine return status variable */ + int32 errorcode = 0; /* GCTP error code */ + int32(*inv_trans[100]) (); /* GCTP function pointer */ + int32 i; + + if(npnts <= 0) + { + HEpush(DFE_GENAPP, " GDmm2ll_cea", __FILE__, __LINE__); + HEreport("Improper npnts value\"%d\"... \n", npnts); + HEreport("npnts must be greater than zero.\n"); + status = -1; + return (status); + } + if ( projcode == GCTP_BCEA) + { + inv_init(projcode, zonecode, projparm, spherecode, NULL, NULL, + &errorcode, inv_trans); + + /* Convert from meters(or whatever unit is, i.e unit + of r_major and r_minor) to lat/lon using GCTP */ + /* ----------------------------------------- */ + for(i=0; i<npnts; i++) + { + errorcode = + inv_trans[projcode] (x[i], y[i],&longitude[i], &latitude[i]); + /* Report error if any */ + /* ------------------- */ + if (errorcode != 0) + { + status = -1; + HEpush(DFE_GENAPP, "GDmm2ll_cea", __FILE__, __LINE__); + HEreport("GCTP Error: %d\n", errorcode); + return (status); + } + longitude[i] = EHconvAng(longitude[i], HDFE_RAD_DMS); + latitude[i] = EHconvAng(latitude[i], HDFE_RAD_DMS); + } + } + else + { + /* Wrong projection code; this function is only for EASE grid */ + } + return(status); +} + diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/GNUmakefile b/Utilities/GDAL/frmts/hdf4/hdf-eos/GNUmakefile new file mode 100644 index 0000000000..a2e1234809 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/GNUmakefile @@ -0,0 +1,22 @@ + +include ../../../GDALmake.opt + +OBJ = \ + EHapi.o \ + GDapi.o \ + SWapi.o \ + gctp_wrap.o + +O_OBJ = $(foreach file,$(OBJ),../../o/$(file)) + +CPPFLAGS := $(GDAL_INCLUDE) $(HDF4_INCLUDE) -I. $(CPPFLAGS) + +default: $(OBJ) + +clean: + $(RM) *.o *.a $(O_OBJ) + +install-obj: $(SUBLIBS) $(O_OBJ) + +../../o/%.o: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/HDFEOSVersion.h b/Utilities/GDAL/frmts/hdf4/hdf-eos/HDFEOSVersion.h new file mode 100644 index 0000000000..e9ea958e65 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/HDFEOSVersion.h @@ -0,0 +1,18 @@ +#include <stdlib.h> + +/* define strings that will be displayed by the using the UNIX "what" command + on a file containing these strings */ + +#define HDFEOSd_BANNER "@(#)## ================= HDFEOS ================" +#ifdef __GNUC__ +#define HDFEOSd_HDFEOS_VER "@(#)## HDFEOS Version: "HDFEOSVERSION1 +#define HDFEOSd_DATE "@(#)## Build date: "__DATE__" @ "__TIME__ +#else +#define HDFEOSd_HDFEOS_VER "@(#)## HDFEOS Version: "##HDFEOSVERSION1 +#define HDFEOSd_DATE "@(#)## Build date: "##__DATE__##" @ "##__TIME__ +#endif + +const char *hdfeosg_LibraryVersionString01 = HDFEOSd_BANNER; +const char *hdfeosg_LibraryVersionString02 = HDFEOSd_HDFEOS_VER; +const char *hdfeosg_LibraryVersionString03 = HDFEOSd_DATE; +const char *hdfeosg_LibraryVersionString04 = HDFEOSd_BANNER; diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/HdfEosDef.h b/Utilities/GDAL/frmts/hdf4/hdf-eos/HdfEosDef.h new file mode 100644 index 0000000000..23b203efd6 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/HdfEosDef.h @@ -0,0 +1,311 @@ +/* +Copyright (C) 1996 Hughes and Applied Research Corporation + +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation. +*/ + +#ifndef HDFEOSDEF_H_ +#define HDFEOSDEF_H_ + +/* include header file for EASE grid */ +#include <ease.h> + +/* Working Buffer Sizes */ +#define HDFE_MAXMEMBUF 256*256*16 +#define HDFE_NAMBUFSIZE 32000 +#define HDFE_DIMBUFSIZE 64000 + + +/* Field Merge */ +#define HDFE_NOMERGE 0 +#define HDFE_AUTOMERGE 1 + + +/* XXentries Modes */ +#define HDFE_NENTDIM 0 +#define HDFE_NENTMAP 1 +#define HDFE_NENTIMAP 2 +#define HDFE_NENTGFLD 3 +#define HDFE_NENTDFLD 4 + + +/* GCTP projection codes */ +#define GCTP_GEO 0 +#define GCTP_UTM 1 +#define GCTP_SPCS 2 +#define GCTP_ALBERS 3 +#define GCTP_LAMCC 4 +#define GCTP_MERCAT 5 +#define GCTP_PS 6 +#define GCTP_POLYC 7 +#define GCTP_EQUIDC 8 +#define GCTP_TM 9 +#define GCTP_STEREO 10 +#define GCTP_LAMAZ 11 +#define GCTP_AZMEQD 12 +#define GCTP_GNOMON 13 +#define GCTP_ORTHO 14 +#define GCTP_GVNSP 15 +#define GCTP_SNSOID 16 +#define GCTP_EQRECT 17 +#define GCTP_MILLER 18 +#define GCTP_VGRINT 19 +#define GCTP_HOM 20 +#define GCTP_ROBIN 21 +#define GCTP_SOM 22 +#define GCTP_ALASKA 23 +#define GCTP_GOOD 24 +#define GCTP_MOLL 25 +#define GCTP_IMOLL 26 +#define GCTP_HAMMER 27 +#define GCTP_WAGIV 28 +#define GCTP_WAGVII 29 +#define GCTP_OBLEQA 30 +#define GCTP_ISINUS1 31 +#define GCTP_CEA 97 +#define GCTP_BCEA 98 +#define GCTP_ISINUS 99 + + +/* Compression Modes */ +#define HDFE_COMP_NONE 0 +#define HDFE_COMP_RLE 1 +#define HDFE_COMP_NBIT 2 +#define HDFE_COMP_SKPHUFF 3 +#define HDFE_COMP_DEFLATE 4 + + +/* Tiling Codes */ +#define HDFE_NOTILE 0 +#define HDFE_TILE 1 + + +/* Swath Subset Modes */ +#define HDFE_MIDPOINT 0 +#define HDFE_ENDPOINT 1 +#define HDFE_ANYPOINT 2 +#define HDFE_INTERNAL 0 +#define HDFE_EXTERNAL 1 +#define HDFE_NOPREVSUB -1 + + + +/* Grid Origin */ +#define HDFE_GD_UL 0 +#define HDFE_GD_UR 1 +#define HDFE_GD_LL 2 +#define HDFE_GD_LR 3 + + + +/* Grid Pixel Registration */ +#define HDFE_CENTER 0 +#define HDFE_CORNER 1 + + +/* Angle Conversion Codes */ +#define HDFE_RAD_DEG 0 +#define HDFE_DEG_RAD 1 +#define HDFE_DMS_DEG 2 +#define HDFE_DEG_DMS 3 +#define HDFE_RAD_DMS 4 +#define HDFE_DMS_RAD 5 + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Swath Prototype */ +int32 SWopen(char *, intn); +int32 SWcreate(int32, char *); +int32 SWattach(int32, char *); +intn SWdefdim(int32, char *, int32); +intn SWdefcomp(int32, int32, intn []); +int32 SWdiminfo(int32, char *); +intn SWmapinfo(int32, char *, char *, int32 *, int32 *); +int32 SWidxmapinfo(int32, char *, char *, int32 []); +intn SWfieldinfo(int32, char *, int32 *, int32 [], int32 *, char *); +intn SWcompinfo(int32, char *, int32 *, intn []); +intn SWdefdimmap(int32, char *, char *, int32, int32); +intn SWdefidxmap(int32, char *, char *, int32 []); +intn SWdefgeofield(int32, char *, char *, int32, int32); +intn SWdefdatafield(int32, char *, char *, int32, int32); +intn SWwritegeometa(int32, char *, char *, int32); +intn SWwritedatameta(int32, char *, char *, int32); +intn SWwriteattr(int32, char *, int32, int32, VOIDP); +intn SWreadattr(int32, char *, VOIDP); +intn SWattrinfo(int32, char *, int32 *, int32 *); +int32 SWinqdims(int32, char *, int32 []); +int32 SWinqmaps(int32, char *, int32 [], int32 []); +int32 SWinqidxmaps(int32, char *, int32 []); +int32 SWinqgeofields(int32, char *, int32 [], int32 []); +int32 SWinqdatafields(int32, char *, int32 [],int32 []); +int32 SWinqattrs(int32, char *, int32 *); +int32 SWnentries(int32, int32, int32 *); +int32 SWinqswath(char *, char *, int32 *); +intn SWwritefield(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn SWreadfield(int32, char *, int32 [], int32 [], int32 [], VOIDP); +int32 SWdefboxregion(int32, float64 [], float64 [], int32); +int32 SWdefscanregion(int32, char *, float64 [], int32); +int32 SWregionindex(int32, float64 [], float64 [], int32, char *, int32 []); +intn SWextractregion(int32, int32, char *, int32, VOIDP); +intn SWregioninfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *); +int32 SWdupregion(int32); +int32 SWdeftimeperiod(int32, float64, float64, int32); +intn SWextractperiod(int32, int32, char *, int32, VOIDP); +intn SWperiodinfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *); +int32 SWdefvrtregion(int32, int32, char *, float64 []); +intn SWsetfillvalue(int32, char *, VOIDP); +intn SWgetfillvalue(int32, char *, VOIDP); +intn SWdetach(int32); +intn SWclose(int32); +int32 SWupdateidxmap(int32, int32, int32 [], int32 [], int32 []); +intn SWgeomapinfo(int32, char *); +intn SWupdatescene(int32, int32); + + +/* Grid Prototypes */ +int32 GDopen(char *, intn); +int32 GDcreate(int32, char *, int32, int32, float64 [], float64 []); +int32 GDattach(int32, char *); +intn GDdefdim(int32, char *, int32); +intn GDdefproj(int32, int32, int32, int32, float64 []); +intn GDblkSOMoffset(int32, float32 [], int32, char *); +intn GDdefcomp(int32, int32, intn []); +intn GDdeftile(int32, int32, int32, int32 []); +intn GDsettilecomp(int32, char *, int32, int32 *, int32, intn *); +intn GDdeforigin(int32, int32); +intn GDdefpixreg(int32, int32); +int32 GDdiminfo(int32, char *); +intn GDgridinfo(int32, int32 *, int32 *, float64 [], float64 []); +intn GDprojinfo(int32, int32 *, int32 *, int32 *, float64 []); +intn GDorigininfo(int32, int32 *); +intn GDpixreginfo(int32, int32 *); +intn GDcompinfo(int32, char *, int32 *, intn []); +intn GDfieldinfo(int32, char *, int32 *, int32 [], int32 *, char *); +intn GDtileinfo(int32, char *, int32 *, int32 *, int32 []); +intn GDsettilecache(int32, char *, int32, int32); +intn GDwritetile(int32, char *, int32 [], VOIDP); +intn GDreadtile(int32, char *, int32 [], VOIDP); +intn GDdeffield(int32, char *, char *, int32, int32); +intn GDwritefieldmeta(int32, char *, char *, int32); +intn GDwritefield(int32, char *, + int32 [], int32 [], int32 [], VOIDP); +intn GDreadfield(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn GDwriteattr(int32, char *, int32 , int32, VOIDP); +intn GDreadattr(int32, char *, VOIDP); +intn GDattrinfo(int32, char *, int32 *, int32 *); +int32 GDinqdims(int32, char *, int32 []); +int32 GDinqfields(int32, char *, int32 [], int32 []); +int32 GDinqattrs(int32, char *, int32 *); +int32 GDnentries(int32, int32, int32 *); +int32 GDinqgrid(char *, char *, int32 *); +int32 GDdefboxregion(int32, float64 [], float64 []); +int32 GDdefvrtregion(int32, int32, char *, float64 []); +int32 GDdeftimeperiod(int32, int32, float64, float64); +intn GDextractregion(int32, int32, char *, VOIDP); +intn GDregioninfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *, + float64 [], float64 []); +int32 GDdupregion(int32); +intn GDgetpixels(int32, int32, float64 [], float64 [], int32 [], int32 []); +int32 GDgetpixvalues(int32, int32, int32 [], int32 [], char *, VOIDP); +int32 GDinterpolate(int32, int32, float64 [], float64 [], char *, float64 []); +intn GDsetfillvalue(int32, char *, VOIDP); +intn GDgetfillvalue(int32, char *, VOIDP); +intn GDdetach(int32); +intn GDclose(int32); +intn GDrs2ll(int32, float64 [], int32, int32, + float64 [], float64 [], + int32, float64 [], float64 [], + float64 [], float64 [], int32, int32); + +/* Point Prototypes */ +int32 PTopen(char *, intn); +int32 PTcreate(int32, char *); +int32 PTnrecs(int32, int32); +int32 PTnlevels(int32); +int32 PTsizeof(int32, char *, int32 []); +int32 PTnfields(int32, int32, int32 *); +int32 PTlevelindx(int32, char *); +int32 PTattach(int32, char *); +intn PTdeflevel(int32, char *, char *, int32 [], int32 []); +intn PTdeflinkage(int32, char *, char *, char *); +intn PTbcklinkinfo(int32, int32, char *); +intn PTfwdlinkinfo(int32, int32, char *); +int32 PTlevelinfo(int32, int32, char *, int32 [], int32 []); +intn PTgetlevelname(int32, int32, char *, int32 *); +intn PTwritelevel(int32, int32, int32, VOIDP); +intn PTupdatelevel(int32, int32, char *, int32, int32 [], VOIDP); +intn PTreadlevel(int32, int32, char *, int32, int32 [], VOIDP); +intn PTgetrecnums(int32, int32, int32, int32, int32 [], int32 *, int32 []); +intn PTwriteattr(int32, char *, int32, int32, VOIDP); +intn PTreadattr(int32, char *, VOIDP); +intn PTattrinfo(int32, char *, int32 *, int32 *); +int32 PTinqattrs(int32, char *, int32 *); +int32 PTinqpoint(char *, char *, int32 *); +int32 PTdefboxregion(int32, float64 [], float64 []); +int32 PTdeftimeperiod(int32, float64, float64); +int32 PTdefvrtregion(int32, int32, char *, float64 []); +intn PTregioninfo(int32, int32 regionID, int32, char *, int32 *); +intn PTregionrecs(int32, int32, int32, int32 *, int32 []); +intn PTperiodrecs(int32, int32, int32, int32 *, int32 []); +intn PTperiodinfo(int32, int32 periodID, int32, char *, int32 *); +intn PTextractregion(int32, int32 regionID, int32, char *, VOIDP); +intn PTextractperiod(int32, int32 periodID, int32, char *, VOIDP); +intn PTdetach(int32); +intn PTclose(int32); + + + +/* EH Utility Prototypes */ +float64 EHconvAng(float64, intn); +int32 EHparsestr(char *, char, char *[], int32 []); +int32 EHstrwithin(char *, char *, char); +intn EHchkODL(char *); +intn EHloadliststr(char *[], int32, char *, char); +intn EHgetversion(int32, char *); +int32 EHopen(char *, intn); +intn EHchkfid(int32, char *, int32 *, int32 *, uint8 *); +intn EHidinfo(int32, int32 *, int32 *); +int32 EHgetid(int32, int32, char *, intn, char *); +intn EHrevflds(char *, char *); +intn EHinsertmeta(int32, char *, char *, int32, char *, int32 []); +intn EHgetmetavalue(char *[], char *, char *); +char * EHmetagroup(int32, char *, char *, char *, char *[]); +intn EHfillfld(int32, int32, int32, int32, int32, int32 [], VOIDP); +intn EHattr(int32, int32, char *, int32, int32, char *, VOIDP); +intn EHattrinfo(int32, int32, char *, int32 *, int32 *); +int32 EHattrcat(int32, int32, char *, int32 *); +intn EHfilename(int32, char *); +int32 EHcntOBJECT(char *[]); +int32 EHcntGROUP(char *[]); +/* 9/3/97 Abe changed the first argument from + float64 (float64 []) to float64 (*) (float64 []) for SunOS + float64 () (float64 []) to float64 (*) (float64 []) for all other OSs */ +intn EHbisect(float64 (*) (float64 []), float64 [], int32, float64, float64, + float64, float64 *); +int32 EHinquire(char *, char *, char *, int32 *); +intn EHclose(int32); + + + +#ifdef __cplusplus +} +#endif + + +#endif /* #ifndef HDFEOSDEF_H_ */ + + + + + + + + + + diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/README b/Utilities/GDAL/frmts/hdf4/hdf-eos/README new file mode 100644 index 0000000000..bfce974b60 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/README @@ -0,0 +1,19 @@ +The following source files are taken from the HDF-EOS package + +EHapi.c, +GDapi.c, +SWapi.c, +HDFEOSVersion.h, +HdfEosDef.h, +ease.h + +and have the following copyright notice: + +Copyright (C) 1996 Hughes and Applied Research Corporation + +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation. + + diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/SWapi.c b/Utilities/GDAL/frmts/hdf4/hdf-eos/SWapi.c new file mode 100644 index 0000000000..2b9c0aa01d --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/SWapi.c @@ -0,0 +1,12160 @@ +/* +Copyright (C) 1996 Hughes and Applied Research Corporation + +Permission to use, modify, and distribute this software and its documentation +for any purpose without fee is hereby granted, provided that the above +copyright notice appear in all copies and that both that copyright notice and +this permission notice appear in supporting documentation. +*/ +/***************************************************************************** +REVISIONS: + +Aug 31, 1999 Abe Taaheri Changed memory allocation for utility strings to + the size of UTLSTR_MAX_SIZE. + Added error check for memory unavailibilty in + several functions. + Added check for NULL metabuf returned from + EHmeta... functions. NULL pointer retruned from + EHmeta... functions indicate that memory could not + be allocated for metabuf. + +June 05, 2003 Abe Taaheri / Bruce Beaumont + + Changed MAXNREGIONS to 1024 to support MOPITT data + Supplied cast for compcode in call to + SDsetcompress to avoid compiler error + Removed declaration for unused variable rstatus + in SWwrrdfield + Removed initialization code for unused variables + in SWwrrdfield + Removed declaration for unused variable tmpVal + in SWdefboxregion + Added code in SWdefboxregion to check for index k + exceeding NSWATHREGN to avoid overwriting + memory + Removed declaration for unused variable retchar + in SWregionindex + Removed initialization code for unused variables + in SWregionindex + Removed declarations for unused variables tstatus, + nfields, nflgs, and swathname in SWextractregion + Removed initialization code for unused variables + in SWextractregion + Removed declaration for unused variable + land_status in SWscan2longlat + Removed initialization code for unused variables + in SWscan2longlat + Added clear (0) of timeflag in SWextractperiod if + return status from SWextractregion is non-zero + Removed declarations for unused variables tstatus, + scandim, ndfields, ndflds, and swathname in + SWregioninfo + Removed initialization code for unused variables + in SWregioninfo + Added clear (0) of timeflag in SWperiodinfo if + return status from SWregioninfo is non-zero + Removed declarations for unused variables size, + nfields, nflds, nswath, idxsz, cornerlon, and + cornerlat in SWdefscanregion + Removed initialization code for unused variables + in SWdefscanregion + Removed declarations for unused variables dims2, + rank, nt, swathname, dimlist, and buffer in + SWupdateidxmap + Removed declaration for unused variable statmeta + in SWgeomapinfo +******************************************************************************/ + +#include "mfhdf.h" +#include "hcomp.h" +#include "HdfEosDef.h" +#include <math.h> + +#define SWIDOFFSET 1048576 + + +int32 SWX1dcomb[512*3]; +int32 SWXSDcomb[512*5]; +char SWXSDname[HDFE_NAMBUFSIZE]; +char SWXSDdims[HDFE_DIMBUFSIZE]; + +/* This flag was added to allow the Time field to have different Dimensions +** than Longitude and Latitude and still be used for subsetting +** 23 June,1997 DaW +*/ +intn timeflag = 0; + + +/* Added for routine that converts scanline to Lat/long +** for floating scene subsetting +** Jul 1999 DaW +*/ +#define PI 3.141592653589793238 +#define RADOE 6371.0 /* Radius of Earth in Km */ + +#define NSWATH 200 +/* Swath Structure External Arrays */ +struct swathStructure +{ + int32 active; + int32 IDTable; + int32 VIDTable[3]; + int32 fid; + int32 nSDS; + int32 *sdsID; + int32 compcode; + intn compparm[5]; + int32 tilecode; + int32 tilerank; + int32 tiledims[8]; +}; +struct swathStructure SWXSwath[NSWATH]; + + + +#define NSWATHREGN 256 +#define MAXNREGIONS 1024 +struct swathRegion +{ + int32 fid; + int32 swathID; + int32 nRegions; + int32 StartRegion[MAXNREGIONS]; + int32 StopRegion[MAXNREGIONS]; + int32 StartVertical[8]; + int32 StopVertical[8]; + int32 StartScan[8]; + int32 StopScan[8]; + char *DimNamePtr[8]; + intn band8flag; + intn scanflag; +}; +struct swathRegion *SWXRegion[NSWATHREGN]; + +/* define a macro for the string size of the utility strings. The value + of 80 in previous version of this code was resulting in core dump (Array + Bounds Write and Array Bounds Read problem in SWfinfo function and the + functions called from there) for 7-8 dimensional fields where the + string length for "DimList" can exceed 80 characters, including " and + commas in the string. The length now is 512 which seems to be more + than enough to avoid the problem mentioned above. */ + +#define UTLSTR_MAX_SIZE 512 + +/* Swath Prototypes (internal routines) */ +intn SWchkswid(int32, char *, int32 *, int32 *, int32 *); +int32 SWimapinfo(int32, char *, char *, int32 []); +int32 SWfinfo(int32, char *, char *, int32 *, int32 [], int32 *, char *); +intn SWfldinfo(int32, char *, int32 *, int32 [], int32 *, char *); +intn SWdefimap(int32, char *, char *, int32 []); +intn SWdefinefield(int32, char *, char *, char *, int32, int32); +intn SWdefgfld(int32, char *, char *, int32, int32); +intn SWdefdfld(int32, char *, char *, int32, int32); +intn SWwrgmeta(int32, char *, char *, int32); +intn SWwrdmeta(int32, char *, char *, int32); +intn SWwrrdattr(int32, char *, int32, int32, char *, VOIDP); +intn SW1dfldsrch(int32, int32, char *, char *, int32 *, int32 *, int32 *); +intn SWSDfldsrch(int32, int32, char *, int32 *, int32 *, + int32 *, int32 *, int32 [], int32 *); +intn SWwrrdfield(int32, char *, char *, int32 [], int32 [], int32 [], VOIDP); +intn SWwrfld(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn SWrdfld(int32, char *, int32 [], int32 [], int32 [], VOIDP); +intn SWreginfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *); +intn SWperinfo(int32, int32, char *, int32 *, int32 *, int32 [], int32 *); +int32 SWinqfields(int32, char *, char *, int32 [], int32 []); +int32 SWdefvrtreg(int32, int32, char *, float64 []); +intn SWscan2longlat(int32, char *, VOIDP, int32 [], int32 [], int32 *, + int32, int32); + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWopen | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| fid int32 HDF-EOS file ID | +| | +| INPUTS: | +| filename char Filename | +| access intn HDF access code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWopen(char *filename, intn access) + +{ + int32 fid /* HDF-EOS file ID */ ; + + /* Call EHopen to perform file access */ + /* ---------------------------------- */ + fid = EHopen(filename, access); + + return (fid); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWcreate | +| | +| DESCRIPTION: Creates a new swath structure and returns swath ID | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| swathID int32 Swath structure ID | +| | +| INPUTS: | +| fid int32 File ID | +| swathname char Swath structure name | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Sep 96 Joel Gales Check swath name for length | +| Mar 97 Joel Gales Enlarge utlbuf to 512 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWcreate(int32 fid, char *swathname) +{ + intn i; /* Loop index */ + intn nswathopen = 0; /* # of swath structures open */ + intn status = 0; /* routine return status variable */ + + uint8 access; /* Read/Write file access code */ + + int32 HDFfid; /* HDF file id */ + int32 vgRef; /* Vgroup reference number */ + int32 vgid[4]; /* Vgroup ID array */ + int32 swathID = -1; /* HDF-EOS swath ID */ + + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nSwath = 0; /* Swath counter */ + + char name[80]; /* Vgroup name */ + char class[80]; /* Vgroup class */ + char errbuf[256];/* Buffer for error message */ + char utlbuf[512];/* Utility buffer */ + char utlbuf2[32];/* Utility buffer 2 */ + + /* + * Check HDF-EOS file ID, get back HDF file ID, SD interface ID and + * access code + */ + status = EHchkfid(fid, swathname, &HDFfid, &sdInterfaceID, &access); + + + /* Check swathname for length */ + /* -------------------------- */ + if ((intn) strlen(swathname) > VGNAMELENMAX) + { + status = -1; + HEpush(DFE_GENAPP, "SWcreate", __FILE__, __LINE__); + HEreport("Swathname \"%s\" must be less than %d characters.\n", + swathname, VGNAMELENMAX); + } + + + if (status == 0) + { + + /* Determine number of swaths currently opened */ + /* ------------------------------------------- */ + for (i = 0; i < NSWATH; i++) + { + nswathopen += SWXSwath[i].active; + } + + + /* Setup file interface */ + /* -------------------- */ + if (nswathopen < NSWATH) + { + + /* Check that swath has not been previously opened */ + /* ----------------------------------------------- */ + vgRef = -1; + + while (1) + { + vgRef = Vgetid(HDFfid, vgRef); + + /* If no more Vgroups then exist while loop */ + /* ---------------------------------------- */ + if (vgRef == -1) + { + break; + } + + /* Get name and class of Vgroup */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, vgRef, "r"); + Vgetname(vgid[0], name); + Vgetclass(vgid[0], class); + Vdetach(vgid[0]); + + /* If SWATH then increment # swath counter */ + /* --------------------------------------- */ + if (strcmp(class, "SWATH") == 0) + { + nSwath++; + } + + /* If swath already exist, return error */ + /* ------------------------------------ */ + if (strcmp(name, swathname) == 0 && + strcmp(class, "SWATH") == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWcreate", __FILE__, __LINE__); + HEreport("\"%s\" already exists.\n", swathname); + break; + } + } + + + if (status == 0) + { + + /* Create Root Vgroup for Swath */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, -1, "w"); + + + /* Set Name and Class (SWATH) */ + /* -------------------------- */ + Vsetname(vgid[0], swathname); + Vsetclass(vgid[0], "SWATH"); + + + + /* Create Geolocation Fields Vgroup */ + /* -------------------------------- */ + vgid[1] = Vattach(HDFfid, -1, "w"); + Vsetname(vgid[1], "Geolocation Fields"); + Vsetclass(vgid[1], "SWATH Vgroup"); + Vinsert(vgid[0], vgid[1]); + + + + /* Create Data Fields Vgroup */ + /* ------------------------- */ + vgid[2] = Vattach(HDFfid, -1, "w"); + Vsetname(vgid[2], "Data Fields"); + Vsetclass(vgid[2], "SWATH Vgroup"); + Vinsert(vgid[0], vgid[2]); + + + + /* Create Attributes Vgroup */ + /* ------------------------ */ + vgid[3] = Vattach(HDFfid, -1, "w"); + Vsetname(vgid[3], "Swath Attributes"); + Vsetclass(vgid[3], "SWATH Vgroup"); + Vinsert(vgid[0], vgid[3]); + + + + /* Establish Swath in Structural MetaData Block */ + /* -------------------------------------------- */ + sprintf(utlbuf, "%s%ld%s%s%s", + "\tGROUP=SWATH_", (long)nSwath + 1, + "\n\t\tSwathName=\"", swathname, "\"\n"); + + strcat(utlbuf, "\t\tGROUP=Dimension\n"); + strcat(utlbuf, "\t\tEND_GROUP=Dimension\n"); + strcat(utlbuf, "\t\tGROUP=DimensionMap\n"); + strcat(utlbuf, "\t\tEND_GROUP=DimensionMap\n"); + strcat(utlbuf, "\t\tGROUP=IndexDimensionMap\n"); + strcat(utlbuf, "\t\tEND_GROUP=IndexDimensionMap\n"); + strcat(utlbuf, "\t\tGROUP=GeoField\n"); + strcat(utlbuf, "\t\tEND_GROUP=GeoField\n"); + strcat(utlbuf, "\t\tGROUP=DataField\n"); + strcat(utlbuf, "\t\tEND_GROUP=DataField\n"); + strcat(utlbuf, "\t\tGROUP=MergedFields\n"); + strcat(utlbuf, "\t\tEND_GROUP=MergedFields\n"); + sprintf(utlbuf2, "%s%ld%s", + "\tEND_GROUP=SWATH_", (long)nSwath + 1, "\n"); + strcat(utlbuf, utlbuf2); + + + status = EHinsertmeta(sdInterfaceID, "", "s", 1001L, + utlbuf, NULL); + } + } + else + { + /* Too many files opened */ + /* --------------------- */ + status = -1; + strcpy(errbuf, + "No more than %d swaths may be open simutaneously"); + strcat(errbuf, " (%s)"); + HEpush(DFE_DENIED, "SWcreate", __FILE__, __LINE__); + HEreport(errbuf, NSWATH, swathname); + } + + + /* Assign swathID # & Load swath and SWXSwath table entries */ + /* -------------------------------------------------------- */ + if (status == 0) + { + + for (i = 0; i < NSWATH; i++) + { + if (SWXSwath[i].active == 0) + { + /* + * Set swathID, Set swath entry active, Store root Vgroup + * ID, Store sub Vgroup IDs, Store HDF-EOS file ID + */ + swathID = i + idOffset; + SWXSwath[i].active = 1; + SWXSwath[i].IDTable = vgid[0]; + SWXSwath[i].VIDTable[0] = vgid[1]; + SWXSwath[i].VIDTable[1] = vgid[2]; + SWXSwath[i].VIDTable[2] = vgid[3]; + SWXSwath[i].fid = fid; + status = 0; + break; + } + } + + } + } + return (swathID); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWattach | +| | +| DESCRIPTION: Attaches to an existing swath within the file. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| swathID int32 swath structure ID | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| swathname char swath structure name | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Apr 99 David Wynne Modified test for memory allocation check when no | +| SDSs are in the Swath, NCR22513 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWattach(int32 fid, char *swathname) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn nswathopen = 0; /* # of swath structures open */ + intn status; /* routine return status variable */ + + uint8 acs; /* Read/Write file access code */ + + int32 HDFfid; /* HDF file id */ + int32 vgRef; /* Vgroup reference number */ + int32 vgid[4]; /* Vgroup ID array */ + int32 swathID = -1; /* HDF-EOS swath ID */ + int32 *tags; /* Pnt to Vgroup object tags array */ + int32 *refs; /* Pnt to Vgroup object refs array */ + int32 dum; /* dummy varible */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 nObjects; /* # of objects in Vgroup */ + int32 nSDS; /* SDS counter */ + int32 index; /* SDS index */ + int32 sdid; /* SDS object ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char name[80]; /* Vgroup name */ + char class[80]; /* Vgroup class */ + char errbuf[256];/* Buffer for error message */ + char acsCode[1]; /* Read/Write access char: "r/w" */ + + + /* Check HDF-EOS file ID, get back HDF file ID and access code */ + /* ----------------------------------------------------------- */ + status = EHchkfid(fid, swathname, &HDFfid, &dum, &acs); + + + if (status == 0) + { + /* Convert numeric access code to character */ + /* ---------------------------------------- */ + acsCode[0] = (acs == 1) ? 'w' : 'r'; + + /* Determine number of swaths currently opened */ + /* ------------------------------------------- */ + for (i = 0; i < NSWATH; i++) + { + nswathopen += SWXSwath[i].active; + } + + /* If room for more ... */ + /* -------------------- */ + if (nswathopen < NSWATH) + { + + /* Search Vgroups for Swath */ + /* ------------------------ */ + vgRef = -1; + + while (1) + { + vgRef = Vgetid(HDFfid, vgRef); + + + /* If no more Vgroups then exist while loop */ + /* ---------------------------------------- */ + if (vgRef == -1) + { + break; + } + + /* Get name and class of Vgroup */ + /* ---------------------------- */ + vgid[0] = Vattach(HDFfid, vgRef, "r"); + Vgetname(vgid[0], name); + Vgetclass(vgid[0], class); + + + /* + * If Vgroup with swathname and class SWATH found, load + * tables + */ + + if (strcmp(name, swathname) == 0 && + strcmp(class, "SWATH") == 0) + { + /* Attach to "Fields" and "Swath Attributes" Vgroups */ + /* ------------------------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * 3); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * 3); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + free(tags); + return(-1); + } + Vgettagrefs(vgid[0], tags, refs, 3); + vgid[1] = Vattach(HDFfid, refs[0], acsCode); + vgid[2] = Vattach(HDFfid, refs[1], acsCode); + vgid[3] = Vattach(HDFfid, refs[2], acsCode); + free(tags); + free(refs); + + /* Setup External Arrays */ + /* --------------------- */ + for (i = 0; i < NSWATH; i++) + { + /* Find empty entry in array */ + /* ------------------------- */ + if (SWXSwath[i].active == 0) + { + /* + * Set swathID, Set swath entry active, Store + * root Vgroup ID, Store sub Vgroup IDs, Store + * HDF-EOS file ID + */ + swathID = i + idOffset; + SWXSwath[i].active = 1; + SWXSwath[i].IDTable = vgid[0]; + SWXSwath[i].VIDTable[0] = vgid[1]; + SWXSwath[i].VIDTable[1] = vgid[2]; + SWXSwath[i].VIDTable[2] = vgid[3]; + SWXSwath[i].fid = fid; + break; + } + } + + /* Get SDS interface ID */ + /* -------------------- */ + status = SWchkswid(swathID, "SWattach", &dum, + &sdInterfaceID, &dum); + + + /* Access swath "Geolocation" SDS */ + /* ------------------------------ */ + + /* Get # of entries within this Vgroup & search for SDS */ + /* ---------------------------------------------------- */ + nObjects = Vntagrefs(vgid[1]); + + if (nObjects > 0) + { + /* Get tag and ref # for Geolocation Vgroup objects */ + /* ------------------------------------------------ */ + tags = (int32 *) malloc(sizeof(int32) * nObjects); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * nObjects); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + free(tags); + return(-1); + } + Vgettagrefs(vgid[1], tags, refs, nObjects); + + /* Count number of SDS & allocate SDS ID array */ + /* ------------------------------------------- */ + nSDS = 0; + for (j = 0; j < nObjects; j++) + { + if (tags[j] == DFTAG_NDG) + { + nSDS++; + } + } + SWXSwath[i].sdsID = (int32 *) calloc(nSDS, 4); + if(SWXSwath[i].sdsID == NULL && nSDS != 0) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + free(tags); + free(refs); + return(-1); + } + nSDS = 0; + + + /* Fill SDS ID array */ + /* ----------------- */ + for (j = 0; j < nObjects; j++) + { + /* If object is SDS then get id */ + /* ---------------------------- */ + if (tags[j] == DFTAG_NDG) + { + index = SDreftoindex(sdInterfaceID, refs[j]); + sdid = SDselect(sdInterfaceID, index); + SWXSwath[i].sdsID[nSDS] = sdid; + nSDS++; + SWXSwath[i].nSDS++; + } + } + free(tags); + free(refs); + } + + /* Access swath "Data" SDS */ + /* ----------------------- */ + + /* Get # of entries within this Vgroup & search for SDS */ + /* ---------------------------------------------------- */ + nObjects = Vntagrefs(vgid[2]); + + if (nObjects > 0) + { + /* Get tag and ref # for Data Vgroup objects */ + /* ----------------------------------------- */ + tags = (int32 *) malloc(sizeof(int32) * nObjects); + if(tags == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + return(-1); + } + refs = (int32 *) malloc(sizeof(int32) * nObjects); + if(refs == NULL) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + free(tags); + return(-1); + } + Vgettagrefs(vgid[2], tags, refs, nObjects); + + + /* Count number of SDS & allocate SDS ID array */ + /* ------------------------------------------- */ + nSDS = 0; + for (j = 0; j < nObjects; j++) + { + if (tags[j] == DFTAG_NDG) + { + nSDS++; + } + } + SWXSwath[i].sdsID = (int32 *) + realloc((void *) SWXSwath[i].sdsID, + (SWXSwath[i].nSDS + nSDS) * 4); + if(SWXSwath[i].sdsID == NULL && nSDS != 0) + { + HEpush(DFE_NOSPACE,"SWattach", __FILE__, __LINE__); + return(-1); + } + + /* Fill SDS ID array */ + /* ----------------- */ + for (j = 0; j < nObjects; j++) + { + /* If object is SDS then get id */ + /* ---------------------------- */ + if (tags[j] == DFTAG_NDG) + { + index = SDreftoindex(sdInterfaceID, refs[j]); + sdid = SDselect(sdInterfaceID, index); + SWXSwath[i].sdsID[SWXSwath[i].nSDS] = sdid; + SWXSwath[i].nSDS++; + } + } + free(tags); + free(refs); + } + break; + } + + /* Detach Vgroup if not desired Swath */ + /* ---------------------------------- */ + Vdetach(vgid[0]); + } + + /* If Swath not found then set up error message */ + /* -------------------------------------------- */ + if (swathID == -1) + { + HEpush(DFE_RANGE, "SWattach", __FILE__, __LINE__); + HEreport("Swath: \"%s\" does not exist within HDF file.\n", + swathname); + } + } + else + { + /* Too many files opened */ + /* --------------------- */ + swathID = -1; + strcpy(errbuf, + "No more than %d swaths may be open simutaneously"); + strcat(errbuf, " (%s)"); + HEpush(DFE_DENIED, "SWattach", __FILE__, __LINE__); + HEreport(errbuf, NSWATH, swathname); + } + + } + return (swathID); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWchkswid | +| | +| DESCRIPTION: Checks for valid swathID and returns file ID, SDS ID, and | +| swath Vgroup ID | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| routname char Name of routine calling SWchkswid | +| | +| OUTPUTS: | +| fid int32 File ID | +| sdInterfaceID int32 SDS interface ID | +| swVgrpID int32 swath Vgroup ID | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWchkswid(int32 swathID, char *routname, + int32 * fid, int32 * sdInterfaceID, int32 * swVgrpID) + +{ + intn status = 0; /* routine return status variable */ + uint8 access; /* Read/Write access code */ + + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char message1[] = + "Invalid swath id: %d in routine \"%s\". ID must be >= %d and < %d.\n"; + char message2[] = + "Swath id %d in routine \"%s\" not active.\n"; + + + /* Check for valid swath id */ + /* ------------------------ */ + if (swathID < idOffset || swathID >= NSWATH + idOffset) + { + status = -1; + HEpush(DFE_RANGE, "SWchkswid", __FILE__, __LINE__); + HEreport(message1, swathID, routname, idOffset, NSWATH + idOffset); + } + else + { + /* Check for active swath ID */ + /* ------------------------- */ + if (SWXSwath[swathID % idOffset].active == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWchkswid", __FILE__, __LINE__); + HEreport(message2, swathID, routname); + } + else + { + + /* Get file & SDS ids and Swath Vgroup */ + /* ----------------------------------- */ + status = EHchkfid(SWXSwath[swathID % idOffset].fid, " ", fid, + sdInterfaceID, &access); + *swVgrpID = SWXSwath[swathID % idOffset].IDTable; + } + } + return (status); +} + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefdim | +| | +| DESCRIPTION: Defines numerical value of dimension | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| dimname char Dimension name to define | +| dim int32 Dimemsion value | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Dec 96 Joel Gales Check that dim value >= 0 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefdim(int32 swathID, char *dimname, int32 dim) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file id */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char swathname[80] /* Swath name */ ; + + + /* Check for valid swath id */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWdefdim", &fid, &sdInterfaceID, &swVgrpID); + + + /* Make sure dimension >= 0 */ + /* ------------------------ */ + if (dim < 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefdim", __FILE__, __LINE__); + HEreport("Dimension value for \"%s\" less than zero: %d.\n", + dimname, dim); + } + + + /* Write Dimension to Structural MetaData */ + /* -------------------------------------- */ + if (status == 0) + { + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + status = EHinsertmeta(sdInterfaceID, swathname, "s", 0L, + dimname, &dim); + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdiminfo | +| | +| DESCRIPTION: Returns size in bytes of named dimension | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| size int32 Size of dimension | +| | +| INPUTS: | +| swathID int32 swath structure id | +| dimname char Dimension name | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdiminfo(int32 swathID, char *dimname) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 size; /* Dimension size */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWdiminfo", __FILE__, __LINE__); + return(-1); + } + /* Initialize return value */ + size = -1; + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWdiminfo", &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "Dimension" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "Dimension", metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + /* Search for dimension name (surrounded by quotes) */ + sprintf(utlstr, "%s%s%s", "\"", dimname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* + * If dimension found within swath structure then get dimension value + */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Set endptr at end of dimension definition entry */ + metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT"); + + status = EHgetmetavalue(metaptrs, "Size", utlstr); + + if (status == 0) + { + size = atol(utlstr); + } + else + { + HEpush(DFE_GENAPP, "SWdiminfo", __FILE__, __LINE__); + HEreport("\"Size\" string not found in metadata.\n"); + } + } + else + { + HEpush(DFE_GENAPP, "SWdiminfo", __FILE__, __LINE__); + HEreport("Dimension \"%s\" not found.\n", dimname); + } + + free(metabuf); + } + free(utlstr); + + return (size); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWmapinfo | +| | +| DESCRIPTION: Returns dimension mapping information | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure id | +| geodim char geolocation dimension name | +| datadim char data dimension name | +| | +| OUTPUTS: | +| offset int32 mapping offset | +| increment int32 mapping increment | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWmapinfo(int32 swathID, char *geodim, char *datadim, int32 * offset, + int32 * increment) + +{ + intn status; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWmapinfo", __FILE__, __LINE__); + return(-1); + } + /* Initialize return values */ + *offset = -1; + *increment = -1; + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWmapinfo", &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "DimensionMap" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DimensionMap", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + /* Search for mapping - GeoDim/DataDim (surrounded by quotes) */ + sprintf(utlstr, "%s%s%s%s%s", "\t\t\t\tGeoDimension=\"", geodim, + "\"\n\t\t\t\tDataDimension=\"", datadim, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* + * If mapping found within swath structure then get offset and + * increment value + */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Offset */ + statmeta = EHgetmetavalue(metaptrs, "Offset", utlstr); + if (statmeta == 0) + { + *offset = atol(utlstr); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__); + HEreport("\"Offset\" string not found in metadata.\n"); + } + + + /* Get Increment */ + statmeta = EHgetmetavalue(metaptrs, "Increment", utlstr); + if (statmeta == 0) + { + *increment = atol(utlstr); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__); + HEreport("\"Increment\" string not found in metadata.\n"); + } + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWmapinfo", __FILE__, __LINE__); + HEreport("Mapping \"%s/%s\" not found.\n", geodim, datadim); + } + + free(metabuf); + } + free(utlstr); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWidxmapinfo | +| | +| DESCRIPTION: Returns indexed mapping information | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| gsize int32 Number of index values (sz of geo dim) | +| | +| INPUTS: | +| swathID int32 swath structure id | +| geodim char geolocation dimension name | +| datadim char data dimension name | +| | +| | +| OUTPUTS: | +| index int32 array of index values | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWidxmapinfo(int32 swathID, char *geodim, char *datadim, int32 index[]) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 vgid; /* Swath Attributes Vgroup ID */ + int32 vdataID; /* Index Mapping Vdata ID */ + int32 gsize = -1; /* Size of geo dim */ + + char utlbuf[256];/* Utility buffer */ + + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWidxmapinfo", + &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Find Index Mapping Vdata with Swath Attributes Vgroup */ + sprintf(utlbuf, "%s%s%s%s", "INDXMAP:", geodim, "/", datadim); + vgid = SWXSwath[swathID % idOffset].VIDTable[2]; + vdataID = EHgetid(fid, vgid, utlbuf, 1, "r"); + + /* If found then get geodim size & read index mapping values */ + if (vdataID != -1) + { + gsize = SWdiminfo(swathID, geodim); + + VSsetfields(vdataID, "Index"); + VSread(vdataID, (uint8 *) index, 1, FULL_INTERLACE); + VSdetach(vdataID); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWidxmapinfo", __FILE__, __LINE__); + HEreport("Index Mapping \"%s\" not found.\n", utlbuf); + } + } + return (gsize); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWcompinfo | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn | +| | +| INPUTS: | +| swathID int32 | +| compcode int32 | +| compparm intn | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWcompinfo(int32 swathID, char *fieldname, int32 * compcode, intn compparm[]) +{ + intn i; /* Loop Index */ + intn status; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + + char *HDFcomp[5] = {"HDFE_COMP_NONE", "HDFE_COMP_RLE", + "HDFE_COMP_NBIT", "HDFE_COMP_SKPHUFF", + "HDFE_COMP_DEFLATE"}; /* Compression Codes */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWcompinfo", __FILE__, __LINE__); + return(-1); + } + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWcompinfo", + &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "DataField" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + /* Search for field */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* If not found then search in "GeoField" section */ + if (metaptrs[0] > metaptrs[1] || metaptrs[0] == NULL) + { + free(metabuf); + + /* Get pointers to "GeoField" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "GeoField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + /* Search for field */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + } + + + /* If field found and user wants compression code ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + if (compcode != NULL) + { + /* Set endptr at end of field's definition entry */ + metaptrs[1] = strstr(metaptrs[0], "\t\t\tEND_OBJECT"); + + /* Get compression type */ + statmeta = EHgetmetavalue(metaptrs, "CompressionType", utlstr); + + /* + * Default is no compression if "CompressionType" string not + * in metadata + */ + *compcode = HDFE_COMP_NONE; + + /* If compression code is found ... */ + if (statmeta == 0) + { + /* Loop through compression types until match */ + for (i = 0; i < 5; i++) + { + if (strcmp(utlstr, HDFcomp[i]) == 0) + { + *compcode = i; + break; + } + } + } + } + + /* If user wants compression parameters ... */ + if (compparm != NULL && compcode != NULL) + { + /* Initialize to zero */ + for (i = 0; i < 4; i++) + { + compparm[i] = 0.0; + } + + /* + * Get compression parameters if NBIT or DEFLATE compression + */ + if (*compcode == HDFE_COMP_NBIT) + { + statmeta = + EHgetmetavalue(metaptrs, "CompressionParams", utlstr); + if (statmeta == 0) + { + sscanf(utlstr, "(%d,%d,%d,%d)", + &compparm[0], &compparm[1], + &compparm[2], &compparm[3]); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWcompinfo", __FILE__, __LINE__); + HEreport( + "\"CompressionParams\" string not found in metadata.\n"); + } + } + else if (*compcode == HDFE_COMP_DEFLATE) + { + statmeta = + EHgetmetavalue(metaptrs, "DeflateLevel", utlstr); + if (statmeta == 0) + { + sscanf(utlstr, "%d", &compparm[0]); + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWcompinfo", __FILE__, __LINE__); + HEreport( + "\"DeflateLevel\" string not found in metadata.\n"); + } + } + } + } + else + { + HEpush(DFE_GENAPP, "SWcompinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + + free(metabuf); + } + free(utlstr); + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWfinfo | +| | +| DESCRIPTION: Returns field info | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure id | +| fieldtype char fieldtype (geo or data) | +| fieldname char name of field | +| | +| | +| OUTPUTS: | +| rank int32 rank of field (# of dims) | +| dims int32 field dimensions | +| numbertype int32 field number type | +| dimlist char field dimension list | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Jan 97 Joel Gales Check for metadata error status from EHgetmetavalue | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWfinfo(int32 swathID, char *fieldtype, char *fieldname, int32 *rank, + int32 dims[], int32 *numbertype, char *dimlist) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn status; /* routine return status variable */ + intn statmeta = 0; /* EHgetmetavalue return status */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 fsize; /* field size in bytes */ + int32 ndims; /* Number of dimensions */ + int32 slen[8]; /* Length of each entry in parsed string */ + int32 dum; /* Dummy variable */ + int32 vdataID; /* 1d field vdata ID */ + + uint8 *buf; /* One-Dim field buffer */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + char *ptr[8]; /* String pointers for parsed string */ + char dimstr[64]; /* Individual dimension entry string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWfinfo", __FILE__, __LINE__); + return(-1); + } + + /* Initialize rank and numbertype to -1 (error) */ + /* -------------------------------------------- */ + *rank = -1; + *numbertype = -1; + + /* Get HDF-EOS file ID and SDS interface ID */ + status = SWchkswid(swathID, "SWfinfo", &fid, &sdInterfaceID, &dum); + + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to appropriate "Field" section within SM */ + if (strcmp(fieldtype, "Geolocation Fields") == 0) + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "GeoField", metaptrs); + + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + } + else + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + } + + + /* Search for field */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* If field found ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get DataType string */ + statmeta = EHgetmetavalue(metaptrs, "DataType", utlstr); + + /* Convert to numbertype code */ + if (statmeta == 0) + { + if (strcmp(utlstr, "DFNT_UCHAR8") == 0) + *numbertype = 3; + else if (strcmp(utlstr, "DFNT_CHAR8") == 0) + *numbertype = 4; + else if (strcmp(utlstr, "DFNT_FLOAT32") == 0) + *numbertype = 5; + else if (strcmp(utlstr, "DFNT_FLOAT64") == 0) + *numbertype = 6; + else if (strcmp(utlstr, "DFNT_INT8") == 0) + *numbertype = 20; + else if (strcmp(utlstr, "DFNT_UINT8") == 0) + *numbertype = 21; + else if (strcmp(utlstr, "DFNT_INT16") == 0) + *numbertype = 22; + else if (strcmp(utlstr, "DFNT_UINT16") == 0) + *numbertype = 23; + else if (strcmp(utlstr, "DFNT_INT32") == 0) + *numbertype = 24; + else if (strcmp(utlstr, "DFNT_UINT32") == 0) + *numbertype = 25; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWfieldinfo", __FILE__, __LINE__); + HEreport( + "\"DataType\" string not found in metadata.\n"); + } + + + /* + * Get DimList string and trim off leading and trailing parens "()" + */ + statmeta = EHgetmetavalue(metaptrs, "DimList", utlstr); + + if (statmeta == 0) + { + memmove(utlstr, utlstr + 1, strlen(utlstr) - 2); + utlstr[strlen(utlstr) - 2] = 0; + + /* Parse trimmed DimList string and get rank */ + ndims = EHparsestr(utlstr, ',', ptr, slen); + *rank = ndims; + } + else + { + status = -1; + HEpush(DFE_GENAPP, "SWfieldinfo", __FILE__, __LINE__); + HEreport( + "\"DimList\" string not found in metadata.\n"); + } + + /* If dimension list is desired by user then initialize length to 0 */ + if (dimlist != NULL) + { + dimlist[0] = 0; + } + + /* + * Copy each entry in DimList and remove leading and trailing quotes, + * Get dimension sizes and concatanate dimension names to dimension + * list + */ + for (i = 0; i < ndims; i++) + { + memcpy(dimstr, ptr[i] + 1, slen[i] - 2); + dimstr[slen[i] - 2] = 0; + dims[i] = SWdiminfo(swathID, dimstr); + if (dimlist != NULL) + { + if (i > 0) + { + strcat(dimlist, ","); + } + strcat(dimlist, dimstr); + } + + } + + + /* Appendable Field Section */ + /* ------------------------ */ + if (dims[0] == 0) + { + /* One-Dimensional Field */ + if (*rank == 1) + { + /* Get vdata ID */ + status = SW1dfldsrch(fid, swathID, fieldname, "r", + &dum, &vdataID, &dum); + + /* Get actual size of field */ + dims[0] = VSelts(vdataID); + + /* + * If size=1 then check where actual record of + * "initialization" record + */ + if (dims[0] == 1) + { + /* Get record size and read 1st record */ + fsize = VSsizeof(vdataID, fieldname); + buf = (uint8 *) calloc(fsize, 1); + if(buf == NULL) + { + HEpush(DFE_NOSPACE,"SWfinfo", __FILE__, __LINE__); + free(utlstr); + return(-1); + } + VSsetfields(vdataID, fieldname); + VSseek(vdataID, 0); + VSread(vdataID, (uint8 *) buf, 1, FULL_INTERLACE); + + /* Sum up "bytes" in record */ + for (i = 0, j = 0; i < fsize; i++) + { + j += buf[i]; + } + + /* + * If filled with 255 then "initialization" record, + * actual number of records = 0 + */ + if (j == 255 * fsize) + { + dims[0] = 0; + } + + free(buf); + } + /* Detach from 1d field */ + VSdetach(vdataID); + } + else + { + /* Get actual size of Multi-Dimensional Field */ + status = SWSDfldsrch(swathID, sdInterfaceID, fieldname, + &dum, &dum, &dum, &dum, dims, + &dum); + } + } + } + free(metabuf); + + if (*rank == -1) + { + status = -1; + } + free(utlstr); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWfieldinfo | +| | +| DESCRIPTION: Wrapper arount SWfinfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure id | +| fieldname char name of field | +| | +| | +| OUTPUTS: | +| rank int32 rank of field (# of dims) | +| dims int32 field dimensions | +| numbertype int32 field number type | +| dimlist char field dimension list | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWfieldinfo(int32 swathID, char *fieldname, int32 * rank, int32 dims[], + int32 * numbertype, char *dimlist) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWfieldinfo", &fid, + &sdInterfaceID, &swVgrpID); + if (status == 0) + { + /* Check for field within Geolocatation Fields */ + status = SWfinfo(swathID, "Geolocation Fields", fieldname, + rank, dims, numbertype, dimlist); + + /* If not there then check within Data Fields */ + if (status == -1) + { + status = SWfinfo(swathID, "Data Fields", fieldname, + rank, dims, numbertype, dimlist); + } + + /* If not there either then can't be found */ + if (status == -1) + { + HEpush(DFE_GENAPP, "SWfieldinfo", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" not found.\n", fieldname); + } + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWfldinfo | +| | +| DESCRIPTION: FORTRAN wrapper arount SWfieldinfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure id | +| fieldname char name of field | +| | +| | +| OUTPUTS: | +| rank int32 rank of field (# of dims) | +| dims int32 field dimensions | +| numbertype int32 field number type | +| fortdimlist char field dimension list (FORTRAN order) | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales Perform swap only if SWfieldinfo succesful | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWfldinfo(int32 swathID, char *fieldname, int32 * rank, int32 dims[], + int32 * numbertype, char *fortdimlist) +{ + intn j; /* Loop Index */ + intn status; /* routine return status variable */ + + int32 swap; /* Temporary swap entry for dimension sizes */ + char *dimlist;/* Dimension list in C order */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"SWfldinfo", __FILE__, __LINE__); + return(-1); + } + + /* Get field info */ + status = SWfieldinfo(swathID, fieldname, rank, dims, + numbertype, dimlist); + + /* If no error then reverse order of dimension sizes */ + if (status == 0) + { + for (j = 0; j < *rank / 2; j++) + { + swap = dims[*rank - 1 - j]; + dims[*rank - 1 - j] = dims[j]; + dims[j] = swap; + } + + /* Reverse order of dimensions entries in dimension list */ + EHrevflds(dimlist, fortdimlist); + } + + free(dimlist); + return (status); + +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefdimmap | +| | +| DESCRIPTION: Defines mapping between geolocation and data dimensions | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| geodim char Geolocation dimension | +| datadim char Data dimension | +| offset int32 Mapping offset | +| increment int32 Mapping increment | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefdimmap(int32 swathID, char *geodim, char *datadim, int32 offset, + int32 increment) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 size; /* Size of geo dim */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 dum; /* Dummy variable */ + int32 metadata[2];/* Offset & Increment (passed to metadata) */ + + char mapname[80];/* Mapping name (geodim/datadim) */ + char swathname[80]; /* Swath name */ + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWdefdimmap", &fid, &sdInterfaceID, &dum); + + if (status == 0) + { + + /* Search Dimension Vdata for dimension entries */ + /* -------------------------------------------- */ + size = SWdiminfo(swathID, geodim); + if (size == -1) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefdimmap", __FILE__, __LINE__); + HEreport("Geolocation dimension name: \"%s\" not found.\n", + geodim); + } + /* Data Dimension Search */ + /* --------------------- */ + if (status == 0) + { + size = SWdiminfo(swathID, datadim); + if (size == -1) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefdimmap", __FILE__, __LINE__); + HEreport("Data dimension name: \"%s\" not found.\n", + datadim); + } + } + + /* Write Dimension Map to Structural MetaData */ + /* ------------------------------------------ */ + if (status == 0) + { + sprintf(mapname, "%s%s%s", geodim, "/", datadim); + metadata[0] = offset; + metadata[1] = increment; + + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + status = EHinsertmeta(sdInterfaceID, swathname, "s", 1L, + mapname, metadata); + + } + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefidxmap | +| | +| DESCRIPTION: Defines indexed (non-linear) mapping between geolocation | +| and data dimensions | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| geodim char Geolocation dimension | +| datadim char Data dimension | +| index int32 Index mapping array | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefidxmap(int32 swathID, char *geodim, char *datadim, int32 index[]) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 attrVgrpID; /* Swath attribute ID */ + int32 vdataID; /* Mapping Index Vdata ID */ + int32 gsize; /* Size of geo dim */ + int32 dsize; /* Size of data dim */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 dum; /* Dummy variable */ + + uint8 *buf; /* Vdata field buffer */ + + char mapname[80];/* Mapping name (geodim/datadim) */ + char swathname[80]; /* Swath name */ + char utlbuf[256];/* Utility buffer */ + + + /* Check Swath ID */ + status = SWchkswid(swathID, "SWdefidxmap", &fid, &sdInterfaceID, &dum); + if (status == 0) + { + /* Search Dimension Vdata for dimension entries */ + /* -------------------------------------------- */ + + /* Geo Dimension Search */ + /* -------------------- */ + + gsize = SWdiminfo(swathID, geodim); + + if (gsize == -1) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefidxmap", __FILE__, __LINE__); + HEreport("Geolocation dimension name: \"%s\" not found.\n", + geodim); + } + /* Data Dimension Search */ + /* --------------------- */ + if (status == 0) + { + dsize = SWdiminfo(swathID, datadim); + if (dsize == -1) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefidxmap", __FILE__, __LINE__); + HEreport("Data dimension name: \"%s\" not found.\n", + datadim); + } + } + /* Define Index Vdata and Store Index Array */ + /* ---------------------------------------- */ + if (status == 0) + { + /* Get attribute Vgroup ID and allocate data buffer */ + /* ------------------------------------------------ */ + attrVgrpID = SWXSwath[swathID % idOffset].VIDTable[2]; + buf = (uint8 *) calloc(4 * gsize, 1); + if(buf == NULL) + { + HEpush(DFE_NOSPACE,"SWdefidxmap", __FILE__, __LINE__); + return(-1); + } + + /* Name: "INDXMAP:" + geodim + "/" + datadim */ + sprintf(utlbuf, "%s%s%s%s", "INDXMAP:", geodim, "/", datadim); + + vdataID = VSattach(fid, -1, "w"); + VSsetname(vdataID, utlbuf); + + /* Attribute Class */ + VSsetclass(vdataID, "Attr0.0"); + + /* Fieldname is "Index" */ + VSfdefine(vdataID, "Index", DFNT_INT32, gsize); + VSsetfields(vdataID, "Index"); + memcpy(buf, index, 4 * gsize); + + /* Write to vdata and free data buffer */ + VSwrite(vdataID, buf, 1, FULL_INTERLACE); + free(buf); + + /* Insert in Attribute Vgroup and detach Vdata */ + Vinsert(attrVgrpID, vdataID); + VSdetach(vdataID); + + + /* Write to Structural Metadata */ + sprintf(mapname, "%s%s%s", geodim, "/", datadim); + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + status = EHinsertmeta(sdInterfaceID, swathname, "s", 2L, + mapname, &dum); + + } + } + return (status); + +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefcomp | +| | +| DESCRIPTION: Defines compression type and parameters | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| compcode int32 compression code | +| compparm intn compression parameters | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Sep 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefcomp(int32 swathID, int32 compcode, intn compparm[]) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file id */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 sID; /* swathID - offset */ + + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWdefcomp", &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + sID = swathID % idOffset; + + /* Set compression code in compression exteral array */ + SWXSwath[sID].compcode = compcode; + + switch (compcode) + { + /* Set NBIT compression parameters in compression external array */ + case HDFE_COMP_NBIT: + + SWXSwath[sID].compparm[0] = compparm[0]; + SWXSwath[sID].compparm[1] = compparm[1]; + SWXSwath[sID].compparm[2] = compparm[2]; + SWXSwath[sID].compparm[3] = compparm[3]; + + break; + + /* Set GZIP compression parameter in compression external array */ + case HDFE_COMP_DEFLATE: + + SWXSwath[sID].compparm[0] = compparm[0]; + + break; + + } + } + + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefinefield | +| | +| DESCRIPTION: Defines geolocation or data field within swath structure | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldtype char geo/data fieldtype | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| merge int32 merge code | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Check name for length | +| Sep 96 Joel Gales Make string array "dimbuf" dynamic | +| Oct 96 Joel Gales Make sure total length of "merged" Vdata < 64 | +| Jun 03 Abe Taaheri Supplied cast comp_coder_t in call to SDsetcompress | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefinefield(int32 swathID, char *fieldtype, char *fieldname, char *dimlist, + int32 numbertype, int32 merge) + +{ + intn i; /* Loop index */ + intn status; /* routine return status variable */ + intn found; /* utility found flag */ + intn foundNT = 0;/* found number type flag */ + intn foundAllDim = 1; /* found all dimensions flag */ + intn first = 1; /* first entry flag */ + intn fac; /* Geo (-1), Data (+1) field factor */ + int32 cnt = 0; + + int32 fid; /* HDF-EOS file ID */ + int32 vdataID; /* Vdata ID */ + int32 vgid; /* Geo/Data field Vgroup ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 sdid; /* SDS object ID */ + int32 dimid; /* SDS dimension ID */ + int32 recSize; /* Vdata record size */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 dims[8]; /* Dimension size array */ + int32 dimsize; /* Dimension size */ + int32 rank = 0; /* Field rank */ + int32 slen[32]; /* String length array */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 compcode; /* Compression code */ + int32 sID; /* SwathID - offset */ + + uint8 *oneDbuf; /* Vdata record buffer */ + char *dimbuf; /* Dimension buffer */ + char *comma; /* Pointer to comma */ + char *dimcheck; /* Dimension check buffer */ + char utlbuf[512];/* Utility buffer */ + char utlbuf2[256]; /* Utility buffer 2 */ + char *ptr[32]; /* String pointer array */ + char swathname[80]; /* Swath name */ + char errbuf1[128]; /* Error message buffer 1 */ + char errbuf2[128]; /* Error message buffer 2 */ + char compparmbuf[128]; /* Compression parmeter string buffer */ + + char *HDFcomp[5] = {"HDFE_COMP_NONE", "HDFE_COMP_RLE", + "HDFE_COMP_NBIT", "HDFE_COMP_SKPHUFF", + "HDFE_COMP_DEFLATE"}; + /* Compression code names */ + + uint16 good_number[10] = {3, 4, 5, 6, 20, 21, 22, 23, 24, 25}; + /* Valid number types */ + comp_info c_info; /* Compression parameter structure */ + + + + /* Setup error message strings */ + /* --------------------------- */ + strcpy(errbuf1, "SWXSDname array too small.\nPlease increase "); + strcat(errbuf1, "size of HDFE_NAMBUFSIZE in \"HdfEosDef.h\".\n"); + strcpy(errbuf2, "SWXSDdims array too small.\nPlease increase "); + strcat(errbuf2, "size of HDFE_DIMBUFSIZE in \"HdfEosDef.h\".\n"); + + + + /* + * Check for proper swath ID and return HDF-EOS file ID, SDinterface ID, + * and swath root Vgroup ID + */ + status = SWchkswid(swathID, "SWdefinefield", + &fid, &sdInterfaceID, &swVgrpID); + + + if (status == 0) + { + /* Remove offset from swath ID & get swathname */ + sID = swathID % idOffset; + Vgetname(swVgrpID, swathname); + + /* Allocate space for dimbuf, copy dimlist into it, & append comma */ + dimbuf = (char *) calloc(strlen(dimlist) + 64, 1); + if(dimbuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + return(-1); + } + strcpy(dimbuf, dimlist); + strcat(dimbuf, ","); + + /* Find comma */ + comma = strchr(dimbuf, ','); + + + /* + * Loop through entries in dimension list to make sure they are + * defined in swath + */ + while (comma != NULL) + { + /* Copy dimension list entry to dimcheck */ + dimcheck = (char *) calloc(comma - dimbuf + 1, 1); + if(dimcheck == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + free(dimbuf); + return(-1); + } + memcpy(dimcheck, dimbuf, comma - dimbuf); + + /* Get dimension size */ + dimsize = SWdiminfo(swathID, dimcheck); + + /* if != -1 then sent found flag, store size and increment rank */ + if (dimsize != -1) + { + dims[rank] = dimsize; + rank++; + } + else + { + /* + * If dimension list entry not found - set error return + * status, append name to utility buffer for error report + */ + status = -1; + foundAllDim = 0; + if (first == 1) + { + strcpy(utlbuf, dimcheck); + } + else + { + strcat(utlbuf, ","); + strcat(utlbuf, dimcheck); + } + first = 0; + } + + /* + * Go to next dimension entry, find next comma, & free up + * dimcheck buffer + */ + *comma = '\0'; /* zero out first comma */ + comma++; + comma = strchr(comma, ','); + if (comma != NULL) + { + for (i=0; i<strlen(dimcheck) + 1; i++) + { + dimbuf++; + cnt++; + } + } + free(dimcheck); + } + for(i=0; i<cnt; i++) + dimbuf--; + + free(dimbuf); + + + /* Check that UNLIMITED dimension is first dimension if present */ + /* ------------------------------------------------------------ */ + if (status == 0) + { + for (i = 0; i < rank; i++) + { + if (dims[i] == 0 && i != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefinefield", __FILE__, __LINE__); + HEreport("UNLIMITED dimension must be first dimension.\n"); + } + } + } + + + /* Check fieldname length */ + /* ---------------------- */ + if (status == 0) + { +/* ((intn) strlen(fieldname) > MAX_NC_NAME - 7) +** this was changed because HDF4.1r3 made a change in the +** hlimits.h file. We have notidfied NCSA and asked to have +** it made the same as in previous versions of HDF +** see ncr 26314. DaW Apr 2000 +*/ + + if (((intn) strlen(fieldname) > VSNAMELENMAX && rank == 1) || + ((intn) strlen(fieldname) > (256 - 7) && rank > 1)) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefinefield", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" too long.\n", fieldname); + } + } + + + + + /* Check for valid numbertype */ + /* -------------------------- */ + if (status == 0) + { + for (i = 0; i < 10; i++) + { + if (numbertype == good_number[i]) + { + foundNT = 1; + } + } + + if (foundNT == 0) + { + HEpush(DFE_BADNUMTYPE, "SWdefinefield", __FILE__, __LINE__); + HEreport("Invalid number type: %d (%s).\n", + numbertype, fieldname); + status = -1; + } + } + + + /* Define Field */ + /* ------------ */ + if (status == 0) + { + /* Set factor & get Field Vgroup id */ + /* -------------------------------- */ + if (strcmp(fieldtype, "Geolocation Fields") == 0) + { + fac = -1; + vgid = SWXSwath[sID].VIDTable[0]; + } + else + { + fac = +1; + vgid = SWXSwath[sID].VIDTable[1]; + } + /* + * Note: "fac" is used to destinguish geo fields from data fields + * so that they are not merged together + */ + + + /* One D Fields */ + /* ------------ */ + if (rank == 1) + { + /* No Compression for 1D (Vdata) fields */ + compcode = HDFE_COMP_NONE; + + + /* If field non-appendable and merge set to AUTOMERGE ... */ + if (dims[0] != 0 && merge == HDFE_AUTOMERGE) + { + i = 0; + found = 0; + + /* Loop through previous entries in 1d combination array */ + while (SWX1dcomb[3 * i] != 0) + { + /* Get name of previous 1d combined field */ + vdataID = SWX1dcomb[3 * i + 2]; + VSgetname(vdataID, utlbuf); + + /* + * If dimension, field type (geo/data), and swath + * structure if current entry match a previous entry + * and combined name is less than max allowed then + * set "found" flag and exit loop + */ + if (SWX1dcomb[3 * i] == fac * dims[0] && + SWX1dcomb[3 * i + 1] == swVgrpID && + (intn) strlen(utlbuf) + + (intn) strlen(fieldname) + 1 <= + VSNAMELENMAX) + { + found = 1; + break; + } + /* Increment loop index */ + i++; + } + + + if (found == 0) + { + /* + * If no matching entry found then start new Vdata + * and store dimension size, swath root Vgroup ID, + * field Vdata and fieldname in external array + * "SWX1dcomb" + */ + vdataID = VSattach(fid, -1, "w"); + SWX1dcomb[3 * i] = fac * dims[0]; + SWX1dcomb[3 * i + 1] = swVgrpID; + SWX1dcomb[3 * i + 2] = vdataID; + VSsetname(vdataID, fieldname); + } + else + { + /* + * If match then concatanate current fieldname to + * previous matching fieldnames + */ + strcat(utlbuf, ","); + strcat(utlbuf, fieldname); + VSsetname(vdataID, utlbuf); + } + + /* Define field as field within Vdata */ + VSfdefine(vdataID, fieldname, numbertype, 1); + Vinsert(vgid, vdataID); + + } + else + { + /* 1d No Merge Section */ + + /* Get new vdata ID and establish field within Vdata */ + vdataID = VSattach(fid, -1, "w"); + VSsetname(vdataID, fieldname); + VSfdefine(vdataID, fieldname, numbertype, 1); + VSsetfields(vdataID, fieldname); + + recSize = VSsizeof(vdataID, fieldname); + if (dims[0] == 0) + { + /* + * If appendable field then write single record + * filled with 255 + */ + oneDbuf = (uint8 *) calloc(recSize, 1); + if(oneDbuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + return(-1); + } + for (i = 0; i < recSize; i++) + oneDbuf[i] = 255; + VSwrite(vdataID, oneDbuf, 1, FULL_INTERLACE); + } + else + { + /* + * If non-appendable then write entire field with + * blank records + */ + oneDbuf = (uint8 *) calloc(recSize, dims[0]); + if(oneDbuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + return(-1); + } + VSwrite(vdataID, oneDbuf, dims[0], FULL_INTERLACE); + } + free(oneDbuf); + + /* Insert Vdata into field Vgroup & detach */ + Vinsert(vgid, vdataID); + VSdetach(vdataID); + + } /* End No Merge Section */ + + } /* End 1d field Section */ + else + { + /* SDS Interface (Multi-dim fields) */ + /* -------------------------------- */ + + /* Get current compression code */ + compcode = SWXSwath[sID].compcode; + + /* + * If rank is less than or equal to 3 (and greater than 1) + * and AUTOMERGE is set and the first dimension is not + * appendable and the compression code is set to none then + * ... + */ + if (rank <= 3 && merge == HDFE_AUTOMERGE && dims[0] != 0 + && compcode == HDFE_COMP_NONE) + { + /* Find first empty slot in external combination array */ + /* --------------------------------------------------- */ + i = 0; + while (SWXSDcomb[5 * i] != 0) + { + i++; + } + + /* + * Store dimensions (with geo/data factor), swath root + * Vgroup ID, and number type in external combination + * array "SWXSDcomb" + */ + + if (rank == 2) + { + /* If 2-dim field then set lowest dimension to +/- 1 */ + SWXSDcomb[5 * i] = fac; + SWXSDcomb[5 * i + 1] = fac * dims[0]; + SWXSDcomb[5 * i + 2] = fac * dims[1]; + } + else + { + SWXSDcomb[5 * i] = fac * dims[0]; + SWXSDcomb[5 * i + 1] = fac * dims[1]; + SWXSDcomb[5 * i + 2] = fac * dims[2]; + } + + SWXSDcomb[5 * i + 3] = swVgrpID; + SWXSDcomb[5 * i + 4] = numbertype; + + + /* Concatanate fieldname with combined name string */ + /* ----------------------------------------------- */ + if ((intn) strlen(SWXSDname) + + (intn) strlen(fieldname) + 2 < HDFE_NAMBUFSIZE) + { + strcat(SWXSDname, fieldname); + strcat(SWXSDname, ","); + } + else + { + /* SWXSDname array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "SWdefinefield", + __FILE__, __LINE__); + HEreport(errbuf1); + status = -1; + return (status); + } + + + + /* + * If 2-dim field then set lowest dimension (in 3-dim + * array) to "ONE" + */ + if (rank == 2) + { + if ((intn) strlen(SWXSDdims) + 5 < HDFE_DIMBUFSIZE) + { + strcat(SWXSDdims, "ONE,"); + } + else + { + /* SWXSDdims array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "SWdefinefield", + __FILE__, __LINE__); + HEreport(errbuf2); + status = -1; + return (status); + } + + } + + /* + * Concatanate field dimlist to merged dimlist and + * separate fields with semi-colon + */ + if ((intn) strlen(SWXSDdims) + + (intn) strlen(dimlist) + 2 < HDFE_DIMBUFSIZE) + { + strcat(SWXSDdims, dimlist); + strcat(SWXSDdims, ";"); + } + else + { + /* SWXSDdims array too small! */ + /* -------------------------- */ + HEpush(DFE_GENAPP, "SWdefinefield", + __FILE__, __LINE__); + HEreport(errbuf2); + status = -1; + return (status); + } + + } /* End Multi-Dim Merge Section */ + else + { + /* Multi-Dim No Merge Section */ + /* ========================== */ + + /* Create SDS dataset */ + /* ------------------ */ + sdid = SDcreate(sdInterfaceID, fieldname, + numbertype, rank, dims); + + + /* Store Dimension Names in SDS */ + /* ---------------------------- */ + rank = EHparsestr(dimlist, ',', ptr, slen); + for (i = 0; i < rank; i++) + { + /* Dimension name = Swathname:Dimname */ + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + strcat(utlbuf, ":"); + strcat(utlbuf, swathname); + + dimid = SDgetdimid(sdid, i); + SDsetdimname(dimid, utlbuf); + } + + + /* Setup compression parameters */ + if (compcode == HDFE_COMP_NBIT) + { + c_info.nbit.nt = numbertype; + c_info.nbit.sign_ext = SWXSwath[sID].compparm[0]; + c_info.nbit.fill_one = SWXSwath[sID].compparm[1]; + c_info.nbit.start_bit = SWXSwath[sID].compparm[2]; + c_info.nbit.bit_len = SWXSwath[sID].compparm[3]; + } + else if (compcode == HDFE_COMP_SKPHUFF) + { + c_info.skphuff.skp_size = (intn) DFKNTsize(numbertype); + } + else if (compcode == HDFE_COMP_DEFLATE) + { + c_info.deflate.level = SWXSwath[sID].compparm[0]; + } + + /* If field is compressed then call SDsetcompress */ + /* ---------------------------------------------- */ + if (compcode != HDFE_COMP_NONE) + { + status = SDsetcompress(sdid, (comp_coder_t) compcode, &c_info); + } + + + /* Attach to Vgroup */ + /* ---------------- */ + Vaddtagref(vgid, DFTAG_NDG, SDidtoref(sdid)); + + + /* Store SDS dataset IDs */ + /* --------------------- */ + if (SWXSwath[sID].nSDS > 0) + { + SWXSwath[sID].sdsID = (int32 *) + realloc((void *) SWXSwath[sID].sdsID, + (SWXSwath[sID].nSDS + 1) * 4); + if(SWXSwath[sID].sdsID == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + return(-1); + } + + } + else + { + SWXSwath[sID].sdsID = (int32 *) calloc(1, 4); + if(SWXSwath[sID].sdsID == NULL) + { + HEpush(DFE_NOSPACE,"SWdefinefield", __FILE__, __LINE__); + return(-1); + } + } + SWXSwath[sID].sdsID[SWXSwath[sID].nSDS] = sdid; + SWXSwath[sID].nSDS++; + + } /* End Multi-Dim No Merge Section */ + + } /* End Multi-Dim Section */ + + + + /* Setup metadata string */ + /* --------------------- */ + sprintf(utlbuf, "%s%s%s", fieldname, ":", dimlist); + + + /* Setup compression metadata */ + /* -------------------------- */ + if (compcode != HDFE_COMP_NONE) + { + sprintf(utlbuf2, + "%s%s", + ":\n\t\t\t\tCompressionType=", HDFcomp[compcode]); + + switch (compcode) + { + case HDFE_COMP_NBIT: + + sprintf(compparmbuf, + "%s%d,%d,%d,%d%s", + "\n\t\t\t\tCompressionParams=(", + SWXSwath[sID].compparm[0], + SWXSwath[sID].compparm[1], + SWXSwath[sID].compparm[2], + SWXSwath[sID].compparm[3], ")"); + strcat(utlbuf2, compparmbuf); + break; + + + case HDFE_COMP_DEFLATE: + + sprintf(compparmbuf, + "%s%d", + "\n\t\t\t\tDeflateLevel=", + SWXSwath[sID].compparm[0]); + strcat(utlbuf2, compparmbuf); + break; + } + + /* Concatanate compression parameters with compression code */ + strcat(utlbuf, utlbuf2); + } + + + /* Insert field metadata within File Structural Metadata */ + /* ----------------------------------------------------- */ + if (strcmp(fieldtype, "Geolocation Fields") == 0) + { + status = EHinsertmeta(sdInterfaceID, swathname, "s", 3L, + utlbuf, &numbertype); + } + else + { + status = EHinsertmeta(sdInterfaceID, swathname, "s", 4L, + utlbuf, &numbertype); + } + + } + } + + /* If all dimensions not found then report error */ + /* --------------------------------------------- */ + if (foundAllDim == 0) + { + HEpush(DFE_GENAPP, "SWdefinefield", __FILE__, __LINE__); + HEreport("Dimension(s): \"%s\" not found (%s).\n", + utlbuf, fieldname); + status = -1; + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefgeofield | +| | +| DESCRIPTION: Defines geolocation field within swath structure (wrapper) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| merge int32 merge code | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefgeofield(int32 swathID, char *fieldname, char *dimlist, + int32 numbertype, int32 merge) +{ + intn status; /* routine return status variable */ + + /* Call SWdefinefield routine */ + /* -------------------------- */ + status = SWdefinefield(swathID, "Geolocation Fields", fieldname, dimlist, + numbertype, merge); + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefdatafield | +| | +| DESCRIPTION: Defines data field within swath structure (wrapper) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| merge int32 merge code | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefdatafield(int32 swathID, char *fieldname, char *dimlist, + int32 numbertype, int32 merge) +{ + intn status; /* routine return status variable */ + + /* Call SWdefinefield routine */ + /* -------------------------- */ + status = SWdefinefield(swathID, "Data Fields", fieldname, dimlist, + numbertype, merge); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwritegeometa | +| | +| DESCRIPTION: Defines structural metadata for pre-existing geolocation | +| field within swath structure | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwritegeometa(int32 swathID, char *fieldname, char *dimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 dum; /* dummy variable */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char utlbuf[256];/* Utility buffer */ + char swathname[80]; /* Swath name */ + + status = SWchkswid(swathID, "SWwritegeometa", &dum, &sdInterfaceID, + &dum); + + if (status == 0) + { + /* Setup and write field metadata */ + /* ------------------------------ */ + sprintf(utlbuf, "%s%s%s", fieldname, ":", dimlist); + + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + status = EHinsertmeta(sdInterfaceID, swathname, "s", 3L, + utlbuf, &numbertype); + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwritedatameta | +| | +| DESCRIPTION: Defines structural metadata for pre-existing data | +| field within swath structure | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| dimlist char Dimension list (comma-separated list) | +| numbertype int32 field type | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwritedatameta(int32 swathID, char *fieldname, char *dimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 dum; /* dummy variable */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char utlbuf[256];/* Utility buffer */ + char swathname[80]; /* Swath name */ + + status = SWchkswid(swathID, "SWwritedatameta", &dum, &sdInterfaceID, + &dum); + + if (status == 0) + { + /* Setup and write field metadata */ + /* ------------------------------ */ + sprintf(utlbuf, "%s%s%s", fieldname, ":", dimlist); + + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + status = EHinsertmeta(sdInterfaceID, swathname, "s", 4L, + utlbuf, &numbertype); + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefgfld | +| | +| DESCRIPTION: Defines geolocation field within swath structure (FORTRAN) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| merge int32 merge code | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefgfld(int32 swathID, char *fieldname, char *fortdimlist, + int32 numbertype, int32 merge) +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"SWdefgfld", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + /* Call Define Field routine */ + /* ------------------------- */ + status = SWdefinefield(swathID, "Geolocation Fields", fieldname, + dimlist, numbertype, merge); + + free(dimlist); + return (status); + +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefdfld | +| | +| | +| DESCRIPTION: Defines data field within swath structure (FORTRAN) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| merge int32 merge code | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdefdfld(int32 swathID, char *fieldname, char *fortdimlist, + int32 numbertype, int32 merge) + +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"SWdefdfld", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + /* Call Define Field routine */ + /* ------------------------- */ + status = SWdefinefield(swathID, "Data Fields", fieldname, + dimlist, numbertype, merge); + + free(dimlist); + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwrgmeta | +| | +| | +| DESCRIPTION: Defines structural metadata for pre-existing geolocation | +| field within swath structure (FORTRAN) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwrgmeta(int32 swathID, char *fieldname, char *fortdimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"SWwrgmeta", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + /* Call Write Metadata routine */ + /* --------------------------- */ + status = SWwritegeometa(swathID, fieldname, dimlist, numbertype); + + free(dimlist); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwrdmeta | +| | +| DESCRIPTION: Defines structural metadata for pre-existing data | +| field within swath structure (FORTRAN) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortdimlist char Dimension list (comma-separated list) | +| FORTRAN dimesion order | +| numbertype int32 field type | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwrdmeta(int32 swathID, char *fieldname, char *fortdimlist, + int32 numbertype) +{ + intn status = 0; /* routine return status variable */ + char *dimlist; /* Dimension list (C order) */ + + /* Allocate space for C order dimension list */ + /* ----------------------------------------- */ + dimlist = (char *) calloc(strlen(fortdimlist) + 1, 1); + if(dimlist == NULL) + { + HEpush(DFE_NOSPACE,"SWwrdmeta", __FILE__, __LINE__); + return(-1); + } + + /* Reverse entries in dimension list (FORTRAN -> C) */ + /* ------------------------------------------------ */ + status = EHrevflds(fortdimlist, dimlist); + + /* Call Write Metadata routine */ + /* --------------------------- */ + status = SWwritedatameta(swathID, fieldname, dimlist, numbertype); + + free(dimlist); + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwrrdattr | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| attrname char attribute name | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| wrcode char Read/Write Code "w/r" | +| datbuf void I/O buffer | +| | +| OUTPUTS: | +| datbuf | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwrrdattr(int32 swathID, char *attrname, int32 numbertype, int32 count, + char *wrcode, VOIDP datbuf) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Swath attribute ID */ + int32 dum; /* dummy variable */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + /* Check Swath id */ + status = SWchkswid(swathID, "SWwrrdattr", &fid, &dum, &dum); + + if (status == 0) + { + /* Get attribute Vgroup ID and call EHattr to perform I/O */ + /* ------------------------------------------------------ */ + attrVgrpID = SWXSwath[swathID % idOffset].VIDTable[2]; + status = EHattr(fid, attrVgrpID, attrname, numbertype, count, + wrcode, datbuf); + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwriteattr | +| | +| DESCRIPTION: Writes/updates attribute in a swath. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| attrname char attribute name | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| datbuf void I/O buffer | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwriteattr(int32 swathID, char *attrname, int32 numbertype, int32 count, + VOIDP datbuf) +{ + intn status = 0; /* routine return status variable */ + + /* Call SWwrrdattr routine to write attribute */ + /* ------------------------------------------ */ + status = SWwrrdattr(swathID, attrname, numbertype, count, "w", datbuf); + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWreadattr | +| | +| DESCRIPTION: Reads attribute from a swath. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| attrname char attribute name | +| | +| OUTPUTS: | +| datbuf void I/O buffer | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWreadattr(int32 swathID, char *attrname, VOIDP datbuf) +{ + intn status = 0; /* routine return status variable */ + int32 dum = 0; /* dummy variable */ + + /* Call SWwrrdattr routine to read attribute */ + /* ----------------------------------------- */ + status = SWwrrdattr(swathID, attrname, dum, dum, "r", datbuf); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWattrinfo | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| attrname char attribute name | +| | +| OUTPUTS: | +| numbertype int32 attribute HDF numbertype | +| count int32 Number of attribute elements | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWattrinfo(int32 swathID, char *attrname, int32 * numbertype, int32 * count) +{ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Swath attribute ID */ + int32 dum; /* dummy variable */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWattrinfo", &fid, &dum, &dum); + + if (status == 0) + { + /* Get attribute Vgroup ID and call EHattrinfo */ + /* ------------------------------------------- */ + attrVgrpID = SWXSwath[swathID % idOffset].VIDTable[2]; + + status = EHattrinfo(fid, attrVgrpID, attrname, numbertype, + count); + } + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqattrs | +| | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nattr int32 Number of attributes in swath struct | +| | +| INPUTS: | +| swath ID int32 swath structure ID | +| | +| OUTPUTS: | +| attrnames char Attribute names in swath struct | +| (Comma-separated list) | +| strbufsize int32 Attributes name list string length | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Initialize nattr | +| Oct 96 Joel Gales Get Attribute Vgroup ID from external array | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqattrs(int32 swathID, char *attrnames, int32 * strbufsize) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 attrVgrpID; /* Swath attribute ID */ + int32 dum; /* dummy variable */ + int32 nattr = 0; /* Number of attributes */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + + /* Check Swath id */ + status = SWchkswid(swathID, "SWinqattrs", &fid, &dum, &dum); + + if (status == 0) + { + /* Get attribute Vgroup ID and call EHattrcat */ + /* ------------------------------------------ */ + attrVgrpID = SWXSwath[swathID % idOffset].VIDTable[2]; + + nattr = EHattrcat(fid, attrVgrpID, attrnames, strbufsize); + } + + return (nattr); +} + +#define REMQUOTE \ +\ +memmove(utlstr, utlstr + 1, strlen(utlstr) - 2); \ +utlstr[strlen(utlstr) - 2] = 0; + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqdims | +| | +| DESCRIPTION: Returns dimension names and values defined in swath structure | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nDim int32 Number of defined dimensions | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| OUTPUTS: | +| dimnames char Dimension names (comma-separated) | +| dims int32 Dimension values | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nDim to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqdims(int32 swathID, char *dimnames, int32 dims[]) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 size; /* Dimension size */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nDim = 0; /* Number of dimensions */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWinqdims", __FILE__, __LINE__); + return(-1); + } + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWinqdims", &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* If dimension names or sizes are desired ... */ + /* ------------------------------------------- */ + if (dimnames != NULL || dims != NULL) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "Dimension" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "Dimension", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + /* If dimension names are desired then "clear" name buffer */ + if (dimnames != NULL) + { + dimnames[0] = 0; + } + + + /* Begin loop through dimension entries in metadata */ + /* ------------------------------------------------ */ + while (1) + { + /* Search for OBJECT string */ + metaptrs[0] = strstr(metaptrs[0], "\t\tOBJECT="); + + /* If found within "Dimension" metadata section ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Dimension Name (if desired) */ + if (dimnames != NULL) + { + /* Check 1st for old meta data then new */ + /* ------------------------------------ */ + EHgetmetavalue(metaptrs, "OBJECT", utlstr); + + /* + * If OBJECT value begins with double quote then old + * metadata, dimension name is OBJECT value. + * Otherwise search for "DimensionName" string + */ + if (utlstr[0] != '"') + { + metaptrs[0] = + strstr(metaptrs[0], "\t\t\t\tDimensionName="); + EHgetmetavalue(metaptrs, "DimensionName", utlstr); + } + + /* Strip off double quotes */ + /* ----------------------- */ + REMQUOTE + + /* If not first name then add comma delimitor */ + if (nDim > 0) + { + strcat(dimnames, ","); + } + /* Add dimension name to dimension list */ + strcat(dimnames, utlstr); + } + + /* Get Dimension Size (if desired) */ + if (dims != NULL) + { + EHgetmetavalue(metaptrs, "Size", utlstr); + size = atol(utlstr); + dims[nDim] = size; + } + /* Increment number of dimensions */ + nDim++; + } + else + /* No more dimensions found */ + { + break; + } + } + free(metabuf); + } + } + + + /* Set nDim to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nDim = -1; + } + free(utlstr); + + return (nDim); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqmaps | +| | +| DESCRIPTION: Returns dimension mappings and offsets and increments | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nMap int32 Number of dimension mappings | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| OUTPUTS: | +| dimmaps char dimension mappings (comma-separated) | +| offset int32 array of offsets | +| increment int32 array of increments | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nMap to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqmaps(int32 swathID, char *dimmaps, int32 offset[], int32 increment[]) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 off; /* Mapping Offset */ + int32 incr; /* Mapping Increment */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nMap = 0; /* Number of mappings */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWinqmaps", __FILE__, __LINE__); + return(-1); + } + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWinqmaps", &fid, &sdInterfaceID, &swVgrpID); + if (status == 0) + { + /* If mapping names or offsets or increments desired ... */ + /* ----------------------------------------------------- */ + if (dimmaps != NULL || offset != NULL || increment != NULL) + { + + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "DimensionMap" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DimensionMap", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + /* If mapping names are desired then "clear" name buffer */ + if (dimmaps != NULL) + { + dimmaps[0] = 0; + } + + /* Begin loop through mapping entries in metadata */ + /* ---------------------------------------------- */ + while (1) + { + /* Search for OBJECT string */ + metaptrs[0] = strstr(metaptrs[0], "\t\tOBJECT="); + + /* If found within "DimensionMap" metadata section ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Geo & Data Dimensions (if desired) */ + if (dimmaps != NULL) + { + /* Get Geo Dim, remove quotes, add "/" */ + EHgetmetavalue(metaptrs, "GeoDimension", utlstr); + REMQUOTE + strcat(utlstr, "/"); + + /* if not first map then add comma delimitor */ + if (nMap > 0) + { + strcat(dimmaps, ","); + } + + /* Add to map list */ + strcat(dimmaps, utlstr); + + /* Get Data Dim, remove quotes */ + EHgetmetavalue(metaptrs, "DataDimension", utlstr); + REMQUOTE + + /* Add to map list */ + strcat(dimmaps, utlstr); + } + + /* Get Offset (if desired) */ + if (offset != NULL) + { + EHgetmetavalue(metaptrs, "Offset", utlstr); + off = atol(utlstr); + offset[nMap] = off; + } + + /* Get Increment (if desired) */ + if (increment != NULL) + { + EHgetmetavalue(metaptrs, "Increment", utlstr); + incr = atol(utlstr); + increment[nMap] = incr; + } + + /* Increment number of maps */ + nMap++; + } + else + /* No more mappings found */ + { + break; + } + } + free(metabuf); + } + } + + + /* Set nMap to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nMap = -1; + } + free(utlstr); + + return (nMap); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqidxmaps | +| | +| DESCRIPTION: Returns indexed mappings and index sizes | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nMap int32 Number of indexed dimension mappings | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| OUTPUTS: | +| idxmaps char indexed dimension mappings | +| (comma-separated) | +| idxsizes int32 Number of elements in each mapping | +| | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nMap to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqidxmaps(int32 swathID, char *idxmaps, int32 idxsizes[]) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nMap = 0; /* Number of mappings */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + char *slash; /* Pointer to slash */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWinqidxmaps", __FILE__, __LINE__); + return(-1); + } + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWinqidxmaps", &fid, + &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* If mapping names or index sizes desired ... */ + /* ------------------------------------------- */ + if (idxmaps != NULL || idxsizes != NULL) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "IndexDimensionMap" section within SM */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "IndexDimensionMap", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + /* If mapping names are desired then "clear" name buffer */ + if (idxmaps != NULL) + { + idxmaps[0] = 0; + } + + /* Begin loop through mapping entries in metadata */ + /* ---------------------------------------------- */ + while (1) + { + /* Search for OBJECT string */ + metaptrs[0] = strstr(metaptrs[0], "\t\tOBJECT="); + + /* If found within "IndexDimensionMap" metadata section ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Geo & Data Dimensions and # of indices */ + if (idxmaps != NULL) + { + /* Get Geo Dim, remove quotes, add "/" */ + EHgetmetavalue(metaptrs, "GeoDimension", utlstr); + REMQUOTE + strcat(utlstr, "/"); + + /* if not first map then add comma delimitor */ + if (nMap > 0) + { + strcat(idxmaps, ","); + } + + /* Add to map list */ + strcat(idxmaps, utlstr); + + + /* Get Index size (if desired) */ + if (idxsizes != NULL) + { + /* Parse off geo dimension and find its size */ + slash = strchr(utlstr, '/'); + *slash = 0; + idxsizes[nMap] = SWdiminfo(swathID, utlstr); + } + + + /* Get Data Dim, remove quotes */ + EHgetmetavalue(metaptrs, "DataDimension", utlstr); + REMQUOTE + + /* Add to map list */ + strcat(idxmaps, utlstr); + } + + /* Increment number of maps */ + nMap++; + } + else + /* No more mappings found */ + { + break; + } + } + free(metabuf); + } + } + + + /* Set nMap to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nMap = -1; + } + free(utlstr); + + return (nMap); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqfields | +| | +| DESCRIPTION: Returns fieldnames, ranks and numbertypes defined in swath. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nFld int32 Number of (geo/data) fields in swath | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldtype char field type (geo or data) | +| | +| | +| OUTPUTS: | +| fieldlist char Field names (comma-separated) | +| rank int32 Array of ranks | +| numbertype int32 Array of HDF number types | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nFld to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqfields(int32 swathID, char *fieldtype, char *fieldlist, int32 rank[], + int32 numbertype[]) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nFld = 0; /* Number of mappings */ + int32 slen[8]; /* String length array */ + int32 ntype; /* Data Type */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + char *utlstr2; /* Utility string 2 */ + char *ptr[8]; /* String pointer array */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWinqfields", __FILE__, __LINE__); + return(-1); + } + + utlstr2 = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr2 == NULL) + { + HEpush(DFE_NOSPACE,"SWinqfields", __FILE__, __LINE__); + free(utlstr); + return(-1); + } + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWinqfields", + &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* If field names, ranks, or number types desired ... */ + /* --------------------------------------------------- */ + if (fieldlist != NULL || rank != NULL || numbertype != NULL) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "GeoField" or "DataField" section within SM */ + if (strcmp(fieldtype, "Geolocation Fields") == 0) + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "GeoField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + free(utlstr2); + return(-1); + } + strcpy(utlstr2, "GeoFieldName"); + } + else + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + free(utlstr2); + return(-1); + } + strcpy(utlstr2, "DataFieldName"); + } + + + /* If field names are desired then "clear" name buffer */ + if (fieldlist != NULL) + { + fieldlist[0] = 0; + } + + + /* Begin loop through mapping entries in metadata */ + /* ---------------------------------------------- */ + while (1) + { + /* Search for OBJECT string */ + metaptrs[0] = strstr(metaptrs[0], "\t\tOBJECT="); + + /* If found within "Geo" or "Data" Field metadata section .. */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + /* Get Fieldnames (if desired) */ + if (fieldlist != NULL) + { + /* Check 1st for old meta data then new */ + /* ------------------------------------ */ + EHgetmetavalue(metaptrs, "OBJECT", utlstr); + + /* + * If OBJECT value begins with double quote then old + * metadata, field name is OBJECT value. Otherwise + * search for "GeoFieldName" or "DataFieldName" + * string + */ + + if (utlstr[0] != '"') + { + strcpy(utlstr, "\t\t\t\t"); + strcat(utlstr, utlstr2); + strcat(utlstr, "="); + metaptrs[0] = strstr(metaptrs[0], utlstr); + EHgetmetavalue(metaptrs, utlstr2, utlstr); + } + + /* Strip off double quotes */ + /* ----------------------- */ + REMQUOTE + + + /* Add to fieldlist */ + /* ---------------- */ + if (nFld > 0) + { + strcat(fieldlist, ","); + } + strcat(fieldlist, utlstr); + + } + /* Get Numbertype */ + if (numbertype != NULL) + { + EHgetmetavalue(metaptrs, "DataType", utlstr); + + if (strcmp(utlstr, "DFNT_UCHAR8") == 0) + ntype = 3; + else if (strcmp(utlstr, "DFNT_CHAR8") == 0) + ntype = 4; + else if (strcmp(utlstr, "DFNT_FLOAT32") == 0) + ntype = 5; + else if (strcmp(utlstr, "DFNT_FLOAT64") == 0) + ntype = 6; + else if (strcmp(utlstr, "DFNT_INT8") == 0) + ntype = 20; + else if (strcmp(utlstr, "DFNT_UINT8") == 0) + ntype = 21; + else if (strcmp(utlstr, "DFNT_INT16") == 0) + ntype = 22; + else if (strcmp(utlstr, "DFNT_UINT16") == 0) + ntype = 23; + else if (strcmp(utlstr, "DFNT_INT32") == 0) + ntype = 24; + else if (strcmp(utlstr, "DFNT_UINT32") == 0) + ntype = 25; + + numbertype[nFld] = ntype; + } + /* + * Get Rank (if desired) by counting # of dimensions in + * "DimList" string + */ + if (rank != NULL) + { + EHgetmetavalue(metaptrs, "DimList", utlstr); + rank[nFld] = EHparsestr(utlstr, ',', ptr, slen); + } + /* Increment number of fields */ + nFld++; + } + else + /* No more fields found */ + { + break; + } + } + free(metabuf); + } + } + + /* Set nFld to -1 if error status exists */ + /* ------------------------------------- */ + if (status == -1) + { + nFld = -1; + } + + free(utlstr); + free(utlstr2); + + return (nFld); +} + + + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqgeofields | +| | +| DESCRIPTION: Inquires about geo fields in swath | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nflds int32 Number of geo fields in swath | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| OUTPUTS: | +| fieldlist char Field names (comma-separated) | +| rank int32 Array of ranks | +| numbertype int32 Array of HDF number types | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqgeofields(int32 swathID, char *fieldlist, int32 rank[], + int32 numbertype[]) +{ + + int32 nflds; /* Number of Geolocation fields */ + + /* Call "SWinqfields" routine */ + /* -------------------------- */ + nflds = SWinqfields(swathID, "Geolocation Fields", fieldlist, rank, + numbertype); + + return (nflds); + +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqdatafields | +| | +| DESCRIPTION: Inquires about data fields in swath | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nflds int32 Number of data fields in swath | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| OUTPUTS: | +| fieldlist char Field names (comma-separated) | +| rank int32 Array of ranks | +| numbertype int32 Array of HDF number types | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqdatafields(int32 swathID, char *fieldlist, int32 rank[], + int32 numbertype[]) +{ + + int32 nflds; /* Number of Data fields */ + + /* Call "SWinqfields" routine */ + /* -------------------------- */ + nflds = SWinqfields(swathID, "Data Fields", fieldlist, rank, + numbertype); + + return (nflds); + +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWnentries | +| | +| DESCRIPTION: Returns number of entries and string buffer size | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nEntries int32 Number of entries | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| entrycode int32 Entry code | +| HDFE_NENTDIM (0) | +| HDFE_NENTMAP (1) | +| HDFE_NENTIMAP (2) | +| HDFE_NENTGFLD (3) | +| HDFE_NENTDFLD (4) | +| | +| | +| OUTPUTS: | +| strbufsize int32 Length of comma-separated list | +| (Does not include null-terminator | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| Feb 97 Joel Gales Set nEntries to -1 if status = -1 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWnentries(int32 swathID, int32 entrycode, int32 * strbufsize) + +{ + intn status; /* routine return status variable */ + intn i; /* Loop index */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 nEntries = 0; /* Number of entries */ + int32 metaflag; /* Old (0), New (1) metadata flag) */ + int32 nVal; /* Number of strings to search for */ + + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + char valName[2][32]; /* Strings to search for */ + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWnemtries", __FILE__, __LINE__); + return(-1); + } + /* Check for valid swath id */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWnentries", &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Zero out string buffer size */ + *strbufsize = 0; + + + /* + * Get pointer to relevant section within SM and Get names of + * metadata strings to inquire about + */ + switch (entrycode) + { + case HDFE_NENTDIM: + /* Dimensions */ + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "Dimension", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + nVal = 1; + strcpy(&valName[0][0], "DimensionName"); + } + break; + + case HDFE_NENTMAP: + /* Dimension Maps */ + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DimensionMap", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + nVal = 2; + strcpy(&valName[0][0], "GeoDimension"); + strcpy(&valName[1][0], "DataDimension"); + } + break; + + case HDFE_NENTIMAP: + /* Indexed Dimension Maps */ + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "IndexDimensionMap", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + nVal = 2; + strcpy(&valName[0][0], "GeoDimension"); + strcpy(&valName[1][0], "DataDimension"); + } + break; + + case HDFE_NENTGFLD: + /* Geolocation Fields */ + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "GeoField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + nVal = 1; + strcpy(&valName[0][0], "GeoFieldName"); + } + break; + + case HDFE_NENTDFLD: + /* Data Fields */ + { + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DataField", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + nVal = 1; + strcpy(&valName[0][0], "DataFieldName"); + } + break; + } + + + /* + * Check for presence of 'GROUP="' string If found then old metadata, + * search on OBJECT string + */ + metaflag = (strstr(metabuf, "GROUP=\"") == NULL) ? 1 : 0; + if (metaflag == 0) + { + nVal = 1; + strcpy(&valName[0][0], "\t\tOBJECT"); + } + + + /* Begin loop through entries in metadata */ + /* -------------------------------------- */ + while (1) + { + /* Search for first string */ + strcpy(utlstr, &valName[0][0]); + strcat(utlstr, "="); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + /* If found within relevant metadata section ... */ + if (metaptrs[0] < metaptrs[1] && metaptrs[0] != NULL) + { + for (i = 0; i < nVal; i++) + { + /* + * Get all string values Don't count quotes + */ + EHgetmetavalue(metaptrs, &valName[i][0], utlstr); + *strbufsize += strlen(utlstr) - 2; + } + /* Increment number of entries */ + nEntries++; + + /* Go to end of OBJECT */ + metaptrs[0] = strstr(metaptrs[0], "END_OBJECT"); + } + else + /* No more entries found */ + { + break; + } + } + free(metabuf); + + + /* Count comma separators & slashes (if mappings) */ + /* ---------------------------------------------- */ + if (nEntries > 0) + { + *strbufsize += nEntries - 1; + *strbufsize += (nVal - 1) * nEntries; + } + } + + + /* Set nEntries to -1 if error status exists */ + /* ----------------------------------------- */ + if (status == -1) + { + nEntries = -1; + } + + free(utlstr); + + return (nEntries); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWinqswath | +| | +| DESCRIPTION: Returns number and names of swath structures in file | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nSwath int32 Number of swath structures in file | +| | +| INPUTS: | +| filename char HDF-EOS filename | +| | +| OUTPUTS: | +| swathlist char List of swath names (comma-separated) | +| strbufsize int32 Length of swathlist | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWinqswath(char *filename, char *swathlist, int32 * strbufsize) +{ + int32 nSwath; /* Number of swath structures in file */ + + /* Call "EHinquire" routine */ + /* ------------------------ */ + nSwath = EHinquire(filename, "SWATH", swathlist, strbufsize); + + return (nSwath); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SW1dfldsrch | +| | +| DESCRIPTION: Retrieves information about a 1D field | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 HDF-EOS file ID | +| swathID int32 swath structure ID | +| fieldname char field name | +| access char Access code (w/r) | +| | +| | +| OUTPUTS: | +| vgidout int32 Field (geo/data) vgroup ID | +| vdataIDout int32 Field Vdata ID | +| fldtype int32 Field type | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SW1dfldsrch(int32 fid, int32 swathID, char *fieldname, char *access, + int32 * vgidout, int32 * vdataIDout, int32 * fldtype) + +{ + intn status = 0; /* routine return status variable */ + + int32 sID; /* SwathID - offset */ + int32 vgid; /* Swath Geo or Data Vgroup ID */ + int32 vdataID; /* 1d field vdata */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + + /* Compute "reduced" swath ID */ + /* -------------------------- */ + sID = swathID % idOffset; + + + /* Get Geolocation Vgroup id and 1D field name Vdata id */ + /* ---------------------------------------------------- */ + vgid = SWXSwath[sID].VIDTable[0]; + vdataID = EHgetid(fid, vgid, fieldname, 1, access); + *fldtype = 0; + + + /* + * If name not found in Geolocation Vgroup then detach Geolocation Vgroup + * and search in Data Vgroup + */ + if (vdataID == -1) + { + vgid = SWXSwath[sID].VIDTable[1];; + vdataID = EHgetid(fid, vgid, fieldname, 1, access); + *fldtype = 1; + + /* If field also not found in Data Vgroup then set error status */ + /* ------------------------------------------------------------ */ + if (vdataID == -1) + { + status = -1; + vgid = -1; + vdataID = -1; + } + } + *vgidout = vgid; + *vdataIDout = vdataID; + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWSDfldsrch | +| | +| DESCRIPTION: Retrieves information SDS field | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| sdInterfaceID int32 SD interface ID | +| fieldname char field name | +| access char Access code (w/r) | +| | +| | +| OUTPUTS: | +| sdid int32 SD element ID | +| rankSDS int32 Rank of SDS | +| rankFld int32 True rank of field (merging) | +| offset int32 Offset of field within merged field | +| dims int32 Dimensions of field | +| solo int32 Solo field flag | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Make metadata ODL compliant | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWSDfldsrch(int32 swathID, int32 sdInterfaceID, char *fieldname, int32 * sdid, + int32 * rankSDS, int32 * rankFld, int32 * offset, int32 dims[], + int32 * solo) +{ + intn i; /* Loop index */ + intn status = -1;/* routine return status variable */ + + int32 sID; /* SwathID - offset */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 dum; /* Dummy variable */ + int32 dums[128]; /* Dummy array */ + int32 attrIndex; /* Attribute index */ + + char name[2048]; /* Merged-Field Names */ + char swathname[80]; /* Swath Name */ + char *utlstr; /* Utility string */ + char *metabuf; /* Pointer to structural metadata (SM) */ + char *metaptrs[2];/* Pointers to begin and end of SM section */ + char *oldmetaptr; /* Pointer within SM section */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstr == NULL) + { + HEpush(DFE_NOSPACE,"SWSDfldsrch", __FILE__, __LINE__); + return(-1); + } + /* Set solo flag to 0 (no) */ + /* ----------------------- */ + *solo = 0; + + + /* Compute "reduced" swath ID */ + /* -------------------------- */ + sID = swathID % idOffset; + + + /* Loop through all SDSs in swath */ + /* ------------------------------ */ + for (i = 0; i < SWXSwath[sID].nSDS; i++) + { + /* If active SDS ... */ + /* ----------------- */ + if (SWXSwath[sID].sdsID[i] != 0) + { + /* Get SDS ID, name, rankSDS, and dimensions */ + /* ----------------------------------------- */ + *sdid = SWXSwath[sID].sdsID[i]; + SDgetinfo(*sdid, name, rankSDS, dims, &dum, &dum); + *rankFld = *rankSDS; + + /* If merged field ... */ + /* ------------------- */ + if (strstr(name, "MRGFLD_") == &name[0]) + { + /* Get swath name */ + /* -------------- */ + Vgetname(SWXSwath[sID].IDTable, swathname); + + + /* Get pointers to "MergedFields" section within SM */ + /* ------------------------------------------------ */ + metabuf = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "MergedFields", metaptrs); + if(metabuf == NULL) + { + free(utlstr); + return(-1); + } + + /* Store metaptr in order to recover */ + /* --------------------------------- */ + oldmetaptr = metaptrs[0]; + + + /* Search for Merged field name */ + /* ---------------------------- */ + sprintf(utlstr, "%s%s%s", "MergedFieldName=\"", + name, "\"\n"); + metaptrs[0] = strstr(metaptrs[0], utlstr); + + + /* If not found check for old metadata */ + /* ----------------------------------- */ + if (metaptrs[0] == NULL) + { + sprintf(utlstr, "%s%s%s", "OBJECT=\"", name, "\"\n"); + metaptrs[0] = strstr(oldmetaptr, utlstr); + } + + + /* Get field list and strip off leading and trailing quotes */ + EHgetmetavalue(metaptrs, "FieldList", name); /* not return status --xhua */ + memmove(name, name + 1, strlen(name) - 2); + name[strlen(name) - 2] = 0; + + /* Search for desired field within merged field list */ + sprintf(utlstr, "%s%s%s", "\"", fieldname, "\""); + dum = EHstrwithin(utlstr, name, ','); + + free(metabuf); + } + else + { + /* If solo (unmerged) check if SDS name matches fieldname */ + /* ------------------------------------------------------ */ + dum = EHstrwithin(fieldname, name, ','); + if (dum != -1) + { + *solo = 1; + *offset = 0; + } + } + + + /* If field found ... */ + /* ------------------ */ + if (dum != -1) + { + status = 0; + + /* If merged field ... */ + /* ------------------- */ + if (*solo == 0) + { + /* Get "Field Offsets" SDS attribute index */ + /* --------------------------------------- */ + attrIndex = SDfindattr(*sdid, "Field Offsets"); + + /* + * If attribute exists then get offset of desired field + * within merged field + */ + if (attrIndex != -1) + { + SDreadattr(*sdid, attrIndex, (VOIDP) dums); + *offset = dums[dum]; + } + + + /* Get "Field Dims" SDS attribute index */ + /* ------------------------------------ */ + attrIndex = SDfindattr(*sdid, "Field Dims"); + + /* + * If attribute exists then get 0th dimension of desired + * field within merged field + */ + if (attrIndex != -1) + { + SDreadattr(*sdid, attrIndex, (VOIDP) dums); + dims[0] = dums[dum]; + + /* If this dimension = 1 then field is really 2 dim */ + /* ------------------------------------------------ */ + if (dums[dum] == 1) + { + *rankFld = 2; + } + } + } + + + /* Break out of SDS loop */ + /* --------------------- */ + break; + } /* End of found field section */ + } + else + { + /* First non-active SDS signifies no more, break out of SDS loop */ + /* ------------------------------------------------------------- */ + break; + } + } + + free(utlstr); + + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwrrdfield | +| | +| DESCRIPTION: Writes/Reads fields | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| code char Write/Read code (w/r) | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| datbuf void data buffer for read | +| | +| | +| OUTPUTS: | +| datbuf void data buffer for write | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Feb 97 Joel Gales Stride = 1 HDF compression workaround | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwrrdfield(int32 swathID, char *fieldname, char *code, + int32 start[], int32 stride[], int32 edge[], VOIDP datbuf) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 vgid; /* Swath Geo or Data Vgroup ID */ + int32 sdid; /* SDS ID */ + int32 dum; /* Dummy variable */ + int32 rankSDS; /* Rank of SDS */ + int32 rankFld; /* Rank of field */ + + int32 vdataID; /* 1d field vdata */ + int32 recsize; /* Vdata record size */ + int32 fldsize; /* Field size */ + int32 nrec; /* Number of records in Vdata */ + + int32 offset[8]; /* I/O offset (start) */ + int32 incr[8]; /* I/O incrment (stride) */ + int32 count[8]; /* I/O count (edge) */ + int32 dims[8]; /* Field/SDS dimensions */ + int32 mrgOffset; /* Merged field offset */ + int32 nflds; /* Number of fields in Vdata */ + int32 strideOne; /* Strides = 1 flag */ + + uint8 *buf; /* I/O (transfer) buffer */ + uint8 *fillbuf; /* Fill value buffer */ + + char attrName[80]; /* Name of fill value attribute */ + char *ptr[64]; /* String pointer array */ + char fieldlist[256]; /* Vdata field list */ + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWwrrdfield", &fid, &sdInterfaceID, &dum); + + + if (status == 0) + { + + /* Check whether fieldname is in SDS (multi-dim field) */ + /* --------------------------------------------------- */ + status = SWSDfldsrch(swathID, sdInterfaceID, fieldname, &sdid, + &rankSDS, &rankFld, &mrgOffset, dims, &dum); + + /* Multi-Dimensional Field Section */ + /* ------------------------------- */ + if (status != -1) + { + /* Set I/O offset Section */ + /* ---------------------- */ + + /* + * If start == NULL (default) set I/O offset of 0th field to + * offset within merged field (if any) and the rest to 0 + */ + if (start == NULL) + { + for (i = 0; i < rankSDS; i++) + { + offset[i] = 0; + } + offset[0] = mrgOffset; + } + else + { + /* + * ... otherwise set I/O offset to user values, adjusting the + * 0th field with the merged field offset (if any) + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + offset[i] = start[i]; + } + offset[0] += mrgOffset; + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field offset to merge offset and then next two to + * the user values + */ + for (i = 0; i < rankFld; i++) + { + offset[i + 1] = start[i]; + } + offset[0] = mrgOffset; + } + } + + + + /* Set I/O stride Section */ + /* ---------------------- */ + + /* + * If stride == NULL (default) set I/O stride to 1 + */ + if (stride == NULL) + { + for (i = 0; i < rankSDS; i++) + { + incr[i] = 1; + } + } + else + { + /* + * ... otherwise set I/O stride to user values + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + incr[i] = stride[i]; + } + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field stride to 1 and then next two to the user + * values. + */ + for (i = 0; i < rankFld; i++) + { + incr[i + 1] = stride[i]; + } + incr[0] = 1; + } + } + + + + /* Set I/O count Section */ + /* --------------------- */ + + /* + * If edge == NULL (default) set I/O count to number of remaining + * entries (dims - start) / increment. Note that 0th field + * offset corrected for merged field offset (if any). + */ + if (edge == NULL) + { + for (i = 1; i < rankSDS; i++) + { + count[i] = (dims[i] - offset[i]) / incr[i]; + } + count[0] = (dims[0] - (offset[0] - mrgOffset)) / incr[0]; + } + else + { + /* + * ... otherwise set I/O count to user values + */ + if (rankFld == rankSDS) + { + for (i = 0; i < rankSDS; i++) + { + count[i] = edge[i]; + } + } + else + { + /* + * If field really 2-dim merged in 3-dim field then set + * 0th field count to 1 and then next two to the user + * values. + */ + for (i = 0; i < rankFld; i++) + { + count[i + 1] = edge[i]; + } + count[0] = 1; + } + } + + /* Perform I/O with relevant HDF I/O routine */ + /* ----------------------------------------- */ + if (strcmp(code, "w") == 0) + { + /* Set strideOne to true (1) */ + /* ------------------------- */ + strideOne = 1; + + + /* If incr[i] != 1 set strideOne to false (0) */ + /* ------------------------------------------ */ + for (i = 0; i < rankSDS; i++) + { + if (incr[i] != 1) + { + strideOne = 0; + break; + } + } + + + /* + * If strideOne is true use NULL paramater for stride. This + * is a work-around to HDF compression problem + */ + if (strideOne == 1) + { + status = SDwritedata(sdid, offset, NULL, count, + (VOIDP) datbuf); + } + else + { + status = SDwritedata(sdid, offset, incr, count, + (VOIDP) datbuf); + } + } + else + { + status = SDreaddata(sdid, offset, incr, count, + (VOIDP) datbuf); + } + } /* End of Multi-Dimensional Field Section */ + else + { + + /* One-Dimensional Field Section */ + /* ----------------------------- */ + + /* Check fieldname within 1d field Vgroups */ + /* --------------------------------------- */ + status = SW1dfldsrch(fid, swathID, fieldname, code, + &vgid, &vdataID, &dum); + + if (status != -1) + { + + /* Get number of records */ + /* --------------------- */ + nrec = VSelts(vdataID); + + + /* Set offset, increment, & count */ + /* ------------------------------ */ + offset[0] = (start == NULL) ? 0 : start[0]; + incr[0] = (stride == NULL) ? 1 : stride[0]; + count[0] = (edge == NULL) + ? (nrec - offset[0]) / incr[0] + : edge[0]; + + + + /* Write Section */ + /* ------------- */ + if (strcmp(code, "w") == 0) + { + /* Get size of field and setup fill buffer */ + /* --------------------------------------- */ + fldsize = VSsizeof(vdataID, fieldname); + fillbuf = (uint8 *) calloc(fldsize, 1); + if(fillbuf == NULL) + { + HEpush(DFE_NOSPACE,"SWwrrdfield", __FILE__, __LINE__); + return(-1); + } + + /* Get size of record in Vdata and setup I/O buffer */ + /* ------------------------------------------------ */ + VSQueryvsize(vdataID, &recsize); + buf = (uint8 *) calloc(recsize, count[0] * incr[0]); + if(buf == NULL) + { + HEpush(DFE_NOSPACE,"SWwrrdfield", __FILE__, __LINE__); + return(-1); + } + + + /* Get names and number of fields in each record */ + /* ---------------------------------------------- */ + VSgetfields(vdataID, fieldlist); + dum = EHstrwithin(fieldname, fieldlist, ','); + nflds = EHparsestr(fieldlist, ',', ptr, NULL); + + + /* Get Merged Field Offset (if any) */ + /* -------------------------------- */ + if (nflds > 1) + { + if (dum > 0) + { + *(ptr[dum] - 1) = 0; + mrgOffset = VSsizeof(vdataID, fieldlist); + *(ptr[dum] - 1) = ','; + } + else + { + mrgOffset = 0; + } + + /* Read records to recover previously written data */ + status = VSsetfields(vdataID, fieldlist); + status = VSseek(vdataID, offset[0]); + nrec = VSread(vdataID, buf, count[0] * incr[0], + FULL_INTERLACE); + } + else + { + mrgOffset = 0; + } + + + + /* Fill buffer with "Fill" value (if any) */ + /* -------------------------------------- */ + strcpy(attrName, "_FV_"); + strcat(attrName, fieldname); + + status = SWreadattr(swathID, attrName, (char *) fillbuf); + if (status == 0) + { + for (i = 0; i < count[0] * incr[0]; i++) + { + memcpy(buf + i * recsize + mrgOffset, + fillbuf, fldsize); + } + } + + + /* Write new data into buffer */ + /* -------------------------- */ + if (incr[0] == 1 && nflds == 1) + { + memcpy(buf, datbuf, count[0] * recsize); + } + else + { + for (i = 0; i < count[0]; i++) + { + memcpy(buf + i * recsize * incr[0] + mrgOffset, + (uint8 *) datbuf + i * fldsize, fldsize); + } + } + + + /* If append read last record */ + /* -------------------------- */ + if (offset[0] == nrec) + { + /* abe added "status =" to next line 8/8/97 */ + status = VSseek(vdataID, offset[0] - 1); + VSread(vdataID, fillbuf, 1, FULL_INTERLACE); + } + else + { + status = VSseek(vdataID, offset[0]); + } + + + /* Write data into Vdata */ + /* --------------------- */ + nrec = VSwrite(vdataID, buf, count[0] * incr[0], + FULL_INTERLACE); + + free(fillbuf); + if (status > 0) + status = 0; + + } /* End Write Section */ + else + { + /* Read Section */ + /* ------------ */ + status = VSsetfields(vdataID, fieldname); + fldsize = VSsizeof(vdataID, fieldname); + buf = (uint8 *) calloc(fldsize, count[0] * incr[0]); + if(buf == NULL) + { + HEpush(DFE_NOSPACE,"SWwrrdfield", __FILE__, __LINE__); + return(-1); + } + + (void) VSseek(vdataID, offset[0]); + (void) VSread(vdataID, buf, count[0] * incr[0], + FULL_INTERLACE); + + + /* Copy from input buffer to returned data buffer */ + /* ---------------------------------------------- */ + if (incr[0] == 1) + { + memcpy(datbuf, buf, count[0] * fldsize); + } + else + { + for (i = 0; i < count[0]; i++) + { + memcpy((uint8 *) datbuf + i * fldsize, + buf + i * fldsize * incr[0], fldsize); + } + } + + } /* End Read Section */ + + free(buf); + VSdetach(vdataID); + } + else + { + HEpush(DFE_GENAPP, "SWwrrdfield", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + } /* End One-D Field Section */ + + } + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwritefield | +| | +| DESCRIPTION: Writes data to field | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| | +| | +| OUTPUTS: | +| data void data buffer for write | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwritefield(int32 swathID, char *fieldname, + int32 start[], int32 stride[], int32 edge[], VOIDP data) + +{ + intn status = 0; /* routine return status variable */ + + status = SWwrrdfield(swathID, fieldname, "w", start, stride, edge, + data); + return (status); +} + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWreadfield | +| | +| DESCRIPTION: Reads data from field | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| start int32 start array | +| stride int32 stride array | +| edge int32 edge array | +| buffer void data buffer for read | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWreadfield(int32 swathID, char *fieldname, + int32 start[], int32 stride[], int32 edge[], VOIDP buffer) + +{ + intn status = 0; /* routine return status variable */ + + status = SWwrrdfield(swathID, fieldname, "r", start, stride, edge, + buffer); + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWwrfld | +| | +| DESCRIPTION: Writes data to field (FORTRAN wrapper around SWwritefield) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortstart int32 start array | +| fortstride int32 stride array | +| fortedge int32 edge array | +| | +| | +| OUTPUTS: | +| data void data buffer for write | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWwrfld(int32 swathID, char *fieldname, + int32 fortstart[], int32 fortstride[], int32 fortedge[], VOIDP data) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *start; /* Pointer to start array (C order) */ + int32 *stride; /* Pointer to stride array (C order) */ + int32 *edge; /* Pointer to edge array (C order) */ + + + status = SWfieldinfo(swathID, fieldname, &rank, dims, &ntype, NULL); + + if (status != -1) + { + start = (int32 *) malloc(4 * rank); + if(start == NULL) + { + HEpush(DFE_NOSPACE,"SWwrfld", __FILE__, __LINE__); + return(-1); + } + stride = (int32 *) malloc(4 * rank); + if(stride == NULL) + { + HEpush(DFE_NOSPACE,"SWwrfld", __FILE__, __LINE__); + free(start); + return(-1); + } + edge = (int32 *) malloc(4 * rank); + if(edge == NULL) + { + HEpush(DFE_NOSPACE,"SWwrfld", __FILE__, __LINE__); + free(start); + free(stride); + return(-1); + } + + /* Reverse order of dimensions (FORTRAN -> C) */ + for (i = 0; i < rank; i++) + { + start[i] = fortstart[rank - 1 - i]; + stride[i] = fortstride[rank - 1 - i]; + edge[i] = fortedge[rank - 1 - i]; + } + + status = SWwrrdfield(swathID, fieldname, "w", start, stride, edge, + data); + + free(start); + free(stride); + free(edge); + } + else + { + HEpush(DFE_GENAPP, "SWwrfld", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWrdfld | +| | +| DESCRIPTION: Reads data from field (FORTRAN wrapper around SWreadfield) | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char fieldname | +| fortstart int32 start array | +| fortstride int32 stride array | +| fortedge int32 edge array | +| buffer void data buffer for read | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWrdfld(int32 swathID, char *fieldname, int32 fortstart[], + int32 fortstride[], int32 fortedge[], VOIDP buffer) + +{ + intn i; /* Loop index */ + intn status = 0; /* routine return status variable */ + + int32 rank; /* Field rank */ + int32 ntype; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 *start; /* Pointer to start array (C order) */ + int32 *stride; /* Pointer to stride array (C order) */ + int32 *edge; /* Pointer to edge array (C order) */ + + + status = SWfieldinfo(swathID, fieldname, &rank, dims, &ntype, NULL); + + if (status != -1) + { + start = (int32 *) malloc(4 * rank); + if(start == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + return(-1); + } + stride = (int32 *) malloc(4 * rank); + if(stride == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + free(start); + return(-1); + } + edge = (int32 *) malloc(4 * rank); + if(edge == NULL) + { + HEpush(DFE_NOSPACE,"GDrdfld", __FILE__, __LINE__); + free(start); + free(stride); + return(-1); + } + + /* Reverse order of dimensions (FORTRAN -> C) */ + for (i = 0; i < rank; i++) + { + start[i] = fortstart[rank - 1 - i]; + stride[i] = fortstride[rank - 1 - i]; + edge[i] = fortedge[rank - 1 - i]; + } + + status = SWwrrdfield(swathID, fieldname, "r", start, stride, edge, + buffer); + + free(start); + free(stride); + free(edge); + } + else + { + HEpush(DFE_GENAPP, "SWrdfld", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefboxregion | +| | +| DESCRIPTION: Finds swath cross tracks within area of interest and returns | +| region ID | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| cornerlon float64 dec deg Longitude of opposite corners of box | +| cornerlat float64 dec deg Latitude of opposite corners of box | +| mode int32 Search mode | +| HDFE_MIDPOINT - Use midpoint of Xtrack | +| HDFE_ENDPOINT - Use endpoints of Xtrack | +| HDFE_ANYPOINT - Use all points of Xtrack| +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Add ability to handle regions crossing date line | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Jul 98 Abe Taaheri Fixed core dump in SWregioninfo associated with | +| SWXRegion[k]->nRegions exceeding MAXNREGIONS in | +| this function | +| Aug 99 Abe Taaheri Fixed the code so that all cross tracks or all | +| points on the along track that fall inside the box | +| are identified. At the same time added code to | +| function "updatescene" to reject cases where there | +| is single cross track in the box (for LANDSAT) | +| Jun 03 Abe Taaheri Added a few lines to report error and return -1 if | +| regionID exceeded NSWATHREGN | +| Mar 04 Abe Taaheri Added recognition for GeodeticLatitude | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdefboxregion(int32 swathID, float64 cornerlon[], float64 cornerlat[], + int32 mode) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + + intn status; /* routine return status variable */ + intn statLon; /* Status from SWfieldinfo for longitude */ + intn statLat; /* Status from SWfieldinfo for latitude */ + intn statCoLat = -1; /* Status from SWfieldinfo for + * Colatitude */ + intn statGeodeticLat = -1; /* Status from SWfieldinfo for + * GeodeticLatitude */ + + uint8 found = 0; /* Found flag */ + uint8 *flag; /* Pointer to track flag array */ + intn validReg = -1; /* -1 is invalid validReg */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + int32 rank; /* Rank of geolocation fields */ + int32 nt; /* Number type of geolocation fields */ + int32 dims[8]; /* Dimensions of geolocation fields */ + int32 nElem; /* Number of elements to read */ + int32 bndflag; /* +/-180 longitude boundary flag */ + int32 lonTest; /* Longitude test flag */ + int32 latTest; /* Latitude test flag */ + int32 start[2]; /* Start array (read) */ + int32 stride[2] = {1, 1}; /* Stride array (read) */ + int32 edge[2]; /* Edge array (read) */ + int32 regionID = -1; /* Region ID (return) */ + int32 anyStart[2];/* ANYPOINT start array (read) */ + int32 anyEdge[2]; /* ANYPOINT edge array (read) */ + + float32 temp32; /* Temporary float32 variable */ + + float64 lonTestVal; /* Longitude test value */ + float64 latTestVal; /* Latitude test value */ + float64 temp64; /* Temporary float64 variable */ + + char *lonArr; /* Longitude data array */ + char *latArr; /* Latitude data array */ + char dimlist[256]; /* Dimension list (geolocation + * fields) */ + char latName[16];/* Latitude field name */ + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWdefboxregion", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Inclusion mode must be between 0 and 2 */ + /* -------------------------------------- */ + if (mode < 0 || mode > 2) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefboxregion", __FILE__, __LINE__); + HEreport("Improper Inclusion Mode: %d.\n", mode); + } + + + if (status == 0) + { + /* Get "Longitude" field info */ + /* -------------------------- */ + statLon = SWfieldinfo(swathID, "Longitude", &rank, dims, &nt, dimlist); + if (statLon != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefboxregion", __FILE__, __LINE__); + HEreport("\"Longitude\" field not found.\n"); + } + + /* Get "Latitude" field info */ + /* -------------------------- */ + statLat = SWfieldinfo(swathID, "Latitude", &rank, dims, &nt, dimlist); + if (statLat != 0) + { + /* If not found check for "Colatitude" field info */ + /* ---------------------------------------------- */ + statCoLat = SWfieldinfo(swathID, "Colatitude", &rank, dims, &nt, + dimlist); + if (statCoLat != 0) + { + /* Check again for Geodeticlatitude */ + statGeodeticLat = SWfieldinfo(swathID, + "GeodeticLatitude", &rank, + dims, &nt, dimlist); + if (statGeodeticLat != 0) + { + /* Neither "Latitude" nor "Colatitude" nor + "GeodeticLatitude" field found */ + /* ----------------------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWdefboxregion", __FILE__, __LINE__); + HEreport( + "Neither \"Latitude\" nor \"Colatitude\" nor \"GeodeticLatitude\" fields found.\n"); + } + else + { + /* Latitude field is "GeodeticLatitude" */ + /* ------------------------------ */ + strcpy(latName, "GeodeticLatitude"); + } + } + else + { + /* Latitude field is "Colatitude" */ + /* ------------------------------ */ + strcpy(latName, "Colatitude"); + } + } + else + { + /* Latitude field is "Latitude" */ + /* ---------------------------- */ + strcpy(latName, "Latitude"); + } + + + if (status == 0) + { + /* Search along entire "Track" dimension from beginning to end */ + /* ----------------------------------------------------------- */ + start[0] = 0; + edge[0] = dims[0]; + + + /* If 1D geolocation fields then set mode to MIDPOINT */ + /* -------------------------------------------------- */ + if (rank == 1) + { + mode = HDFE_MIDPOINT; + } + + + switch (mode) + { + /* If MIDPOINT search single point in middle of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_MIDPOINT: + + start[1] = dims[1] / 2; + edge[1] = 1; + + break; + + /* If ENDPOINT search 2 points at either end of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_ENDPOINT: + + start[1] = 0; + stride[1] = dims[1] - 1; + edge[1] = 2; + + break; + + /* If ANYPOINT do initial MIDPOINT search */ + /* -------------------------------------- */ + case HDFE_ANYPOINT: + + start[1] = dims[1] / 2; + edge[1] = 1; + + break; + } + + + /* Compute number of elements */ + /* -------------------------- */ + nElem = edge[0] * edge[1]; + + + /* Allocate space for longitude and latitude (float64) */ + /* --------------------------------------------------- */ + lonArr = (char *) calloc(nElem, sizeof(float64)); + if(lonArr == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + return(-1); + } + + latArr = (char *) calloc(nElem, sizeof(float64)); + if(latArr == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + free(lonArr); + return(-1); + } + + + /* Allocate space for flag array (uint8) */ + /* ------------------------------------- */ + flag = (uint8 *) calloc(edge[0] + 1, 1); + if(flag == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + free(lonArr); + free(latArr); + return(-1); + } + + + /* Read Longitude and Latitude fields */ + /* ---------------------------------- */ + status = SWreadfield(swathID, "Longitude", + start, stride, edge, lonArr); + status = SWreadfield(swathID, latName, + start, stride, edge, latArr); + + + + /* + * If geolocation fields are FLOAT32 then cast each entry as + * FLOAT64 + */ + if (nt == DFNT_FLOAT32) + { + for (i = nElem - 1; i >= 0; i--) + { + memcpy(&temp32, lonArr + 4 * i, 4); + temp64 = (float64) temp32; + memcpy(lonArr + 8 * i, &temp64, 8); + + memcpy(&temp32, latArr + 4 * i, 4); + temp64 = (float64) temp32; + memcpy(latArr + 8 * i, &temp64, 8); + } + } + + + /* Set boundary flag */ + /* ----------------- */ + + /* + * This variable is set to 1 if the region of interest crosses + * the +/- 180 longitude boundary + */ + bndflag = (cornerlon[0] < cornerlon[1]) ? 0 : 1; + + + + /* Main Search Loop */ + /* ---------------- */ + + /* For each track ... */ + /* ------------------ */ + + for (i = 0; i < edge[0]; i++) + { + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < edge[1]; j++) + { + /* Read in single lon & lat values from data buffers */ + /* ------------------------------------------------- */ + memcpy(&lonTestVal, &lonArr[8 * (i * edge[1] + j)], 8); + memcpy(&latTestVal, &latArr[8 * (i * edge[1] + j)], 8); + + + /* If longitude value > 180 convert to -180 to 180 range */ + /* ----------------------------------------------------- */ + if (lonTestVal > 180) + { + lonTestVal = lonTestVal - 360; + } + + /* If Colatitude value convert to latitude value */ + /* --------------------------------------------- */ + if (statCoLat == 0) + { + latTestVal = 90 - latTestVal; + } + + + /* Test if lat value is within range */ + /* --------------------------------- */ + latTest = (latTestVal >= cornerlat[0] && + latTestVal <= cornerlat[1]); + + + if (bndflag == 1) + { + /* + * If boundary flag set test whether longitude value + * is outside region and then flip + */ + lonTest = (lonTestVal >= cornerlon[1] && + lonTestVal <= cornerlon[0]); + lonTest = 1 - lonTest; + } + else + { + lonTest = (lonTestVal >= cornerlon[0] && + lonTestVal <= cornerlon[1]); + } + + + /* + * If both longitude and latitude are within region set + * flag on for this track + */ + if (lonTest + latTest == 2) + { + flag[i] = 1; + found = 1; + break; + } + } + } + + + + /* ANYPOINT search */ + /* --------------- */ + if (mode == HDFE_ANYPOINT && rank > 1) + { + free(lonArr); + free(latArr); + + /* Allocate space for an entire single cross track */ + /* ----------------------------------------------- */ + lonArr = (char *) calloc(dims[1], sizeof(float64)); + if(lonArr == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + return(-1); + } + + latArr = (char *) calloc(dims[1], sizeof(float64)); + if(latArr == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + free(lonArr); + return(-1); + } + + + /* Setup start and edge */ + /* -------------------- */ + anyStart[1] = 0; + anyEdge[0] = 1; + anyEdge[1] = dims[1]; + + + /* For each track starting from 0 */ + /* ------------------------------ */ + for (i = 0; i < edge[0]; i++) + { + + /* If cross track not in region (with MIDPOINT search ... */ + /* ------------------------------------------------------ */ + if (flag[i] == 0) + { + /* Setup track start */ + /* ----------------- */ + anyStart[0] = i; + + + /* Read in lon and lat values for cross track */ + /* ------------------------------------------ */ + status = SWreadfield(swathID, "Longitude", + anyStart, NULL, anyEdge, lonArr); + status = SWreadfield(swathID, latName, + anyStart, NULL, anyEdge, latArr); + + + + /* + * If geolocation fields are FLOAT32 then cast each + * entry as FLOAT64 + */ + if (nt == DFNT_FLOAT32) + { + for (j = dims[1] - 1; j >= 0; j--) + { + memcpy(&temp32, lonArr + 4 * j, 4); + temp64 = (float64) temp32; + memcpy(lonArr + 8 * j, &temp64, 8); + + memcpy(&temp32, latArr + 4 * j, 4); + temp64 = (float64) temp32; + memcpy(latArr + 8 * j, &temp64, 8); + } + } + + + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < dims[1]; j++) + { + /* Read in single lon & lat values from buffers */ + /* -------------------------------------------- */ + memcpy(&lonTestVal, &lonArr[8 * j], 8); + memcpy(&latTestVal, &latArr[8 * j], 8); + + + /* If lon value > 180 convert to -180 - 180 range */ + /* ---------------------------------------------- */ + if (lonTestVal > 180) + { + lonTestVal = lonTestVal - 360; + } + + /* If Colatitude value convert to latitude value */ + /* --------------------------------------------- */ + if (statCoLat == 0) + { + latTestVal = 90 - latTestVal; + } + + + /* Test if lat value is within range */ + /* --------------------------------- */ + latTest = (latTestVal >= cornerlat[0] && + latTestVal <= cornerlat[1]); + + + if (bndflag == 1) + { + /* + * If boundary flag set test whether + * longitude value is outside region and then + * flip + */ + lonTest = (lonTestVal >= cornerlon[1] && + lonTestVal <= cornerlon[0]); + lonTest = 1 - lonTest; + } + else + { + lonTest = (lonTestVal >= cornerlon[0] && + lonTestVal <= cornerlon[1]); + } + + + /* + * If both longitude and latitude are within + * region set flag on for this track + */ + if (lonTest + latTest == 2) + { + flag[i] = 1; + found = 1; + break; + } + } + } + } + } + + /* If within region setup Region Structure */ + /* --------------------------------------- */ + if (found == 1) + { + /* For all entries in SWXRegion array ... */ + /* -------------------------------------- */ + for (k = 0; k < NSWATHREGN; k++) + { + /* If empty region ... */ + /* ------------------- */ + if (SWXRegion[k] == 0) + { + /* Allocate space for region entry */ + /* ------------------------------- */ + SWXRegion[k] = (struct swathRegion *) + calloc(1, sizeof(struct swathRegion)); + if(SWXRegion[k] == NULL) + { + HEpush(DFE_NOSPACE,"SWdefboxregion", __FILE__, __LINE__); + return(-1); + } + + /* Store file and swath ID */ + /* ----------------------- */ + SWXRegion[k]->fid = fid; + SWXRegion[k]->swathID = swathID; + + + /* Set Start & Stop Vertical arrays to -1 */ + /* -------------------------------------- */ + for (j = 0; j < 8; j++) + { + SWXRegion[k]->StartVertical[j] = -1; + SWXRegion[k]->StopVertical[j] = -1; + SWXRegion[k]->StartScan[j] = -1; + SWXRegion[k]->StopScan[j] = -1; + } + + + /* Set region ID */ + /* ------------- */ + regionID = k; + break; + } + } + if (k >= NSWATHREGN) + { + HEpush(DFE_GENAPP, "SWdefboxregion", __FILE__, __LINE__); + HEreport( + "regionID exceeded NSWATHREGN.\n"); + return (-1); + } + + /* Find start and stop of regions */ + /* ------------------------------ */ + + /* Subtract previous flag value from current one */ + /* --------------------------------------------- */ + + /* + * Transisition points will have flag value (+1) start or + * (255 = (uint8) -1) stop of region + */ + for (i = edge[0]; i > 0; i--) + { + flag[i] -= flag[i - 1]; + } + + + for (i = 0; i <= edge[0]; i++) + { + /* Start of region */ + /* --------------- */ + if (flag[i] == 1) + { + /* Increment (multiple) region counter */ + /* ----------------------------------- */ + j = ++SWXRegion[k]->nRegions; + + /* if SWXRegion[k]->nRegions greater than MAXNREGIONS */ + /* free allocated memory and return FAIL */ + + if ((SWXRegion[k]->nRegions) > MAXNREGIONS) + { + HEpush(DFE_GENAPP, "SWdefboxregion", __FILE__, __LINE__); + HEreport("SWXRegion[%d]->nRegions exceeds MAXNREGIONS= %d.\n", k, MAXNREGIONS); + free(lonArr); + free(latArr); + free(flag); + return(-1); + } + + SWXRegion[k]->StartRegion[j - 1] = i; + } + + /* End of region */ + /* ------------- */ + if (flag[i] == 255) + { + SWXRegion[k]->StopRegion[j - 1] = i - 1; + validReg = 0; + } + } + } + free(lonArr); + free(latArr); + free(flag); + } + } + if(validReg==0) + { + return (regionID); + } + else + { + return (-1); + } + +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWregionindex | +| | +| DESCRIPTION: Finds swath cross tracks within area of interest and returns | +| region index and region ID | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| cornerlon float64 dec deg Longitude of opposite corners of box | +| cornerlat float64 dec deg Latitude of opposite corners of box | +| mode int32 Search mode | +| HDFE_MIDPOINT - Use midpoint of Xtrack | +| HDFE_ENDPOINT - Use endpoints of Xtrack | +| HDFE_ANYPOINT - Use all points of Xtrack| +| | +| OUTPUTS: | +| geodim char geolocation track dimension | +| idxrange int32 indices of region for along track dim. | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Oct 96 Joel Gales Add ability to handle regions crossing date line | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Nov 97 Daw Add multiple vertical subsetting capability | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWregionindex(int32 swathID, float64 cornerlon[], float64 cornerlat[], + int32 mode, char *geodim, int32 idxrange[]) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + + intn l=0; /* Loop index */ + intn tmpVal; /* temp value for start region Delyth Jones*/ + /*intn j1; */ /* Loop index */ + intn status; /* routine return status variable */ + intn mapstatus; /* status for type of mapping */ + intn statLon; /* Status from SWfieldinfo for longitude */ + intn statLat; /* Status from SWfieldinfo for latitude */ + intn statCoLat = -1; /* Status from SWfieldinfo for + * Colatitude */ + intn statGeodeticLat = -1; /* Status from SWfieldinfo for + * GeodeticLatitude */ + + uint8 found = 0; /* Found flag */ + uint8 *flag; /* Pointer to track flag array */ + intn validReg = -1; /* -1 is invalid validReg */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + int32 rank; /* Rank of geolocation fields */ + int32 nt; /* Number type of geolocation fields */ + int32 dims[8]; /* Dimensions of geolocation fields */ + int32 nElem; /* Number of elements to read */ + int32 bndflag; /* +/-180 longitude boundary flag */ + int32 lonTest; /* Longitude test flag */ + int32 latTest; /* Latitude test flag */ + int32 start[2]; /* Start array (read) */ + int32 stride[2] = {1, 1}; /* Stride array (read) */ + int32 edge[2]; /* Edge array (read) */ + int32 regionID = -1; /* Region ID (return) */ + int32 anyStart[2];/* ANYPOINT start array (read) */ + int32 anyEdge[2]; /* ANYPOINT edge array (read) */ + + float32 temp32; /* Temporary float32 variable */ + + float64 lonTestVal; /* Longitude test value */ + float64 latTestVal; /* Latitude test value */ + float64 temp64; /* Temporary float64 variable */ + + char *lonArr; /* Longitude data array */ + char *latArr; /* Latitude data array */ + char dimlist[256]; /* Dimension list (geolocation + * fields) */ + char latName[16];/* Latitude field name */ + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWregionindex", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Inclusion mode must be between 0 and 2 */ + /* -------------------------------------- */ + if (mode < 0 || mode > 2) + { + status = -1; + HEpush(DFE_GENAPP, "SWregionindex", __FILE__, __LINE__); + HEreport("Improper Inclusion Mode: %d.\n", mode); + } + + + if (status == 0) + { + /* Get "Longitude" field info */ + /* -------------------------- */ + statLon = SWfieldinfo(swathID, "Longitude", &rank, dims, &nt, dimlist); + if (statLon != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWregionindex", __FILE__, __LINE__); + HEreport("\"Longitude\" field not found.\n"); + } + + /* Get "Latitude" field info */ + /* -------------------------- */ + statLat = SWfieldinfo(swathID, "Latitude", &rank, dims, &nt, dimlist); + if (statLat != 0) + { + /* If not found check for "Colatitude" field info */ + /* ---------------------------------------------- */ + statCoLat = SWfieldinfo(swathID, "Colatitude", &rank, dims, &nt, + dimlist); + if (statCoLat != 0) + { + /* Check again for Geodeticlatitude */ + statGeodeticLat = SWfieldinfo(swathID, + "GeodeticLatitude", &rank, + dims, &nt, dimlist); + if (statGeodeticLat != 0) + { + /* Neither "Latitude" nor "Colatitude" field found */ + /* ----------------------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWregionindex", __FILE__, __LINE__); + HEreport( + "Neither \"Latitude\" nor \"Colatitude\" fields found.\n"); + } + else + { + /* Latitude field is "Colatitude" */ + /* ------------------------------ */ + strcpy(latName, "GeodeticLatitude"); + } + } + else + { + /* Latitude field is "Colatitude" */ + /* ------------------------------ */ + strcpy(latName, "Colatitude"); + } + } + else + { + /* Latitude field is "Latitude" */ + /* ---------------------------- */ + strcpy(latName, "Latitude"); + } + + /* This line modifies the dimlist variable so only the along-track */ + /* dimension remains. */ + /* --------------------------------------------------------------- */ + (void) strtok(dimlist,","); + mapstatus = SWgeomapinfo(swathID,dimlist); + (void) strcpy(geodim,dimlist); + + if (status == 0) + { + /* Search along entire "Track" dimension from beginning to end */ + /* ----------------------------------------------------------- */ + start[0] = 0; + edge[0] = dims[0]; + + + /* If 1D geolocation fields then set mode to MIDPOINT */ + /* -------------------------------------------------- */ + if (rank == 1) + { + mode = HDFE_MIDPOINT; + } + + + switch (mode) + { + /* If MIDPOINT search single point in middle of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_MIDPOINT: + + start[1] = dims[1] / 2; + edge[1] = 1; + + break; + + /* If ENDPOINT search 2 points at either end of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_ENDPOINT: + + start[1] = 0; + stride[1] = dims[1] - 1; + edge[1] = 2; + + break; + + /* If ANYPOINT do initial MIDPOINT search */ + /* -------------------------------------- */ + case HDFE_ANYPOINT: + + start[1] = dims[1] / 2; + edge[1] = 1; + + break; + } + + + /* Compute number of elements */ + /* -------------------------- */ + nElem = edge[0] * edge[1]; + + + /* Allocate space for longitude and latitude (float64) */ + /* --------------------------------------------------- */ + lonArr = (char *) calloc(nElem, sizeof(float64)); + if(lonArr == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + return(-1); + } + + latArr = (char *) calloc(nElem, sizeof(float64)); + if(latArr == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + free(lonArr); + return(-1); + } + + + /* Allocate space for flag array (uint8) */ + /* ------------------------------------- */ + flag = (uint8 *) calloc(edge[0] + 1, 1); + if(flag == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + free(lonArr); + free(latArr); + return(-1); + } + + + /* Read Longitude and Latitude fields */ + /* ---------------------------------- */ + status = SWreadfield(swathID, "Longitude", + start, stride, edge, lonArr); + status = SWreadfield(swathID, latName, + start, stride, edge, latArr); + + + + /* + * If geolocation fields are FLOAT32 then cast each entry as + * FLOAT64 + */ + if (nt == DFNT_FLOAT32) + { + for (i = nElem - 1; i >= 0; i--) + { + memcpy(&temp32, lonArr + 4 * i, 4); + temp64 = (float64) temp32; + memcpy(lonArr + 8 * i, &temp64, 8); + + memcpy(&temp32, latArr + 4 * i, 4); + temp64 = (float64) temp32; + memcpy(latArr + 8 * i, &temp64, 8); + } + } + + + /* Set boundary flag */ + /* ----------------- */ + + /* + * This variable is set to 1 if the region of interest crosses + * the +/- 180 longitude boundary + */ + bndflag = (cornerlon[0] < cornerlon[1]) ? 0 : 1; + + + + /* Main Search Loop */ + /* ---------------- */ + + /* For each track ... */ + /* ------------------ */ + for (i = 0; i < edge[0]; i++) + { + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < edge[1]; j++) + { + /* Read in single lon & lat values from data buffers */ + /* ------------------------------------------------- */ + memcpy(&lonTestVal, &lonArr[8 * (i * edge[1] + j)], 8); + memcpy(&latTestVal, &latArr[8 * (i * edge[1] + j)], 8); + + + /* If longitude value > 180 convert to -180 to 180 range */ + /* ----------------------------------------------------- */ + if (lonTestVal > 180) + { + lonTestVal = lonTestVal - 360; + } + + /* If Colatitude value convert to latitude value */ + /* --------------------------------------------- */ + if (statCoLat == 0) + { + latTestVal = 90 - latTestVal; + } + + + /* Test if lat value is within range */ + /* --------------------------------- */ + latTest = (latTestVal >= cornerlat[0] && + latTestVal <= cornerlat[1]); + + + if (bndflag == 1) + { + /* + * If boundary flag set test whether longitude value + * is outside region and then flip + */ + lonTest = (lonTestVal >= cornerlon[1] && + lonTestVal <= cornerlon[0]); + lonTest = 1 - lonTest; + } + else + { + lonTest = (lonTestVal >= cornerlon[0] && + lonTestVal <= cornerlon[1]); + } + + + /* + * If both longitude and latitude are within region set + * flag on for this track + */ + if (lonTest + latTest == 2) + { + flag[i] = 1; + found = 1; + break; + } + } + } + + + + /* ANYPOINT search */ + /* --------------- */ + if (mode == HDFE_ANYPOINT && rank > 1) + { + free(lonArr); + free(latArr); + + /* Allocate space for an entire single cross track */ + /* ----------------------------------------------- */ + lonArr = (char *) calloc(dims[1], sizeof(float64)); + if(lonArr == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + return(-1); + } + latArr = (char *) calloc(dims[1], sizeof(float64)); + if(latArr == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + free(lonArr); + return(-1); + } + + /* Setup start and edge */ + /* -------------------- */ + anyStart[1] = 0; + anyEdge[0] = 1; + anyEdge[1] = dims[1]; + + + /* For each track ... */ + /* ------------------ */ + for (i = 0; i < edge[0]; i++) + { + + /* If cross track not in region (with MIDPOINT search ... */ + /* ------------------------------------------------------ */ + if (flag[i] == 0) + { + /* Setup track start */ + /* ----------------- */ + anyStart[0] = i; + + + /* Read in lon and lat values for cross track */ + /* ------------------------------------------ */ + status = SWreadfield(swathID, "Longitude", + anyStart, NULL, anyEdge, lonArr); + status = SWreadfield(swathID, latName, + anyStart, NULL, anyEdge, latArr); + + + + /* + * If geolocation fields are FLOAT32 then cast each + * entry as FLOAT64 + */ + if (nt == DFNT_FLOAT32) + { + for (j = dims[1] - 1; j >= 0; j--) + { + memcpy(&temp32, lonArr + 4 * j, 4); + temp64 = (float64) temp32; + memcpy(lonArr + 8 * j, &temp64, 8); + + memcpy(&temp32, latArr + 4 * j, 4); + temp64 = (float64) temp32; + memcpy(latArr + 8 * j, &temp64, 8); + } + } + + + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < dims[1]; j++) + { + /* Read in single lon & lat values from buffers */ + /* -------------------------------------------- */ + memcpy(&lonTestVal, &lonArr[8 * j], 8); + memcpy(&latTestVal, &latArr[8 * j], 8); + + + /* If lon value > 180 convert to -180 - 180 range */ + /* ---------------------------------------------- */ + if (lonTestVal > 180) + { + lonTestVal = lonTestVal - 360; + } + + /* If Colatitude value convert to latitude value */ + /* --------------------------------------------- */ + if (statCoLat == 0) + { + latTestVal = 90 - latTestVal; + } + + + /* Test if lat value is within range */ + /* --------------------------------- */ + latTest = (latTestVal >= cornerlat[0] && + latTestVal <= cornerlat[1]); + + + if (bndflag == 1) + { + /* + * If boundary flag set test whether + * longitude value is outside region and then + * flip + */ + lonTest = (lonTestVal >= cornerlon[1] && + lonTestVal <= cornerlon[0]); + lonTest = 1 - lonTest; + } + else + { + lonTest = (lonTestVal >= cornerlon[0] && + lonTestVal <= cornerlon[1]); + } + + + /* + * If both longitude and latitude are within + * region set flag on for this track + */ + if (lonTest + latTest == 2) + { + flag[i] = 1; + found = 1; + break; + } + } + } + } + } + /* + for (j1 = 0; j1 < edge[0]; j1++) + { + idxrange[j1] = (int32) flag[j1]; + } + */ + /* If within region setup Region Structure */ + /* --------------------------------------- */ + if (found == 1) + { + /* For all entries in SWXRegion array ... */ + /* -------------------------------------- */ + for (k = 0; k < NSWATHREGN; k++) + { + /* If empty region ... */ + /* ------------------- */ + if (SWXRegion[k] == 0) + { + /* Allocate space for region entry */ + /* ------------------------------- */ + SWXRegion[k] = (struct swathRegion *) + calloc(1, sizeof(struct swathRegion)); + if(SWXRegion[k] == NULL) + { + HEpush(DFE_NOSPACE,"SWregionindex", __FILE__, __LINE__); + return(-1); + } + + /* Store file and swath ID */ + /* ----------------------- */ + SWXRegion[k]->fid = fid; + SWXRegion[k]->swathID = swathID; + + + /* Set Start & Stop Vertical arrays to -1 */ + /* -------------------------------------- */ + for (j = 0; j < 8; j++) + { + SWXRegion[k]->StartVertical[j] = -1; + SWXRegion[k]->StopVertical[j] = -1; + SWXRegion[k]->StartScan[j] = -1; + SWXRegion[k]->StopScan[j] = -1; + } + + + /* Set region ID */ + /* ------------- */ + regionID = k; + break; + } + } + if (k >= NSWATHREGN) + { + HEpush(DFE_GENAPP, "SWregionindex", __FILE__, __LINE__); + HEreport( + "regionID exceeded NSWATHREGN.\n"); + return (-1); + } + + /* Find start and stop of regions */ + /* ------------------------------ */ + + /* Subtract previous flag value from current one */ + /* --------------------------------------------- */ + + /* + * Transisition points will have flag value (+1) start or + * (255 = (uint8) -1) stop of region + */ + for (i = edge[0]; i > 0; i--) + { + flag[i] -= flag[i - 1]; + } + + + for (i = 0; i <= edge[0]; i++) + { + /* Start of region */ + /* --------------- */ + if (flag[i] == 1) + { + /* Delyth Jones Moved the increment of the region down + to next if statement j = ++SWXRegion[k]->nRegions; */ + + /* using temp value, if not equal to stop region + invalid region otherwise ok Delyth Jones */ + tmpVal = i+1; + } + + /* End of region */ + /* ------------- */ + if (flag[i] == 255) + { + if( tmpVal!=i ) + { + /* Increment (multiple) region counter */ + /* ----------------------------------- */ + j = ++SWXRegion[k]->nRegions; + + if (mapstatus == 2) + { + l = i; + if ((tmpVal-1) % 2 == 1) + { + tmpVal = tmpVal + 1; + } + + if ((l-1) % 2 == 0) + { + l = l - 1; + } + } + SWXRegion[k]->StartRegion[j - 1] = tmpVal-1; + idxrange[0] = tmpVal - 1; + SWXRegion[k]->StopRegion[j - 1] = l - 1; + idxrange[1] = l - 1; + validReg = 0; + } + } + + } + + } + free(lonArr); + free(latArr); + free(flag); + } + } + if(validReg==0) + { + return (regionID); + } + else + { + return (-1); + } + +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdeftimeperiod | +| | +| DESCRIPTION: Finds swath cross tracks observed during time period and | +| returns period ID | +| | +| region ID | +| DESCRIPTION: | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| periodID int32 Period ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| starttime float64 TAI sec Start of time period | +| stoptime float64 TAI sec Stop of time period | +| mode int32 Search mode | +| HDFE_MIDPOINT - Use midpoint of Xtrack | +| HDFE_ENDPOINT - Use endpoints of Xtrack | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdeftimeperiod(int32 swathID, float64 starttime, float64 stoptime, + int32 mode) +{ + + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status; /* routine return status variable */ + intn statTime; /* Status from SWfieldinfo for time */ + + uint8 found = 0; /* Found flag */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + int32 rank; /* Rank of geolocation fields */ + int32 nt; /* Number type of geolocation fields */ + int32 dims[8]; /* Dimensions of geolocation fields */ + int32 start[2]; /* Start array (read) */ + int32 stride[2] = {1, 1}; /* Stride array (read) */ + int32 edge[2]; /* Edge array (read) */ + int32 periodID = -1; /* Period ID (return) */ + int32 dum; /* Dummy (loop) variable */ + + float64 time64Test; /* Time test value */ + float64 *time64; /* Time data array */ + + char dimlist[256]; /* Dimension list (geolocation + * fields) */ + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWdeftimeperiod", &fid, &sdInterfaceID, + &swVgrpID); + + if (status == 0) + { + /* Get "Time" field info */ + /* --------------------- */ + statTime = SWfieldinfo(swathID, "Time", &rank, dims, &nt, dimlist); + if (statTime != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdeftimeperiod", __FILE__, __LINE__); + HEreport("\"Time\" field not found.\n"); + } + + if (status == 0) + { + /* Search along entire "Track" dimension from beginning to end */ + /* ----------------------------------------------------------- */ + start[0] = 0; + edge[0] = dims[0]; + + + /* If 1D geolocation fields then set mode to MIDPOINT */ + /* -------------------------------------------------- */ + if (rank == 1) + { + mode = HDFE_MIDPOINT; + } + + + switch (mode) + { + + /* If MIDPOINT search single point in middle of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_MIDPOINT: + + start[1] = dims[1] / 2; + edge[1] = 1; + + + /* Allocate space for time data */ + /* ---------------------------- */ + time64 = (float64 *) calloc(edge[0], 8); + if(time64 == NULL) + { + HEpush(DFE_NOSPACE,"SWdeftimeperiod", __FILE__, __LINE__); + return(-1); + } + + + /* Read "Time" field */ + /* ----------------- */ + status = SWreadfield(swathID, "Time", + start, NULL, edge, time64); + break; + + + /* If ENDPOINT search 2 points at either end of "CrossTrack" */ + /* --------------------------------------------------------- */ + case HDFE_ENDPOINT: + start[1] = 0; + stride[1] = dims[1] - 1; + edge[1] = 2; + + + /* Allocate space for time data */ + /* ---------------------------- */ + time64 = (float64 *) calloc(edge[0] * 2, 8); + if(time64 == NULL) + { + HEpush(DFE_NOSPACE,"SWdeftimeperiod", __FILE__, __LINE__); + return(-1); + } + + /* Read "Time" field */ + /* ----------------- */ + status = SWreadfield(swathID, "Time", + start, stride, edge, time64); + break; + + } + + + + /* For each track (from top) ... */ + /* ----------------------------- */ + for (i = 0; i < edge[0]; i++) + { + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < edge[1]; j++) + { + + /* Get time test value */ + /* ------------------- */ + time64Test = time64[i * edge[1] + j]; + + + /* If within time period ... */ + /* ------------------------- */ + if (time64Test >= starttime && + time64Test <= stoptime) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + + /* For all entries in SWXRegion array ... */ + /* -------------------------------------- */ + for (k = 0; k < NSWATHREGN; k++) + { + /* If empty region ... */ + /* ------------------- */ + if (SWXRegion[k] == 0) + { + /* Allocate space for region entry */ + /* ------------------------------- */ + SWXRegion[k] = (struct swathRegion *) + calloc(1, sizeof(struct swathRegion)); + if(SWXRegion[k] == NULL) + { + HEpush(DFE_NOSPACE,"SWdeftimeperiod", __FILE__, __LINE__); + return(-1); + } + + /* Store file and swath ID */ + /* ----------------------- */ + SWXRegion[k]->fid = fid; + SWXRegion[k]->swathID = swathID; + + + /* Set number of isolated regions to 1 */ + /* ----------------------------------- */ + SWXRegion[k]->nRegions = 1; + + + /* Set start of region to first track found */ + /* ---------------------------------------- */ + SWXRegion[k]->StartRegion[0] = i; + + + /* Set Start & Stop Vertical arrays to -1 */ + /* -------------------------------------- */ + for (dum = 0; dum < 8; dum++) + { + SWXRegion[k]->StartVertical[dum] = -1; + SWXRegion[k]->StopVertical[dum] = -1; + SWXRegion[k]->StartScan[dum] = -1; + SWXRegion[k]->StopScan[dum] = -1; + } + + + /* Set period ID */ + /* ------------- */ + periodID = k; + + break; /* Break from "k" loop */ + } + } + } + if (found == 1) + { + break; /* Break from "j" loop */ + } + } + if (found == 1) + { + break; /* Break from "i" loop */ + } + } + + + + /* Clear found flag */ + /* ---------------- */ + found = 0; + + + /* For each track (from bottom) ... */ + /* -------------------------------- */ + for (i = edge[0] - 1; i >= 0; i--) + { + /* For each value from Cross Track ... */ + /* ----------------------------------- */ + for (j = 0; j < edge[1]; j++) + { + + /* Get time test value */ + /* ------------------- */ + time64Test = time64[i * edge[1] + j]; + + + /* If within time period ... */ + /* ------------------------- */ + if (time64Test >= starttime && + time64Test <= stoptime) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + /* Set start of region to first track found */ + /* ---------------------------------------- */ + SWXRegion[k]->StopRegion[0] = i; + + break; /* Break from "j" loop */ + } + } + if (found == 1) + { + break; /* Break from "i" loop */ + } + } + + free(time64); + } + } + + return (periodID); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWextractregion | +| | +| DESCRIPTION: Retrieves data from specified region. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| externalflag int32 External geolocation fields flag | +| HDFE_INTERNAL (0) | +| HDFE_EXTERNAL (1) | +| | +| OUTPUTS: | +| buffer void Data buffer containing subsetted region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Add vertical subsetting | +| Oct 96 Joel Gales Mapping offset value not read from SWmapinfo | +| Dec 96 Joel Gales Vert Subset overwriting data buffer | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Mar 97 Joel Gales Add support for index mapping | +| Jul 99 DaW Add support for floating scene subsetting | +| Feb 03 Terry Haran/ | +| Abe Taaheri Forced map offset to 0 so that data is extracted | +| without offset consideration. This will preserve | +| original mapping between geofields and the data | +| field. | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWextractregion(int32 swathID, int32 regionID, char *fieldname, + int32 externalflag, VOIDP buffer) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn l; /* Loop index */ + intn status; /* routine return status variable */ + intn long_status = 3; /* routine return status variable */ + /* for longitude */ + intn land_status = 3; /* Used for L7 float scene sub. */ + intn statMap = -1; /* Status from SWmapinfo */ + + uint8 found = 0; /* Found flag */ + uint8 vfound = 0; /* Found flag for vertical subsetting*/ + /* --- xhua */ + uint8 scene_cnt = 0; /* Used for L7 float scene sub. */ + uint8 detect_cnt = 0; /* Used to convert scan to scanline */ + /* L7 float scene sub. */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + + int32 numtype = 0; /* Used for L7 float scene sub. */ + int32 count = 0; /* Used for L7 float scene sub. */ + int32 index; /* Geo Dim Index */ + int32 nDim; /* Number of dimensions */ + int32 slen[64]; /* String length array */ + int32 dum; /* Dummy variable */ + int32 offset; /* Mapping offset */ + int32 incr; /* Mapping increment */ + int32 nXtrk; /* Number of cross tracks */ + int32 scan_shift = 0; /* Used to take out partial scans */ + int32 dumdims[8]; /* Dimensions from SWfieldinfo */ + int32 start[8]; /* Start array for data read */ + int32 edge[8]; /* Edge array for data read */ + int32 dims[8]; /* Dimensions */ + int32 rank = 0; /* Field rank */ + int32 rk = 0; /* Field rank */ + int32 ntype = 0; /* Field number type */ + int32 bufOffset; /* Output buffer offset */ + int32 size; /* Size of data buffer */ + int32 idxMapElem = -1; /* Number of index map elements */ + int32 *idxmap = NULL; /* Pointer to index mapping array */ + + int32 startscanline = 0; + int32 stopscanline = 0; + char *dfieldlist = (char *)NULL; + int32 strbufsize = 0; + int32 dfrank[8]; + int32 numtype2[8]; + uint16 *buffer2 = (uint16 *)NULL; + uint16 *tbuffer = (uint16 *)NULL; + int32 dims2[8]; + int32 nt = 0; + int32 startscandim = -1; + int32 stopscandim = -1; + int32 rank2 = 0; + + char dimlist[256]; /* Dimension list */ + char geodim[256];/* Geolocation field dimension list */ + char tgeodim[256];/* Time field dimension list */ + char dgeodim[256];/* Data field dimension list for subsetting */ + char utlbuf[256];/* Utility buffer */ + char *ptr[64]; /* String pointer array */ + + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWextractregion", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NSWATHREGN) + { + status = -1; + HEpush(DFE_RANGE, "SWextractregion", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (SWXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + + /* This code checks for the attribute detector_count */ + /* which is found in Landsat 7 files. It is used */ + /* for some of the loops. */ + /* ================================================= */ + if (SWXRegion[regionID]->scanflag == 1) + { + land_status = SWattrinfo(swathID, "detector_count", &numtype, &count); + if (land_status == 0) + land_status = SWreadattr(swathID, "detector_count", &detect_cnt); + } + + /* Check that geo file and data file are same for INTERNAL subsetting */ + /* ------------------------------------------------------------------ */ + if (status == 0) + { + if (SWXRegion[regionID]->fid != fid && externalflag != HDFE_EXTERNAL) + { + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Region is not defined for this file.\n"); + } + } + + + + /* Check that geo swath and data swath are same for INTERNAL subsetting */ + /* -------------------------------------------------------------------- */ + if (status == 0) + { + if (SWXRegion[regionID]->swathID != swathID && + externalflag != HDFE_EXTERNAL) + { + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Region is not defined for this Swath.\n"); + } + } + + + + /* Check for valid fieldname */ + /* ------------------------- */ + if (status == 0) + { + + /* Get data field info */ + /* ------------------- */ + status = SWfieldinfo(swathID, fieldname, &rank, + dims, &ntype, dimlist); + + if (status != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Field \"%s\" Not Found.\n", fieldname); + } + } + + + /* No problems so proceed ... */ + /* -------------------------- */ + if (status == 0) + { + + + /* Initialize start and edge for all dimensions */ + /* -------------------------------------------- */ + for (j = 0; j < rank; j++) + { + start[j] = 0; + edge[j] = dims[j]; + } + + + /* Vertical Subset */ + /* --------------- */ + for (j = 0; j < 8; j++) + { + /* If active vertical subset ... */ + /* ----------------------------- */ + if (SWXRegion[regionID]->StartVertical[j] != -1) + { + + /* Find vertical dimension within dimlist */ + /* -------------------------------------- */ + dum = EHstrwithin(SWXRegion[regionID]->DimNamePtr[j], + dimlist, ','); + + /* If dimension found ... */ + /* ---------------------- */ + if (dum != -1) + { + /* Compute start and edge for vertical dimension */ + /* --------------------------------------------- */ + vfound = 1; /* xhua */ + start[dum] = SWXRegion[regionID]->StartVertical[j]; + edge[dum] = SWXRegion[regionID]->StopVertical[j] - + SWXRegion[regionID]->StartVertical[j] + 1; + } + else + { + /* Vertical dimension not found */ + /* ---------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Vertical Dimension Not Found: \"%s\".\n", + SWXRegion[regionID]->DimNamePtr); + } + } + } /* End of Vertical Subset loop */ + + + + /* No problems so proceed ... */ + /* -------------------------- */ + if (status == 0) + { + /* If non-vertical subset regions defined ... */ + /* ------------------------------------------ */ + if (SWXRegion[regionID]->nRegions > 0) + { + + /* Get geolocation dimension name */ + /* ------------------------------ */ + status = SWfieldinfo(SWXRegion[regionID]->swathID, + "Longitude", &dum, + dumdims, &dum, geodim); + long_status = status; + + /* If Time field being used, check for dimensions */ + /* ---------------------------------------------- */ + if (timeflag == 1) + { + /* code change to fix time subset bug for Landsat7 */ + + status = SWfieldinfo(SWXRegion[regionID]->swathID, + "Time", &dum, + dumdims, &dum, tgeodim); + + if (strcmp(geodim, tgeodim) != 0) + { + strcpy(geodim, tgeodim); + } + } + timeflag = 0; + + /* If defscanregion being used, get dimensions */ + /* of field being used */ + /* ---------------------------------------------- */ + if (SWXRegion[regionID]->scanflag == 1) + { + (void) SWnentries(SWXRegion[regionID]->swathID,4,&strbufsize); + dfieldlist = (char *)calloc(strbufsize + 1, sizeof(char)); + (void) SWinqdatafields(SWXRegion[regionID]->swathID,dfieldlist,dfrank,numtype2); + status = SWfieldinfo(SWXRegion[regionID]->swathID,dfieldlist,&dum,dumdims,&dum,dgeodim); + + /* The dimensions have to be switched, because */ + /* the mappings force a geodim and datadim */ + /* so to find the mapping, the dimensions must */ + /* be switched, but the subsetting will still */ + /* be based on the correct dimensions */ + /* ------------------------------------------- */ + if (strcmp(dgeodim,dimlist) != 0 || long_status == -1) + { + strcpy(geodim,dimlist); + strcpy(dimlist,dgeodim); + } + } + + + /* Get "Track" (first) Dimension from geo dimlist */ + /* ---------------------------------------------- */ + nDim = EHparsestr(geodim, ',', ptr, slen); + geodim[slen[0]] = 0; + + + /* Parse Data Field Dimlist & find mapping */ + /* --------------------------------------- */ + nDim = EHparsestr(dimlist, ',', ptr, slen); + + + /* Loop through all dimensions and search for mapping */ + /* -------------------------------------------------- */ + for (i = 0; i < nDim; i++) + { + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + statMap = SWmapinfo(swathID, geodim, utlbuf, + &offset, &incr); + + + /* + * Force offset to 0. + * We're not changing the mapping, so we want + * the original offset to apply to the subsetted data. + * Otherwise, bad things happen, such as subsetting + * past the end of the original data, and being unable + * to read the first <offset> elements of the + * original data. + * The offset is only important for aligning the + * data with interpolated (incr > 0) or decimated + * (incr < 0) geolocation information for the data. + */ + + offset = 0; + + + /* Mapping found */ + /* ------------- */ + if (statMap == 0) + { + found = 1; + index = i; + break; + } + } + + + /* If mapping not found check for geodim within dimlist */ + /* ---------------------------------------------------- */ + if (found == 0) + { + index = EHstrwithin(geodim, dimlist, ','); + + /* Geo dimension found within subset field dimlist */ + /* ----------------------------------------------- */ + if (index != -1) + { + found = 1; + offset = 0; + incr = 1; + } + } + + + + /* If mapping not found check for indexed mapping */ + /* ---------------------------------------------- */ + if (found == 0) + { + /* Get size of geo dim & allocate space of index mapping */ + /* ----------------------------------------------------- */ + dum = SWdiminfo(swathID, geodim); + + /* For Landsat files, the index mapping has two values */ + /* for each point, a left and right point. So for a 37 */ + /* scene band file there are 2x2 points for each scene */ + /* meaning, 2x2x37 = 148 values. The above function */ + /* only returns the number of values in the track */ + /* dimension. */ + /* ----------------------------------------------------- */ + if(land_status == 0) + if(strcmp(fieldname, "Latitude") == 0 || + strcmp(fieldname, "Longitude") == 0) + { + dum = dum * 2; + } + idxmap = (int32 *) calloc(dum, sizeof(int32)); + if(idxmap == NULL) + { + HEpush(DFE_NOSPACE,"SWextractregion", __FILE__, __LINE__); + return(-1); + } + + /* Loop through all dimensions and search for mapping */ + /* -------------------------------------------------- */ + for (i = 0; i < nDim; i++) + { + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + + idxMapElem = + SWidxmapinfo(swathID, geodim, utlbuf, idxmap); + + + /* Mapping found */ + /* ------------- */ + if (idxMapElem != -1) + { + found = 1; + index = i; + break; + } + } + } + + + /* If regular mapping found ... */ + /* ---------------------------- */ + if (found == 1 && idxMapElem == -1) + { + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + if (k > 0) + { + /* Compute size in bytes of previous region */ + /* ---------------------------------------- */ + size = edge[0]; + for (j = 1; j < rank; j++) + { + size *= edge[j]; + } + size *= DFKNTsize(ntype); + + + /* Compute output buffer offset */ + /* ---------------------------- */ + bufOffset += size; + } + else + { + /* Initialize output buffer offset */ + /* ------------------------------- */ + bufOffset = 0; + } + + + /* Compute number of cross tracks in region */ + /* ---------------------------------------- */ + nXtrk = SWXRegion[regionID]->StopRegion[k] - + SWXRegion[regionID]->StartRegion[k] + 1; + + + /* Positive increment (geodim <= datadim) */ + /* -------------------------------------- */ + if (incr > 0) + { + if (SWXRegion[regionID]->scanflag == 1) + { + start[index] = SWXRegion[regionID]->StartRegion[k]/incr; + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + start[index] = (SWXRegion[regionID]->StartRegion[k]+detect_cnt)/incr; + status = SWfieldinfo(SWXRegion[regionID]->swathID,"scan_no",&rank,dims2,&nt,dimlist); + buffer2 = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(SWXRegion[regionID]->swathID,"scan_no",NULL,NULL,NULL,buffer2); + if(incr == 1) + start[index] = start[index] - (buffer2[0] * detect_cnt); + else + start[index] = start[index] - buffer2[0]; + free(buffer2); + } + scan_shift = nXtrk % incr; + if(scan_shift != 0) + nXtrk = nXtrk - scan_shift; + edge[index] = nXtrk / incr; + if (nXtrk % incr != 0) + edge[index]++; + if(long_status == -1 || incr == 1) + { + scan_shift = nXtrk % detect_cnt; + if(scan_shift != 0) + edge[index] = nXtrk - scan_shift; + } + + } + else + { + start[index] = SWXRegion[regionID]->StartRegion[k] * incr + offset; + edge[index] = nXtrk * incr - offset; + } + } + else + { + /* Negative increment (geodim > datadim) */ + /* ------------------------------------- */ + start[index] = SWXRegion[regionID]->StartRegion[k] + / (-incr) + offset; + edge[index] = nXtrk / (-incr); + + /* + * If Xtrk not exactly divisible by incr, round + * edge to next highest integer + */ + + if (nXtrk % (-incr) != 0) + { + edge[index]++; + } + } + + + /* Read Data into output buffer */ + /* ---------------------------- */ + status = SWreadfield(swathID, fieldname, + start, NULL, edge, + (uint8 *) buffer + bufOffset); + } + } + else if (found == 1 && idxMapElem != -1) + { + /* Indexed Mapping */ + /* --------------- */ + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + if (k > 0) + { + /* Compute size in bytes of previous region */ + /* ---------------------------------------- */ + size = edge[0]; + for (j = 1; j < rank; j++) + { + size *= edge[j]; + } + size *= DFKNTsize(ntype); + + + /* Compute output buffer offset */ + /* ---------------------------- */ + bufOffset += size; + } + else + { + /* Initialize output buffer offset */ + /* ------------------------------- */ + bufOffset = 0; + } + + + /* Compute start & edge from index mappings */ + /* ---------------------------------------- */ + if (SWXRegion[regionID]->scanflag == 1 && + (strcmp(fieldname, "Latitude") == 0 || + strcmp(fieldname, "Longitude") == 0)) + { + if (land_status == 0) + status = SWreadattr(swathID, "scene_count", &scene_cnt); + startscanline = SWXRegion[regionID]->StartRegion[k]; + stopscanline = SWXRegion[regionID]->StopRegion[k]; + if(SWXRegion[regionID]->band8flag == 2 || SWXRegion[regionID]->band8flag == 3) + { + status = SWfieldinfo(swathID,"scan_no",&rk,dims2,&nt,dimlist); + tbuffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status =SWreadfield(swathID,"scan_no",NULL,NULL,NULL,tbuffer); + startscanline = startscanline - ((tbuffer[0] * detect_cnt) - detect_cnt); + stopscanline = stopscanline - ((tbuffer[0] * detect_cnt) - 1); + } + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + if(startscandim == -1) + if(startscanline < idxmap[0]) + { + startscandim = 0; + start[index] = 0; + if(stopscanline > idxmap[scene_cnt * 2 - 1]) + { + stopscandim = scene_cnt*2 - startscandim; + edge[index] = scene_cnt*2 - startscandim; + } + } + } + j = 0; + for (l = 0; l < scene_cnt; l++) + { + if(idxmap[j] <= startscanline && idxmap[j+1] >= startscanline) + if(startscandim == -1) + { + start[index] = j; + startscandim = j; + } + if(idxmap[j] <= stopscanline && idxmap[j+1] >= stopscanline) + if(startscandim != -1) + { + edge[index] = j - start[index] + 2; + stopscandim = j - start[index] + 1; + } + j = j + 2; + } + if(SWXRegion[regionID]->band8flag == 1 || + SWXRegion[regionID]->band8flag == 2) + { + if(startscandim == -1) + if(startscanline < idxmap[0]) + { + startscandim = 0; + start[index] = 0; + } + if(stopscandim == -1) + if(stopscanline > idxmap[scene_cnt * 2 - 1]) + { + stopscandim = scene_cnt*2 - start[index]; + edge[index] = scene_cnt*2 - start[index]; + } + } + if(SWXRegion[regionID]->band8flag == 2) + { + if(startscandim == -1) + if(startscanline > idxmap[j - 1]) + { + status = SWfieldinfo(SWXRegion[regionID]->swathID,"scan_no",&rank2,dims2,&nt,dimlist); + buffer2 = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(SWXRegion[regionID]->swathID,"scan_no",NULL,NULL,NULL,buffer2); + startscanline = startscanline - (buffer2[0] * detect_cnt); + stopscanline = stopscanline - (buffer2[0] * detect_cnt); + free(buffer2); + j = 0; + for (l = 0; l < scene_cnt; l++) + { + if(idxmap[j] <= startscanline && idxmap[j+1] >= startscanline) + { + start[index] = j; + } + if(idxmap[j] <= stopscanline && idxmap[j+1] >= stopscanline) + edge[index] = j - start[index] + 2; + j = j + 2; + if(idxmap[j] == 0 || idxmap[j+1] == 0) + l = scene_cnt; + } + + } + } + + } + else if(SWXRegion[regionID]->scanflag == 1 && + (strcmp(fieldname, "scene_center_latitude") == 0 || + strcmp(fieldname, "scene_center_longitude") == 0)) + { + if (land_status == 0) + status = SWreadattr(swathID, "scene_count", &scene_cnt); + startscanline = SWXRegion[regionID]->StartRegion[k]; + stopscanline = SWXRegion[regionID]->StopRegion[k]; + if(startscanline < idxmap[0]) + { + startscandim = 0; + start[index] = 0; + } + for (l = 0; l < scene_cnt-1; l++) + { + if(idxmap[l] <= startscanline && idxmap[l+1] >= startscanline) + if(startscandim == -1) + { + start[index] = l; + startscandim = l; + } + if(idxmap[l] <= stopscanline && idxmap[l+1] >= stopscanline) + if(stopscandim == -1) + { + edge[index] = l - start[index] + 2; + stopscandim = l + 1; + } + } + if(stopscandim == -1) + { + if(stopscanline > idxmap[scene_cnt - 1]) + { + edge[index] = scene_cnt - start[index]; + stopscandim = scene_cnt - 1; + } + } + + if(SWXRegion[regionID]->band8flag == 1) + { + if(stopscandim == -1) + if(stopscanline > idxmap[scene_cnt - 1]) + { + edge[index] = scene_cnt - start[index]; + stopscandim = scene_cnt -1; + } + } + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + if(startscandim == -1) + { + if(startscanline < idxmap[0]) + { + startscandim = 0; + start[index] = 0; + edge[index] = stopscandim - startscandim + 1; + } + } + if(startscandim == -1) + { + startscanline = SWXRegion[regionID]->StartScan[k] * detect_cnt - detect_cnt; + stopscanline = SWXRegion[regionID]->StopScan[k] * detect_cnt - 1; + for (l = 0; l < scene_cnt-1; l++) + { + if(idxmap[l] <= startscanline && idxmap[l+1] >= startscanline) + start[index] = l; + if(idxmap[l] <= stopscanline && idxmap[l+1] >= stopscanline) + edge[index] = l - start[index] + 1; + } + } + } + } + else + { + if (SWXRegion[regionID]->scanflag == 1 && + strcmp(fieldname,dfieldlist) == 0) + { + start[index] = SWXRegion[regionID]->StartRegion[k]; + edge[index] = SWXRegion[regionID]->StopRegion[k] - + SWXRegion[regionID]->StartRegion[k] + 1; + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3 ) + { + status = SWfieldinfo(SWXRegion[regionID]->swathID,"scan_no",&rank,dims2,&nt,dimlist); + buffer2 = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(SWXRegion[regionID]->swathID,"scan_no",NULL,NULL,NULL,buffer2); + start[index] = start[index] - (buffer2[0] * detect_cnt - detect_cnt); + free(buffer2); + } + } + else + { + start[index] = idxmap[SWXRegion[regionID]->StartRegion[k]]; + + edge[index] = idxmap[SWXRegion[regionID]->StopRegion[k]] - + idxmap[SWXRegion[regionID]->StartRegion[k]] + 1; + } + } + /* Read Data into output buffer */ + /* ---------------------------- */ + status = SWreadfield(swathID, fieldname, + start, NULL, edge, + buffer); + if (SWXRegion[regionID]->scanflag == 1) + { + + if (strcmp(fieldname,"Longitude") == 0) + { + status = SWscan2longlat(swathID, fieldname, buffer, start, + edge, idxmap, startscanline, stopscanline); + } + if (strcmp(fieldname,"Latitude") == 0) + { + status = SWscan2longlat(swathID, fieldname, buffer, start, + edge, idxmap, startscanline, stopscanline); + } + } + } + } + else if(vfound == 1) /* Vertical subsetting */ + { /* found previously, */ + status = SWreadfield(swathID, fieldname, /* perform the vertical*/ + start, NULL, edge, /* subsetting. */ + (uint8 *) buffer); /* -- xhua */ + } + else + { + /* Mapping not found */ + /* ----------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Mapping Not Defined for \"%s\" Dimension.\n", + geodim); + } + } + else + { + /* Read Data (Vert SS only) */ + /* ------------------------ */ + status = SWreadfield(swathID, fieldname, + start, NULL, edge, + (uint8 *) buffer); + } + } + } + + /* Free index mappings if applicable */ + /* --------------------------------- */ + if (idxmap != NULL) + { + free(idxmap); + } + if(dfieldlist != NULL) + free(dfieldlist); + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWscan2longlat | +| | +| DESCRIPTION: Convert scanline to Long/Lat for floating scene subsetting. | +| This will calculate/interpolate the long/lat for a given | +| scanline. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| fieldname char Fieldname | +| buffer void Values to update | +| start int32 | +| edge int32 | +| idxmap int32 * Buffer of index mapping values | +| startscanline int32 Start of scan region | +| stopscanline int32 Stop of scan region | +| | +| OUTPUTS: | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jul 99 DaW Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWscan2longlat(int32 swathID, char *fieldname, VOIDP buffer, int32 start[], +int32 edge[], int32 *idxmap, int32 startscanline, int32 stopscanline) +{ + + enum corner {UL, UR, LL, LR}; + enum corner pos = UL; + enum corner pos2 = UL; + + uint8 scene_cnt = 0; /* Used to convert scan to scanline */ + /* L7 float scene sub. */ + float32 *buffer2; + float32 *bufferc; + float32 deg2rad = PI/180.00; + + float32 p1_long = 0.0; /* point 1, longitude */ + float32 p2_long = 0.0; /* point 2, longitude */ + float32 pi_long = 0.0; /* interpolated point, longitude */ + int32 scanline_p1 = 0; + + float32 p1_lat = 0.0; /* point 1, latitude */ + float32 p2_lat = 0.0; /* point 2, latitude */ + float32 pi_lat = 0.0; /* interpolated point, latitude */ + int32 scanline_p2 = 0; + + + float32 x_p1 = 0.0; /* Cartesian coordinates */ + float32 y_p1 = 0.0; /* point 1 */ + float32 z_p1 = 0.0; + + float32 x_p2 = 0.0; /* Cartesian coordinates */ + float32 y_p2 = 0.0; /* point 2 */ + float32 z_p2 = 0.0; + + float32 x_pi = 0.0; /* Cartesian coordinates */ + float32 y_pi = 0.0; /* interpolated point */ + float32 z_pi = 0.0; + int32 scanline_pi = 0; + + intn status = -1; + + int i = 0; + int p1_long_l90_flag = 0; + int p1_long_g90_flag = 0; + int p2_long_l90_flag = 0; + int p2_long_g90_flag = 0; + int fieldflag = 0; + + int numofval = 0; + + + + numofval = edge[0] * 2; + + + buffer2 = (float32 *)calloc(numofval, sizeof(float32)); + bufferc = (float32 *)calloc(numofval, sizeof(float32)); + memmove(bufferc, buffer, numofval*sizeof(float32)); + + (void) SWreadattr(swathID, "scene_count", &scene_cnt); + + if (strcmp(fieldname, "Longitude") == 0) + { + fieldflag = 1; + status = SWreadfield(swathID, "Latitude", start, NULL, edge, buffer2); + } + else if (strcmp(fieldname, "Latitude") == 0) + { + fieldflag = 2; + status = SWreadfield(swathID, "Longitude", start, NULL, edge, buffer2); + } + + for(i=0; i<4; i++) + { + switch(pos) + { + case UL: + if (fieldflag == 1) + { + p1_long = bufferc[0]; + p2_long = bufferc[2]; + p1_lat = buffer2[0]; + p2_lat = buffer2[2]; + } + if (fieldflag == 2) + { + p1_long = buffer2[0]; + p2_long = buffer2[2]; + p1_lat = bufferc[0]; + p2_lat = bufferc[2]; + } + scanline_p1 = idxmap[start[0]]; + scanline_p2 = idxmap[start[0]+1]; + scanline_pi = startscanline; + pos = UR; + break; + case UR: + if (fieldflag == 1) + { + p1_long = bufferc[1]; + p2_long = bufferc[3]; + p1_lat = buffer2[1]; + p2_lat = buffer2[3]; + } + if (fieldflag == 2) + { + p1_long = buffer2[1]; + p2_long = buffer2[3]; + p1_lat = bufferc[1]; + p2_lat = bufferc[3]; + } + scanline_p1 = idxmap[start[0]]; + scanline_p2 = idxmap[start[0]+1]; + scanline_pi = startscanline; + pos = LL; + break; + case LL: + if (fieldflag == 1) + { + p1_long = bufferc[numofval-4]; + p2_long = bufferc[numofval-2]; + p1_lat = buffer2[numofval-4]; + p2_lat = buffer2[numofval-2]; + } + if (fieldflag == 2) + { + p1_long = buffer2[numofval-4]; + p2_long = buffer2[numofval-2]; + p1_lat = bufferc[numofval-4]; + p2_lat = bufferc[numofval-2]; + } + scanline_p1 = idxmap[start[0] + edge[0] - 2]; + scanline_p2 = idxmap[start[0] + edge[0] - 1]; + scanline_pi = stopscanline; + pos = LR; + break; + case LR: + if (fieldflag == 1) + { + p1_long = bufferc[numofval-3]; + p2_long = bufferc[numofval-1]; + p1_lat = buffer2[numofval-3]; + p2_lat = buffer2[numofval-1]; + } + if (fieldflag == 2) + { + p1_long = buffer2[numofval-3]; + p2_long = buffer2[numofval-1]; + p1_lat = bufferc[numofval-3]; + p2_lat = bufferc[numofval-1]; + } + scanline_p1 = idxmap[start[0] + edge[0] - 2]; + scanline_p2 = idxmap[start[0] + edge[0] - 1]; + scanline_pi = stopscanline; + break; + } + + + + if (p1_long <= -90.0) + { + if (p2_long >= 90.0) + { + p1_long = p1_long + 180.0; + p2_long = p2_long - 180.0; + p1_long_l90_flag = 2; + } + else + { + p1_long = p1_long + 180.0; + p1_long_l90_flag = 1; + } + } + if (p1_long >= 90.0 && p1_long_l90_flag != 2) + { + if(p2_long <= -90.0) + { + p1_long = p1_long - 180.0; + p2_long = p2_long + 180.0; + p1_long_g90_flag = 2; + } + else + { + p1_long = p1_long - 90.0; + p1_long_g90_flag = 1; + } + } + if (p2_long <= -90.0) + { + if (p1_long < 0.0) + { + p2_long = p2_long + 90.0; + p1_long = p1_long + 90.0; + p2_long_l90_flag = 2; + } + else + { + p2_long = p2_long + 180.0; + p2_long_l90_flag = 1; + } + } + if (p2_long >= 90.0 && p1_long_l90_flag != 2) + { + p2_long = p2_long - 90.0; + p2_long_g90_flag = 1; + } + + + x_p1 = RADOE * cos((p1_long*deg2rad)) * sin((p1_lat*deg2rad)); + y_p1 = RADOE * sin((p1_long*deg2rad)) * sin((p1_lat*deg2rad)); + z_p1 = RADOE * cos((p1_lat*deg2rad)); + + + x_p2 = RADOE * cos((p2_long*deg2rad)) * sin((p2_lat*deg2rad)); + y_p2 = RADOE * sin((p2_long*deg2rad)) * sin((p2_lat*deg2rad)); + z_p2 = RADOE * cos((p2_lat*deg2rad)); + + x_pi = x_p1 + (x_p2 - x_p1)*(scanline_pi-scanline_p1)/(scanline_p2-scanline_p1); + y_pi = y_p1 + (y_p2 - y_p1)*(scanline_pi-scanline_p1)/(scanline_p2-scanline_p1); + z_pi = z_p1 + (z_p2 - z_p1)*(scanline_pi-scanline_p1)/(scanline_p2-scanline_p1); + + if (fieldflag == 1) + { + pi_long = atan(y_pi/x_pi)*180.0/PI; + if (p1_long_l90_flag == 1 || p2_long_l90_flag == 1) + { + pi_long = pi_long - 180.0; + p1_long_l90_flag = 0; + p2_long_l90_flag = 0; + } + if (p1_long_g90_flag == 1 || p2_long_g90_flag == 1) + { + pi_long = pi_long + 90.0; + p1_long_g90_flag = 0; + p2_long_g90_flag = 0; + } + if (p1_long_l90_flag == 2) + { + if (pi_long > 0.0) + pi_long = pi_long - 180.0; + else if (pi_long < 0.0) + pi_long = pi_long + 180.0; + p1_long_l90_flag = 0; + } + if (p1_long_g90_flag == 2) + { + if (pi_long > 0.0) + pi_long = pi_long - 180.0; + else if (pi_long < 0.0) + pi_long = pi_long + 180.0; + p1_long_g90_flag = 0; + } + if (p2_long_l90_flag == 2) + { + pi_long = pi_long - 90.0; + p2_long_l90_flag = 0; + } + + + + switch(pos2) + { + case UL: + bufferc[0] = pi_long; + pos2 = UR; + break; + case UR: + bufferc[1] = pi_long; + pos2 = LL; + break; + case LL: + if(stopscanline > idxmap[scene_cnt*2 - 1]) + break; + bufferc[numofval-2] = pi_long; + pos2 = LR; + break; + case LR: + if(stopscanline > idxmap[scene_cnt*2 - 1]) + break; + bufferc[numofval-1] = pi_long; + break; + } + + } + if (fieldflag == 2) + { + pi_lat = atan((sqrt(x_pi*x_pi + y_pi*y_pi)/z_pi))*180.0/PI; + switch(pos2) + { + case UL: + bufferc[0] = pi_lat; + pos2 = UR; + break; + case UR: + bufferc[1] = pi_lat; + pos2 = LL; + break; + case LL: + if(stopscanline > idxmap[scene_cnt*2 - 1]) + break; + bufferc[numofval-2] = pi_lat; + pos2 = LR; + break; + case LR: + if(stopscanline > idxmap[scene_cnt*2 - 1]) + break; + bufferc[numofval-1] = pi_lat; + break; + } + } + } + memmove(buffer, bufferc, numofval*sizeof(float32)); + free(buffer2); + free(bufferc); + return(status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWextractperiod | +| | +| DESCRIPTION: Retrieves data from specified period. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| periodID int32 Period ID | +| fieldname char Fieldname | +| externalflag int32 External geolocation fields flag | +| HDFE_INTERNAL (0) | +| HDFE_EXTERNAL (1) | +| | +| OUTPUTS: | +| buffer void Data buffer containing subsetted region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jun 03 Abe Taaheri added clearing timeflag if SWextractregion failes | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWextractperiod(int32 swathID, int32 periodID, char *fieldname, + int32 externalflag, VOIDP buffer) + +{ + intn status; /* routine return status variable */ + + timeflag = 1; + + /* Call SWextractregion routine */ + /* ---------------------------- */ + status = SWextractregion(swathID, periodID, fieldname, externalflag, + (char *) buffer); + if (status != 0) timeflag = 0; /*clear timeflag if SWextractregion failed*/ + return (status); +} + + + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdupregion | +| | +| DESCRIPTION: Duplicates a region | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| newregionID int32 New region ID | +| | +| INPUTS: | +| oldregionID int32 Old region ID | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jan 97 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdupregion(int32 oldregionID) +{ + intn i; /* Loop index */ + + int32 newregionID = -1; /* New region ID */ + + + /* Find first empty (inactive) region */ + /* ---------------------------------- */ + for (i = 0; i < NSWATHREGN; i++) + { + if (SWXRegion[i] == 0) + { + /* Allocate space for new swath region entry */ + /* ----------------------------------------- */ + SWXRegion[i] = (struct swathRegion *) + calloc(1, sizeof(struct swathRegion)); + if(SWXRegion[i] == NULL) + { + HEpush(DFE_NOSPACE,"SWdupregion", __FILE__, __LINE__); + return(-1); + } + + /* Copy old region structure data to new region */ + /* -------------------------------------------- */ + *SWXRegion[i] = *SWXRegion[oldregionID]; + + + /* Define new region ID */ + /* -------------------- */ + newregionID = i; + + break; + } + } + + return (newregionID); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWregioninfo | +| | +| DESCRIPTION: Returns size of region in bytes | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| size int32 size in bytes of field region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Add vertical subsetting | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| Mar 97 Joel Gales Add support for index mapping | +| Jul 99 DaW Add support for floating scene subsetting | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWregioninfo(int32 swathID, int32 regionID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn l = 0; /* Loop index */ + intn status; /* routine return status variable */ + intn long_status = 3; /* routine return status variable for longitude */ + intn land_status = 3; /* Used for L7 float scene sub. */ + intn statMap = -1; /* Status from SWmapinfo */ + + uint8 found = 0; /* Found flag */ + uint8 detect_cnt = 0; /* Used for L7 float scene sub. */ + + int32 numtype = 0; /* Used for L7 float scene sub. */ + int32 count = 0; /* Used for L7 float scene sub. */ + + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + + int32 index; /* Geo Dim Index */ + int32 nDim; /* Number of dimensions */ + int32 slen[64]; /* String length array */ + int32 dum; /* Dummy variable */ + int32 incr; /* Mapping increment */ + int32 nXtrk = 0; /* Number of cross tracks */ + int32 scan_shift = 0; /* Used to take out partial scans */ + int32 startscandim = -1; /* Used for floating scene region size */ + int32 stopscandim = -1; /* Used for floating scene region size */ + int32 dumdims[8]; /* Dimensions from SWfieldinfo */ + int32 idxMapElem = -1; /* Number of index map elements */ + int32 *idxmap = NULL; /* Pointer to index mapping array */ + int32 datafld = 0; + + uint8 scene_cnt = 0; /* Number of scenes in swath */ + int32 startscanline = 0; + int32 stopscanline = 0; + char *dfieldlist = (char *)NULL; + int32 strbufsize = 0; + int32 dfrank[8]; + int32 numtype2[8]; + int32 rank2 = 0; + int32 rk = 0; + int32 dims2[8]; + int32 nt = 0; + uint16 *buffer2 = (uint16 *)NULL; + uint16 *tbuffer = (uint16 *)NULL; + + char dimlist[256]; /* Dimension list */ + char geodim[256];/* Geolocation field dimension list */ + char tgeodim[256];/* Time Geolocation field dimension list */ + char dgeodim[256];/* Data Subsetting field dimension list */ + char utlbuf[256];/* Utility buffer */ + char *ptr[64]; /* String pointer array */ + char *errMesg = "Vertical Dimension Not Found: \"%s\".\n"; + + + + /* Set region size to -1 */ + /* --------------------- */ + *size = -1; + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWregioninfo", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NSWATHREGN) + { + status = -1; + HEpush(DFE_RANGE, "SWregioninfo", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (SWXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWregioninfo", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + /* This code checks for the attribute detector_count */ + /* which is found in Landsat 7 files. It is used */ + /* for some of the loops. */ + /* ================================================= */ + if (SWXRegion[regionID]->scanflag == 1) + { + land_status = SWattrinfo(swathID, "detector_count", &numtype, &count); + if (land_status == 0) + { + land_status = SWreadattr(swathID, "detector_count", &detect_cnt); + land_status = SWreadattr(swathID, "scene_count", &scene_cnt); + + } + } + + + + + /* Check for valid fieldname */ + /* ------------------------- */ + if (status == 0) + { + /* Get data field info */ + /* ------------------- */ + status = SWfieldinfo(swathID, fieldname, rank, + dims, ntype, dimlist); + + if (status != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWregioninfo", __FILE__, __LINE__); + HEreport("Field \"%s\" Not Found.\n", fieldname); + } + } + + + + /* No problems so proceed ... */ + /* -------------------------- */ + if (status == 0) + { + /* If non-vertical subset regions defined ... */ + /* ------------------------------------------ */ + if (SWXRegion[regionID]->nRegions > 0 || SWXRegion[regionID]->scanflag == 1) + { + + /* Get geolocation dimension name */ + /* ------------------------------ */ + status = SWfieldinfo(SWXRegion[regionID]->swathID, + "Longitude", &dum, + dumdims, &dum, geodim); + long_status = status; + + /* If Time field being used, check for dimensions */ + /* ---------------------------------------------- */ + if (timeflag == 1) + { + /* code change to fix time subset bug for Landsat7 */ + + status = SWfieldinfo(SWXRegion[regionID]->swathID, + "Time", &dum, + dumdims, &dum, tgeodim); + + if (strcmp(geodim, tgeodim) != 0) + { + strcpy(geodim, tgeodim); + } + timeflag = 0; + } + + /* If defscanregion being used, get dimensions */ + /* of field being used */ + /* ---------------------------------------------- */ + if (SWXRegion[regionID]->scanflag == 1) + { + (void) SWnentries(SWXRegion[regionID]->swathID,4,&strbufsize); + dfieldlist = (char *)calloc(strbufsize + 1, sizeof(char)); + (void) SWinqdatafields(SWXRegion[regionID]->swathID,dfieldlist,dfrank,numtype2); + status = SWfieldinfo(SWXRegion[regionID]->swathID,dfieldlist,&dum,dumdims,&dum,dgeodim); + + /* The dimensions have to be switched, because */ + /* the mappings force a geodim and datadim */ + /* so to find the mapping, the dimensions must */ + /* be switched, but the subsetting will still */ + /* be based on the correct dimensions */ + /* "long_status == -1" added for CAL file which */ + /* doesn't have a Traditional geolocation field */ + /* ---------------------------------------------- */ + if (strcmp(dgeodim,dimlist) != 0 || long_status == -1) + { + strcpy(geodim,dimlist); + strcpy(dimlist,dgeodim); + } + } + + + /* Get "Track" (first) Dimension from geo dimlist */ + /* ---------------------------------------------- */ + nDim = EHparsestr(geodim, ',', ptr, slen); + geodim[slen[0]] = 0; + + + /* Parse Data Field Dimlist & find mapping */ + /* --------------------------------------- */ + nDim = EHparsestr(dimlist, ',', ptr, slen); + + + /* Loop through all dimensions and search for mapping */ + /* -------------------------------------------------- */ + for (i = 0; i < nDim; i++) + { + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + statMap = SWmapinfo(swathID, geodim, utlbuf, + &dum, &incr); + + /* Mapping found */ + /* ------------- */ + if (statMap == 0) + { + found = 1; + index = i; + break; + } + } + + + /* If mapping not found check for geodim within dimlist */ + /* ---------------------------------------------------- */ + if (found == 0) + { + index = EHstrwithin(geodim, dimlist, ','); + + /* Geo dimension found within subset field dimlist */ + /* ----------------------------------------------- */ + if (index != -1) + { + found = 1; + incr = 1; + } + } + + + + /* If mapping not found check for indexed mapping */ + /* ---------------------------------------------- */ + if (found == 0) + { + /* Get size of geo dim & allocate space of index mapping */ + /* ----------------------------------------------------- */ + dum = SWdiminfo(swathID, geodim); + idxmap = (int32 *) calloc(dum, sizeof(int32)); + if(idxmap == NULL) + { + HEpush(DFE_NOSPACE,"SWregioninfo", __FILE__, __LINE__); + return(-1); + } + + /* Loop through all dimensions and search for mapping */ + /* -------------------------------------------------- */ + for (i = 0; i < nDim; i++) + { + memcpy(utlbuf, ptr[i], slen[i]); + utlbuf[slen[i]] = 0; + + idxMapElem = SWidxmapinfo(swathID, geodim, utlbuf, idxmap); + + + /* Mapping found */ + /* ------------- */ + if (idxMapElem != -1) + { + found = 1; + index = i; + break; + } + } + } + + + /* Regular Mapping Found */ + /* --------------------- */ + if (found == 1 && idxMapElem == -1) + { + dims[index] = 0; + + /* Loop through all regions */ + /* ------------------------ */ + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + /* Get number of cross tracks in particular region */ + /* ----------------------------------------------- */ + nXtrk = SWXRegion[regionID]->StopRegion[k] - + SWXRegion[regionID]->StartRegion[k] + 1; + + + /* If increment is positive (geodim <= datadim) ... */ + /* ------------------------------------------------ */ + if (incr > 0) + { + if (SWXRegion[regionID]->scanflag == 1) + { + scan_shift = nXtrk % incr; + if(scan_shift != 0) + nXtrk = nXtrk - scan_shift; + dims[index] += nXtrk/incr; + if(long_status == -1 || incr == 1) + { + scan_shift = nXtrk % detect_cnt; + if(scan_shift != 0) + dims[index] = nXtrk - scan_shift; + } + } + else + { + dims[index] += nXtrk * incr; + } + } + else + { + /* Negative increment (geodim > datadim) */ + /* ------------------------------------- */ + dims[index] += nXtrk / (-incr); + + /* + * If Xtrk not exactly divisible by incr, round dims + * to next highest integer + */ + if (nXtrk % (-incr) != 0) + { + dims[index]++; + } + } + } + } + else if (found == 1 && idxMapElem != -1) + { + + /* Indexed Mapping */ + /* --------------- */ + + dims[index] = 0; + + /* Loop through all regions */ + /* ------------------------ */ + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + j = 0; + if(SWXRegion[regionID]->scanflag == 1) + { + startscanline = SWXRegion[regionID]->StartRegion[k]; + stopscanline = SWXRegion[regionID]->StopRegion[k]; + if (strcmp(fieldname,dfieldlist) == 0) + { + dims[index] = stopscanline - startscanline + 1; + datafld = 1; + } + if (strcmp(fieldname, "Latitude") == 0 || + strcmp(fieldname, "Longitude") == 0) + { + if(SWXRegion[regionID]->band8flag == 2 || SWXRegion[regionID]->band8flag == 3) + { + status = SWfieldinfo(swathID,"scan_no",&rk,dims2,&nt,dimlist); + tbuffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status =SWreadfield(swathID,"scan_no",NULL,NULL,NULL,tbuffer); + startscanline = startscanline - ((tbuffer[0] * detect_cnt) - detect_cnt); + stopscanline = stopscanline - ((tbuffer[0] * detect_cnt) - 1); + } + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + if(startscandim == -1) + if(startscanline < idxmap[0]) + { + startscandim = 0; + dims[index] = 0; + if(stopscanline > idxmap[scene_cnt *2 - 1]) + { + stopscandim = scene_cnt*2 - startscandim; + dims[index] = scene_cnt*2 - startscandim; + } + } + } + for (l = 0; l < scene_cnt; l++) + { + if(idxmap[j] <= startscanline && idxmap[j+1] >= startscanline) + if(startscandim == -1) + { + dims[index] = j; + startscandim = j; + } + if(idxmap[j] <= stopscanline && idxmap[j+1] >= stopscanline) + if(startscandim != -1) + { + dims[index] = j - startscandim + 2; + stopscandim = j + 1; + } + j = j + 2; + if(idxmap[j] == 0 || idxmap[j+1] == 0) + l = scene_cnt; + } + if(SWXRegion[regionID]->band8flag == 1 || + SWXRegion[regionID]->band8flag == 2) + { + if(stopscandim == -1) + if(stopscanline > idxmap[scene_cnt * 2 - 1]) + { + stopscandim = scene_cnt*2 - dims[index]; + dims[index] = scene_cnt*2 - dims[index]; + } + } + if(SWXRegion[regionID]->band8flag == 3) + { + if(startscandim == -1) + if(startscanline < idxmap[0]) + { + startscandim = 0; + if(stopscandim != -1) + dims[index] = stopscandim - startscandim + 1; + } + } + if(SWXRegion[regionID]->band8flag == 2) + { + if(startscandim == -1) + if(startscanline > idxmap[j - 1]) + { + status = SWfieldinfo(SWXRegion[regionID]->swathID,"scan_no",&rank2,dims2,&nt,dimlist); + buffer2 = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(SWXRegion[regionID]->swathID,"scan_no",NULL,NULL,NULL,buffer2); + startscanline = startscanline - (buffer2[0] * detect_cnt); + stopscanline = stopscanline - (buffer2[0] * detect_cnt); + free(buffer2); + j = 0; + for (l = 0; l < scene_cnt; l++) + { + if(idxmap[j] <= startscanline && idxmap[j+1] >= startscanline) + { + dims[index] = j; + startscandim = j; + } + if(idxmap[j] <= stopscanline && idxmap[j+1] >= stopscanline) + dims[index] = j - startscandim + 2; + j = j + 2; + if(idxmap[j] == 0 || idxmap[j+1] == 0) + l = scene_cnt; + } + + } + } + } + if (strcmp(fieldname, "scene_center_latitude") == 0 || + strcmp(fieldname, "scene_center_longitude") == 0) + { + startscanline = SWXRegion[regionID]->StartRegion[k]; + stopscanline = SWXRegion[regionID]->StopRegion[k]; + if(startscanline < idxmap[0]) + { + startscandim = 0; + dims[index] = 0; + } + for (l = 0; l < scene_cnt-1; l++) + { + if(idxmap[l] <= startscanline && idxmap[l+1] >= startscanline) + if(startscandim == -1) + { + dims[index] = l; + startscandim = l; + } + if(idxmap[l] <= stopscanline && idxmap[l+1] >= stopscanline) + { + dims[index] = l - startscandim + 2; + stopscandim = l + 1; + } + } + if(stopscandim == -1) + { + if(stopscanline > idxmap[scene_cnt - 1]) + { + dims[index] = scene_cnt - startscandim; + stopscandim = scene_cnt - 1; + } + } + if(SWXRegion[regionID]->band8flag == 1) + { + if(stopscandim == -1) + if(stopscanline > idxmap[scene_cnt - 1]) + { + dims[index] = scene_cnt - startscandim; + stopscandim = scene_cnt - 1; + } + } + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + if(startscandim == -1) + { + if(startscanline < idxmap[0]) + { + startscandim = 0; + dims[index] = stopscandim - startscandim + 1; + } + } + if(startscandim == -1) + { + startscanline = SWXRegion[regionID]->StartScan[k] * detect_cnt; + stopscanline = SWXRegion[regionID]->StopScan[k] * detect_cnt; + for (l = 0; l < scene_cnt-1; l++) + { + if(idxmap[l] <= startscanline && idxmap[l+1] >= startscanline) + dims[index] = l; + if(idxmap[l] <= stopscanline && idxmap[l+1] >= stopscanline) + dims[index] = l - dims[index] + 1; + } + } + } + } + } + else + { + if (datafld != 1) + { + /* Get number of cross tracks in particular region */ + /* ----------------------------------------------- */ + nXtrk = idxmap[SWXRegion[regionID]->StopRegion[k]] - + idxmap[SWXRegion[regionID]->StartRegion[k]] + 1; + + dims[index] += nXtrk; + } + } + } + } + else + { + /* Mapping not found */ + /* ----------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWregioninfo", + __FILE__, __LINE__); + HEreport( + "Mapping Not Defined for \"%s\" Dimension.\n", + geodim); + } + } + + + + /* Vertical Subset */ + /* --------------- */ + if (status == 0 || status == -1) /* check the vertical subset in any case -- xhua */ + { + for (j = 0; j < 8; j++) + { + /* If active vertical subset ... */ + /* ----------------------------- */ + if (SWXRegion[regionID]->StartVertical[j] != -1) + { + + /* Find vertical dimension within dimlist */ + /* -------------------------------------- */ + index = EHstrwithin(SWXRegion[regionID]->DimNamePtr[j], + dimlist, ','); + + /* If dimension found ... */ + /* ---------------------- */ + if (index != -1) + { + /* Compute dimension size */ + /* ---------------------- */ + dims[index] = + SWXRegion[regionID]->StopVertical[j] - + SWXRegion[regionID]->StartVertical[j] + 1; + } + else + { + /* Vertical dimension not found */ + /* ---------------------------- */ + status = -1; + *size = -1; + HEpush(DFE_GENAPP, "SWregioninfo", __FILE__, __LINE__); + HEreport(errMesg, SWXRegion[regionID]->DimNamePtr[j]); + } + } + } + + + + /* Compute size of region data buffer */ + /* ---------------------------------- */ + if (status == 0) + { + if(idxMapElem == 1 && SWXRegion[regionID]->scanflag == 1 && land_status == 0) + { + if(startscandim == dims[0]) + dims[0] = scene_cnt*2 - startscandim; + } + + /* Compute number of total elements */ + /* -------------------------------- */ + *size = dims[0]; + for (j = 1; j < *rank; j++) + { + *size *= dims[j]; + } + + /* Multiply by size in bytes of numbertype */ + /* --------------------------------------- */ + *size *= DFKNTsize(*ntype); + } + } + } + + + + /* Free index mappings if applicable */ + /* --------------------------------- */ + if (idxmap != NULL) + { + free(idxmap); + } + if(dfieldlist != NULL) + free(dfieldlist); + + return (status); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWreginfo | +| | +| DESCRIPTION: FORTRAN wrapper around SWregioninfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| (FORTRAN order) | +| size int32 size in bytes of field region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWreginfo(int32 swathID, int32 regionID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size) +{ + intn j; /* Loop index */ + intn status; /* routine return status variable */ + + int32 swap; /* Temporary swap variable */ + + + /* Call SWregioninfo */ + /* ----------------- */ + status = SWregioninfo(swathID, regionID, fieldname, + ntype, rank, dims, size); + + + /* Change dimensions to FORTRAN order */ + /* ---------------------------------- */ + for (j = 0; j < *rank / 2; j++) + { + swap = dims[*rank - 1 - j]; + dims[*rank - 1 - j] = dims[j]; + dims[j] = swap; + } + return (status); +} + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWperiodinfo | +| | +| DESCRIPTION: Returns size in bytes of region | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| periodID int32 Period ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| size int32 size in bytes of field region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jun 03 Abe Taaheri added clearing timeflag if SWregioninfo failes | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWperiodinfo(int32 swathID, int32 periodID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size) +{ + intn status; /* routine return status variable */ + + + timeflag = 1; + /* Call SWregioninfo */ + /* ----------------- */ + status = SWregioninfo(swathID, periodID, fieldname, ntype, rank, + dims, size); + if (status != 0) timeflag = 0;/* clear timeflag if SWregioninfo failed */ + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWperinfo | +| | +| DESCRIPTION: FORTRAN wrapper around SWperiodinfo | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| periodID int32 Period ID | +| fieldname char Fieldname | +| | +| | +| OUTPUTS: | +| ntype int32 field number type | +| rank int32 field rank | +| dims int32 dimensions of field region | +| (FORTRAN order) | +| size int32 size in bytes of field region | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Jul 96 Joel Gales Fix FORTRAN ordering of dims omitted in original | +| version | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWperinfo(int32 swathID, int32 periodID, char *fieldname, + int32 * ntype, int32 * rank, int32 dims[], int32 * size) +{ + intn j; /* Loop index */ + intn status; /* routine return status variable */ + + int32 swap; /* Temporary swap variable */ + + + /* Call SWreginfo */ + /* -------------- */ + status = SWreginfo(swathID, periodID, fieldname, ntype, rank, + dims, size); + + + /* Change dimensions to FORTRAN order */ + /* ---------------------------------- */ + for (j = 0; j < *rank / 2; j++) + { + swap = dims[*rank - 1 - j]; + dims[*rank - 1 - j] = dims[j]; + dims[j] = swap; + } + + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefvrtregion | +| | +| DESCRIPTION: Finds elements of a monotonic field within a given range. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| vertObj char Vertical object to subset | +| range float64 Vertical subsetting range | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 96 Joel Gales Original Programmer | +| Dec 96 Joel Gales Add multiple vertical subsetting capability | +| May 97 Joel Gales Check for supported field types | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ + + +/* Macro to initialize swath region entry */ +/* -------------------------------------- */ + +/* + * 1) Find empty (inactive) region. 2) Allocate space for region entry. 3) + * Store file ID and swath ID. 4) Set region ID. 5) Initialize vertical + * subset entries to -1. + */ + +#define SETSWTHREG \ +\ +for (k = 0; k < NSWATHREGN; k++) \ +{ \ + if (SWXRegion[k] == 0) \ + { \ + SWXRegion[k] = (struct swathRegion *) \ + calloc(1, sizeof(struct swathRegion)); \ + SWXRegion[k]->fid = fid; \ + SWXRegion[k]->swathID = swathID; \ + regionID = k; \ + for (j=0; j<8; j++) \ + { \ + SWXRegion[k]->StartVertical[j] = -1; \ + SWXRegion[k]->StopVertical[j] = -1; \ + SWXRegion[k]->StartScan[j] = -1; \ + SWXRegion[k]->StopScan[j] = -1; \ + SWXRegion[k]->band8flag = -1; \ + } \ + break; \ + } \ +} + + +/* Macro to fill vertical subset entry */ +/* ----------------------------------- */ + +/* + * 1) Find empty (inactive) vertical region. 2) Set start of vertical region. + * 3) Allocate space for name of vertical dimension. 4) Write vertical + * dimension name. + */ + +#define FILLVERTREG \ +for (j=0; j<8; j++) \ +{ \ + if (SWXRegion[regionID]->StartVertical[j] == -1) \ + { \ + SWXRegion[regionID]->StartVertical[j] = i; \ + SWXRegion[regionID]->DimNamePtr[j] = \ + (char *) malloc(slen + 1); \ + memcpy(SWXRegion[regionID]->DimNamePtr[j], \ + dimlist, slen + 1); \ + break; \ + } \ +} \ + + + +int32 +SWdefvrtregion(int32 swathID, int32 regionID, char *vertObj, float64 range[]) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status; /* routine return status variable */ + + uint8 found = 0; /* Found flag */ + + int16 vertINT16; /* Temporary INT16 variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + int32 slen; /* String length */ + int32 rank; /* Field rank */ + int32 nt; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 size; /* Size of numbertype in bytes */ + int32 vertINT32; /* Temporary INT32 variable */ + + float32 vertFLT32; /* Temporary FLT32 variable */ + + float64 vertFLT64; /* Temporary FLT64 variable */ + + char *vertArr; /* Pointer to vertical field data buffer */ + char dimlist[256]; /* Dimension list */ + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWdefvrtregion", &fid, &sdInterfaceID, + &swVgrpID); + + if (status == 0) + { + /* Copy first 4 characters of vertObj into dimlist */ + /* ----------------------------------------------- */ + memcpy(dimlist, vertObj, 4); + dimlist[4] = 0; + + + + /* If first 4 characters of vertObj = "DIM:" ... */ + /* --------------------------------------------- */ + + /* Vertical Object is dimension name */ + /* --------------------------------- */ + if (strcmp(dimlist, "DIM:") == 0) + { + /* Get string length of vertObj (minus "DIM:) */ + /* ------------------------------------------ */ + slen = strlen(vertObj) - 4; + + + /* If regionID = -1 then setup swath region entry */ + /* ---------------------------------------------- */ + if (regionID == -1) + { + SETSWTHREG; + } + + + /* Find first empty (inactive) vertical subset entry */ + /* ------------------------------------------------- */ + for (j = 0; j < 8; j++) + { + if (SWXRegion[regionID]->StartVertical[j] == -1) + { + /* Store start & stop of vertical region */ + /* ------------------------------------- */ + SWXRegion[regionID]->StartVertical[j] = (int32) range[0]; + SWXRegion[regionID]->StopVertical[j] = (int32) range[1]; + + /* Store vertical dimension name */ + /* ----------------------------- */ + SWXRegion[regionID]->DimNamePtr[j] = + (char *) malloc(slen + 1); + if(SWXRegion[regionID]->DimNamePtr[j] == NULL) + { + HEpush(DFE_NOSPACE,"SWdefvrtregion", __FILE__, __LINE__); + return(-1); + } + memcpy(SWXRegion[regionID]->DimNamePtr[j], + vertObj + 4, slen + 1); + break; + } + } + } + else + { + + /* Vertical Object is fieldname */ + /* ---------------------------- */ + + + /* Check for valid fieldname */ + /* ------------------------- */ + status = SWfieldinfo(swathID, vertObj, &rank, dims, &nt, + dimlist); + + if (status != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", __FILE__, __LINE__); + HEreport("Vertical Field: \"%s\" not found.\n", vertObj); + } + + + + /* Check for supported field types */ + /* ------------------------------- */ + if (nt != DFNT_INT16 && + nt != DFNT_INT32 && + nt != DFNT_FLOAT32 && + nt != DFNT_FLOAT64) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", __FILE__, __LINE__); + HEreport("Fieldtype: %d not supported for vertical subsetting.\n", nt); + } + + + + /* Check that vertical dimension is 1D */ + /* ----------------------------------- */ + if (status == 0) + { + if (rank != 1) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", __FILE__, __LINE__); + HEreport("Vertical Field: \"%s\" must be 1-dim.\n", + vertObj); + } + } + + + /* If no problems then continue */ + /* ---------------------------- */ + if (status == 0) + { + /* Get string length of vertical dimension */ + /* --------------------------------------- */ + slen = strlen(dimlist); + + + /* Get size in bytes of vertical field numbertype */ + /* ---------------------------------------------- */ + size = DFKNTsize(nt); + + + /* Allocate space for vertical field */ + /* --------------------------------- */ + vertArr = (char *) calloc(dims[0], size); + if(vertArr == NULL) + { + HEpush(DFE_NOSPACE,"SWdefvrtregion", __FILE__, __LINE__); + return(-1); + } + + /* Read vertical field */ + /* ------------------- */ + status = SWreadfield(swathID, vertObj, + NULL, NULL, NULL, vertArr); + + + + switch (nt) + { + case DFNT_INT16: + + for (i = 0; i < dims[0]; i++) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertINT16, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertINT16 >= range[0] && + vertINT16 <= range[1]) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + + /* If regionID=-1 then setup swath region entry */ + /* -------------------------------------------- */ + if (regionID == -1) + { + SETSWTHREG; + } + + + /* Fill-in vertical region entries */ + /* ------------------------------- */ + FILLVERTREG; + + break; + } + } + + + /* If found read from "bottom" of data field */ + /* ----------------------------------------- */ + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertINT16, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertINT16 >= range[0] && + vertINT16 <= range[1]) + { + /* Set end of vertical region */ + /* -------------------------- */ + SWXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + /* No vertical entries within region */ + /* --------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", + __FILE__, __LINE__); + HEreport("No vertical field entries within region.\n"); + } + break; + + + case DFNT_INT32: + + for (i = 0; i < dims[0]; i++) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertINT32, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertINT32 >= range[0] && + vertINT32 <= range[1]) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + + /* If regionID=-1 then setup swath region entry */ + /* -------------------------------------------- */ + if (regionID == -1) + { + SETSWTHREG; + } + + + /* Fill-in vertical region entries */ + /* ------------------------------- */ + FILLVERTREG; + + break; + } + } + + + /* If found read from "bottom" of data field */ + /* ----------------------------------------- */ + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertINT32, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertINT32 >= range[0] && + vertINT32 <= range[1]) + { + /* Set end of vertical region */ + /* -------------------------- */ + SWXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + /* No vertical entries within region */ + /* --------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", + __FILE__, __LINE__); + HEreport("No vertical field entries within region.\n"); + } + break; + + + case DFNT_FLOAT32: + + for (i = 0; i < dims[0]; i++) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertFLT32, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertFLT32 >= range[0] && + vertFLT32 <= range[1]) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + + /* If regionID=-1 then setup swath region entry */ + /* -------------------------------------------- */ + if (regionID == -1) + { + SETSWTHREG; + } + + + /* Fill-in vertical region entries */ + /* ------------------------------- */ + FILLVERTREG; + + break; + } + } + + + /* If found read from "bottom" of data field */ + /* ----------------------------------------- */ + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertFLT32, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertFLT32 >= range[0] && + vertFLT32 <= range[1]) + { + /* Set end of vertical region */ + /* -------------------------- */ + SWXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + /* No vertical entries within region */ + /* --------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", + __FILE__, __LINE__); + HEreport("No vertical field entries within region.\n"); + } + break; + + + case DFNT_FLOAT64: + + for (i = 0; i < dims[0]; i++) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertFLT64, vertArr + i * size, size); + + + /* If within range ... */ + /* ------------------- */ + if (vertFLT64 >= range[0] && + vertFLT64 <= range[1]) + { + /* Set found flag */ + /* -------------- */ + found = 1; + + + /* If regionID=-1 then setup swath region entry */ + /* -------------------------------------------- */ + if (regionID == -1) + { + SETSWTHREG; + } + + + /* Fill-in vertical region entries */ + /* ------------------------------- */ + FILLVERTREG; + + break; + } + } + + + /* If found read from "bottom" of data field */ + /* ----------------------------------------- */ + if (found == 1) + { + for (i = dims[0] - 1; i >= 0; i--) + { + /* Get single element of vertical field */ + /* ------------------------------------ */ + memcpy(&vertFLT64, vertArr + i * size, size); + + /* If within range ... */ + /* ------------------- */ + if (vertFLT64 >= range[0] && + vertFLT64 <= range[1]) + { + /* Set end of vertical region */ + /* -------------------------- */ + SWXRegion[regionID]->StopVertical[j] = i; + break; + } + } + } + else + { + /* No vertical entries within region */ + /* --------------------------------- */ + status = -1; + HEpush(DFE_GENAPP, "SWdefvrtregion", + __FILE__, __LINE__); + HEreport("No vertical field entries within region.\n"); + } + break; + + } /* End of switch */ + free(vertArr); + } + } + } + + + /* Set regionID to -1 if bad return status */ + /* --------------------------------------- */ + if (status == -1) + { + regionID = -1; + } + + + return (regionID); +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefvrtreg | +| | +| DESCRIPTION: FORTRAN wrapper arount SWdefvrtregion | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| vertObj char Vertical object to subset | +| range float64 Vertical subsetting range | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Oct 96 Joel Gales Original Programmer | +| Feb 97 Joel Gales Change call SWdefvrtreg to SWdefvrtregion | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdefvrtreg(int32 swathID, int32 regionID, char *vertObj, float64 fortrange[]) +{ + float64 range[2]; /* range (C) */ + + char utlbuf[16]; /* Utility buffer */ + + + /* Copy first four character of vertObj to utlbuf */ + /* ---------------------------------------------- */ + memcpy(utlbuf, vertObj, 4); + utlbuf[4] = 0; + + + /* If subsetting on dimension elements convert FORTRAN indices to C */ + /* ---------------------------------------------------------------- */ + if (strcmp(utlbuf, "DIM:") == 0) + { + range[0] = fortrange[0] - 1; + range[1] = fortrange[1] - 1; + } + else + { + range[0] = fortrange[0]; + range[1] = fortrange[1]; + } + + + /* Call SWdefvrtregion */ + /* ------------------- */ + regionID = SWdefvrtregion(swathID, regionID, vertObj, range); + + return (regionID); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdefscanregion | +| | +| DESCRIPTION: Initialize the region structure for Landsat 7 float scene | +| subset | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| regionID int32 Region ID | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| fieldname char Field name to subset | +| range float64 subsetting range | +| mode int32 HDFE_ENDPOINT, HDFE_MIDPOINT or | +| HDFE_ANYPOINT | +| | +| OUTPUTS: | +| regionID int32 Region ID | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jul 99 DaW Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWdefscanregion(int32 swathID, char *fieldname, float64 range[], int32 mode) +{ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status; /* routine return status variable */ + intn land_status = 3; /* routine return status variable */ + intn band81flag = 0; + intn band82flag = 0; + intn band83flag = 0; + uint8 detect_cnt = 0; /* Used to convert scan to scanline */ + /* L7 float scene sub. */ + uint8 scene_cnt = 0; + + + int32 nmtype = 0; /* Used for L7 float scene sub. */ + int32 count = 0; /* Used for L7 float scene sub. */ + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + int32 slen; /* String length */ + int32 dfrank[8]; /* data fields rank */ + int32 rank; /* Field rank */ + int32 numtype[8]; /* number type of data fields */ + int32 nt; /* Field numbertype */ + int32 dims[8]; /* Field dimensions */ + int32 dims2[8]; /* Field dimensions */ + int32 strbufsize = 0; /* string buffer size */ + int32 tmprange0 = 0; + + + uint16 *buffer = (uint16 *)NULL; + int32 *idxmap = (int32 *)NULL; + + int32 dimsize = 0; + + int32 regionID = -1; /* Region ID (return) */ + + float64 scan[2]; + float64 original_scan[2]; + + char dimlist[256]; /* Dimension list */ + char swathname[80]; + char *dfieldlist = (char *)NULL; /* data field list */ + char *tfieldname = (char *)NULL; /* temp field buffer */ + char *band81 = (char *)NULL; + char *band82 = (char *)NULL; + char *band83 = (char *)NULL; + + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWdefscanregion", &fid, &sdInterfaceID, + &swVgrpID); + + /* This code checks for the attribute detector_count */ + /* which is found in Landsat 7 files. It is used */ + /* for some of the loops. The other code checks if */ + /* one scan is requested. */ + /* ================================================= */ + land_status = SWattrinfo(swathID, "detector_count", &nmtype, &count); + if (land_status == 0) + { + scan[0] = range[0]; + scan[1] = range[1]; + original_scan[0] = range[0]; + original_scan[1] = range[1]; + + land_status = SWreadattr(swathID, "scene_count", &scene_cnt); + land_status = SWreadattr(swathID, "detector_count", &detect_cnt); + if (range[0] == range[1]) + { + range[0] = range[0] * detect_cnt - detect_cnt; + range[1] = range[0] + detect_cnt - 1; + } + else + { + range[0] = range[0] * detect_cnt - detect_cnt; + range[1] = range[1] * detect_cnt - 1; + } + + Vgetname(SWXSwath[0].IDTable, swathname); + band81 = strstr(swathname, "B81"); + if (band81 != (char *)NULL) + band81flag = 1; + band82 = strstr(swathname, "B82"); + if (band82 != (char *)NULL) + band82flag = 1; + band83 = strstr(swathname, "B83"); + if (band83 != (char *)NULL) + band83flag = 1; + } + + + /* If fieldname is null then subsetting Landsat 7 */ + /* floating scene. Get data field name, assume */ + /* only one data field in swath */ + /* ---------------------------------------------- */ + + if (fieldname == (char *)NULL) + { + (void) SWnentries(swathID, 4, &strbufsize); + dfieldlist = (char *)calloc(strbufsize + 1, sizeof(char)); + (void) SWinqdatafields(swathID, dfieldlist, dfrank, numtype); + tfieldname = (char *)calloc(strbufsize + 1, sizeof(char)); + strcpy(tfieldname, dfieldlist); + } + else + { + slen = strlen(fieldname); + tfieldname = (char *)calloc(slen + 1, sizeof(char)); + strcpy(tfieldname, fieldname); + } + + /* Check for valid fieldname */ + /* ------------------------- */ + status = SWfieldinfo(swathID, tfieldname, &rank, dims, &nt, + dimlist); + + if (status != 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWdefscanregion", __FILE__, __LINE__); + HEreport("Field: \"%s\" not found.\n", tfieldname); + } + + + /* Check if input range values are within range of */ + /* data field */ + /* ----------------------------------------------- */ + if(status == 0) + { + status = SWfieldinfo(swathID, "scan_no", &rank, dims2, &nt, dimlist); + buffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(swathID,"scan_no", NULL, NULL, NULL, buffer); + if(scan[0] > buffer[dims2[0]-1]) + { + HEpush(DFE_GENAPP, "SWdefscanregion", __FILE__, __LINE__); + HEreport("Range values not within bounds of data field\n"); + free(buffer); + buffer = (uint16 *)NULL; + if (dfieldlist != NULL) + free(dfieldlist); + free(tfieldname); + return(-1); + } + if(scan[0] < buffer[0]) + { + if(scan[1] < buffer[0]) + { + HEpush(DFE_GENAPP, "SWdefscanregion", __FILE__, __LINE__); + HEreport("Range values not within bounds of data field\n"); + free(buffer); + buffer = (uint16 *)NULL; + if (dfieldlist != NULL) + free(dfieldlist); + free(tfieldname); + return(-1); + } + else + { + scan[0] = buffer[0]; + range[0] = scan[0] * detect_cnt - detect_cnt; + } + } + if(scan[1] > buffer[dims2[0] - 1]) + { + scan[1] = buffer[dims2[0] - 1]; + range[1] = scan[1] * detect_cnt - 1; + } + } + + if(status == 0) + { + dimsize = SWdiminfo(swathID, "GeoTrack"); + if(dimsize > 0) + { + idxmap = (int32 *)calloc(dimsize, sizeof(int32)); + (void) SWidxmapinfo(swathID, "GeoTrack", "ScanLineTrack", idxmap); + tmprange0 = range[0]; + if(band82flag != 1 && band83flag != 1) + { + if (range[1] > idxmap[scene_cnt*2 - 1]) + { + range[1] = idxmap[scene_cnt*2 - 1]; + fprintf(stderr,"Data length compared to geolocation length\n"); + } + } + if(band82flag == 1 || band83flag == 1) + { + tmprange0 = range[0] - (buffer[0] * detect_cnt - detect_cnt); + } + if(tmprange0 >= idxmap[scene_cnt * 2 - 1]) + { + HEpush(DFE_GENAPP, "SWdefscanregion", __FILE__, __LINE__); + HEreport("Range values not within bounds of Latitude/Longitude field(s)\n"); + if (dfieldlist != NULL) + free(dfieldlist); + free(tfieldname); + free(buffer); + free(idxmap); + return(-1); + } + } + } + + if (status == 0) + { + slen = strlen(tfieldname); + + SETSWTHREG; + + /* Find first empty (inactive) vertical subset entry */ + /* ------------------------------------------------- */ + for (j = 0; j < 8; j++) + { + if (SWXRegion[regionID]->StartVertical[j] == -1) + { + /* Store start & stop of region */ + /* ------------------------------------- */ + SWXRegion[regionID]->StartScan[j] = (int32) original_scan[0]; + SWXRegion[regionID]->StopScan[j] = (int32) original_scan[1]; + SWXRegion[regionID]->StartRegion[j] = (int32) range[0]; + SWXRegion[regionID]->StopRegion[j] = (int32) range[1]; + ++SWXRegion[regionID]->nRegions; + SWXRegion[regionID]->scanflag = 1; + if(band81flag == 1) + SWXRegion[regionID]->band8flag = 1; + if(band82flag == 1) + SWXRegion[regionID]->band8flag = 2; + if(band83flag == 1) + SWXRegion[regionID]->band8flag = 3; + break; + } + } + } + + + /* Set regionID to -1 if bad return status */ + /* --------------------------------------- */ + if (status == -1) + { + regionID = -1; + } + + if (dfieldlist != NULL) + free(dfieldlist); + free(tfieldname); + if (buffer != NULL) + free(buffer); + if (idxmap != NULL) + free(idxmap); + + return (regionID); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWsetfillvalue | +| | +| DESCRIPTION: Sets fill value for the specified field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char field name | +| fillval void fill value | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWsetfillvalue(int32 swathID, char *fieldname, VOIDP fillval) +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 sdid; /* SDS id */ + int32 nt; /* Number type */ + int32 dims[8]; /* Dimensions array */ + int32 dum; /* Dummy variable */ + int32 solo; /* "Solo" (non-merged) field flag */ + + char name[80]; /* Fill value "attribute" name */ + + /* Check for valid swath ID and get SDS interface ID */ + status = SWchkswid(swathID, "SWsetfillvalue", + &fid, &sdInterfaceID, &swVgrpID); + + if (status == 0) + { + /* Get field info */ + status = SWfieldinfo(swathID, fieldname, &dum, dims, &nt, NULL); + + if (status == 0) + { + /* Get SDS ID and solo flag */ + status = SWSDfldsrch(swathID, sdInterfaceID, fieldname, + &sdid, &dum, &dum, &dum, + dims, &solo); + + /* If unmerged field then call HDF set field routine */ + if (solo == 1) + { + status = SDsetfillvalue(sdid, fillval); + } + + /* + * Store fill value in attribute. Name is given by fieldname + * prepended with "_FV_" + */ + strcpy(name, "_FV_"); + strcat(name, fieldname); + status = SWwriteattr(swathID, name, nt, 1, fillval); + } + else + { + HEpush(DFE_GENAPP, "SWsetfillvalue", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + } + return (status); +} + + + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWgetfillvalue | +| | +| DESCRIPTION: Retrieves fill value for a specified field. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| fieldname char field name | +| | +| OUTPUTS: | +| fillval void fill value | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWgetfillvalue(int32 swathID, char *fieldname, VOIDP fillval) +{ + intn status; /* routine return status variable */ + + int32 nt; /* Number type */ + int32 dims[8]; /* Dimensions array */ + int32 dum; /* Dummy variable */ + + char name[80]; /* Fill value "attribute" name */ + + /* Check for valid swath ID */ + status = SWchkswid(swathID, "SWgetfillvalue", &dum, &dum, &dum); + + if (status == 0) + { + /* Get field info */ + status = SWfieldinfo(swathID, fieldname, &dum, dims, &nt, NULL); + + if (status == 0) + { + /* Read fill value attribute */ + strcpy(name, "_FV_"); + strcat(name, fieldname); + status = SWreadattr(swathID, name, fillval); + } + else + { + HEpush(DFE_GENAPP, "SWgetfillvalue", __FILE__, __LINE__); + HEreport("Fieldname \"%s\" does not exist.\n", fieldname); + } + + } + return (status); +} + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWdetach | +| | +| DESCRIPTION: Detachs swath structure and performs housekeeping | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure ID | +| | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| Aug 96 Joel Gales Cleanup Region External Structure | +| Sep 96 Joel Gales Setup dim names for SDsetdimnane in dimbuf1 rather | +| than utlstr | +| Nov 96 Joel Gales Call SWchkgdid to check for proper swath ID | +| Dec 96 Joel Gales Add multiple vertical subsetting garbage collection | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWdetach(int32 swathID) + +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + intn status = 0; /* routine return status variable */ + intn statusFill = 0; /* return status from SWgetfillvalue */ + + uint8 *buf; /* Buffer for blank (initial) 1D records */ + + int32 vdataID; /* Vdata ID */ + int32 *namelen; /* Pointer to name string length array */ + int32 *dimlen; /* Pointer to dim string length array */ + int32 slen1[3]; /* String length array 1 */ + int32 slen2[3]; /* String length array 2 */ + int32 nflds; /* Number of fields */ + int32 match[5]; /* Merged field match array */ + int32 cmbfldcnt; /* Number of fields combined */ + int32 sdid; /* SDS ID */ + int32 vgid; /* Vgroup ID */ + int32 dims[3]; /* Dimension array */ + int32 *offset; /* Pointer to merged field offset array */ + int32 *indvdims; /* Pointer to merged field size array */ + int32 sdInterfaceID; /* SDS interface ID */ + int32 sID; /* Swath ID - offset */ + int32 nflds0; /* Number of fields */ + int32 *namelen0; /* Pointer to name string length array */ + int32 rank; /* Rank of merged field */ + int32 truerank; /* True rank of merged field */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + int32 dum; /* Dummy variable */ + + char *nambuf; /* Pointer to name buffer */ + char **nameptr; /* Pointer to name string pointer array */ + char **dimptr; /* Pointer to dim string pointer array */ + char **nameptr0; /* Pointer to name string pointer array */ + char *ptr1[3]; /* String pointer array */ + char *ptr2[3]; /* String pointer array */ + char dimbuf1[128]; /* Dimension buffer 1 */ + char dimbuf2[128]; /* Dimension buffer 2 */ + char swathname[VGNAMELENMAX + 1]; /* Swath name */ + char *utlbuf; /* Utility buffer */ + char fillval[32];/* Fill value buffer */ + + /* Check for proper swath ID and get SD interface ID */ + /* ------------------------------------------------- */ + status = SWchkswid(swathID, "SWdetach", &dum, &sdInterfaceID, &dum); + + if (status == 0) + { + /* Subtract off swath ID offset and get swath name */ + /* ----------------------------------------------- */ + sID = swathID % idOffset; + Vgetname(SWXSwath[sID].IDTable, swathname); + + + /* Create 1D "orphened" fields */ + /* --------------------------- */ + i = 0; + + /* Find "active" entries in 1d combination array */ + /* --------------------------------------------- */ + while (SWX1dcomb[3 * i] != 0) + { + /* For fields defined within swath... */ + /* ---------------------------------- */ + if (SWX1dcomb[3 * i + 1] == SWXSwath[sID].IDTable) + { + /* Get dimension size and vdata ID */ + /* ------------------------------- */ + dims[0] = abs(SWX1dcomb[3 * i]); + vdataID = SWX1dcomb[3 * i + 2]; + + /* Get fieldname (= vdata name) */ + /* ---------------------------- */ + nambuf = (char *) calloc(VSNAMELENMAX + 1, 1); + if(nambuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + return(-1); + } + + VSgetname(vdataID, nambuf); + + /* Set field within vdata */ + /* ---------------------- */ + VSsetfields(vdataID, nambuf); + + /* Write (blank) records */ + /* --------------------- */ + buf = (uint8 *) calloc(VSsizeof(vdataID, nambuf), dims[0]); + if(buf == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nambuf); + return(-1); + } + VSwrite(vdataID, buf, dims[0], FULL_INTERLACE); + + free(buf); + free(nambuf); + + /* Detach Vdata */ + /* ------------ */ + VSdetach(vdataID); + } + i++; + } + + + /* SDS combined fields */ + /* ------------------- */ + if (strlen(SWXSDname) == 0) + { + nflds = 0; + + /* Allocate "dummy" arrays so free() doesn't bomb later */ + /* ---------------------------------------------------- */ + nameptr = (char **) calloc(1, sizeof(char *)); + if(nameptr == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + return(-1); + } + namelen = (int32 *) calloc(1, sizeof(int32)); + if(namelen == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + return(-1); + } + nameptr0 = (char **) calloc(1, sizeof(char *)); + if(nameptr0 == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + return(-1); + } + namelen0 = (int32 *) calloc(1, sizeof(int32)); + if(namelen0 == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + return(-1); + } + dimptr = (char **) calloc(1, sizeof(char *)); + if(dimptr == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + return(-1); + } + dimlen = (int32 *) calloc(1, sizeof(int32)); + if(dimlen == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + return(-1); + } + offset = (int32 *) calloc(1, sizeof(int32)); + if(offset == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + return(-1); + } + indvdims = (int32 *) calloc(1, sizeof(int32)); + if(indvdims == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + } + else + { + /* + * "Trim Off" trailing "," and ";" in SWXSDname & SWXSDdims + * respectively + */ + SWXSDname[strlen(SWXSDname) - 1] = 0; + SWXSDdims[strlen(SWXSDdims) - 1] = 0; + + + /* Get number of fields from SWXSDname string */ + /* ------------------------------------------ */ + nflds = EHparsestr(SWXSDname, ',', NULL, NULL); + + + /* Allocate space for various dynamic arrays */ + /* ----------------------------------------- */ + nameptr = (char **) calloc(nflds, sizeof(char *)); + if(nameptr == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + return(-1); + } + namelen = (int32 *) calloc(nflds, sizeof(int32)); + if(namelen == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + return(-1); + } + nameptr0 = (char **) calloc(nflds, sizeof(char *)); + if(nameptr0 == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + return(-1); + } + namelen0 = (int32 *) calloc(nflds, sizeof(int32)); + if(namelen0 == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + return(-1); + } + dimptr = (char **) calloc(nflds, sizeof(char *)); + if(dimptr == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + return(-1); + } + dimlen = (int32 *) calloc(nflds, sizeof(int32)); + if(dimlen == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + return(-1); + } + offset = (int32 *) calloc(nflds, sizeof(int32)); + if(offset == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + return(-1); + } + indvdims = (int32 *) calloc(nflds, sizeof(int32)); + if(indvdims == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + return(-1); + } + + + /* Parse SWXSDname and SWXSDdims strings */ + /* ------------------------------------- */ + nflds = EHparsestr(SWXSDname, ',', nameptr, namelen); + nflds = EHparsestr(SWXSDdims, ';', dimptr, dimlen); + } + + + /* Loop through all the fields */ + /* --------------------------- */ + for (i = 0; i < nflds; i++) + { + /* If active entry and field is within swath to be detached ... */ + /* ------------------------------------------------------------ */ + if (SWXSDcomb[5 * i] != 0 && + SWXSDcomb[5 * i + 3] == SWXSwath[sID].IDTable) + { + nambuf = (char *) calloc(strlen(SWXSDname) + 1, 1); + if(nambuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + return(-1); + } + utlbuf = (char *) calloc(2 * strlen(SWXSDname) + 7, 1); + if(utlbuf == NULL) + { + HEpush(DFE_NOSPACE,"SWdetach", __FILE__, __LINE__); + free(nambuf); + return(-1); + } + /* Zero out dimbuf1 */ + /* ---------------- */ + for (k = 0; k < sizeof(dimbuf1); k++) + { + dimbuf1[k] = 0; + } + + + /* Load array to match, name & parse dims */ + /* -------------------------------------- */ + memcpy(match, &SWXSDcomb[5 * i], 20); + memcpy(nambuf, nameptr[i], namelen[i]); + + memcpy(dimbuf1, dimptr[i], dimlen[i]); + dum = EHparsestr(dimbuf1, ',', ptr1, slen1); + + + /* Separate combined (first) dimension from others */ + /* ----------------------------------------------- */ + dimbuf1[slen1[0]] = 0; + + offset[0] = 0; + indvdims[0] = abs(match[0]); + + /* + * Loop through remaining fields to check for matches with + * current one + */ + for (j = i + 1, cmbfldcnt = 0; j < nflds; j++) + { + if (SWXSDcomb[5 * j] != 0) + { + /* Zero out dimbuf2 */ + /* ---------------- */ + for (k = 0; k < sizeof(dimbuf2); k++) + { + dimbuf2[k] = 0; + } + + /* + * Parse the dimensions and separate first for this + * entry + */ + memcpy(dimbuf2, dimptr[j], dimlen[j]); + dum = EHparsestr(dimbuf2, ',', ptr2, slen2); + dimbuf2[slen2[0]] = 0; + + + /* + * If 2nd & 3rd dimension values and names (1st and + * 2nd for rank=2 array), swath ID, and numbertype + * are equal, then these fields can be combined. + */ + if (match[1] == SWXSDcomb[5 * j + 1] && + match[2] == SWXSDcomb[5 * j + 2] && + match[3] == SWXSDcomb[5 * j + 3] && + match[4] == SWXSDcomb[5 * j + 4] && + strcmp(dimbuf1 + slen1[0] + 1, + dimbuf2 + slen2[0] + 1) == 0) + { + /* Add to combined dimension size */ + /* ------------------------------ */ + match[0] += SWXSDcomb[5 * j]; + + /* Concatanate name */ + /* ---------------- */ + strcat(nambuf, ","); + memcpy(nambuf + strlen(nambuf), + nameptr[j], namelen[j]); + + /* + * Increment number of merged fields, store + * individual dims and dim offsets + */ + cmbfldcnt++; + indvdims[cmbfldcnt] = abs(SWXSDcomb[5 * j]); + offset[cmbfldcnt] = offset[cmbfldcnt - 1] + + indvdims[cmbfldcnt - 1]; + + /* Delete this field from combination list */ + /* --------------------------------------- */ + SWXSDcomb[5 * j] = 0; + } + } + } + + + /* Create SDS */ + /* ---------- */ + + /* Parse names string */ + /* ------------------ */ + nflds0 = EHparsestr(nambuf, ',', nameptr0, namelen0); + + if (abs(match[0]) == 1) + { + /* Two Dimensional Array (no merging has occured) */ + /* ---------------------------------------------- */ + dims[0] = abs(match[1]); + dims[1] = abs(match[2]); + + /* Create SDS */ + /* ---------- */ + rank = 2; + sdid = SDcreate(sdInterfaceID, nambuf, + SWXSDcomb[5 * i + 4], 2, dims); + } + else + { + /* Three Dimensional Array */ + /* ----------------------- */ + dims[0] = abs(match[0]); + dims[1] = abs(match[1]); + dims[2] = abs(match[2]); + + rank = 3; + + /* + * If merged fields then form string consisting of + * "MRGFLD_" + 1st field in merge + ":" + entire merged + * field list and store in utlbuf. Then write to + * MergedField metadata section + */ + if (cmbfldcnt > 0) + { + strcpy(utlbuf, "MRGFLD_"); + memcpy(utlbuf + 7, nameptr0[0], namelen0[0]); + utlbuf[7 + namelen0[0]] = 0; + strcat(utlbuf, ":"); + strcat(utlbuf, nambuf); + + status = EHinsertmeta(sdInterfaceID, swathname, "s", + 6L, utlbuf, NULL); + } + else + { + /* + * If not merged field then store field name in + * utlbuf + */ + strcpy(utlbuf, nambuf); + } + + /* Create SDS */ + /* ---------- */ + sdid = SDcreate(sdInterfaceID, utlbuf, + SWXSDcomb[5 * i + 4], 3, dims); + + + /* + * If merged field then store dimensions and offsets as + * SD attributes + */ + if (cmbfldcnt > 0) + { + SDsetattr(sdid, "Field Dims", DFNT_INT32, + cmbfldcnt + 1, (VOIDP) indvdims); + + SDsetattr(sdid, "Field Offsets", DFNT_INT32, + cmbfldcnt + 1, (VOIDP) offset); + } + } + + + + /* Register Dimensions in SDS */ + /* -------------------------- */ + for (k = 0; k < rank; k++) + { + if (rank == 2) + { + /* Copy k+1th dimension into dimbuf2 if rank = 2 */ + /* --------------------------------------------- */ + memcpy(dimbuf2, ptr1[k + 1], slen1[k + 1]); + dimbuf2[slen1[k + 1]] = 0; + } + else + { + /* Copy kth dimension into dimbuf2 if rank > 2 */ + /* ------------------------------------------- */ + memcpy(dimbuf2, ptr1[k], slen1[k]); + dimbuf2[slen1[k]] = 0; + } + + /* + * If first dimension and merged field then generate + * dimension name consisting of "MRGDIM:" + swathname + + * dimension size + */ + if (k == 0 && cmbfldcnt > 0) + { + sprintf(dimbuf2, "%s%s_%ld", "MRGDIM:", + swathname, (long)dims[0]); + } + else + { + /* Otherwise concatanate swathname to dim name */ + /* ------------------------------------------- */ + strcat(dimbuf2, ":"); + strcat(dimbuf2, swathname); + } + + /* Register dimensions using "SDsetdimname" */ + /* ---------------------------------------- */ + SDsetdimname(SDgetdimid(sdid, k), (char *) dimbuf2); + } + + + + /* Write Fill Value */ + /* ---------------- */ + for (k = 0; k < nflds0; k++) + { + /* Check if fill values has been set */ + /* --------------------------------- */ + memcpy(utlbuf, nameptr0[k], namelen0[k]); + utlbuf[namelen[k]] = 0; + statusFill = SWgetfillvalue(swathID, utlbuf, fillval); + + if (statusFill == 0) + { + /* + * If merged field then fill value must be stored + * manually using EHfillfld + */ + if (cmbfldcnt > 0) + { + dims[0] = indvdims[k]; + truerank = (dims[0] == 1) ? 2 : 3; + EHfillfld(sdid, rank, truerank, + DFKNTsize(match[4]), offset[k], + dims, fillval); + } + /* + * If single field then just use the HDF set fill + * function + */ + else + { + status = SDsetfillvalue(sdid, fillval); + } + } + } + + + /* + * Insert SDS within the appropriate Vgroup (geo or data) and + * "detach" newly-created SDS + */ + vgid = (match[0] < 0) + ? SWXSwath[sID].VIDTable[0] + : SWXSwath[sID].VIDTable[1]; + + Vaddtagref(vgid, DFTAG_NDG, SDidtoref(sdid)); + SDendaccess(sdid); + + free(nambuf); + free(utlbuf); + } + } + + + + /* "Contract" 1dcomb array */ + /* ----------------------- */ + i = 0; + while (SWX1dcomb[3 * i] != 0) + { + if (SWX1dcomb[3 * i + 1] == SWXSwath[sID].IDTable) + { + memcpy(&SWX1dcomb[3 * i], + &SWX1dcomb[3 * (i + 1)], + (512 - i - 1) * 3 * 4); + } + else + i++; + } + + + /* "Contract" SDcomb array */ + /* ----------------------- */ + for (i = 0; i < nflds; i++) + { + if (SWXSDcomb[5 * i + 3] == SWXSwath[sID].IDTable) + { + if (i == (nflds - 1)) + { + SWXSDcomb[5 * i] = 0; + *(nameptr[i] - (nflds != 1)) = 0; + *(dimptr[i] - (nflds != 1)) = 0; + } + else + { + memmove(&SWXSDcomb[5 * i], + &SWXSDcomb[5 * (i + 1)], + (512 - i - 1) * 5 * 4); + + memmove(nameptr[i], + nameptr[i + 1], + nameptr[0] + 2048 - nameptr[i + 1] - 1); + + memmove(dimptr[i], + dimptr[i + 1], + dimptr[0] + 2048 * 2 - dimptr[i + 1] - 1); + } + + i--; + nflds = EHparsestr(SWXSDname, ',', nameptr, namelen); + nflds = EHparsestr(SWXSDdims, ';', dimptr, dimlen); + } + } + + + /* Replace trailing delimitors on SWXSDname & SWXSDdims */ + /* ---------------------------------------------------- */ + if (nflds != 0) + { + strcat(SWXSDname, ","); + strcat(SWXSDdims, ";"); + } + + + + /* Free up a bunch of dynamically allocated arrays */ + /* ----------------------------------------------- */ + free(nameptr); + free(namelen); + free(nameptr0); + free(namelen0); + free(dimptr); + free(dimlen); + free(offset); + free(indvdims); + + + + + /* "Detach" from previously attached SDSs */ + /* -------------------------------------- */ + for (k = 0; k < SWXSwath[sID].nSDS; k++) + { + SDendaccess(SWXSwath[sID].sdsID[k]); + } + free(SWXSwath[sID].sdsID); + SWXSwath[sID].sdsID = 0; + SWXSwath[sID].nSDS = 0; + + + /* Detach Swath Vgroups */ + /* -------------------- */ + Vdetach(SWXSwath[sID].VIDTable[0]); + Vdetach(SWXSwath[sID].VIDTable[1]); + Vdetach(SWXSwath[sID].VIDTable[2]); + Vdetach(SWXSwath[sID].IDTable); + + + /* Delete entries from External Arrays */ + /* ----------------------------------- */ + SWXSwath[sID].active = 0; + SWXSwath[sID].VIDTable[0] = 0; + SWXSwath[sID].VIDTable[1] = 0; + SWXSwath[sID].VIDTable[2] = 0; + SWXSwath[sID].IDTable = 0; + SWXSwath[sID].fid = 0; + + + /* Free Region Pointers */ + /* -------------------- */ + for (k = 0; k < NSWATHREGN; k++) + { + if (SWXRegion[k] != 0 && + SWXRegion[k]->swathID == swathID) + { + for (i = 0; i < 8; i++) + { + if (SWXRegion[k]->DimNamePtr[i] != 0) + { + free(SWXRegion[k]->DimNamePtr[i]); + } + } + + free(SWXRegion[k]); + SWXRegion[k] = 0; + } + } + + } + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWclose | +| | +| DESCRIPTION: Closes HDF-EOS file | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| fid int32 File ID | +| | +| OUTPUTS: | +| None | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Jun 96 Joel Gales Original Programmer | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWclose(int32 fid) + +{ + intn status = 0; /* routine return status variable */ + + /* Call EHclose to perform file close */ + /* ---------------------------------- */ + status = EHclose(fid); + + return (status); +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWupdatescene | +| | +| DESCRIPTION: Updates the StartRegion and StopRegion values | +| for a specified region. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn return status (0) SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| | +| NOTES: | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Nov 98 Xinmin Hua Original developing | +| Aug 99 Abe Taaheri Added code to exclude regions that have the same | +| start and stop. | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWupdatescene(int32 swathID, int32 regionID) +{ + intn k; /* Loop index */ + int32 status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + + int32 startReg; /* Indexed start region */ + int32 stopReg; /* Indexed stop region */ + int32 index[MAXNREGIONS]; /* to store indicies when stop and + start are different */ + + int32 ind; /* index */ + int32 tempnRegions; /* temp number of regions */ + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWupdatescene", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NSWATHREGN) + { + status = -1; + HEpush(DFE_RANGE, "SWupdatescene", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (SWXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWupdatescene", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + if (status == 0) + { + tempnRegions = SWXRegion[regionID]->nRegions; + ind =0; + + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + startReg = SWXRegion[regionID]->StartRegion[k]; + stopReg = SWXRegion[regionID]->StopRegion[k]; + if(startReg == stopReg) + { + /* reduce number of regions by 1, if tempnRegions is 0 issue + error and break from loop*/ + tempnRegions -= 1; + + if(tempnRegions == 0) + { + /* first free allocated memory for SWXRegion[regionID] + in the function SWdefboxregion and make regionID + inactive */ + free(SWXRegion[regionID]); + SWXRegion[regionID] = 0; + status = -1; + HEpush(DFE_GENAPP, "SWupdatescene", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + break; + } + } + else + { + /* store index number of regions that have different start and + stop */ + index[ind] = k; + ind += 1; + } + } + if (status != 0) + { + return (status); + } + else + { + SWXRegion[regionID]->nRegions = tempnRegions; + } + /* keep starts and stops that are different in the structure */ + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + SWXRegion[regionID]->StartRegion[k] = + SWXRegion[regionID]->StartRegion[index[k]]; + SWXRegion[regionID]->StopRegion[k] = + SWXRegion[regionID]->StopRegion[index[k]]; + } + + } + + + if (status == 0) + { + + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + + startReg = SWXRegion[regionID]->StartRegion[k]; + stopReg = SWXRegion[regionID]->StopRegion[k]; + + if(startReg % 2 == 1) { + + SWXRegion[regionID]->StartRegion[k] = ++startReg; + + } + if(stopReg % 2 == 0) { + + SWXRegion[regionID]->StopRegion[k] = --stopReg; + + } + + } + + } + + return(status); + +} + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWupdateidxmap | +| | +| DESCRIPTION: Updates the map index for a specified region. | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| nout int32 return Number of elements in output | +| index array if SUCCEED, (-1) FAIL | +| | +| INPUTS: | +| swathID int32 Swath structure ID | +| regionID int32 Region ID | +| indexin int32 array of index values | +| | +| OUTPUTS: | +| indexout int32 array of index values | +| indicies int32 array of start and stop in region | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 97 Abe Taaheri Original Programmer | +| AUG 97 Abe Taaheri Add support for index mapping | +| Sep 99 DaW Add support for Floating Scene Subsetting Landsat 7 | +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +int32 +SWupdateidxmap(int32 swathID, int32 regionID, int32 indexin[], int32 indexout[], int32 indicies[]) +{ + intn i; /* Loop index */ + intn j; /* Loop index */ + intn k; /* Loop index */ + int32 status; /* routine return status variable */ + int32 land_status = 3; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath Vgroup ID */ + + int32 numtype = 0; /* Used for L7 float scene sub. */ + int32 count = 0; /* Used for L7 float scene sub. */ + + int32 startReg = 0; /* Indexed start region */ + int32 stopReg = 0; /* Indexed stop region */ + int32 nout=-1; /* Number of elements in output index array */ + int32 indexoffset = 0; + uint8 scene_cnt = 0; /* Used for L7 float scene sub. */ + uint8 detect_cnt = 0; /* Used to convert scan to scanline */ + intn gtflag = 0; + intn ngtflag = 0; + int32 *buffer1 = (int32 *)NULL; + int32 *buffer2 = (int32 *)NULL; + + /* Check for valid swath ID */ + /* ------------------------ */ + status = SWchkswid(swathID, "SWupdateidxmap", &fid, &sdInterfaceID, + &swVgrpID); + + + /* Check for valid region ID */ + /* ------------------------- */ + if (status == 0) + { + if (regionID < 0 || regionID >= NSWATHREGN) + { + status = -1; + HEpush(DFE_RANGE, "SWupdateidxmap", __FILE__, __LINE__); + HEreport("Invalid Region id: %d.\n", regionID); + } + } + + /* Check for active region ID */ + /* -------------------------- */ + if (status == 0) + { + if (SWXRegion[regionID] == 0) + { + status = -1; + HEpush(DFE_GENAPP, "SWextractregion", __FILE__, __LINE__); + HEreport("Inactive Region ID: %d.\n", regionID); + } + } + + if (status == 0) + { + /* Loop through all regions */ + /* ------------------------ */ + for (k = 0; k < SWXRegion[regionID]->nRegions; k++) + { + + /* fix overlap index mapping problem for Landsat 7 */ + + startReg = SWXRegion[regionID]->StartRegion[k]; + stopReg = SWXRegion[regionID]->StopRegion[k]; + + + if(SWXRegion[regionID]->scanflag == 1) + { + indicies[0] = -1; + indicies[1] = -1; + j = 0; + /* This code checks for the attribute detector_count */ + /* which is found in Landsat 7 files. It is used */ + /* for some of the loops. */ + /* ================================================= */ + land_status = SWattrinfo(swathID, "scene_count", &numtype, &count); + if (land_status == 0) + { + land_status = SWreadattr(swathID, "scene_count", &scene_cnt); + land_status = SWreadattr(swathID, "detector_count", &detect_cnt); + } + + + /* calculate the offsets first */ + buffer1 = (int32 *)calloc(74, sizeof(int32)); + buffer2 = (int32 *)calloc(74, sizeof(int32)); + + status = SWidxmapinfo(swathID,"GeoTrack", + "ScanLineTrack", (int32*)buffer1); + status = SWidxmapinfo(swathID,"UpperTrack", + "ScanLineTrack", (int32*)buffer2); + + indexoffset = buffer2[0] - buffer1[0]; + free(buffer1); + free(buffer2); + + if(SWXRegion[regionID]->band8flag == -1) + { + for(i=0; i<scene_cnt;i++) + { + if(indexin[j] <= startReg && indexin[j+1] >= startReg) + if(indicies[0] == -1) + indicies[0] = j; + if(indexin[j] <= stopReg && indexin[j+1] >= stopReg) + indicies[1] = j + 1; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + if(indicies[0] == -1) + { + if(startReg <= indexin[0]) + indicies[0] = 0; + } + if(indicies[0] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if(indexin[j] <= startReg && indexin[j+1] >= startReg) + if(indicies[0] == -1) + indicies[0] = j; + j = j + 1; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + if(indicies[1] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if(indexin[j] <= stopReg && indexin[j+1] >= stopReg) + if(indicies[1] == -1) + indicies[1] = j + 1; + j = j + 1; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + if(indicies[1] == -1) + if(stopReg > indexin[scene_cnt - 1]) + indicies[1] = scene_cnt - 1; + } + + /* This section of code handles exceptions in Landsat 7 */ + /* data. The Band 8 data - multiple files, data gaps */ + /* ===================================================== */ + if(SWXRegion[regionID]->band8flag == 1 || + SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + { + if(indexin[j] == 0) + gtflag = 1; + else + ngtflag = 1; + i = scene_cnt; + } + } + j = 0; + if(gtflag == 1) + { + for(i=0; i<scene_cnt; i++) + { + if( startReg >= (indexin[j] + indexoffset - detect_cnt) && + startReg <= (indexin[j+1] + indexoffset - detect_cnt) ) + if(indicies[0] == -1) + indicies[0] = j; + if( stopReg >= (indexin[j] + indexoffset - detect_cnt ) && + stopReg <= (indexin[j+1] + indexoffset - detect_cnt ) ) + indicies[1] = j + 1; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + if(SWXRegion[regionID]->band8flag == 1) + { + if(indicies[1] == -1) + if(stopReg > (indexin[j - 1] + indexoffset - detect_cnt)) + indicies[1] = j - 1; + } + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + + if(startReg >= (indexin[j - 1] + indexoffset - detect_cnt)) + { + indicies[0] = -1; + indicies[1] = -1; + /* status = SWfieldinfo(swathID, "scan_no", &rank, dims2, &nt, dimlist); + buffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(swathID,"scan_no", NULL, NULL, NULL, buffer); + indexoffset = buffer[0] * detect_cnt; + free(buffer); + startReg = startReg - (indexoffset - detect_cnt); + stopReg = stopReg - (indexoffset - 1); */ + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( startReg >= (indexin[j] + indexoffset - detect_cnt) && + startReg <= (indexin[j+1] + indexoffset - detect_cnt) ) + if(indicies[0] == -1) + indicies[0] = j; + if( stopReg >= (indexin[j] + indexoffset - detect_cnt ) && + stopReg <= (indexin[j+1] + indexoffset - detect_cnt ) ) + indicies[1] = j + 1; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + + if(indicies[0] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( startReg >= (indexin[j] + indexoffset - detect_cnt) && + startReg <= (indexin[j+1] + indexoffset - detect_cnt) ) + if(indicies[0] == -1) + indicies[0] = j; + + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + if(indicies[1] == -1) + if(stopReg > (indexin[j - 1] + indexoffset - detect_cnt) ) + indicies[1] = j - 1; + } + if(indicies[1] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( stopReg >= (indexin[j] + indexoffset - detect_cnt ) && + stopReg <= (indexin[j+1] + indexoffset - detect_cnt ) ) + indicies[1] = j; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + } + + if(ngtflag == 1) + { + for(i=0; i<scene_cnt; i++) + { + if( startReg >= indexin[j] && startReg <= indexin[j+1]) + if(indicies[0] == -1) + indicies[0] = j; + if( stopReg >= indexin[j] && stopReg <= indexin[j+1]) + indicies[1] = j + 1; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + if(SWXRegion[regionID]->band8flag == 2) + { + if(startReg >= indexin[j] ) + { + if(indicies[0] == -1) + indicies[0] = j; + if(indicies[1] == -1) + indicies[1] = j; + } + if(indicies[0] == -1) + if(startReg <= indexin[0]) + indicies[0] = 0; + if(indicies[1] == -1) + if(stopReg > indexin[j]) + indicies[1] = j; + } + if(indicies[0] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( startReg >= indexin[j] && startReg <= indexin[j+1]) + indicies[0] = j; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + if(indicies[1] == -1) + { + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( stopReg >= indexin[j] && stopReg <= indexin[j+1]) + indicies[1] = j; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + if(indicies[1] == -1) + { + if(stopReg > indexin[j]) + indicies[1] = j; + } + } + if(indicies[0] == -1) + { + if(startReg <= (indexin[0]+ indexoffset - detect_cnt) ) + indicies[0] = 0; + if(indicies[1] == -1) + if(stopReg > (indexin[j] + indexoffset - detect_cnt)) + indicies[1] = j; + } + } + if (indicies[1] == -1) + { + if(SWXRegion[regionID]->band8flag == 2 || + SWXRegion[regionID]->band8flag == 3) + { + if(stopReg < (indexin[0] + indexoffset - detect_cnt)) + { + /*status = SWfieldinfo(swathID, "scan_no", &rank, dims2, &nt, dimlist); + buffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(swathID,"scan_no", NULL, NULL, NULL, buffer); + indexoffset = buffer[0] * detect_cnt; + free(buffer); + startReg = startReg + (indexoffset - detect_cnt); + stopReg = stopReg + (indexoffset - 1); */ + if(stopReg >= (indexin[scene_cnt - 1] + indexoffset - detect_cnt)) + { + indicies[1] = scene_cnt - 1; + } + else + { + j = 0; + for(i=0;i<scene_cnt;i++) + { + if( stopReg >= (indexin[j] + indexoffset - detect_cnt ) && + stopReg <= (indexin[j+1] + indexoffset - detect_cnt ) ) + indicies[1] = j; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + } + } + + if(startReg > (indexin[j - 1] + indexoffset - detect_cnt )) + { + indicies[0] = -1; + indicies[1] = -1; + /*status = SWfieldinfo(swathID, "scan_no", &rank, dims2, &nt, dimlist); + buffer = (uint16 *)calloc(dims2[0], sizeof(uint16)); + status = SWreadfield(swathID,"scan_no", NULL, NULL, NULL, buffer); + indexoffset = buffer[0] * detect_cnt; + free(buffer); + startReg = startReg - (indexoffset - detect_cnt); + stopReg = stopReg - (indexoffset - 1);*/ + j = 0; + for(i=0; i<scene_cnt; i++) + { + if( startReg >= (indexin[j] + indexoffset - detect_cnt) && + startReg <= (indexin[j+1] + indexoffset - detect_cnt) ) + if(indicies[0] == -1) + indicies[0] = j; + if( stopReg >= (indexin[j] + indexoffset - detect_cnt ) && + stopReg <= (indexin[j+1] + indexoffset - detect_cnt ) ) + indicies[1] = j + 1; + j = j + 2; + if(indexin[j] == 0 || indexin[j+1] == 0) + i = scene_cnt; + } + if(indicies[0] == -1) + if(startReg < (indexin[0] + indexoffset - detect_cnt)) + indicies[0] = 0; + if(indicies[1] == -1) + if(stopReg > (indexin[j - 1] + indexoffset - detect_cnt)) + indicies[1] = j - 1; + } + } + } + } /* end of if for floating scene update */ + else + { + /* If start of region is odd then increment */ + /* ---------------------------------------- */ + if (startReg % 2 == 1) + { + startReg++; + } + + /* If end of region is even then decrement */ + /* --------------------------------------- */ + if (stopReg % 2 == 0) + { + stopReg--; + } + + indicies[0]=startReg; + indicies[1]=stopReg; + } + } + + if (indexout != NULL) + { + if(SWXRegion[regionID]->scanflag == 1) + { + nout = (indicies[1] - indicies[0] + 1); + j = 0; + if (nout == 1) + indexout[0] = indexin[indicies[0]]; + for(i=0; i<nout;i++) + { + indexout[i] = indexin[indicies[0] + i]; + } + } + else + { + /* get new index values */ + /* ==================== */ + for(i = startReg; i <= stopReg ; i++) + { + indexout[i-startReg] = indexin[i]; + } + nout = (stopReg - startReg) + 1; + } + } + else + { + nout = indicies[1] - indicies[0] + 1; + } + } + + + if(status == -1) + { + return(status); + } + else + { + return(nout); + } + +} + + + +/*----------------------------------------------------------------------------| +| BEGIN_PROLOG | +| | +| FUNCTION: SWgeomapinfo | +| | +| DESCRIPTION: Returns mapping information for dimension | +| | +| | +| Return Value Type Units Description | +| ============ ====== ========= ===================================== | +| status intn 2 for indexed mapping, 1 for regular | +| mapping, 0 if the dimension is not | +| and (-1) FAIL | +| | +| INPUTS: | +| swathID int32 swath structure id | +| geodim char geolocation dimension name | +| | +| OUTPUTS: | +| | +| NONE | +| | +| NOTES: | +| | +| | +| Date Programmer Description | +| ====== ============ ================================================= | +| Aug 97 Abe Taaheri Original Programmer | +| Sept 97 DaW Modified return value so errors can be trapped +| | +| END_PROLOG | +-----------------------------------------------------------------------------*/ +intn +SWgeomapinfo(int32 swathID, char *geodim) + +{ + intn status; /* routine return status variable */ + + int32 fid; /* HDF-EOS file ID */ + int32 sdInterfaceID; /* HDF SDS interface ID */ + int32 swVgrpID; /* Swath root Vgroup ID */ + int32 idOffset = SWIDOFFSET; /* Swath ID offset */ + + char *metabufr; /* Pointer to structural metadata (SM) */ + char *metabufi; /* Pointer to structural metadata (SM) */ + char *metaptrsr[2];/* Pointers to begin and end of SM section */ + char *metaptrsi[2];/* Pointers to begin and end of SM section */ + char swathname[80]; /* Swath Name */ + char *utlstrr; /* Utility string */ + char *utlstri; /* Utility string */ + + + /* Allocate space for utility string */ + /* --------------------------------- */ + utlstrr = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstrr == NULL) + { + HEpush(DFE_NOSPACE,"SWgeomapinfo", __FILE__, __LINE__); + return(-1); + } + utlstri = (char *) calloc(UTLSTR_MAX_SIZE, sizeof(char)); + if(utlstri == NULL) + { + HEpush(DFE_NOSPACE,"SWgeomapinfo", __FILE__, __LINE__); + free(utlstrr); + return(-1); + } + status = -1; + + /* Check for valid swath id */ + status = SWchkswid(swathID, "SWgeomapinfo", &fid, &sdInterfaceID, &swVgrpID); + if (status == 0) + { + /* Get swath name */ + Vgetname(SWXSwath[swathID % idOffset].IDTable, swathname); + + /* Get pointers to "DimensionMap" section within SM */ + metabufr = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "DimensionMap", metaptrsr); + + if(metabufr == NULL) + { + free(utlstrr); + free(utlstri); + return(-1); + } + /* Search for mapping - GeoDim/DataDim (surrounded by quotes) */ + sprintf(utlstrr, "%s%s%s", "\t\t\t\tGeoDimension=\"", geodim, + "\"\n\t\t\t\tDataDimension="); + metaptrsr[0] = strstr(metaptrsr[0], utlstrr); + + /* Get pointers to "IndexDimensionMap" section within SM */ + metabufi = (char *) EHmetagroup(sdInterfaceID, swathname, "s", + "IndexDimensionMap", metaptrsi); + if(metabufi == NULL) + { + free(utlstrr); + free(utlstri); + return(-1); + } + /* Search for mapping - GeoDim/DataDim (surrounded by quotes) */ + sprintf(utlstri, "%s%s%s", "\t\t\t\tGeoDimension=\"", geodim, + "\"\n\t\t\t\tDataDimension="); + metaptrsi[0] = strstr(metaptrsi[0], utlstri); + + /* + ** If regular mapping found add 1 to status + ** If indexed mapping found add 2 + */ + if (metaptrsr[0] < metaptrsr[1] && metaptrsr[0] != NULL) + { + status = status + 1; + } + + if (metaptrsi[0] < metaptrsi[1] && metaptrsi[0] != NULL) + { + status = status + 2; + } + + free(metabufr); + free(metabufi); + } + + free(utlstrr); + free(utlstri); + + return (status); +} + diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/ease.h b/Utilities/GDAL/frmts/hdf4/hdf-eos/ease.h new file mode 100644 index 0000000000..8f28622c03 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/ease.h @@ -0,0 +1,18 @@ +#ifndef EASE_H_ +#define EASE_H_ + +#include <math.h> +#define BCEA_COLS25 1383 /* total number of columns for EASE grid */ +#define BCEA_ROWS25 586 /* total number of rows for EASE grid */ +#define BCEA_CELL_M 25067.525 /* Cell size for EASE grid */ +#define BCEA_RE_M 6371228.0 /* Earth radius used in GCTP projection tools for + Behrmann Cylindrical Equal Area projection */ +#define DEFAULT_BCEA_LTRUESCALE 30.00 /*Latitude of true scale in DMS */ +#define BCEA_COS_PHI1 cos(DEFAULT_BCEA_LTRUESCALE *3.141592653589793238 /180.0) +#define PI 3.141592653589793238 +#define EASE_GRID_DEFAULT_UPLEFT_LON -180.0 +#define EASE_GRID_DEFAULT_UPLEFT_LAT 86.72 +#define EASE_GRID_DEFAULT_LOWRGT_LON 180.0 +#define EASE_GRID_DEFAULT_LOWRGT_LAT -86.72 + +#endif /* #ifndef EASE_H_ */ diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/gctp_wrap.c b/Utilities/GDAL/frmts/hdf4/hdf-eos/gctp_wrap.c new file mode 100644 index 0000000000..c4c93b1b39 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/gctp_wrap.c @@ -0,0 +1,149 @@ +/****************************************************************************** + * $Id$ + * + * Project: Hierarchical Data Format Release 4 (HDF4) + * Purpose: This is the wrapper code to use OGR Coordinate Transformation + * services instead of GCTP library + * Author: Andrey Kiselev, dron@ak4719.spb.edu + * + ****************************************************************************** + * Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu> + * + * 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: gctp_wrap.c,v $ + * Revision 1.3 2006/04/20 13:45:13 dron + * Definitions for for_init() and inv_init() changed to be fully compatible + * with HDF-EOS code. + * + * Revision 1.2 2006/04/06 14:22:02 dron + * Added explicit copyright statement. + * + */ + +#include "ogr_srs_api.h" +#include "mfhdf.h" + +static int iOutsys, iOutzone, iOutdatum, iInsys, iInzone, iIndatum; +static double *pdfOutparm, *pdfInparm; + +int32 osr_for( +double lon, /* (I) Longitude */ +double lat, /* (I) Latitude */ +double *x, /* (O) X projection coordinate */ +double *y) /* (O) Y projection coordinate */ +{ + OGRSpatialReferenceH hSourceSRS, hLatLong; + OGRCoordinateTransformationH hCT; + double dfX, dfY, dfZ = 0.0; + + hSourceSRS = OSRNewSpatialReference( NULL ); + OSRImportFromUSGS( hSourceSRS, iOutsys, iOutzone, pdfOutparm, iOutdatum ); + hLatLong = OSRCloneGeogCS( hSourceSRS ); + hCT = OCTNewCoordinateTransformation( hLatLong, hSourceSRS ); + if( hCT == NULL ) + { + ; + } + + dfY = lon, dfX = lat; + if( !OCTTransform( hCT, 1, &dfX, &dfY, &dfZ ) ) + ; + + *x = dfX, *y = dfY; + + OSRDestroySpatialReference( hSourceSRS ); + OSRDestroySpatialReference( hLatLong ); + + return 0; +} + +void for_init( +int32 outsys, /* output system code */ +int32 outzone, /* output zone number */ +float64 *outparm, /* output array of projection parameters */ +int32 outdatum, /* output datum */ +char *fn27, /* NAD 1927 parameter file */ +char *fn83, /* NAD 1983 parameter file */ +int32 *iflg, /* status flag */ +int32 (*for_trans[])(double, double, double *, double *)) + /* forward function pointer */ +{ + iflg = 0; + iOutsys = outsys; + iOutzone = outzone; + pdfOutparm = outparm; + iOutdatum = outdatum; + for_trans[iOutsys] = osr_for; + + return 0; +} + +int32 osr_inv( +double x, /* (O) X projection coordinate */ +double y, /* (O) Y projection coordinate */ +double *lon, /* (I) Longitude */ +double *lat) /* (I) Latitude */ +{ + OGRSpatialReferenceH hSourceSRS, hLatLong; + OGRCoordinateTransformationH hCT; + double dfX, dfY, dfZ = 0.0; + + hSourceSRS = OSRNewSpatialReference( NULL ); + OSRImportFromUSGS( hSourceSRS, iInsys, iInzone, pdfInparm, iIndatum ); + hLatLong = OSRCloneGeogCS( hSourceSRS ); + hCT = OCTNewCoordinateTransformation( hSourceSRS, hLatLong ); + if( hCT == NULL ) + { + ; + } + + //OSRDestroySpatialReference(); + + dfX = x, dfY = x; + if( !OCTTransform( hCT, 1, &dfX, &dfY, &dfZ ) ) + ; + + *lon = dfX, *lat = dfY; + + return 0; +} + +void inv_init( +int32 insys, /* input system code */ +int32 inzone, /* input zone number */ +float64 *inparm, /* input array of projection parameters */ +int32 indatum, /* input datum code */ +char *fn27, /* NAD 1927 parameter file */ +char *fn83, /* NAD 1983 parameter file */ +int32 *iflg, /* status flag */ +int32 (*inv_trans[])(double, double, double*, double*)) + /* inverse function pointer */ +{ + iflg = 0; + iInsys = insys; + iInzone = inzone; + pdfInparm = inparm; + iIndatum = indatum; + inv_trans[insys] = osr_inv; + + return 0; +} + diff --git a/Utilities/GDAL/frmts/hdf4/hdf-eos/makefile.vc b/Utilities/GDAL/frmts/hdf4/hdf-eos/makefile.vc new file mode 100644 index 0000000000..46c229e772 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf-eos/makefile.vc @@ -0,0 +1,16 @@ + +OBJ = \ + SWapi.obj GDapi.obj EHapi.obj gctp_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +EXTRAFLAGS = -I$(HDF4_DIR)\include -I.\ -DFRMT_hdf4 -DWIN32 + +default: $(OBJ) + copy *.obj ..\..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/hdf4/hdf4dataset.cpp b/Utilities/GDAL/frmts/hdf4/hdf4dataset.cpp new file mode 100644 index 0000000000..17a858b7f3 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf4dataset.cpp @@ -0,0 +1,1177 @@ +/****************************************************************************** + * $Id: hdf4dataset.cpp,v 1.32 2005/04/25 20:05:27 dron Exp $ + * + * Project: Hierarchical Data Format Release 4 (HDF4) + * Purpose: HDF4 Datasets. Open HDF4 file, fetch metadata and list of + * subdatasets. + * This driver initially based on code supplied by Markus Neteler + * Author: Andrey Kiselev, dron@remotesensing.org + * + ****************************************************************************** + * Copyright (c) 2002, Andrey Kiselev <dron@remotesensing.org> + * + * 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: hdf4dataset.cpp,v $ + * Revision 1.32 2005/04/25 20:05:27 dron + * Memory leak fixed. + * + * Revision 1.31 2005/04/19 12:21:03 dron + * Meory leak fixed. + * + * Revision 1.30 2005/03/30 11:21:15 dron + * Remove inline keyword from function definitions. + * + * Revision 1.29 2005/03/29 12:42:53 dron + * Added AnyTypeToDouble() method. + * + * Revision 1.28 2004/09/08 17:55:13 dron + * Few problems fixed. + * + * Revision 1.27 2004/06/19 21:37:31 dron + * Use HDF-EOS library for appropriate datasets; major cpde rewrite. + * + * Revision 1.26 2003/11/07 15:48:01 dron + * TranslateHDF4Attributes() improved, added GetDataTypeSize(). + * + * Revision 1.25 2003/11/05 17:05:02 warmerda + * Fixed type casting problem (bug 431). + * + * Revision 1.24 2003/06/26 20:42:31 dron + * Support for Hyperion Level 1 data product. + * + * Revision 1.23 2003/06/25 08:26:18 dron + * Support for Aster Level 1A/1B/2 products. + * + * Revision 1.22 2003/06/12 15:07:04 dron + * Added support for SeaWiFS Level 3 Standard Mapped Image Products. + * + * Revision 1.21 2003/06/10 09:32:31 dron + * Added support for MODIS Level 3 products. + * + * Revision 1.20 2003/05/21 14:11:43 dron + * MODIS Level 1B earth-view (EV) product now supported. + * + * Revision 1.19 2003/03/01 15:54:43 dron + * Significant improvements in HDF EOS metadata parsing. + * + * Revision 1.18 2003/02/27 14:28:55 dron + * Fixes in HDF-EOS metadata parsing algorithm. + * + * Revision 1.17 2002/12/19 17:42:57 dron + * Size of string buffer in TranslateHDF4EOSAttributes() fixed. + * + * Revision 1.16 2002/11/29 18:25:22 dron + * MODIS determination improved. + * + * Revision 1.15 2002/11/13 06:43:15 warmerda + * quote filename in case it contains a drive indicator + * + * Revision 1.14 2002/11/13 06:00:04 warmerda + * avoid use of long long type as it doesn't exist perse on windows + * + * Revision 1.13 2002/11/08 18:29:04 dron + * Added Create() method. + * + * Revision 1.12 2002/11/07 13:23:44 dron + * Support for projection information writing. + * + * Revision 1.11 2002/11/06 15:47:14 dron + * Added support for 3D datasets creation + * + * Revision 1.10 2002/10/25 14:28:54 dron + * Initial support for HDF4 creation. + * + * Revision 1.9 2002/09/25 14:44:40 warmerda + * Fixed iSubdatasetType initialization. + * + * Revision 1.8 2002/09/06 10:42:23 dron + * Georeferencing for ASTER Level 1b datasets and ASTER DEMs. + * + * Revision 1.7 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.6 2002/07/23 12:27:58 dron + * General Raster Interface support added. + * + * Revision 1.5 2002/07/19 13:39:17 dron + * Lists supported in HDF-EOS attributes. + * + * Revision 1.4 2002/07/17 16:24:31 dron + * MODIS support improved a bit. + * + * Revision 1.3 2002/07/17 13:36:18 dron + * <hdf.h> and <mfhdf.h> changed to "hdf.h" and "mfhdf.h". + * + * Revision 1.2 2002/07/16 17:51:10 warmerda + * removed hdf/ from include statements + * + * Revision 1.1 2002/07/16 11:04:11 dron + * New driver: HDF4 datasets. Initial version. + * + * + */ + +#include "hdf.h" +#include "mfhdf.h" + +#include "HdfEosDef.h" + +#include "gdal_priv.h" +#include "cpl_string.h" +#include "hdf4dataset.h" + +CPL_CVSID("$Id: hdf4dataset.cpp,v 1.32 2005/04/25 20:05:27 dron Exp $"); + +CPL_C_START +void GDALRegister_HDF4(void); +CPL_C_END + +extern const char *pszGDALSignature; + +/************************************************************************/ +/* ==================================================================== */ +/* HDF4Dataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HDF4Dataset() */ +/************************************************************************/ + +HDF4Dataset::HDF4Dataset() + +{ + fp = NULL; + hHDF4 = 0; + hSD = 0; + hGR = 0; + papszGlobalMetadata = NULL; + papszSubDatasets = NULL; +} + +/************************************************************************/ +/* ~HDF4Dataset() */ +/************************************************************************/ + +HDF4Dataset::~HDF4Dataset() + +{ + if ( hSD ) + SDend( hSD ); + if ( hGR ) + GRend( hGR ); + if ( papszSubDatasets ) + CSLDestroy( papszSubDatasets ); + if ( papszGlobalMetadata ) + CSLDestroy( papszGlobalMetadata ); + if( fp != NULL ) + VSIFClose( fp ); + if( hHDF4 > 0 ) + Hclose( hHDF4 ); +} + +/************************************************************************/ +/* GetMetadata() */ +/************************************************************************/ + +char **HDF4Dataset::GetMetadata( const char *pszDomain ) + +{ + if( pszDomain != NULL && EQUALN( pszDomain, "SUBDATASETS", 11 ) ) + return papszSubDatasets; + else + return GDALDataset::GetMetadata( pszDomain ); +} + +/************************************************************************/ +/* SPrintArray() */ +/* Prints numerical arrays in string buffer. */ +/* This function takes pfaDataArray as a pointer to printed array, */ +/* nValues as a number of values to print and pszDelimiter as a */ +/* field delimiting strings. */ +/* Pointer to filled buffer will be returned. */ +/************************************************************************/ + +char *SPrintArray( GDALDataType eDataType, void *paDataArray, + int nValues, char * pszDelimiter ) +{ + char *pszString, *pszField; + int i, iFieldSize, iStringSize; + + iFieldSize = 32 + strlen( pszDelimiter ); + pszField = (char *)CPLMalloc( iFieldSize + 1 ); + iStringSize = nValues * iFieldSize + 1; + pszString = (char *)CPLMalloc( iStringSize ); + memset( pszString, 0, iStringSize ); + for ( i = 0; i < nValues; i++ ) + { + switch ( eDataType ) + { + case GDT_Byte: + sprintf( pszField, "%d%s", ((GByte *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_UInt16: + sprintf( pszField, "%u%s", ((GUInt16 *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_Int16: + default: + sprintf( pszField, "%d%s", ((GInt16 *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_UInt32: + sprintf( pszField, "%u%s", ((GUInt32 *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_Int32: + sprintf( pszField, "%d%s", ((GInt32 *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_Float32: + sprintf( pszField, "%.7g%s", ((float *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + case GDT_Float64: + sprintf( pszField, "%.15g%s", ((double *)paDataArray)[i], + (i < nValues - 1)?pszDelimiter:"" ); + break; + } + strcat( pszString, pszField ); + } + + CPLFree( pszField ); + return pszString; +} + +/************************************************************************/ +/* Translate HDF4 data type into GDAL data type */ +/************************************************************************/ +GDALDataType HDF4Dataset::GetDataType( int32 iNumType ) const +{ + switch (iNumType) + { + case DFNT_CHAR8: // The same as DFNT_CHAR + case DFNT_UCHAR8: // The same as DFNT_UCHAR + case DFNT_INT8: + case DFNT_UINT8: + return GDT_Byte; + case DFNT_INT16: + return GDT_Int16; + case DFNT_UINT16: + return GDT_UInt16; + case DFNT_INT32: + return GDT_Int32; + case DFNT_UINT32: + return GDT_UInt32; + case DFNT_INT64: + return GDT_Unknown; + case DFNT_UINT64: + return GDT_Unknown; + case DFNT_FLOAT32: + return GDT_Float32; + case DFNT_FLOAT64: + return GDT_Float64; + default: + return GDT_Unknown; + } +} + +/************************************************************************/ +/* Return the human readable name of data type */ +/************************************************************************/ + +const char *HDF4Dataset::GetDataTypeName( int32 iNumType ) const +{ + switch (iNumType) + { + case DFNT_CHAR8: // The same as DFNT_CHAR + return "8-bit character"; + case DFNT_UCHAR8: // The same as DFNT_UCHAR + return "8-bit unsigned character"; + case DFNT_INT8: + return "8-bit integer"; + case DFNT_UINT8: + return "8-bit unsigned integer"; + case DFNT_INT16: + return "16-bit integer"; + case DFNT_UINT16: + return "16-bit unsigned integer"; + case DFNT_INT32: + return "32-bit integer"; + case DFNT_UINT32: + return "32-bit unsigned integer"; + case DFNT_INT64: + return "64-bit integer"; + case DFNT_UINT64: + return "64-bit unsigned integer"; + case DFNT_FLOAT32: + return "32-bit floating-point"; + case DFNT_FLOAT64: + return "64-bit floating-point"; + default: + return "unknown type"; + } +} + +/************************************************************************/ +/* Return the size of data type in bytes */ +/************************************************************************/ + +int HDF4Dataset::GetDataTypeSize( int32 iNumType ) const +{ + switch (iNumType) + { + case DFNT_CHAR8: // The same as DFNT_CHAR + case DFNT_UCHAR8: // The same as DFNT_UCHAR + case DFNT_INT8: + case DFNT_UINT8: + return 1; + case DFNT_INT16: + case DFNT_UINT16: + return 2; + case DFNT_INT32: + case DFNT_UINT32: + case DFNT_FLOAT32: + return 4; + case DFNT_INT64: + case DFNT_UINT64: + case DFNT_FLOAT64: + return 8; + default: + return 0; + } +} + +/************************************************************************/ +/* Convert value stored in the input buffer to double value. */ +/************************************************************************/ + +double HDF4Dataset::AnyTypeToDouble( int32 iNumType, void *pData ) const +{ + switch ( iNumType ) + { + case DFNT_INT8: + return (double)*(char *)pData; + case DFNT_UINT8: + return (double)*(unsigned char *)pData; + case DFNT_INT16: + return (double)*(short *)pData; + case DFNT_UINT16: + return (double)*(unsigned short *)pData; + case DFNT_INT32: + return (double)*(long *)pData; + case DFNT_UINT32: + return (double)*(unsigned long *)pData; + case DFNT_INT64: + return (double)*(char *)pData; + case DFNT_UINT64: + return (double)*(GIntBig *)pData; + case DFNT_FLOAT32: + return (double)*(float *)pData; + case DFNT_FLOAT64: + return (double)*(double *)pData; + default: + return 0.0; + } +} + +/************************************************************************/ +/* Tokenize HDF-EOS attributes. */ +/************************************************************************/ + +char **HDF4Dataset::HDF4EOSTokenizeAttrs( const char * pszString ) const + +{ + const char *pszDelimiters = " \t\n\r"; + char **papszRetList = NULL; + char *pszToken; + int nTokenMax, nTokenLen; + + pszToken = (char *) CPLCalloc( 10, 1 ); + nTokenMax = 10; + + while( pszString != NULL && *pszString != '\0' ) + { + int bInString = FALSE, bInBracket = FALSE; + + nTokenLen = 0; + + // Try to find the next delimeter, marking end of token + for( ; *pszString != '\0'; pszString++ ) + { + + // End if this is a delimeter skip it and break. + if ( !bInBracket && !bInString + && strchr(pszDelimiters, *pszString) != NULL ) + { + pszString++; + break; + } + + // Sometimes in bracketed tokens we may found a sort of + // paragraph formatting. We will remove unneeded spaces and new + // lines. + if ( bInBracket ) + if ( strchr("\r\n", *pszString) != NULL + || ( *pszString == ' ' + && strchr(" \r\n", *(pszString - 1)) != NULL ) ) + continue; + + if ( *pszString == '"' ) + { + if ( bInString ) + { + bInString = FALSE; + continue; + } + else + { + bInString = TRUE; + continue; + } + } + else if ( *pszString == '(' ) + { + bInBracket = TRUE; + continue; + } + else if ( *pszString == ')' ) + { + bInBracket = FALSE; + continue; + } + + if( nTokenLen >= nTokenMax - 2 ) + { + nTokenMax = nTokenMax * 2 + 10; + pszToken = (char *) CPLRealloc( pszToken, nTokenMax ); + } + + pszToken[nTokenLen] = *pszString; + nTokenLen++; + } + + pszToken[nTokenLen] = '\0'; + + if( pszToken[0] != '\0' ) + { + papszRetList = CSLAddString( papszRetList, pszToken ); + } + + // If the last token is an empty token, then we have to catch + // it now, otherwise we won't reenter the loop and it will be lost. + if ( *pszString == '\0' && strchr(pszDelimiters, *(pszString-1)) ) + { + papszRetList = CSLAddString( papszRetList, "" ); + } + } + + if( papszRetList == NULL ) + papszRetList = (char **) CPLCalloc( sizeof(char *), 1 ); + + CPLFree( pszToken ); + + return papszRetList; +} + +/************************************************************************/ +/* Find object name and its value in HDF-EOS attributes. */ +/* Function returns pointer to the string in list next behind */ +/* recognized object. */ +/************************************************************************/ + +char **HDF4Dataset::HDF4EOSGetObject( char **papszAttrList, char **ppszAttrName, + char **ppszAttrValue ) const +{ + int iCount, i, j; + *ppszAttrName = NULL; + *ppszAttrValue = NULL; + + iCount = CSLCount( papszAttrList ); + for ( i = 0; i < iCount - 2; i++ ) + { + if ( EQUAL( papszAttrList[i], "OBJECT" ) ) + { + i += 2; + for ( j = 1; i + j < iCount - 2; j++ ) + { + if ( EQUAL( papszAttrList[i + j], "END_OBJECT" ) || + EQUAL( papszAttrList[i + j], "OBJECT" ) ) + return &papszAttrList[i + j]; + else if ( EQUAL( papszAttrList[i + j], "VALUE" ) ) + { + *ppszAttrName = papszAttrList[i]; + *ppszAttrValue = papszAttrList[i + j + 2]; + + return &papszAttrList[i + j + 2]; + } + } + } + } + + return NULL; +} + +/************************************************************************/ +/* Translate HDF4-EOS attributes in GDAL metadata items */ +/************************************************************************/ + +char** HDF4Dataset::TranslateHDF4EOSAttributes( int32 iHandle, + int32 iAttribute, int32 nValues, char **papszMetadata ) const +{ + char *pszData; + + pszData = (char *)CPLMalloc( (nValues + 1) * sizeof(char) ); + pszData[nValues] = '\0'; + SDreadattr( iHandle, iAttribute, pszData ); + // HDF4-EOS attributes has followed structure: + // + // GROUP = <name> + // GROUPTYPE = <name> + // + // GROUP = <name> + // + // OBJECT = <name> + // CLASS = <string> + // NUM_VAL = <number> + // VALUE = <string> or <number> + // END_OBJECT = <name> + // + // ....... + // ....... + // ....... + // + // END_GROUP = <name> + // + // ....... + // ....... + // ....... + // + // END_GROUP = <name> + // END + // + // Used data types: + // <name> --- unquoted character strings + // <string> --- quoted character strings + // <number> --- numerical value + // If NUM_VAL != 1 then values combined in lists: + // (<string>,<string>,...) + // or + // (<number>,<number>,...) + // + // Records within objects may follows in any order, objects may contains + // other objects (and lacks VALUE record), groups contains other groups + // and objects. Names of groups and objects are not unique and may repeat. + // Objects may contains other types of records. + // + // We are interested in OBJECTS structures only. + + char *pszAttrName, *pszAttrValue; + char *pszAddAttrName = NULL; + char **papszAttrList, **papszAttrs; + + papszAttrList = HDF4EOSTokenizeAttrs( pszData ); + papszAttrs = papszAttrList; + while ( papszAttrs ) + { + papszAttrs = + HDF4EOSGetObject( papszAttrs, &pszAttrName, &pszAttrValue ); + if ( pszAttrName && pszAttrValue ) + { + // Now we should recognize special type of HDF EOS metastructures: + // ADDITIONALATTRIBUTENAME = <name> + // PARAMETERVALUE = <value> + if ( EQUAL( pszAttrName, "ADDITIONALATTRIBUTENAME" ) ) + pszAddAttrName = pszAttrValue; + else if ( pszAddAttrName && EQUAL( pszAttrName, "PARAMETERVALUE" ) ) + { + papszMetadata = + CSLAddNameValue( papszMetadata, pszAddAttrName, pszAttrValue ); + pszAddAttrName = NULL; + } + else + { + papszMetadata = + CSLAddNameValue( papszMetadata, pszAttrName, pszAttrValue ); + } + } + } + + CSLDestroy( papszAttrList ); + CPLFree( pszData ); + + return papszMetadata; +} + +/************************************************************************/ +/* Translate HDF4 attributes in GDAL metadata items */ +/************************************************************************/ + +char** HDF4Dataset::TranslateHDF4Attributes( int32 iHandle, + int32 iAttribute, char *pszAttrName, int32 iNumType, int32 nValues, + char **papszMetadata ) const +{ + void *pData = NULL; + char *pszTemp = NULL; + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer to hold the attribute data. */ +/* -------------------------------------------------------------------- */ + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + pData = CPLMalloc( (nValues + 1) * GetDataTypeSize(iNumType) ); + else + pData = CPLMalloc( nValues * GetDataTypeSize(iNumType) ); + +/* -------------------------------------------------------------------- */ +/* Read the attribute data. */ +/* -------------------------------------------------------------------- */ + SDreadattr( iHandle, iAttribute, pData ); + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + { + ((char *)pData)[nValues] = '\0'; + papszMetadata = CSLAddNameValue( papszMetadata, pszAttrName, + (const char *) pData ); + } + else + { + pszTemp = SPrintArray( GetDataType(iNumType), pData, nValues, ", " ); + papszMetadata = CSLAddNameValue( papszMetadata, pszAttrName, pszTemp ); + if ( pszTemp ) + CPLFree( pszTemp ); + } + + if ( pData ) + CPLFree( pData ); + + return papszMetadata; +} + +/************************************************************************/ +/* ReadGlobalAttributes() */ +/************************************************************************/ + +CPLErr HDF4Dataset::ReadGlobalAttributes( int32 iHandler ) +{ + int32 iAttribute, nValues, iNumType, nAttributes; + char szAttrName[MAX_NC_NAME]; + +/* -------------------------------------------------------------------- */ +/* Obtain number of SDSs and global attributes in input file. */ +/* -------------------------------------------------------------------- */ + if ( SDfileinfo( hSD, &nDatasets, &nAttributes ) != 0 ) + return CE_Failure; + + // Loop trough the all attributes + for ( iAttribute = 0; iAttribute < nAttributes; iAttribute++ ) + { + // Get information about the attribute. Note that the first + // parameter is an SD interface identifier. + SDattrinfo( iHandler, iAttribute, szAttrName, &iNumType, &nValues ); + if ( EQUALN( szAttrName, "coremetadata.", 13 ) || + EQUALN( szAttrName, "archivemetadata.", 16 ) || + EQUALN( szAttrName, "productmetadata.", 16 ) || + EQUALN( szAttrName, "badpixelinformation", 19 ) || + EQUALN( szAttrName, "product_summary", 15 ) || + EQUALN( szAttrName, "dem_specific", 12 ) || + EQUALN( szAttrName, "bts_specific", 12 ) || + EQUALN( szAttrName, "etse_specific", 13 ) || + EQUALN( szAttrName, "dst_specific", 12 ) || + EQUALN( szAttrName, "acv_specific", 12 ) || + EQUALN( szAttrName, "act_specific", 12 ) || + EQUALN( szAttrName, "etst_specific", 13 ) || + EQUALN( szAttrName, "level_1_carryover", 17 ) ) + { + papszGlobalMetadata = TranslateHDF4EOSAttributes( iHandler, + iAttribute, nValues, papszGlobalMetadata ); + } + else if ( EQUALN( szAttrName, "structmetadata.", 15 ) ) + continue; + else + { + papszGlobalMetadata = TranslateHDF4Attributes( iHandler, + iAttribute, szAttrName, iNumType, nValues, papszGlobalMetadata ); + } + } + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *HDF4Dataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int32 i; + + if( poOpenInfo->fp == NULL ) + return NULL; + + // We have special routine in the HDF library for format checking! + if ( !Hishdf(poOpenInfo->pszFilename) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + int32 hHDF4; + + hHDF4 = Hopen(poOpenInfo->pszFilename, DFACC_READ, 0); + + if( hHDF4 <= 0 ) + return( NULL ); + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + HDF4Dataset *poDS; + + poDS = new HDF4Dataset(); + + poDS->fp = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +/* -------------------------------------------------------------------- */ +/* Open HDF SDS Interface. */ +/* -------------------------------------------------------------------- */ + poDS->hSD = SDstart( poOpenInfo->pszFilename, DFACC_READ ); + if ( poDS->hSD == -1 ) + { + Hclose( hHDF4 ); + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Now read Global Attributes. */ +/* -------------------------------------------------------------------- */ + if ( poDS->ReadGlobalAttributes( poDS->hSD ) != CE_None ) + { + Hclose( hHDF4 ); + delete poDS; + return NULL; + } + + poDS->SetMetadata( poDS->papszGlobalMetadata, "" ); + +/* -------------------------------------------------------------------- */ +/* Determine type of file we read. */ +/* -------------------------------------------------------------------- */ + const char *pszValue; + + if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, + "Signature")) + && EQUAL( pszValue, pszGDALSignature ) ) + { + poDS->iSubdatasetType = GDAL_HDF4; + poDS->pszSubdatasetType = "GDAL_HDF4"; + } + + else if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, "Title")) + && EQUAL( pszValue, "SeaWiFS Level-1A Data" ) ) + { + poDS->iSubdatasetType = SEAWIFS_L1A; + poDS->pszSubdatasetType = "SEAWIFS_L1A"; + } + + else if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, "Title")) + && EQUAL( pszValue, "SeaWiFS Level-2 Data" ) ) + { + poDS->iSubdatasetType = SEAWIFS_L2; + poDS->pszSubdatasetType = "SEAWIFS_L2"; + } + + else if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, "Title")) + && EQUAL( pszValue, "SeaWiFS Level-3 Standard Mapped Image" ) ) + { + poDS->iSubdatasetType = SEAWIFS_L3; + poDS->pszSubdatasetType = "SEAWIFS_L3"; + } + + else if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, + "L1 File Generated By")) + && EQUALN( pszValue, "HYP version ", 12 ) ) + { + poDS->iSubdatasetType = HYPERION_L1; + poDS->pszSubdatasetType = "HYPERION_L1"; + } + + else + { + poDS->iSubdatasetType = UNKNOWN; + poDS->pszSubdatasetType = "UNKNOWN"; + } + +/* -------------------------------------------------------------------- */ +/* If we have HDF-EOS dataset, process it here. */ +/* -------------------------------------------------------------------- */ + char szName[VSNAMELENMAX + 1], szTemp[8192]; + char *pszString; + const char *pszName; + int nCount; + int32 aiDimSizes[MAX_VAR_DIMS]; + int32 iRank, iNumType, nAttrs; + + if ( CSLFetchNameValue(poDS->papszGlobalMetadata, "HDFEOSVersion") ) + { + int32 nSubDatasets, nStrBufSize; + +/* -------------------------------------------------------------------- */ +/* Close previously opened dataset. */ +/* -------------------------------------------------------------------- */ + Hclose( hHDF4 ); + +/* -------------------------------------------------------------------- */ +/* Process swath layers. */ +/* -------------------------------------------------------------------- */ + hHDF4 = SWopen( poOpenInfo->pszFilename, DFACC_READ ); + nSubDatasets = SWinqswath(poOpenInfo->pszFilename, NULL, &nStrBufSize); +#if DEBUG + CPLDebug( "HDF4", "Number of HDF-EOS swaths: %d", nSubDatasets ); +#endif + if ( nSubDatasets > 0 && nStrBufSize > 0 ) + { + char *pszSwathList; + char **papszSwaths; + + pszSwathList = (char *)CPLMalloc( nStrBufSize + 1 ); + SWinqswath( poOpenInfo->pszFilename, pszSwathList, &nStrBufSize ); + pszSwathList[nStrBufSize] = '\0'; + +#if DEBUG + CPLDebug( "HDF4", "List of HDF-EOS swaths: %s", pszSwathList ); +#endif + + papszSwaths = + CSLTokenizeString2( pszSwathList, ",", CSLT_HONOURSTRINGS ); + CPLFree( pszSwathList ); + + if ( nSubDatasets != CSLCount(papszSwaths) ) + { + CSLDestroy( papszSwaths ); + delete poDS; + CPLDebug( "HDF4", "Can not parse list of HDF-EOS grids." ); + return NULL; + } + + for ( i = 0; i < nSubDatasets; i++) + { + char *pszFieldList; + char **papszFields; + int32 *paiRank, *paiNumType; + int32 hSW, nFields, j; + + hSW = SWattach( hHDF4, papszSwaths[i] ); + + nFields = SWnentries( hSW, HDFE_NENTDFLD, &nStrBufSize ); + pszFieldList = (char *)CPLMalloc( nStrBufSize + 1 ); + paiRank = (int32 *)CPLMalloc( nFields * sizeof(int32) ); + paiNumType = (int32 *)CPLMalloc( nFields * sizeof(int32) ); + + SWinqdatafields( hSW, pszFieldList, paiRank, paiNumType ); + +#if DEBUG + { + char *pszTmp = + SPrintArray( GDT_UInt32, paiRank, nFields, "," ); + + CPLDebug( "HDF4", "Number of data fields in swath %ld: %d", + i, nFields ); + CPLDebug( "HDF4", "List of data fields in swath %ld: %s", + i, pszFieldList ); + CPLDebug( "HDF4", "Data fields ranks: %s", pszTmp ); + + CPLFree( pszTmp ); + } +#endif + + papszFields = CSLTokenizeString2( pszFieldList, ",", + CSLT_HONOURSTRINGS ); + + for ( j = 0; j < nFields; j++ ) + { + SWfieldinfo( hSW, papszFields[j], &iRank, aiDimSizes, + &iNumType, NULL ); + + if ( iRank < 2 ) + continue; + + // Add field to the list of GDAL subdatasets + nCount = CSLCount( poDS->papszSubDatasets ) / 2; + sprintf( szTemp, "SUBDATASET_%d_NAME", nCount + 1 ); + // We will use the field index as an identificator. + poDS->papszSubDatasets = + CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "HDF4_EOS:EOS_SWATH:\"%s\":%s:%s", + poOpenInfo->pszFilename, + papszSwaths[i], papszFields[j])); + + sprintf( szTemp, "SUBDATASET_%d_DESC", nCount + 1 ); + pszString = SPrintArray( GDT_UInt32, aiDimSizes, + iRank, "x" ); + poDS->papszSubDatasets = + CSLSetNameValue( poDS->papszSubDatasets, szTemp, + CPLSPrintf( "[%s] %s (%s)", pszString, + papszFields[j], + poDS->GetDataTypeName(iNumType) ) ); + CPLFree( pszString ); + } + + CSLDestroy( papszFields ); + CPLFree( paiNumType ); + CPLFree( paiRank ); + CPLFree( pszFieldList ); + SWdetach( hSW ); + } + + CSLDestroy( papszSwaths ); + SWclose( hHDF4 ); + } + +/* -------------------------------------------------------------------- */ +/* Process grid layers. */ +/* -------------------------------------------------------------------- */ + hHDF4 = GDopen( poOpenInfo->pszFilename, DFACC_READ ); + nSubDatasets = GDinqgrid( poOpenInfo->pszFilename, NULL, &nStrBufSize ); +#if DEBUG + CPLDebug( "HDF4", "Number of HDF-EOS grids: %d", nSubDatasets ); +#endif + if ( nSubDatasets > 0 && nStrBufSize > 0 ) + { + char *pszGridList; + char **papszGrids; + + pszGridList = (char *)CPLMalloc( nStrBufSize + 1 ); + GDinqgrid( poOpenInfo->pszFilename, pszGridList, &nStrBufSize ); + +#if DEBUG + CPLDebug( "HDF4", "List of HDF-EOS grids: %s", pszGridList ); +#endif + + papszGrids = + CSLTokenizeString2( pszGridList, ",", CSLT_HONOURSTRINGS ); + CPLFree( pszGridList ); + + if ( nSubDatasets != CSLCount(papszGrids) ) + { + CSLDestroy( papszGrids ); + delete poDS; + CPLDebug( "HDF4", "Can not parse list of HDF-EOS grids." ); + return NULL; + } + + for ( i = 0; i < nSubDatasets; i++) + { + char *pszFieldList; + char **papszFields; + int32 *paiRank, *paiNumType; + int32 hGD, nFields, j; + + hGD = GDattach( hHDF4, papszGrids[i] ); + + nFields = GDnentries( hGD, HDFE_NENTDFLD, &nStrBufSize ); + pszFieldList = (char *)CPLMalloc( nStrBufSize + 1 ); + paiRank = (int32 *)CPLMalloc( nFields * sizeof(int32) ); + paiNumType = (int32 *)CPLMalloc( nFields * sizeof(int32) ); + + GDinqfields( hGD, pszFieldList, paiRank, paiNumType ); + +#if DEBUG + CPLDebug( "HDF4", "Number of fields in grid %ld: %d", + i, nFields ); + CPLDebug( "HDF4", "List of fields in grid %ld: %s", + i, pszFieldList ); + CPLDebug( "HDF4", "Fields ranks: %s", + SPrintArray( GDT_UInt32, paiRank, nFields, "," ) ); +#endif + + papszFields = CSLTokenizeString2( pszFieldList, ",", + CSLT_HONOURSTRINGS ); + + for ( j = 0; j < nFields; j++ ) + { + GDfieldinfo( hGD, papszFields[j], &iRank, aiDimSizes, + &iNumType, NULL ); + + if ( iRank < 2 ) + continue; + + // Add field to the list of GDAL subdatasets + nCount = CSLCount( poDS->papszSubDatasets ) / 2; + sprintf( szTemp, "SUBDATASET_%d_NAME", nCount + 1 ); + // We will use the field index as an identificator. + poDS->papszSubDatasets = + CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "HDF4_EOS:EOS_GRID:\"%s\":%s:%s", + poOpenInfo->pszFilename, + papszGrids[i], papszFields[j])); + + sprintf( szTemp, "SUBDATASET_%d_DESC", nCount + 1 ); + pszString = SPrintArray( GDT_UInt32, aiDimSizes, + iRank, "x" ); + poDS->papszSubDatasets = + CSLSetNameValue( poDS->papszSubDatasets, szTemp, + CPLSPrintf("[%s] %s (%s)", pszString, + papszFields[j], + poDS->GetDataTypeName(iNumType)) ); + CPLFree( pszString ); + } + + CSLDestroy( papszFields ); + CPLFree( paiNumType ); + CPLFree( paiRank ); + CPLFree( pszFieldList ); + GDdetach( hGD ); + } + + CSLDestroy( papszGrids ); + GDclose( hHDF4 ); + } + GDclose( hHDF4 ); + } + + else + { + +/* -------------------------------------------------------------------- */ +/* Make a list of subdatasets from SDSs contained in input HDF file. */ +/* -------------------------------------------------------------------- */ + int32 iSDS; + + for ( i = 0; i < poDS->nDatasets; i++ ) + { + iSDS = SDselect( poDS->hSD, i ); + if ( SDgetinfo( iSDS, szName, &iRank, aiDimSizes, &iNumType, &nAttrs) != 0 ) + return NULL; + + if ( iRank == 1 ) // Skip 1D datsets + continue; + + // Do sort of known datasets. We will display only image bands + if ( (poDS->iSubdatasetType == SEAWIFS_L1A ) && + !EQUALN( szName, "l1a_data", 8 ) ) + continue; + else + pszName = szName; + + // Add datasets with multiple dimensions to the list of GDAL subdatasets + nCount = CSLCount( poDS->papszSubDatasets ) / 2; + sprintf( szTemp, "SUBDATASET_%d_NAME", nCount + 1 ); + // We will use SDS index as an identificator, because SDS names + // are not unique. Filename also needed for further file opening + poDS->papszSubDatasets = CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "HDF4_SDS:%s:\"%s\":%d", poDS->pszSubdatasetType, + poOpenInfo->pszFilename, i) ); + sprintf( szTemp, "SUBDATASET_%d_DESC", nCount + 1 ); + pszString = SPrintArray( GDT_UInt32, aiDimSizes, iRank, "x" ); + poDS->papszSubDatasets = CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "[%s] %s (%s)", pszString, + pszName, poDS->GetDataTypeName(iNumType)) ); + CPLFree( pszString ); + + SDendaccess( iSDS ); + } + SDend( poDS->hSD ); + +/* -------------------------------------------------------------------- */ +/* The same list builds for raster images. */ +/* -------------------------------------------------------------------- */ + int32 iGR; + int32 iInterlaceMode; + + poDS->hGR = GRstart( hHDF4 ); + if ( poDS->hGR == -1 ) + {fprintf(stderr,"GRstart failed\n");} + + if ( GRfileinfo( poDS->hGR, &poDS->nImages, &nAttrs ) != 0 ) + return NULL; + + for ( i = 0; i < poDS->nImages; i++ ) + { + iGR = GRselect( poDS->hGR, i ); + // iRank in GR interface has another meaning. It represents number + // of samples per pixel. aiDimSizes has only two dimensions. + if ( GRgetiminfo( iGR, szName, &iRank, &iNumType, &iInterlaceMode, + aiDimSizes, &nAttrs ) != 0 ) + return NULL; + nCount = CSLCount( poDS->papszSubDatasets ) / 2; + sprintf( szTemp, "SUBDATASET_%d_NAME", nCount + 1 ); + poDS->papszSubDatasets = CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "HDF4_GR:UNKNOWN:\"%s\":%d", poOpenInfo->pszFilename, i)); + sprintf( szTemp, "SUBDATASET_%d_DESC", nCount + 1 ); + pszString = SPrintArray( GDT_UInt32, aiDimSizes, 2, "x" ); + poDS->papszSubDatasets = CSLSetNameValue(poDS->papszSubDatasets, szTemp, + CPLSPrintf( "[%sx%d] %s (%s)", pszString, + iRank, szName, poDS->GetDataTypeName(iNumType)) ); + CPLFree( pszString ); + + GRendaccess( iGR ); + } + GRend( poDS->hGR ); + + Hclose( hHDF4 ); + + } + + poDS->nRasterXSize = poDS->nRasterYSize = 512; // XXX: bogus values + +/* -------------------------------------------------------------------- */ +/* If we have single subdataset only, open it immediately */ +/* -------------------------------------------------------------------- */ + if ( CSLCount( poDS->papszSubDatasets ) / 2 == 1 ) + { + char *pszSDSName; + pszSDSName = CPLStrdup( CSLFetchNameValue( poDS->papszSubDatasets, + "SUBDATASET_1_NAME" )); + delete poDS; + poDS = (HDF4Dataset *) GDALOpen( pszSDSName, GA_ReadOnly ); + CPLFree( pszSDSName ); + } + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_HDF4() */ +/************************************************************************/ + +void GDALRegister_HDF4() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "HDF4" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "HDF4" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Hierarchical Data Format Release 4" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_hdf4.html" ); + + poDriver->pfnOpen = HDF4Dataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/hdf4/hdf4dataset.h b/Utilities/GDAL/frmts/hdf4/hdf4dataset.h new file mode 100644 index 0000000000..5f6efca131 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf4dataset.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * $Id$ + * + * Project: Hierarchical Data Format Release 4 (HDF4) + * Purpose: Header file for HDF4 datasets reader. + * Author: Andrey Kiselev, dron@remotesensing.org + * + ****************************************************************************** + * Copyright (c) 2002, Andrey Kiselev <dron@remotesensing.org> + * + * 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: hdf4dataset.h,v $ + * Revision 1.16 2005/04/25 20:04:43 dron + * Make more functions constant. + * + * Revision 1.15 2005/03/29 12:42:53 dron + * Added AnyTypeToDouble() method. + * + * Revision 1.14 2004/06/19 21:37:31 dron + * Use HDF-EOS library for appropriate datasets; major cpde rewrite. + * + * Revision 1.13 2003/11/07 15:49:14 dron + * Added GetDataType() and GetDataTypeName(). + * + * Revision 1.12 2003/06/26 20:42:31 dron + * Support for Hyperion Level 1 data product. + * + * Revision 1.11 2003/06/25 08:26:18 dron + * Support for Aster Level 1A/1B/2 products. + * + * Revision 1.10 2003/06/12 15:07:34 dron + * Value for MODIS Level 2 added. + * + * Revision 1.9 2003/06/10 09:33:48 dron + * Added support for MODIS Level 3 products. + * + * Revision 1.8 2003/05/21 14:11:43 dron + * MODIS Level 1B earth-view (EV) product now supported. + * + * Revision 1.7 2002/11/08 17:57:43 dron + * Type of pszDataType changet to const char*. + * + * Revision 1.6 2002/11/06 15:47:14 dron + * Added support for 3D datasets creation + * + * Revision 1.5 2002/10/25 14:28:54 dron + * Initial support for HDF4 creation. + * + * Revision 1.4 2002/09/06 10:42:23 dron + * Georeferencing for ASTER Level 1b datasets and ASTER DEMs. + * + * Revision 1.3 2002/07/23 12:27:58 dron + * General Raster Interface support added. + * + * Revision 1.2 2002/07/17 16:24:31 dron + * MODIS support improved a bit. + * + * Revision 1.1 2002/07/16 11:04:11 dron + * New driver: HDF4 datasets. Initial version. + * + * + */ + +#ifndef _HDF4DATASET_H_INCLUDED_ +#define _HDF4DATASET_H_INCLUDED_ + +#include "cpl_list.h" + +typedef enum // Types of dataset: +{ + HDF4_SDS, // Scientific Dataset + HDF4_GR, // General Raster Image + HDF4_EOS, // HDF EOS + HDF4_UNKNOWN +} HDF4DatasetType; + +typedef enum // Types of data products: +{ + GDAL_HDF4, // HDF written by GDAL + EOS_GRID, // HDF-EOS Grid + EOS_SWATH, // HDF-EOS Swath + SEAWIFS_L1A, // SeaWiFS Level-1A Data + SEAWIFS_L2, // SeaWiFS Level-2 Data + SEAWIFS_L3, // SeaWiFS Level-3 Standard Mapped Image + HYPERION_L1, // Hyperion L1 Data Product + UNKNOWN +} HDF4SubdatasetType; + +/************************************************************************/ +/* ==================================================================== */ +/* HDF4Dataset */ +/* ==================================================================== */ +/************************************************************************/ + +class HDF4Dataset : public GDALDataset +{ + + private: + + char **HDF4EOSTokenizeAttrs( const char *pszString ) const; + char **HDF4EOSGetObject( char **papszAttrList, char **ppszAttrName, + char **ppszAttrValue ) const; + + protected: + + FILE *fp; + int32 hHDF4, hSD, hGR; + int32 nDatasets, nImages; + HDF4DatasetType iDatasetType; + HDF4SubdatasetType iSubdatasetType; + const char *pszSubdatasetType; + + char **papszGlobalMetadata; + char **papszSubDatasets; + + GDALDataType GetDataType( int32 ) const; + const char *GetDataTypeName( int32 ) const; + int GetDataTypeSize( int32 ) const; + double AnyTypeToDouble( int32, void * ) const; + char **TranslateHDF4Attributes( int32, int32, char *, + int32, int32, char ** ) const; + char ** TranslateHDF4EOSAttributes( int32, int32, int32, + char ** ) const; + CPLErr ReadGlobalAttributes( int32 ); + + public: + HDF4Dataset(); + ~HDF4Dataset(); + + virtual char **GetMetadata( const char * pszDomain = "" ); + static GDALDataset *Open( GDALOpenInfo * ); +}; + +char *SPrintArray( GDALDataType eDataType, void *paDataArray, + int nValues, char * pszDelimiter ); + + +#endif /* _HDF4DATASET_H_INCLUDED_ */ + diff --git a/Utilities/GDAL/frmts/hdf4/hdf4imagedataset.cpp b/Utilities/GDAL/frmts/hdf4/hdf4imagedataset.cpp new file mode 100644 index 0000000000..2106871666 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/hdf4imagedataset.cpp @@ -0,0 +1,2772 @@ +/****************************************************************************** + * $Id: hdf4imagedataset.cpp,v 1.57 2006/05/02 16:42:49 fwarmerdam Exp $ + * + * Project: Hierarchical Data Format Release 4 (HDF4) + * Purpose: Read subdatasets of HDF4 file. + * This driver initially based on code supplied by Markus Neteler + * Author: Andrey Kiselev, dron@remotesensing.org + * + ****************************************************************************** + * Copyright (c) 2002, Andrey Kiselev <dron@remotesensing.org> + * + * 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: hdf4imagedataset.cpp,v $ + * Revision 1.57 2006/05/02 16:42:49 fwarmerdam + * fix to preserve backslashes when parsing, and various initializations + * + * Revision 1.55 2005/11/11 01:11:24 fwarmerdam + * Added support for Coastwatch offset/scale. + * + * Revision 1.54 2005/10/27 16:41:54 fwarmerdam + * added scale/offset/units support for selected modis products + * + * Revision 1.53 2005/10/27 15:43:13 fwarmerdam + * Fixed bug with NRL geotransform calculation due to nRasterXSize + * and nRasterYSize not having been set properly yet. + * + * Revision 1.52 2005/10/13 15:21:42 fwarmerdam + * Don't try to use papszMetadata directly. + * + * Revision 1.51 2005/04/21 13:42:24 dron + * Added suppodt for ASTER 3D Orto product. + * + * Revision 1.50 2005/04/21 12:52:39 dron + * Added support for ASTER DE product. + * + * Revision 1.49 2005/04/20 14:19:20 dron + * Added support for ASTER Level 1A products. + * + * Revision 1.48 2005/04/19 14:08:09 dron + * Support for ASTER Level 1B/Level 2 datasets. + * + * Revision 1.47 2005/03/30 11:55:36 dron + * Fixes in Swath geolocation; fetch NoData value for Swath; fetch attributes. + * + * Revision 1.46 2005/03/29 12:49:50 dron + * Fixes in HDF-EOS Grid georeferencing; fetch NoData for Grid datasets. + * + * Revision 1.45 2005/03/28 13:33:50 dron + * Restore support for HDF-EOS Swath GCPs extraction (preliminary version). + * + * Revision 1.44 2005/03/21 14:07:39 dron + * More fixes for geotransformation handling. + * + * Revision 1.43 2005/03/21 11:05:02 dron + * Added 1/2 pixel shift of origin of projected Grid datasets. + * + * Revision 1.42 2005/03/14 21:32:26 fwarmerdam + * Added special support for pulling parent metadata down in MODIS L1B + * mode, and using the GRing to derive corner coordinates. + * + * Revision 1.41 2005/02/24 01:49:24 fwarmerdam + * Establish iBandDim for rank-3 HDFEOS datasets (swath/grid). + * + * Revision 1.40 2005/01/27 16:57:58 fwarmerdam + * added coastwatch missing_value support + * + * Revision 1.39 2005/01/25 20:38:09 fwarmerdam + * Added coastwatch convention support. + * + * Revision 1.38 2005/01/24 17:09:45 fwarmerdam + * added support for "NRL(USGS) mapProjectionSystem" datasets (geotransform) + * + * Revision 1.37 2004/11/26 19:39:18 fwarmerdam + * avoid initialization warning from purify + * + * Revision 1.36 2004/09/08 17:55:13 dron + * Few problems fixed. + * + * Revision 1.35 2004/06/19 21:37:31 dron + * Use HDF-EOS library for appropriate datasets; major cpde rewrite. + * + * Revision 1.34 2003/11/07 15:48:49 dron + * GetDataType() moved to HDF4Dataset class. + * + * Revision 1.33 2003/10/31 19:12:47 dron + * Read properly GR datasets with multiple samples per pixel. + * + * Revision 1.32 2003/10/25 10:34:39 dron + * Disable GCP collecting for MODIS_L1B datasets. + * + * Revision 1.31 2003/09/28 05:45:02 dron + * More logic to distinguish dimesions. + */ + +#include <string.h> +#include <math.h> + +#include "hdf.h" +#include "mfhdf.h" + +#include "HdfEosDef.h" + +#include "gdal_priv.h" +#include "cpl_string.h" +#include "ogr_spatialref.h" + +#include "hdf4dataset.h" + +CPL_CVSID("$Id: hdf4imagedataset.cpp,v 1.57 2006/05/02 16:42:49 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_HDF4(void); +CPL_C_END + +// Signature to recognize files written by GDAL +const char *pszGDALSignature = + "Created with GDAL (http://www.remotesensing.org/gdal/)"; + +/************************************************************************/ +/* ==================================================================== */ +/* List of HDF-EOS Swath product types. */ +/* ==================================================================== */ +/************************************************************************/ + +enum HDF4EOSProduct +{ + PROD_UNKNOWN, + PROD_ASTER_L1A, + PROD_ASTER_L1B, + PROD_ASTER_L2, + PROD_ASTER_L3, + PROD_AST14DEM, + PROD_MODIS_L1B +}; + +/************************************************************************/ +/* ==================================================================== */ +/* HDF4ImageDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class HDF4ImageDataset : public HDF4Dataset +{ + friend class HDF4ImageRasterBand; + + char *pszFilename; + int32 iGR, iPal, iDataset; + int32 iRank, iNumType, nAttrs, + iInterlaceMode, iPalInterlaceMode, iPalDataType; + int32 nComps, nPalEntries; + int32 aiDimSizes[MAX_VAR_DIMS]; + int iXDim, iYDim, iBandDim; + char **papszLocalMetadata; +#define N_COLOR_ENTRIES 256 + uint8 aiPaletteData[N_COLOR_ENTRIES][3]; // XXX: Static array for now + char szName[65]; + char *pszSubdatasetName; + char *pszFieldName; + + GDALColorTable *poColorTable; + + OGRSpatialReference oSRS; + int bHasGeoTransform; + double adfGeoTransform[6]; + char *pszProjection; + char *pszGCPProjection; + GDAL_GCP *pasGCPList; + int nGCPCount; + + static long USGSMnemonicToCode( const char* ); + void ReadCoordinates( const char*, double*, double* ); + void ToGeoref( double *, double * ); + char** GetSwatAttrs( int32 hSW, char **papszMetadata ); + char** GetGridAttrs( int32 hGD, char **papszMetadata ); + void CaptureNRLGeoTransform(void); + void CaptureCoastwatchGCTPInfo(void); + + public: + HDF4ImageDataset(); + ~HDF4ImageDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); + virtual void FlushCache( void ); + CPLErr GetGeoTransform( double * padfTransform ); + virtual CPLErr SetGeoTransform( double * ); + const char *GetProjectionRef(); + virtual CPLErr SetProjection( const char * ); + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* HDF4ImageRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class HDF4ImageRasterBand : public GDALRasterBand +{ + friend class HDF4ImageDataset; + + int bNoDataSet; + double dfNoDataValue; + + int bHaveScaleAndOffset; + double dfScale; + double dfOffset; + + CPLString osUnitType; + + public: + + HDF4ImageRasterBand( HDF4ImageDataset *, int, GDALDataType ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + virtual double GetNoDataValue( int * ); + virtual CPLErr SetNoDataValue( double ); + virtual double GetOffset( int *pbSuccess ); + virtual double GetScale( int *pbSuccess ); + virtual const char *GetUnitType(); +}; + +/************************************************************************/ +/* HDF4ImageRasterBand() */ +/************************************************************************/ + +HDF4ImageRasterBand::HDF4ImageRasterBand( HDF4ImageDataset *poDS, int nBand, + GDALDataType eType ) + +{ + this->poDS = poDS; + this->nBand = nBand; + eDataType = eType; + bNoDataSet = FALSE; + dfNoDataValue = -9999.0; + + bHaveScaleAndOffset = FALSE; + dfScale = 1.0; + dfOffset = 0.0; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr HDF4ImageRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) +{ + HDF4ImageDataset *poGDS = (HDF4ImageDataset *) poDS; + int32 aiStart[MAX_NC_DIMS], aiEdges[MAX_NC_DIMS]; + CPLErr eErr = CE_None; + + if( poGDS->eAccess == GA_Update ) + { + memset( pImage, 0, + nBlockXSize * nBlockYSize * GDALGetDataTypeSize(eDataType) / 8 ); + return CE_None; + } + + switch ( poGDS->iDatasetType ) + { + case HDF4_SDS: + { + int32 iSDS = SDselect( poGDS->hSD, poGDS->iDataset ); + /* HDF rank: + A rank 2 dataset is an image read in scan-line order (2D). + A rank 3 dataset is a series of images which are read in + an image at a time to form a volume. + A rank 4 dataset may be thought of as a series of volumes. + + The "aiStart" array specifies the multi-dimensional index of the + starting corner of the hyperslab to read. The values are zero + based. + + The "edge" array specifies the number of values to read along + each dimension of the hyperslab. + + The "iStride" array allows for sub-sampling along each + dimension. If a iStride value is specified for a dimension, + that many values will be skipped over when reading along that + dimension. Specifying iStride = NULL in the C interface or + iStride = 1 in either interface specifies contiguous reading + of data. If the iStride values are set to 0, SDreaddata + returns FAIL (or -1). No matter what iStride value is + provided, data is always placed contiguously in buffer. + */ + switch ( poGDS->iRank ) + { + case 4: // 4Dim: volume-time + // FIXME: needs sample file. Does not work currently. + aiStart[3] = 0/* range: 0--aiDimSizes[3]-1 */; + aiEdges[3] = 1; + aiStart[2] = 0/* range: 0--aiDimSizes[2]-1 */; + aiEdges[2] = 1; + aiStart[1] = nBlockYOff; aiEdges[1] = nBlockYSize; + aiStart[0] = nBlockXOff; aiEdges[0] = nBlockXSize; + break; + case 3: // 3Dim: volume + aiStart[poGDS->iBandDim] = nBand - 1; + aiEdges[poGDS->iBandDim] = 1; + + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + case 2: // 2Dim: rows/cols + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + } + + // Read HDF SDS array + SDreaddata( iSDS, aiStart, NULL, aiEdges, pImage ); + + SDendaccess( iSDS ); + } + break; + + case HDF4_GR: + { + int nDataTypeSize = + GDALGetDataTypeSize(poGDS->GetDataType(poGDS->iNumType)) / 8; + GByte *pbBuffer = (GByte *) + CPLMalloc(nBlockXSize*nBlockYSize*poGDS->iRank*nBlockYSize); + int i, j; + + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + + GRreadimage( poGDS->iGR, aiStart, NULL, aiEdges, pbBuffer ); + + for ( i = 0, j = (nBand - 1) * nDataTypeSize; + i < nBlockXSize * nDataTypeSize; + i += nDataTypeSize, j += poGDS->nBands * nDataTypeSize ) + memcpy( (GByte *)pImage + i, pbBuffer + j, nDataTypeSize ); + + CPLFree( pbBuffer ); + } + break; + + case HDF4_EOS: + { + switch ( poGDS->iSubdatasetType ) + { + case EOS_GRID: + { + int32 hGD; + + hGD = GDattach( poGDS->hHDF4, + poGDS->pszSubdatasetName ); + switch ( poGDS->iRank ) + { + case 3: // 3Dim: volume + aiStart[poGDS->iBandDim] = nBand - 1; + aiEdges[poGDS->iBandDim] = 1; + + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + case 2: // 2Dim: rows/cols + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + } + GDreadfield( hGD, poGDS->pszFieldName, + aiStart, NULL, aiEdges, pImage ); + GDdetach( hGD ); + } + break; + + case EOS_SWATH: + { + int32 hSW; + + hSW = SWattach( poGDS->hHDF4, + poGDS->pszSubdatasetName ); + switch ( poGDS->iRank ) + { + case 3: // 3Dim: volume + aiStart[poGDS->iBandDim] = nBand - 1; + aiEdges[poGDS->iBandDim] = 1; + + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + case 2: // 2Dim: rows/cols + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + break; + } + SWreadfield( hSW, poGDS->pszFieldName, + aiStart, NULL, aiEdges, pImage ); + SWdetach( hSW ); + } + break; + default: + break; + } + } + break; + + default: + eErr = CE_Failure; + break; + } + + return eErr; +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr HDF4ImageRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) +{ + HDF4ImageDataset *poGDS = (HDF4ImageDataset *)poDS; + int32 aiStart[MAX_NC_DIMS], aiEdges[MAX_NC_DIMS]; + CPLErr eErr = CE_None; + + CPLAssert( poGDS != NULL + && nBlockXOff >= 0 + && nBlockYOff >= 0 + && pImage != NULL ); + + switch ( poGDS->iRank ) + { + case 3: + { + int32 iSDS = SDselect( poGDS->hSD, poGDS->iDataset ); + + aiStart[poGDS->iBandDim] = nBand - 1; + aiEdges[poGDS->iBandDim] = 1; + + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + + if ( (SDwritedata( iSDS, aiStart, NULL, + aiEdges, (VOIDP)pImage )) < 0 ) + eErr = CE_Failure; + + SDendaccess( iSDS ); + } + break; + + case 2: + { + int32 iSDS = SDselect( poGDS->hSD, nBand - 1 ); + aiStart[poGDS->iYDim] = nBlockYOff; + aiEdges[poGDS->iYDim] = nBlockYSize; + + aiStart[poGDS->iXDim] = nBlockXOff; + aiEdges[poGDS->iXDim] = nBlockXSize; + + if ( (SDwritedata( iSDS, aiStart, NULL, + aiEdges, (VOIDP)pImage )) < 0 ) + eErr = CE_Failure; + + SDendaccess( iSDS ); + } + break; + + default: + eErr = CE_Failure; + break; + } + + return eErr; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *HDF4ImageRasterBand::GetColorTable() +{ + HDF4ImageDataset *poGDS = (HDF4ImageDataset *) poDS; + + return poGDS->poColorTable; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp HDF4ImageRasterBand::GetColorInterpretation() +{ + HDF4ImageDataset *poGDS = (HDF4ImageDataset *) poDS; + + if ( poGDS->iDatasetType == HDF4_SDS ) + return GCI_GrayIndex; + else if ( poGDS->iDatasetType == HDF4_GR ) + { + if ( poGDS->poColorTable != NULL ) + return GCI_PaletteIndex; + else if ( poGDS->nBands != 1 ) + { + if ( nBand == 1 ) + return GCI_RedBand; + else if ( nBand == 2 ) + return GCI_GreenBand; + else if ( nBand == 3 ) + return GCI_BlueBand; + else if ( nBand == 4 ) + return GCI_AlphaBand; + else + return GCI_Undefined; + } + else + return GCI_GrayIndex; + } + else + return GCI_GrayIndex; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double HDF4ImageRasterBand::GetNoDataValue( int * pbSuccess ) + +{ + if( pbSuccess ) + *pbSuccess = bNoDataSet; + + return dfNoDataValue; +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr HDF4ImageRasterBand::SetNoDataValue( double dfNoData ) + +{ + bNoDataSet = TRUE; + dfNoDataValue = dfNoData; + + return CE_None; +} + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ + +const char *HDF4ImageRasterBand::GetUnitType() + +{ + if( osUnitType.size() > 0 ) + return osUnitType; + else + return GDALRasterBand::GetUnitType(); +} + +/************************************************************************/ +/* GetOffset() */ +/************************************************************************/ + +double HDF4ImageRasterBand::GetOffset( int *pbSuccess ) + +{ + if( bHaveScaleAndOffset ) + { + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + return dfOffset; + } + else + return GDALRasterBand::GetOffset( pbSuccess ); +} + +/************************************************************************/ +/* GetScale() */ +/************************************************************************/ + +double HDF4ImageRasterBand::GetScale( int *pbSuccess ) + +{ + if( bHaveScaleAndOffset ) + { + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + return dfScale; + } + else + return GDALRasterBand::GetScale( pbSuccess ); +} + +/************************************************************************/ +/* ==================================================================== */ +/* HDF4ImageDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HDF4ImageDataset() */ +/************************************************************************/ + +HDF4ImageDataset::HDF4ImageDataset() +{ + pszFilename = NULL; + hSD = 0; + hGR = 0; + iGR = 0; + iBandDim = -1; + iDatasetType = HDF4_UNKNOWN; + pszSubdatasetName = NULL; + pszFieldName = NULL; + papszLocalMetadata = NULL; + poColorTable = NULL; + pszProjection = CPLStrdup( "" ); + pszGCPProjection = CPLStrdup( "" ); + bHasGeoTransform = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + + nGCPCount = 0; + pasGCPList = NULL; + +} + +/************************************************************************/ +/* ~HDF4ImageDataset() */ +/************************************************************************/ + +HDF4ImageDataset::~HDF4ImageDataset() +{ + FlushCache(); + + if ( pszFilename ) + CPLFree( pszFilename ); + if ( hSD > 0 ) + SDend( hSD ); + if ( iGR > 0 ) + GRendaccess( iGR ); + if ( hGR > 0 ) + GRend( hGR ); + if ( pszSubdatasetName ) + CPLFree( pszSubdatasetName ); + if ( pszFieldName ) + CPLFree( pszFieldName ); + if ( papszLocalMetadata ) + CSLDestroy( papszLocalMetadata ); + if ( poColorTable != NULL ) + delete poColorTable; + if ( pszProjection ) + CPLFree( pszProjection ); + if ( pszGCPProjection ) + CPLFree( pszGCPProjection ); + if( nGCPCount > 0 ) + { + for( int i = 0; i < nGCPCount; i++ ) + { + if ( pasGCPList[i].pszId ) + CPLFree( pasGCPList[i].pszId ); + if ( pasGCPList[i].pszInfo ) + CPLFree( pasGCPList[i].pszInfo ); + } + + CPLFree( pasGCPList ); + } + if ( hHDF4 ) + { + switch ( iDatasetType ) + { + case HDF4_EOS: + switch ( iSubdatasetType ) + { + case EOS_SWATH: + SWclose( hHDF4 ); + break; + case EOS_GRID: + GDclose( hHDF4 ); + default: + break; + + } + break; + case HDF4_SDS: + case HDF4_GR: + hHDF4 = Hclose( hHDF4 ); + break; + default: + break; + } + } +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr HDF4ImageDataset::GetGeoTransform( double * padfTransform ) +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + + if ( !bHasGeoTransform ) + return CE_Failure; + + return CE_None; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr HDF4ImageDataset::SetGeoTransform( double * padfTransform ) +{ + bHasGeoTransform = TRUE; + memcpy( adfGeoTransform, padfTransform, sizeof(double) * 6 ); + + return CE_None; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *HDF4ImageDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr HDF4ImageDataset::SetProjection( const char *pszNewProjection ) + +{ + if ( pszProjection ) + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszNewProjection ); + + return CE_None; +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int HDF4ImageDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *HDF4ImageDataset::GetGCPProjection() + +{ + if( nGCPCount > 0 ) + return pszGCPProjection; + else + return ""; +} + +/************************************************************************/ +/* GetGCPs() */ +/************************************************************************/ + +const GDAL_GCP *HDF4ImageDataset::GetGCPs() +{ + return pasGCPList; +} + +/************************************************************************/ +/* FlushCache() */ +/************************************************************************/ + +void HDF4ImageDataset::FlushCache() + +{ + int iBand; + char *pszName; + const char *pszValue; + + GDALDataset::FlushCache(); + + if( eAccess == GA_ReadOnly ) + return; + + // Write out transformation matrix + pszValue = CPLSPrintf( "%f, %f, %f, %f, %f, %f", + adfGeoTransform[0], adfGeoTransform[1], + adfGeoTransform[2], adfGeoTransform[3], + adfGeoTransform[4], adfGeoTransform[5] ); + if ( (SDsetattr( hSD, "TransformationMatrix", DFNT_CHAR8, + strlen(pszValue) + 1, pszValue )) < 0 ) + { + CPLDebug( "HDF4Image", + "Cannot write transformation matrix to output file" ); + } + + // Write out projection + if ( pszProjection != NULL && !EQUAL( pszProjection, "" ) ) + { + if ( (SDsetattr( hSD, "Projection", DFNT_CHAR8, + strlen(pszProjection) + 1, pszProjection )) < 0 ) + { + CPLDebug( "HDF4Image", + "Cannot write projection information to output file"); + } + } + + // Store all metadata from source dataset as HDF attributes + if( GetMetadata() ) + { + char **papszMeta = GetMetadata(); + + while ( *papszMeta ) + { + pszValue = CPLParseNameValue( *papszMeta++, &pszName ); + if ( (SDsetattr( hSD, pszName, DFNT_CHAR8, + strlen(pszValue) + 1, pszValue )) < 0 ); + { + CPLDebug( "HDF4Image", + "Cannot write metadata information to output file"); + } + + CPLFree( pszName ); + } + } + + // Write out NoData values + for ( iBand = 1; iBand <= nBands; iBand++ ) + { + HDF4ImageRasterBand *poBand = + (HDF4ImageRasterBand *)GetRasterBand(iBand); + + if ( poBand->bNoDataSet ) + { + pszName = CPLStrdup( CPLSPrintf( "NoDataValue%d", iBand ) ); + pszValue = CPLSPrintf( "%lf", poBand->dfNoDataValue ); + if ( (SDsetattr( hSD, pszName, DFNT_CHAR8, + strlen(pszValue) + 1, pszValue )) < 0 ) + { + CPLDebug( "HDF4Image", + "Cannot write NoData value for band %d " + "to output file", iBand); + } + + CPLFree( pszName ); + } + } + + // Write out band descriptions + for ( iBand = 1; iBand <= nBands; iBand++ ) + { + HDF4ImageRasterBand *poBand = + (HDF4ImageRasterBand *)GetRasterBand(iBand); + + pszName = CPLStrdup( CPLSPrintf( "BandDesc%d", iBand ) ); + pszValue = poBand->GetDescription(); + if ( pszValue != NULL && !EQUAL( pszValue, "" ) ) + { + if ( (SDsetattr( hSD, pszName, DFNT_CHAR8, + strlen(pszValue) + 1, pszValue )) < 0 ) + { + CPLDebug( "HDF4Image", + "Cannot write band's %d description to output file", + iBand); + } + } + + CPLFree( pszName ); + } +} + +/************************************************************************/ +/* USGSMnemonicToCode() */ +/************************************************************************/ + +long HDF4ImageDataset::USGSMnemonicToCode( const char* pszMnemonic ) +{ + if ( EQUAL(pszMnemonic, "UTM") ) + return 1L; + else if ( EQUAL(pszMnemonic, "LAMCC") ) + return 4L; + else if ( EQUAL(pszMnemonic, "PS") ) + return 6L; + else if ( EQUAL(pszMnemonic, "PC") ) + return 7L; + else if ( EQUAL(pszMnemonic, "TM") ) + return 9L; + else if ( EQUAL(pszMnemonic, "EQRECT") ) + return 17L; + else if ( EQUAL(pszMnemonic, "OM") ) + return 20L; + else if ( EQUAL(pszMnemonic, "SOM") ) + return 22L; + else + return 1L; // UTM by default +} + +/************************************************************************/ +/* ToGeoref() */ +/************************************************************************/ + +void HDF4ImageDataset::ToGeoref( double *pdfGeoX, double *pdfGeoY ) +{ + OGRCoordinateTransformation *poTransform = NULL; + OGRSpatialReference *poLatLong = NULL; + poLatLong = oSRS.CloneGeogCS(); + poTransform = OGRCreateCoordinateTransformation( poLatLong, &oSRS ); + + if( poTransform != NULL ) + poTransform->Transform( 1, pdfGeoX, pdfGeoY, NULL ); + + if( poTransform != NULL ) + delete poTransform; + + if( poLatLong != NULL ) + delete poLatLong; +} + +/************************************************************************/ +/* ReadCoordinates() */ +/************************************************************************/ + +void HDF4ImageDataset::ReadCoordinates( const char *pszString, + double *pdfX, double *pdfY ) +{ + char **papszStrList; + papszStrList = CSLTokenizeString2( pszString, ", ", 0 ); + *pdfX = atof(papszStrList[0]); + *pdfY = atof(papszStrList[1]); + CSLDestroy( papszStrList ); +} + +/************************************************************************/ +/* CaptureNRLGeoTransform() */ +/* */ +/* Capture geotransform and coordinate system from NRL (Navel */ +/* Research Laboratory, Stennis Space Center) metadata. */ +/************************************************************************/ + +/* Example metadata: +Metadata: + createTime=Fri Oct 1 18:00:07 2004 + createSoftware=APS v2.8.4 + createPlatform=i686-pc-linux-gnu + createAgency=Naval Research Laboratory, Stennis Space Center + sensor=MODIS + sensorPlatform=TERRA-AM + sensorAgency=NASA + sensorType=whiskbroom + sensorSpectrum=Visible/Thermal + sensorNumberOfBands=36 + sensorBandUnits=nano meters + sensorBands=645, 858.5, 469, 555, 1240, 1640, 2130, 412.5, 443, 488, 531, 551, + 667, 678, 748, 869.5, 905, 936, 940, 3750, 3959, 3959, 4050, 4465.5, 4515.5, 13 +75, 6715, 7325, 8550, 9730, 11130, 12020, 13335, 13635, 13935, 14235 + sensorBandWidths=50, 35, 20, 20, 20, 24, 50, 15, 10, 10, 10, 10, 10, 10, 10, 1 +5, 30, 10, 50, 90, 60, 60, 60, 65, 67, 30, 360, 300, 300, 300, 500, 500, 300, 30 +0, 300, 300 + sensorNominalAltitudeInKM=705 + sensorScanWidthInKM=2330 + sensorResolutionInKM=1 + sensorPlatformType=Polar-orbiting Satellite + timeStartYear=2004 + timeStartDay=275 + timeStartTime=56400000 + timeStart=Fri Oct 1 15:40:00 2004 + timeDayNight=Day + timeEndYear=2004 + timeEndDay=275 + timeEndTime=56700000 + timeEnd=Fri Oct 1 15:45:00 2004 + inputMasks=HIGLINT,CLDICE,LAND,ATMFAIL + inputMasksInt=523 + processedVersion=1.2 + file=MODAM2004275.L3_Mosaic_NOAA_GMX + fileTitle=NRL Level-3 Mosaic + fileVersion=3.0 + fileClassification=UNCLASSIFIED + fileStatus=EXPERIMENTAL + navType=mapped + mapProjectionSystem=NRL(USGS) + mapProjection=Gomex + mapUpperLeft=31, -99 + mapUpperRight=31, -79 + mapLowerLeft=14.9844128048645, -99 + mapLowerRight=14.9844128048645, -79 + inputFiles=MODAM2004275154000.L3_NOAA_GMX + ... + */ + +void HDF4ImageDataset::CaptureNRLGeoTransform() + +{ + double adfXY[8]; + static char *apszItems[] = { + "mapUpperLeft", "mapUpperRight", "mapLowerLeft", "mapLowerRight" }; + int iCorner; + + for( iCorner = 0; iCorner < 4; iCorner++ ) + { + const char *pszCornerLoc = + CSLFetchNameValue( papszGlobalMetadata, apszItems[iCorner] ); + + if( pszCornerLoc == NULL ) + return; + + char **papszTokens = CSLTokenizeStringComplex( pszCornerLoc, ",", + FALSE, FALSE ); + if( CSLCount( papszTokens ) != 2 ) + return; + + adfXY[iCorner*2+0] = atof(papszTokens[1]); + adfXY[iCorner*2+1] = atof(papszTokens[0]); + + CSLDestroy( papszTokens ); + } + + if( adfXY[0*2+0] == adfXY[2*2+0] && adfXY[0*2+1] == adfXY[1*2+1] ) + { + bHasGeoTransform = TRUE; + adfGeoTransform[0] = adfXY[0*2+0]; + adfGeoTransform[1] = (adfXY[1*2+0] - adfXY[0*2+0]) / nRasterXSize; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = adfXY[0*2+1]; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = (adfXY[2*2+1] - adfXY[0*2+1]) / nRasterYSize; + + oSRS.SetWellKnownGeogCS( "WGS84" ); + CPLFree( pszProjection ); + oSRS.exportToWkt( &pszProjection ); + } +} + +/************************************************************************/ +/* CaptureCoastwatchGCTPInfo() */ +/************************************************************************/ + +/* Example Metadata from: + + http://coastwatch.noaa.gov/interface/most_recent.php?sensor=MODIS&product=chlorNASA + +Definitions at: + http://coastwatch.noaa.gov/cw_form_hdf.html + +Metadata: + satellite=Aqua + sensor=MODIS + origin=USDOC/NOAA/NESDIS CoastWatch + history=PGE01:4.1.12;PGE02:4.3.1.12;SeaDAS Version ?.?, MSl12 4.0.2, Linux 2.4.21-27.0.1.EL +cwregister GulfOfMexicoSinusoidal.hdf MODSCW.P2005023.1835.swath09.hdf MODSCW.P2005023.1835.GM16.mapped09.hdf +cwgraphics MODSCW.P2005023.1835.GM16.closest.hdf +cwmath --template chlor_a --expr chlor_a=select(and(l2_flags,514)!=0,nan,chlor_a) /data/aps/browse/lvl3/seadas/coastwatch/hdf/MODSCW_P2005023_1835_GM16_closest.hdf /data/aps/browse/lvl3/seadas/coastwatch/maskhdf/MODSCW_P2005023_1835_GM16_closest_chlora.hdf +cwmath --template latitude --expr latitude=latitude /data/aps/browse/lvl3/seadas/coastwatch/hdf/MODSCW_P2005023_1835_GM16_closest.hdf /data/aps/browse/lvl3/seadas/coastwatch/maskhdf/MODSCW_P2005023_1835_GM16_closest_chlora.hdf +cwmath --template longitude --expr longitude=longitude /data/aps/browse/lvl3/seadas/coastwatch/hdf/MODSCW_P2005023_1835_GM16_closest.hdf /data/aps/browse/lvl3/seadas/coastwatch/maskhdf/MODSCW_P2005023_1835_GM16_closest_chlora.hdf + cwhdf_version=3.2 + pass_type=day + pass_date=12806 + start_time=66906 + temporal_extent=298 + projection_type=mapped + projection=Sinusoidal + gctp_sys=16 + gctp_zone=62 + gctp_parm=6378137, 0, 0, 0, -89000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + gctp_datum=12 + et_affine=0, -1008.74836097881, 1008.74836097881, 0, -953126.102425113, 3447041.10282512 + rows=1540 + cols=2000 + polygon_latitude=31, 31, 31, 31, 31, 27.5095879249529, 24.0191758499058, 20.5287637748587, 17.0383516998116, 17.0383516998116, 17.0383516998116, 17.0383516998116, 17.0383516998116, 20.5287637748587, 24.0191758499058, 27.5095879249529, 31 + polygon_longitude=-99, -93.7108573344442, -88.4217146688883, -83.1325720033325, -77.8434293377767, -78.217853417453, -78.5303805448579, -78.7884829057512, -78.9979508907244, -83.7397542896832, -88.481557688642, -93.2233610876007, -97.9651644865595, -98.1529175079091, -98.3842631146439, -98.664391423662, -99 + orbit_type=ascending + raster_type=RasterPixelIsArea + swath_sync_lines=1 + + */ + +void HDF4ImageDataset::CaptureCoastwatchGCTPInfo() + +{ + if( CSLFetchNameValue( papszGlobalMetadata, "gctp_sys" ) == NULL + || CSLFetchNameValue( papszGlobalMetadata, "gctp_zone" ) == NULL + || CSLFetchNameValue( papszGlobalMetadata, "gctp_parm" ) == NULL + || CSLFetchNameValue( papszGlobalMetadata, "gctp_datum" ) == NULL + || CSLFetchNameValue( papszGlobalMetadata, "et_affine" ) == NULL ) + return; + +/* -------------------------------------------------------------------- */ +/* Grab USGS/GCTP Parameters. */ +/* -------------------------------------------------------------------- */ + int nSys, nZone, nDatum, iParm; + double adfParms[15]; + char **papszTokens; + + nSys = atoi( CSLFetchNameValue( papszGlobalMetadata, "gctp_sys" ) ); + nZone = atoi( CSLFetchNameValue( papszGlobalMetadata, "gctp_zone" ) ); + nDatum = atoi( CSLFetchNameValue( papszGlobalMetadata, "gctp_datum" ) ); + + papszTokens = CSLTokenizeStringComplex( + CSLFetchNameValue( papszGlobalMetadata, "gctp_parm" ), ",", + FALSE, FALSE ); + if( CSLCount(papszTokens) < 15 ) + return; + + for( iParm = 0; iParm < 15; iParm++ ) + adfParms[iParm] = atof(papszTokens[iParm]); + CSLDestroy( papszTokens ); + +/* -------------------------------------------------------------------- */ +/* Convert into an SRS. */ +/* -------------------------------------------------------------------- */ + + if( oSRS.importFromUSGS( nSys, nZone, adfParms, nDatum ) != OGRERR_NONE ) + return; + + CPLFree( pszProjection ); + oSRS.exportToWkt( &pszProjection ); + +/* -------------------------------------------------------------------- */ +/* Capture the affine transform info. */ +/* -------------------------------------------------------------------- */ + + papszTokens = CSLTokenizeStringComplex( + CSLFetchNameValue( papszGlobalMetadata, "et_affine" ), ",", + FALSE, FALSE ); + if( CSLCount(papszTokens) != 6 ) + return; + + // We don't seem to have proper ef_affine docs so I don't + // know which of these two coefficients goes where. + if( atof(papszTokens[0]) != 0.0 || atof(papszTokens[3]) != 0.0 ) + return; + + bHasGeoTransform = TRUE; + adfGeoTransform[0] = atof(papszTokens[4]); + adfGeoTransform[1] = atof(papszTokens[2]); + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = atof(papszTokens[5]); + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = atof(papszTokens[1]); + + // Middle of pixel adjustment. + adfGeoTransform[0] -= adfGeoTransform[1] * 0.5; + adfGeoTransform[3] -= adfGeoTransform[5] * 0.5; +} + +/************************************************************************/ +/* GetSwatAttrs() */ +/************************************************************************/ + +char** HDF4ImageDataset::GetSwatAttrs( int32 hSW, char **papszMetadata ) +{ + int32 nStrBufSize = 0; + + if ( SWinqattrs( hSW, NULL, &nStrBufSize ) > 0 && nStrBufSize > 0 ) + { + char *pszAttrList; + char **papszAttributes; + int i, nAttrs; + + pszAttrList = (char *)CPLMalloc( nStrBufSize + 1 ); + SWinqattrs( hSW, pszAttrList, &nStrBufSize ); + +#if DEBUG + CPLDebug( "HDF4Image", "List of attributes in swath %s: %s", + pszFieldName, pszAttrList ); +#endif + + papszAttributes = CSLTokenizeString2( pszAttrList, ",", + CSLT_HONOURSTRINGS ); + nAttrs = CSLCount( papszAttributes ); + for ( i = 0; i < nAttrs; i++ ) + { + int32 iNumType, nValues; + void *pData = NULL; + char *pszTemp = NULL; + + SWattrinfo( hSW, papszAttributes[i], &iNumType, &nValues ); + + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + pData = CPLMalloc( (nValues + 1) * GetDataTypeSize(iNumType) ); + else + pData = CPLMalloc( nValues * GetDataTypeSize(iNumType) ); + + SWreadattr( hSW, papszAttributes[i], pData ); + + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + { + ((char *)pData)[nValues] = '\0'; + papszMetadata = CSLAddNameValue( papszMetadata, + papszAttributes[i], + (const char *) pData ); + } + else + { + pszTemp = SPrintArray( GetDataType(iNumType), pData, + nValues, ", " ); + papszMetadata = CSLAddNameValue( papszMetadata, + papszAttributes[i], pszTemp ); + if ( pszTemp ) + CPLFree( pszTemp ); + } + + if ( pData ) + CPLFree( pData ); + + } + + CSLDestroy( papszAttributes ); + CPLFree( pszAttrList ); + } + + return papszMetadata; +} + +/************************************************************************/ +/* GetGridAttrs() */ +/************************************************************************/ + +char** HDF4ImageDataset::GetGridAttrs( int32 hGD, char **papszMetadata ) +{ + int32 nStrBufSize = 0; + + if ( GDinqattrs( hGD, NULL, &nStrBufSize ) > 0 && nStrBufSize > 0 ) + { + char *pszAttrList; + char **papszAttributes; + int i, nAttrs; + + pszAttrList = (char *)CPLMalloc( nStrBufSize + 1 ); + GDinqattrs( hGD, pszAttrList, &nStrBufSize ); +#if DEBUG + CPLDebug( "HDF4Image", "List of attributes in grid %s: %s", + pszFieldName, pszAttrList ); +#endif + papszAttributes = CSLTokenizeString2( pszAttrList, ",", + CSLT_HONOURSTRINGS ); + nAttrs = CSLCount( papszAttributes ); + for ( i = 0; i < nAttrs; i++ ) + { + int32 iNumType, nValues; + void *pData = NULL; + char *pszTemp = NULL; + + GDattrinfo( hGD, papszAttributes[i], &iNumType, &nValues ); + + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + pData = CPLMalloc( (nValues + 1) * GetDataTypeSize(iNumType) ); + else + pData = CPLMalloc( nValues * GetDataTypeSize(iNumType) ); + + GDreadattr( hGD, papszAttributes[i], pData ); + + if ( iNumType == DFNT_CHAR8 || iNumType == DFNT_UCHAR8 ) + { + ((char *)pData)[nValues] = '\0'; + papszMetadata = CSLAddNameValue( papszMetadata, + papszAttributes[i], + (const char *) pData ); + } + else + { + pszTemp = SPrintArray( GetDataType(iNumType), pData, + nValues, ", " ); + papszMetadata = CSLAddNameValue( papszMetadata, + papszAttributes[i], pszTemp ); + if ( pszTemp ) + CPLFree( pszTemp ); + } + + if ( pData ) + CPLFree( pData ); + + } + + CSLDestroy( papszAttributes ); + CPLFree( pszAttrList ); + } + + return papszMetadata; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *HDF4ImageDataset::Open( GDALOpenInfo * poOpenInfo ) +{ + int i; + + if( !EQUALN( poOpenInfo->pszFilename, "HDF4_SDS:", 9 ) && + !EQUALN( poOpenInfo->pszFilename, "HDF4_GR:", 8 ) && + !EQUALN( poOpenInfo->pszFilename, "HDF4_GD:", 8 ) && + !EQUALN( poOpenInfo->pszFilename, "HDF4_EOS:", 9 ) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + char **papszSubdatasetName; + HDF4ImageDataset *poDS; + + poDS = new HDF4ImageDataset( ); + + poDS->fp = poOpenInfo->fp; + poOpenInfo->fp = NULL; + + papszSubdatasetName = CSLTokenizeString2( poOpenInfo->pszFilename, + ":", CSLT_HONOURSTRINGS | CSLT_PRESERVEESCAPES); + if ( CSLCount( papszSubdatasetName ) != 4 + && CSLCount( papszSubdatasetName ) != 5 ) + { + CSLDestroy( papszSubdatasetName ); + return NULL; + } + + poDS->pszFilename = CPLStrdup( papszSubdatasetName[2] ); + + if( EQUAL( papszSubdatasetName[0], "HDF4_SDS" ) ) + poDS->iDatasetType = HDF4_SDS; + else if ( EQUAL( papszSubdatasetName[0], "HDF4_GR" ) ) + poDS->iDatasetType = HDF4_GR; + else if ( EQUAL( papszSubdatasetName[0], "HDF4_EOS" ) ) + poDS->iDatasetType = HDF4_EOS; + else + poDS->iDatasetType = HDF4_UNKNOWN; + + if( EQUAL( papszSubdatasetName[1], "GDAL_HDF4" ) ) + poDS->iSubdatasetType = GDAL_HDF4; + else if( EQUAL( papszSubdatasetName[1], "EOS_GRID" ) ) + poDS->iSubdatasetType = EOS_GRID; + else if( EQUAL( papszSubdatasetName[1], "EOS_SWATH" ) ) + poDS->iSubdatasetType = EOS_SWATH; + else if( EQUAL( papszSubdatasetName[1], "SEAWIFS_L3" ) ) + poDS->iSubdatasetType= SEAWIFS_L3; + else if( EQUAL( papszSubdatasetName[1], "HYPERION_L1" ) ) + poDS->iSubdatasetType= HYPERION_L1; + else + poDS->iSubdatasetType = UNKNOWN; + + // Is our file still here? + if ( !Hishdf( poDS->pszFilename ) ) + { + CSLDestroy( papszSubdatasetName ); + CPLFree( poDS->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + int32 iAttribute, nValues, iAttrNumType; + char szAttrName[MAX_NC_NAME]; + double dfNoData = 0.0; + int bNoDataSet = FALSE; + +/* -------------------------------------------------------------------- */ +/* Select SDS or GR to read from. */ +/* -------------------------------------------------------------------- */ + if ( poDS->iDatasetType == HDF4_EOS ) + { + poDS->pszSubdatasetName = CPLStrdup( papszSubdatasetName[3] ); + poDS->pszFieldName = CPLStrdup( papszSubdatasetName[4] ); + } + else + poDS->iDataset = atoi( papszSubdatasetName[3] ); + CSLDestroy( papszSubdatasetName ); + + switch ( poDS->iDatasetType ) + { + case HDF4_EOS: + { + void *pNoDataValue = NULL; + + switch ( poDS->iSubdatasetType ) + { + +/* -------------------------------------------------------------------- */ +/* HDF-EOS Swath. */ +/* -------------------------------------------------------------------- */ + case EOS_SWATH: + { + int32 hHDF4, hSW, nDimensions, nStrBufSize, iNumType; + char **papszDimList = NULL, + **papszGeolocations = NULL, **papszDimMap = NULL; + char *pszDimList = NULL, + *pszGeoList = NULL, *pszDimMaps = NULL; + int32 *paiRank = NULL, *paiNumType = NULL, + *paiOffset = NULL, *paiIncrement = NULL; + int nDimCount; + + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->hHDF4 = SWopen( poDS->pszFilename, DFACC_READ ); + else + poDS->hHDF4 = SWopen( poDS->pszFilename, DFACC_WRITE ); + + if( poDS->hHDF4 <= 0 ) + { + CPLDebug( "HDF4Image", "Can't open HDF4 file %s", + poDS->pszFilename ); + CPLFree( poDS->pszFilename ); + CPLFree( poDS->pszSubdatasetName ); + CPLFree( poDS->pszFieldName ); + return( NULL ); + } + + hSW = SWattach( poDS->hHDF4, poDS->pszSubdatasetName ); + if( hSW < 0 ) + { + CPLDebug( "HDF4Image", "Can't attach to subdataset %s", + poDS->pszSubdatasetName ); + CPLFree( poDS->pszFilename ); + CPLFree( poDS->pszSubdatasetName ); + CPLFree( poDS->pszFieldName ); + return( NULL ); + } + + nDimensions = SWnentries( hSW, HDFE_NENTDIM, &nStrBufSize ); + pszDimList = (char *)CPLMalloc( nStrBufSize + 1 ); + SWfieldinfo( hSW, poDS->pszFieldName, &poDS->iRank, + poDS->aiDimSizes, &poDS->iNumType, pszDimList ); +#if DEBUG + CPLDebug( "HDF4Image", + "List of dimensions in swath %s: %s", + poDS->pszFieldName, pszDimList ); +#endif + + papszDimList = CSLTokenizeString2( pszDimList, ",", + CSLT_HONOURSTRINGS ); + nDimCount = CSLCount( papszDimList ); + + poDS->papszLocalMetadata = + poDS->GetSwatAttrs( hSW, poDS->papszLocalMetadata ); + + // Search for the "Bands" name or take the first dimension + // as a number of bands + if ( poDS->iRank == 2 ) + poDS->nBands = 1; + else + { + poDS->nBands = poDS->aiDimSizes[0]; + /*for ( i = 0; i < nDimCount; i++ ) + { + if ( EQUALN( papszDimList[i], "Band", 4 ) ) + { + poDS->nBands = poDS->aiDimSizes[i]; + break; + } + }*/ + } + + // Search for the "XDim" and "YDim" names or take the last + // two dimensions as X and Y sizes + poDS->iXDim = nDimCount - 1; + poDS->iYDim = nDimCount - 2; + if( nDimCount >= 3 ) + poDS->iBandDim = nDimCount - 3; + +#if DEBUG + CPLDebug( "HDF4Image", + "X dimension is %d, Y dimension is %d", + poDS->iXDim, poDS->iYDim ); +#endif + + /*for ( i = 0; i < nDimCount; i++ ) + { + if ( EQUALN( papszDimList[i], "X", 1 ) ) + poDS->iXDim = i; + else if ( EQUALN( papszDimList[i], "Y", 1 ) ) + poDS->iYDim = i; + }*/ + +/* -------------------------------------------------------------------- */ +/* Fetch NODATA value. */ +/* -------------------------------------------------------------------- */ + pNoDataValue = + CPLMalloc( poDS->GetDataTypeSize(poDS->iNumType) ); + if ( SWgetfillvalue( hSW, poDS->pszFieldName, + pNoDataValue ) != -1 ) + { + dfNoData = poDS->AnyTypeToDouble( poDS->iNumType, + pNoDataValue ); + bNoDataSet = TRUE; + } + CPLFree( pNoDataValue ); + +/* -------------------------------------------------------------------- */ +/* Fetch metadata. */ +/* -------------------------------------------------------------------- */ + EHidinfo( poDS->hHDF4, &hHDF4, &poDS->hSD ); + poDS->ReadGlobalAttributes( poDS->hSD ); + poDS->papszLocalMetadata = + CSLDuplicate( poDS->papszGlobalMetadata ); + poDS->papszLocalMetadata = + poDS->GetSwatAttrs( hSW, poDS->papszLocalMetadata ); + poDS->SetMetadata( poDS->papszLocalMetadata ); + +/* -------------------------------------------------------------------- */ +/* Determine a product name. */ +/* -------------------------------------------------------------------- */ + const char *pszProduct = + CSLFetchNameValue( poDS->papszLocalMetadata, + "SHORTNAME" ); + HDF4EOSProduct eProduct = PROD_UNKNOWN; + if ( pszProduct ) + { + if ( EQUALN(pszProduct, "ASTL1A", 6) ) + eProduct = PROD_ASTER_L1A; + else if ( EQUALN(pszProduct, "ASTL1B", 6) ) + eProduct = PROD_ASTER_L1B; + else if ( EQUALN(pszProduct, "AST_04", 6) + || EQUALN(pszProduct, "AST_05", 6) + || EQUALN(pszProduct, "AST_06", 6) + || EQUALN(pszProduct, "AST_07", 6) + || EQUALN(pszProduct, "AST_08", 6) + || EQUALN(pszProduct, "AST_09", 6) + || EQUALN(pszProduct, "AST13", 5) + || EQUALN(pszProduct, "AST3", 4) ) + eProduct = PROD_ASTER_L2; + else if ( EQUALN(pszProduct, "AST14", 5) ) + eProduct = PROD_ASTER_L3; + else if ( EQUALN(pszProduct, "MOD02", 5) + || EQUALN(pszProduct, "MYD02", 5) ) + eProduct = PROD_MODIS_L1B; + } + +/* -------------------------------------------------------------------- */ +/* Fetch geolocation fields. */ +/* -------------------------------------------------------------------- */ + char szXGeo[8192] = ""; + char szYGeo[8192] = ""; + char szPixel[8192]= ""; + char szLine[8192] = ""; + char szGeoDimList[8192] = ""; + int32 nDataFields, nDimMaps; + void *pLat = NULL, *pLong = NULL; + void *pLatticeX = NULL, *pLatticeY = NULL; + int32 iLatticeType, iLatticeDataSize, iRank; + int32 nLatCount = 0, nLongCount = 0; + int32 nXPoints, nYPoints; + int32 aiDimSizes[MAX_VAR_DIMS]; + int j, iDataSize, iPixelDim, iLineDim; + + nDataFields = SWnentries( hSW, HDFE_NENTGFLD, &nStrBufSize ); + pszGeoList = (char *)CPLMalloc( nStrBufSize + 1 ); + paiRank = (int32 *)CPLMalloc( nDataFields * sizeof(int32) ); + paiNumType = (int32 *)CPLMalloc( nDataFields * sizeof(int32) ); + if ( nDataFields != + SWinqgeofields(hSW, pszGeoList, paiRank, paiNumType) ) + { + CPLDebug( "HDF4Image", + "Can't get the list of geolocation fields in swath %s", + poDS->pszSubdatasetName ); + } + +#if DEBUG + else + { + char *pszTmp; + CPLDebug( "HDF4Image", + "Number of geolocation fields in swath %s: %d", + poDS->pszSubdatasetName, nDataFields ); + CPLDebug( "HDF4Image", + "List of geolocation fields in swath %s: %s", + poDS->pszSubdatasetName, pszGeoList ); + pszTmp = SPrintArray( GDT_UInt32, paiRank, + nDataFields, "," ); + CPLDebug( "HDF4Image", + "Geolocation fields ranks: %s", pszTmp ); + CPLFree( pszTmp ); + } +#endif + + papszGeolocations = CSLTokenizeString2( pszGeoList, ",", + CSLT_HONOURSTRINGS ); + // Read geolocation data + nDimMaps = SWnentries( hSW, HDFE_NENTMAP, &nStrBufSize ); + pszDimMaps = (char *)CPLMalloc( nStrBufSize + 1 ); + paiOffset = (int32 *)CPLMalloc( nDimMaps * sizeof(int32) ); + memset( paiOffset, 0, nDimMaps * sizeof(int32) ); + paiIncrement = (int32 *)CPLMalloc( nDimMaps * sizeof(int32) ); + memset( paiIncrement, 0, nDimMaps * sizeof(int32) ); + if ( nDimMaps != + SWinqmaps(hSW, pszDimMaps, paiOffset, paiIncrement) ) + { + CPLDebug( "HDF4Image", + "Can't get the list of geolocation maps in swath %s", + poDS->pszSubdatasetName ); + } + +#if DEBUG + else + { + char *pszTmp; + + CPLDebug( "HDF4Image", + "List of geolocation maps in swath %s: %s", + poDS->pszSubdatasetName, pszDimMaps ); + pszTmp = SPrintArray( GDT_Int32, paiOffset, + nDimMaps, "," ); + CPLDebug( "HDF4Image", + "Geolocation map offsets: %s", pszTmp ); + CPLFree( pszTmp ); + pszTmp = SPrintArray( GDT_Int32, paiIncrement, + nDimMaps, "," ); + CPLDebug( "HDF4Image", + "Geolocation map increments: %s", pszTmp ); + CPLFree( pszTmp ); + } +#endif + + papszDimMap = CSLTokenizeString2( pszDimMaps, ",", + CSLT_HONOURSTRINGS ); + for ( i = 0; i < CSLCount(papszDimMap); i++ ) + { + if ( strstr(papszDimMap[i], papszDimList[poDS->iXDim]) ) + { + strncpy( szPixel, papszDimList[poDS->iXDim], 8192 ); + strncpy( szXGeo, papszDimMap[i], 8192 ); + char *pszTemp = strchr( szXGeo, '/' ); + if ( pszTemp ) + *pszTemp = '\0'; + } + else if ( strstr(papszDimMap[i], papszDimList[poDS->iYDim]) ) + { + strncpy( szLine, papszDimList[poDS->iYDim], 8192 ); + strncpy( szYGeo, papszDimMap[i], 8192 ); + char *pszTemp = strchr( szYGeo, '/' ); + if ( pszTemp ) + *pszTemp = '\0'; + } + } + + for ( i = 0; i < CSLCount(papszGeolocations); i++ ) + { + char **papszGeoDimList = NULL; + + SWfieldinfo( hSW, papszGeolocations[i], &iRank, + aiDimSizes, &iNumType, szGeoDimList ); + papszGeoDimList = CSLTokenizeString2( szGeoDimList, + ",", CSLT_HONOURSTRINGS ); + +#if DEBUG + CPLDebug( "HDF4Image", + "List of dimensions in geolocation field %s: %s", + papszGeolocations[i], szGeoDimList ); +#endif + + if (szXGeo[0] == 0 || szYGeo[0] == 0) + return NULL; + + nXPoints = aiDimSizes[CSLFindString( papszGeoDimList, szXGeo )]; + nYPoints = aiDimSizes[CSLFindString( papszGeoDimList, szYGeo )]; + + if ( EQUAL(szPixel, papszDimList[poDS->iXDim]) ) + { + iPixelDim = 1; + iLineDim = 0; + } + else + { + iPixelDim = 0; + iLineDim = 1; + } + + iDataSize = poDS->GetDataTypeSize( iNumType ); + if ( strstr( papszGeolocations[i], "Latitude" ) ) + { + nLatCount = nXPoints * nYPoints; + pLat = CPLMalloc( nLatCount * iDataSize ); + if (SWreadfield( hSW, papszGeolocations[i], NULL, + NULL, NULL, (VOIDP)pLat ) < 0) + { + CPLDebug( "HDF4Image", + "Can't read geolocation field %s", + papszGeolocations[i]); + CPLFree( pLat ); + pLat = NULL; + } + } + else if ( strstr( papszGeolocations[i], "Longitude" ) ) + { + nLongCount = nXPoints * nYPoints; + pLong = CPLMalloc( nLongCount * iDataSize ); + if (SWreadfield( hSW, papszGeolocations[i], NULL, + NULL, NULL, (VOIDP)pLong ) < 0) + { + CPLDebug( "HDF4Image", + "Can't read geolocation field %s", + papszGeolocations[i]); + CPLFree( pLong ); + pLong = NULL; + } + } + + CSLDestroy( papszGeoDimList ); + + } + + // Do we have a lattice table? + if (SWfieldinfo(hSW, "LatticePoint", &iRank, aiDimSizes, + &iLatticeType, szGeoDimList) == 0 + && iRank == 3 + && nXPoints == aiDimSizes[1] + && nYPoints == aiDimSizes[0] + && aiDimSizes[2] == 2 ) + { + int32 iStart[MAX_NC_DIMS], iEdges[MAX_NC_DIMS]; + + iLatticeDataSize = + poDS->GetDataTypeSize( iLatticeType ); + + iStart[1] = 0; + iEdges[1] = nXPoints; + + iStart[0] = 0; + iEdges[0] = nYPoints; + + iStart[2] = 0; + iEdges[2] = 1; + + pLatticeX = CPLMalloc( nLatCount * iLatticeDataSize ); + if (SWreadfield( hSW, "LatticePoint", iStart, NULL, + iEdges, (VOIDP)pLatticeX ) < 0) + { + CPLDebug( "HDF4Image", "Can't read lattice field" ); + CPLFree( pLatticeX ); + pLatticeX = NULL; + } + + iStart[2] = 1; + iEdges[2] = 1; + + pLatticeY = CPLMalloc( nLatCount * iLatticeDataSize ); + if (SWreadfield( hSW, "LatticePoint", iStart, NULL, + iEdges, (VOIDP)pLatticeY ) < 0) + { + CPLDebug( "HDF4Image", "Can't read lattice field" ); + CPLFree( pLatticeY ); + pLatticeY = NULL; + } + + } + + if ( nLatCount && nLongCount && nLatCount == nLongCount + && pLat && pLong ) + { +/* -------------------------------------------------------------------- */ +/* Fetch projection information for various datasets. */ +/* -------------------------------------------------------------------- */ + if ( poDS->pszGCPProjection ) + CPLFree( poDS->pszGCPProjection ); + + // ASTER Level 1A + if ( eProduct == PROD_ASTER_L1A ) + { + poDS->pszGCPProjection = CPLStrdup( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]" ); + } + + // ASTER Level 1B, Level 2 + else if ( eProduct == PROD_ASTER_L1B + || eProduct == PROD_ASTER_L2 ) + { + // Constuct the metadata keys. + // A band number is taken from the field name. + char *pszBand = strpbrk( poDS->pszFieldName, + "0123456789" ); + + if ( !pszBand ) + pszBand = ""; + + char *pszProjLine = + CPLStrdup(CPLSPrintf("MPMETHOD%s", pszBand)); + char *pszParmsLine = + CPLStrdup(CPLSPrintf("PROJECTIONPARAMETERS%s", + pszBand)); + char *pszZoneLine = + CPLStrdup(CPLSPrintf("UTMZONECODE%s", + pszBand)); + char *pszEllipsoidLine = + CPLStrdup(CPLSPrintf("ELLIPSOIDANDDATUM%s", + pszBand)); + + // Fetch projection related values from the + // metadata. + const char *pszProj = + CSLFetchNameValue( poDS->papszLocalMetadata, + pszProjLine ); + const char *pszParms = + CSLFetchNameValue( poDS->papszLocalMetadata, + pszParmsLine ); + const char *pszZone = + CSLFetchNameValue( poDS->papszLocalMetadata, + pszZoneLine ); + const char* pszEllipsoid = + CSLFetchNameValue( poDS->papszLocalMetadata, + pszEllipsoidLine ); + +#if DEBUG + CPLDebug( "HDF4Image", + "Projection %s=%s, parameters %s=%s, " + "zone %s=%s", + pszProjLine, pszProj, pszParmsLine, + pszParms, pszZoneLine, pszZone ); + CPLDebug( "HDF4Image", "Ellipsoid %s=%s", + pszEllipsoidLine, pszEllipsoid ); +#endif + + // Transform all mnemonical codes in the values. + int i, nParms; + // Projection is UTM by default + long iProjSys = (pszProj) ? + poDS->USGSMnemonicToCode(pszProj) : 1L; + long iZone = + (pszZone && iProjSys == 1L) ? atoi(pszZone): 0L; + char **papszEllipsoid = (pszEllipsoid) ? + CSLTokenizeString2( pszEllipsoid, ",", + CSLT_HONOURSTRINGS ) : NULL; + + long iEllipsoid = 8L; // WGS84 by default + if ( papszEllipsoid + && CSLCount(papszEllipsoid) > 0 ) + { + if (EQUAL( papszEllipsoid[0], "WGS84")) + iEllipsoid = 8L; + } + + double adfProjParms[15]; + char **papszParms = (pszParms) ? + CSLTokenizeString2( pszParms, ",", + CSLT_HONOURSTRINGS ) : NULL; + nParms = CSLCount(papszParms); + if (nParms >= 15) + nParms = 15; + for (i = 0; i < nParms; i++) + adfProjParms[i] = atof(papszParms[i]); + for (; i < 15; i++) + adfProjParms[i] = 0.0; + + // Create projection definition + poDS->oSRS.importFromUSGS( iProjSys, iZone, + adfProjParms, iEllipsoid ); + poDS->oSRS.SetLinearUnits( SRS_UL_METER, 1.0 ); + poDS->oSRS.exportToWkt( &poDS->pszGCPProjection ); + + CSLDestroy( papszParms ); + CPLFree( pszZoneLine ); + CPLFree( pszParmsLine ); + CPLFree( pszProjLine ); + } + + // ASTER Level 3 (DEM) + else if ( eProduct == PROD_ASTER_L3 ) + { + double dfCenterX, dfCenterY; + int iZone; + + poDS->ReadCoordinates( CSLFetchNameValue( + poDS->papszGlobalMetadata, "SCENECENTER" ), + &dfCenterY, &dfCenterX ); + + // Calculate UTM zone from scene center coordinates + iZone = 30 + (int) ((dfCenterX + 6.0) / 6.0); + + // Create projection definition + if( dfCenterY > 0 ) + poDS->oSRS.SetUTM( iZone, TRUE ); + else + poDS->oSRS.SetUTM( - iZone, FALSE ); + poDS->oSRS.SetWellKnownGeogCS( "WGS84" ); + poDS->oSRS.SetLinearUnits( SRS_UL_METER, 1.0 ); + poDS->oSRS.exportToWkt( &poDS->pszGCPProjection ); + } + + // MODIS L1B + else if ( eProduct == PROD_MODIS_L1B ) + { + poDS->pszGCPProjection = CPLStrdup( "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]" ); + } + } + +/* -------------------------------------------------------------------- */ +/* Fill the GCPs list. */ +/* -------------------------------------------------------------------- */ + poDS->nGCPCount = nLatCount; + + poDS->pasGCPList = (GDAL_GCP *) + CPLCalloc( poDS->nGCPCount, sizeof( GDAL_GCP ) ); + GDALInitGCPs( poDS->nGCPCount, poDS->pasGCPList ); + + for ( i = 0; i < nYPoints; i++ ) + { + for ( j = 0; j < nXPoints; j++ ) + { + int iGCP = i * nXPoints + j; + + poDS->pasGCPList[iGCP].dfGCPX = + poDS->AnyTypeToDouble(iNumType, + (void *)((char *)pLong + iGCP * iDataSize)); + poDS->pasGCPList[iGCP].dfGCPY = + poDS->AnyTypeToDouble(iNumType, + (void *)((char *)pLat + iGCP * iDataSize)); + + // GCPs in Level 1A/1B dataset are in geocentric + // coordinates. Convert them in geodetic (we + // will convert latitudes only, longitudes + // do not need to be converted, because + // they are the same). + // This calculation valid for WGS84 datum only. + if ( eProduct == PROD_ASTER_L1A + || eProduct == PROD_ASTER_L1B ) + { + poDS->pasGCPList[iGCP].dfGCPY = + atan(tan(poDS->pasGCPList[iGCP].dfGCPY + *PI/180)/0.99330562)*180/PI; + } + + poDS->ToGeoref(&poDS->pasGCPList[iGCP].dfGCPX, + &poDS->pasGCPList[iGCP].dfGCPY); + + poDS->pasGCPList[iGCP].dfGCPZ = 0.0; + + if ( pLatticeX && pLatticeY ) + { + poDS->pasGCPList[iGCP].dfGCPPixel = + poDS->AnyTypeToDouble(iLatticeType, + (void *)((char *)pLatticeX + + iGCP * iLatticeDataSize))+0.5; + poDS->pasGCPList[iGCP].dfGCPLine = + poDS->AnyTypeToDouble(iLatticeType, + (void *)((char *)pLatticeY + + iGCP * iLatticeDataSize))+0.5; + } + else + { + poDS->pasGCPList[iGCP].dfGCPPixel = + paiOffset[iPixelDim] + + j * paiIncrement[iPixelDim] + 0.5; + poDS->pasGCPList[iGCP].dfGCPLine = + paiOffset[iLineDim] + + i * paiIncrement[iLineDim] + 0.5; + } + } + } + + if ( pLatticeX ) + CPLFree( pLatticeX ); + if ( pLatticeY ) + CPLFree( pLatticeY ); + if ( pLat ) + CPLFree( pLat ); + if ( pLong ) + CPLFree( pLong ); + CSLDestroy( papszDimMap ); + CSLDestroy( papszGeolocations ); + CPLFree( paiOffset ); + CPLFree( paiIncrement ); + CPLFree( paiNumType ); + CPLFree( paiRank ); + CPLFree( pszDimMaps ); + CPLFree( pszGeoList ); + CPLFree( pszDimList ); + + CSLDestroy( papszDimList ); + SWdetach( hSW ); + } + break; + +/* -------------------------------------------------------------------- */ +/* HDF-EOS Grid. */ +/* -------------------------------------------------------------------- */ + case EOS_GRID: + { + int32 hHDF4, hGD, + iProjCode = 0, iZoneCode = 0, iSphereCode = 0; + int32 nXSize, nYSize; + char szDimList[8192]; + char **papszDimList = NULL; + int nDimCount; + double adfUpLeft[2], adfLowRight[2], adfProjParms[15]; + + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->hHDF4 = GDopen( poDS->pszFilename, DFACC_READ ); + else + poDS->hHDF4 = GDopen( poDS->pszFilename, DFACC_WRITE ); + + if( poDS->hHDF4 <= 0 ) + return( NULL ); + + hGD = GDattach( poDS->hHDF4, poDS->pszSubdatasetName ); + GDfieldinfo( hGD, poDS->pszFieldName, &poDS->iRank, + poDS->aiDimSizes, &poDS->iNumType, szDimList ); +#if DEBUG + CPLDebug( "HDF4Image", + "List of dimensions in grid %s: %s", + poDS->pszFieldName, szDimList); +#endif + papszDimList = CSLTokenizeString2( szDimList, ",", + CSLT_HONOURSTRINGS ); + nDimCount = CSLCount( papszDimList ); + + // Search for the "Bands" name or take the first dimension + // as a number of bands + if ( poDS->iRank == 2 ) + poDS->nBands = 1; + else + { + poDS->nBands = poDS->aiDimSizes[0]; + for ( i = 0; i < nDimCount; i++ ) + { + if ( EQUALN( papszDimList[i], "Band", 4 ) ) + { + poDS->nBands = poDS->aiDimSizes[i]; + break; + } + } + } + + // Search for the "XDim" and "YDim" names or take the last + // two dimensions as X and Y sizes + poDS->iXDim = nDimCount - 1; + poDS->iYDim = nDimCount - 2; + + if( nDimCount >= 3 ) + poDS->iBandDim = nDimCount - 3; + + for ( i = 0; i < nDimCount; i++ ) + { + if ( EQUALN( papszDimList[i], "X", 1 ) ) + poDS->iXDim = i; + else if ( EQUALN( papszDimList[i], "Y", 1 ) ) + poDS->iYDim = i; + } + + // Fetch projection information + if ( GDprojinfo( hGD, &iProjCode, &iZoneCode, + &iSphereCode, adfProjParms) >= 0 ) + { +#if DEBUG + CPLDebug( "HDF4Image", + "Grid projection: " + "projection code: %d, zone code %d, " + "sphere code %d", + iProjCode, iZoneCode, iSphereCode ); +#endif + poDS->oSRS.importFromUSGS( iProjCode, iZoneCode, + adfProjParms, iSphereCode ); + + if ( poDS->pszProjection ) + CPLFree( poDS->pszProjection ); + poDS->oSRS.exportToWkt( &poDS->pszProjection ); + } + + // Fetch geotransformation matrix + if ( GDgridinfo( hGD, &nXSize, &nYSize, + adfUpLeft, adfLowRight ) >= 0 ) + { +#if DEBUG + CPLDebug( "HDF4Image", + "Grid geolocation: " + "top left X %f, top left Y %f, " + "low right X %f, low right Y %f, " + "cols %d, rows %d", + adfUpLeft[0], adfUpLeft[1], + adfLowRight[0], adfLowRight[1], + nXSize, nYSize ); +#endif + if ( iProjCode ) + { + // For projected systems coordinates are in meters + poDS->adfGeoTransform[1] = + (adfLowRight[0] - adfUpLeft[0]) / nXSize; + poDS->adfGeoTransform[5] = + (adfLowRight[1] - adfUpLeft[1]) / nYSize; + poDS->adfGeoTransform[0] = adfUpLeft[0]; + poDS->adfGeoTransform[3] = adfUpLeft[1]; + } + else + { + // Handle angular geographic coordinates here + poDS->adfGeoTransform[1] = + (CPLPackedDMSToDec(adfLowRight[0]) - + CPLPackedDMSToDec(adfUpLeft[0])) / nXSize; + poDS->adfGeoTransform[5] = + (CPLPackedDMSToDec(adfLowRight[1]) - + CPLPackedDMSToDec(adfUpLeft[1])) / nYSize; + poDS->adfGeoTransform[0] = + CPLPackedDMSToDec(adfUpLeft[0]); + poDS->adfGeoTransform[3] = + CPLPackedDMSToDec(adfUpLeft[1]); + } + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->bHasGeoTransform = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Fetch NODATA value. */ +/* -------------------------------------------------------------------- */ + pNoDataValue = + CPLMalloc( poDS->GetDataTypeSize(poDS->iNumType) ); + if ( GDgetfillvalue( hGD, poDS->pszFieldName, + pNoDataValue ) != -1 ) + { + dfNoData = poDS->AnyTypeToDouble( poDS->iNumType, + pNoDataValue ); + bNoDataSet = TRUE; + } + CPLFree( pNoDataValue ); + +/* -------------------------------------------------------------------- */ +/* Fetch metadata. */ +/* -------------------------------------------------------------------- */ + EHidinfo( poDS->hHDF4, &hHDF4, &poDS->hSD ); + poDS->ReadGlobalAttributes( poDS->hSD ); + poDS->papszLocalMetadata = + CSLDuplicate( poDS->papszGlobalMetadata ); + poDS->papszLocalMetadata = + poDS->GetGridAttrs( hGD, poDS->papszLocalMetadata ); + poDS->SetMetadata( poDS->papszLocalMetadata ); + + CSLDestroy( papszDimList ); + GDdetach( hGD ); + } + break; + + default: + break; + } + } + break; + +/* -------------------------------------------------------------------- */ +/* 'Plain' HDF scientific datasets. */ +/* -------------------------------------------------------------------- */ + case HDF4_SDS: + { + int32 iSDS; + +/* -------------------------------------------------------------------- */ +/* Part, common for all types of SDSs. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->hHDF4 = Hopen( poDS->pszFilename, DFACC_READ, 0 ); + else + poDS->hHDF4 = Hopen( poDS->pszFilename, DFACC_WRITE, 0 ); + + if( poDS->hHDF4 <= 0 ) + return( NULL ); + + poDS->hSD = SDstart( poDS->pszFilename, DFACC_READ ); + if ( poDS->hSD == -1 ) + return NULL; + + if ( poDS->ReadGlobalAttributes( poDS->hSD ) != CE_None ) + return NULL; + + memset( poDS->aiDimSizes, 0, sizeof(int32) * MAX_VAR_DIMS ); + iSDS = SDselect( poDS->hSD, poDS->iDataset ); + SDgetinfo( iSDS, poDS->szName, &poDS->iRank, poDS->aiDimSizes, + &poDS->iNumType, &poDS->nAttrs); + + // We will duplicate global metadata for every subdataset + poDS->papszLocalMetadata = + CSLDuplicate( poDS->papszGlobalMetadata ); + + for ( iAttribute = 0; iAttribute < poDS->nAttrs; iAttribute++ ) + { + SDattrinfo( iSDS, iAttribute, szAttrName, + &iAttrNumType, &nValues ); + poDS->papszLocalMetadata = + poDS->TranslateHDF4Attributes( iSDS, iAttribute, + szAttrName, iAttrNumType, + nValues, + poDS->papszLocalMetadata ); + } + poDS->SetMetadata( poDS->papszLocalMetadata, "" ); + SDendaccess( iSDS ); + +#ifdef DEBUG + CPLDebug( "HDF4Image", + "aiDimSizes[0]=%d, aiDimSizes[1]=%d, " + "aiDimSizes[2]=%d, aiDimSizes[3]=%d", + poDS->aiDimSizes[0], poDS->aiDimSizes[1], + poDS->aiDimSizes[2], poDS->aiDimSizes[3] ); +#endif + + switch( poDS->iRank ) + { + case 2: + poDS->nBands = 1; + poDS->iXDim = 1; + poDS->iYDim = 0; + break; + case 3: + if( poDS->aiDimSizes[0] < poDS->aiDimSizes[2] ) + { + poDS->iBandDim = 0; + poDS->iXDim = 2; + poDS->iYDim = 1; + } + else + { + if( poDS->aiDimSizes[1] <= poDS->aiDimSizes[0] && + poDS->aiDimSizes[1] <= poDS->aiDimSizes[2] ) + { + poDS->iBandDim = 1; + poDS->iXDim = 2; + poDS->iYDim = 0; + } + else + { + poDS->iBandDim = 2; + poDS->iXDim = 1; + poDS->iYDim = 0; + + } + } + poDS->nBands = poDS->aiDimSizes[poDS->iBandDim]; + break; + case 4: // FIXME + poDS->nBands = poDS->aiDimSizes[2] * poDS->aiDimSizes[3]; + break; + default: + break; + } + + // We preset this because CaptureNRLGeoTransform needs it. + poDS->nRasterXSize = poDS->aiDimSizes[poDS->iXDim]; + poDS->nRasterYSize = poDS->aiDimSizes[poDS->iYDim]; + + // Special case projection info for NRL generated files. + const char *pszMapProjectionSystem = + CSLFetchNameValue(poDS->papszGlobalMetadata, + "mapProjectionSystem"); + if( pszMapProjectionSystem != NULL + && EQUAL(pszMapProjectionSystem,"NRL(USGS)") ) + { + poDS->CaptureNRLGeoTransform(); + } + + // Special cast for coastwatch hdf files. + if( CSLFetchNameValue( poDS->papszGlobalMetadata, + "gctp_sys" ) != NULL ) + poDS->CaptureCoastwatchGCTPInfo(); + } + break; + +/* -------------------------------------------------------------------- */ +/* 'Plain' HDF rasters. */ +/* -------------------------------------------------------------------- */ + case HDF4_GR: + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->hHDF4 = Hopen( poDS->pszFilename, DFACC_READ, 0 ); + else + poDS->hHDF4 = Hopen( poDS->pszFilename, DFACC_WRITE, 0 ); + + if( poDS->hHDF4 <= 0 ) + return( NULL ); + + poDS->hGR = GRstart( poDS->hHDF4 ); + if ( poDS->hGR == -1 ) + return NULL; + + poDS->iGR = GRselect( poDS->hGR, poDS->iDataset ); + if ( GRgetiminfo( poDS->iGR, poDS->szName, + &poDS->iRank, &poDS->iNumType, + &poDS->iInterlaceMode, poDS->aiDimSizes, + &poDS->nAttrs ) != 0 ) + return NULL; + + // We will duplicate global metadata for every subdataset + poDS->papszLocalMetadata = CSLDuplicate( poDS->papszGlobalMetadata ); + + for ( iAttribute = 0; iAttribute < poDS->nAttrs; iAttribute++ ) + { + GRattrinfo( poDS->iGR, iAttribute, szAttrName, + &iAttrNumType, &nValues ); + poDS->papszLocalMetadata = + poDS->TranslateHDF4Attributes( poDS->iGR, iAttribute, + szAttrName, iAttrNumType, nValues, poDS->papszLocalMetadata ); + } + poDS->SetMetadata( poDS->papszLocalMetadata, "" ); + // Read colour table + GDALColorEntry oEntry; + + poDS->iPal = GRgetlutid ( poDS->iGR, poDS->iDataset ); + if ( poDS->iPal != -1 ) + { + GRgetlutinfo( poDS->iPal, &poDS->nComps, &poDS->iPalDataType, + &poDS->iPalInterlaceMode, &poDS->nPalEntries ); + GRreadlut( poDS->iPal, poDS->aiPaletteData ); + poDS->poColorTable = new GDALColorTable(); + for( i = 0; i < N_COLOR_ENTRIES; i++ ) + { + oEntry.c1 = poDS->aiPaletteData[i][0]; + oEntry.c2 = poDS->aiPaletteData[i][1]; + oEntry.c3 = poDS->aiPaletteData[i][2]; + oEntry.c4 = 255; + + poDS->poColorTable->SetColorEntry( i, &oEntry ); + } + } + + poDS->iXDim = 0; + poDS->iYDim = 1; + poDS->nBands = poDS->iRank; + break; + default: + return NULL; + } + + poDS->nRasterXSize = poDS->aiDimSizes[poDS->iXDim]; + poDS->nRasterYSize = poDS->aiDimSizes[poDS->iYDim]; + + if ( poDS->iSubdatasetType == HYPERION_L1 ) + { + // XXX: Hyperion SDSs has Height x Bands x Width dimensions scheme + poDS->nBands = poDS->aiDimSizes[1]; + poDS->nRasterXSize = poDS->aiDimSizes[2]; + poDS->nRasterYSize = poDS->aiDimSizes[0]; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( i = 1; i <= poDS->nBands; i++ ) + { + HDF4ImageRasterBand *poBand = new HDF4ImageRasterBand( poDS, i, + poDS->GetDataType( poDS->iNumType ) ); + poDS->SetBand( i, poBand ); + if ( bNoDataSet ) + poBand->SetNoDataValue( dfNoData ); + } + +/* -------------------------------------------------------------------- */ +/* Now we will handle particular types of HDF products. Every */ +/* HDF product has its own structure. */ +/* -------------------------------------------------------------------- */ + + // Variables for reading georeferencing + double dfULX, dfULY, dfLRX, dfLRY; + + switch ( poDS->iSubdatasetType ) + { +/* -------------------------------------------------------------------- */ +/* HDF, created by GDAL. */ +/* -------------------------------------------------------------------- */ + case GDAL_HDF4: + { + const char *pszValue; + + CPLDebug( "HDF4Image", + "Input dataset interpreted as GDAL_HDF4" ); + + if ( (pszValue = + CSLFetchNameValue(poDS->papszGlobalMetadata, + "Projection")) ) + { + if ( poDS->pszProjection ) + CPLFree( poDS->pszProjection ); + poDS->pszProjection = CPLStrdup( pszValue ); + } + if ( (pszValue = CSLFetchNameValue(poDS->papszGlobalMetadata, + "TransformationMatrix")) ) + { + int i = 0; + char *pszString = (char *) pszValue; + while ( *pszValue && i < 6 ) + { + poDS->adfGeoTransform[i++] = strtod(pszString, &pszString); + pszString++; + } + poDS->bHasGeoTransform = TRUE; + } + for( i = 1; i <= poDS->nBands; i++ ) + { + if ( (pszValue = + CSLFetchNameValue(poDS->papszGlobalMetadata, + CPLSPrintf("BandDesc%d", i))) ) + poDS->GetRasterBand( i )->SetDescription( pszValue ); + } + for( i = 1; i <= poDS->nBands; i++ ) + { + if ( (pszValue = + CSLFetchNameValue(poDS->papszGlobalMetadata, + CPLSPrintf("NoDataValue%d", i))) ) + poDS->GetRasterBand(i)->SetNoDataValue(atof(pszValue)); + } + } + break; + +/* -------------------------------------------------------------------- */ +/* SeaWiFS Level 3 Standard Mapped Image Products. */ +/* Organized similar to MODIS Level 3 products. */ +/* -------------------------------------------------------------------- */ + case SEAWIFS_L3: + { + CPLDebug( "HDF4Image", "Input dataset interpreted as SEAWIFS_L3" ); + + // Read band description + for ( i = 1; i <= poDS->nBands; i++ ) + { + poDS->GetRasterBand( i )->SetDescription( + CSLFetchNameValue( poDS->papszGlobalMetadata, "Parameter" ) ); + } + + // Read coordinate system and geotransform matrix + poDS->oSRS.SetWellKnownGeogCS( "WGS84" ); + + if ( EQUAL(CSLFetchNameValue(poDS->papszGlobalMetadata, + "Map Projection"), + "Equidistant Cylindrical") ) + { + poDS->oSRS.SetEquirectangular( 0.0, 0.0, 0.0, 0.0 ); + poDS->oSRS.SetLinearUnits( SRS_UL_METER, 1 ); + if ( poDS->pszProjection ) + CPLFree( poDS->pszProjection ); + poDS->oSRS.exportToWkt( &poDS->pszProjection ); + } + + dfULX = atof( CSLFetchNameValue(poDS->papszGlobalMetadata, + "Westernmost Longitude") ); + dfULY = atof( CSLFetchNameValue(poDS->papszGlobalMetadata, + "Northernmost Latitude") ); + dfLRX = atof( CSLFetchNameValue(poDS->papszGlobalMetadata, + "Easternmost Longitude") ); + dfLRY = atof( CSLFetchNameValue(poDS->papszGlobalMetadata, + "Southernmost Latitude") ); + poDS->ToGeoref( &dfULX, &dfULY ); + poDS->ToGeoref( &dfLRX, &dfLRY ); + poDS->adfGeoTransform[0] = dfULX; + poDS->adfGeoTransform[3] = dfULY; + poDS->adfGeoTransform[1] = (dfLRX - dfULX) / poDS->nRasterXSize; + poDS->adfGeoTransform[5] = (dfULY - dfLRY) / poDS->nRasterYSize; + if ( dfULY > 0) // Northern hemisphere + poDS->adfGeoTransform[5] = - poDS->adfGeoTransform[5]; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->bHasGeoTransform = TRUE; + } + break; + + +/* -------------------------------------------------------------------- */ +/* Generic SDS */ +/* -------------------------------------------------------------------- */ + case UNKNOWN: + { + + // This is a coastwatch convention. + if( CSLFetchNameValue( poDS->papszLocalMetadata, "missing_value" ) ) + { + int i; + for( i = 1; i <= poDS->nBands; i++ ) + { + poDS->GetRasterBand(i)->SetNoDataValue( + atof( CSLFetchNameValue(poDS->papszLocalMetadata, + "missing_value") ) ); + } + } + + // Coastwatch offset and scale. + if( CSLFetchNameValue( poDS->papszLocalMetadata, "scale_factor" ) + && CSLFetchNameValue( poDS->papszLocalMetadata, "add_offset" ) ) + { + for( i = 1; i <= poDS->nBands; i++ ) + { + HDF4ImageRasterBand *poBand = + (HDF4ImageRasterBand *) poDS->GetRasterBand(i); + + poBand->bHaveScaleAndOffset = TRUE; + poBand->dfScale = + atof( CSLFetchNameValue( poDS->papszLocalMetadata, + "scale_factor" ) ); + poBand->dfOffset = -1 * poBand->dfScale * + atof( CSLFetchNameValue( poDS->papszLocalMetadata, + "add_offset" ) ); + } + } + + // this is a modis level3 convention (data from ACT) + // Eg data/hdf/act/modis/MODAM2004280160000.L3_NOAA_GMX + + if( CSLFetchNameValue( poDS->papszLocalMetadata, + "scalingSlope" ) + && CSLFetchNameValue( poDS->papszLocalMetadata, + "scalingIntercept" ) ) + { + int i; + CPLString osUnits; + + if( CSLFetchNameValue( poDS->papszLocalMetadata, + "productUnits" ) ) + { + osUnits = CSLFetchNameValue( poDS->papszLocalMetadata, + "productUnits" ); + } + + for( i = 1; i <= poDS->nBands; i++ ) + { + HDF4ImageRasterBand *poBand = + (HDF4ImageRasterBand *) poDS->GetRasterBand(i); + + poBand->bHaveScaleAndOffset = TRUE; + poBand->dfScale = + atof( CSLFetchNameValue( poDS->papszLocalMetadata, + "scalingSlope" ) ); + poBand->dfOffset = + atof( CSLFetchNameValue( poDS->papszLocalMetadata, + "scalingIntercept" ) ); + + poBand->osUnitType = osUnits; + } + } + } + break; + +/* -------------------------------------------------------------------- */ +/* Hyperion Level 1. */ +/* -------------------------------------------------------------------- */ + case HYPERION_L1: + { + CPLDebug( "HDF4Image", "Input dataset interpreted as HYPERION_L1" ); + } + break; + + default: + break; + } + + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *HDF4ImageDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char **papszOptions ) + +{ +/* -------------------------------------------------------------------- */ +/* Create the dataset. */ +/* -------------------------------------------------------------------- */ + HDF4ImageDataset *poDS; + const char *pszSDSName; + int iBand; + int32 iSDS = -1; + int32 aiDimSizes[MAX_VAR_DIMS]; + + poDS = new HDF4ImageDataset(); + +/* -------------------------------------------------------------------- */ +/* Choose rank for the created dataset. */ +/* -------------------------------------------------------------------- */ + poDS->iRank = 3; + if ( CSLFetchNameValue( papszOptions, "RANK" ) != NULL && + EQUAL( CSLFetchNameValue( papszOptions, "RANK" ), "2" ) ) + poDS->iRank = 2; + + poDS->hSD = SDstart( pszFilename, DFACC_CREATE ); + if ( poDS->hSD == -1 ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Can't create HDF4 file %s", pszFilename ); + return NULL; + } + poDS->iXDim = 1; + poDS->iYDim = 0; + poDS->iBandDim = 2; + aiDimSizes[poDS->iXDim] = nXSize; + aiDimSizes[poDS->iYDim] = nYSize; + aiDimSizes[poDS->iBandDim] = nBands; + + if ( poDS->iRank == 2 ) + { + for ( iBand = 0; iBand < nBands; iBand++ ) + { + pszSDSName = CPLSPrintf( "Band%d", iBand ); + switch ( eType ) + { + case GDT_Float64: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_FLOAT64, + poDS->iRank, aiDimSizes ); + break; + case GDT_Float32: + iSDS = SDcreate( poDS-> hSD, pszSDSName, DFNT_FLOAT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_UInt32: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_UInt16: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT16, + poDS->iRank, aiDimSizes ); + break; + case GDT_Int32: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_INT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_Int16: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_INT16, + poDS->iRank, aiDimSizes ); + break; + case GDT_Byte: + default: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT8, + poDS->iRank, aiDimSizes ); + break; + } + SDendaccess( iSDS ); + } + } + else if ( poDS->iRank == 3 ) + { + pszSDSName = "3-dimensional Scientific Dataset"; + poDS->iDataset = 0; + switch ( eType ) + { + case GDT_Float64: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_FLOAT64, + poDS->iRank, aiDimSizes ); + break; + case GDT_Float32: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_FLOAT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_UInt32: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_UInt16: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT16, + poDS->iRank, aiDimSizes ); + break; + case GDT_Int32: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_INT32, + poDS->iRank, aiDimSizes ); + break; + case GDT_Int16: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_INT16, + poDS->iRank, aiDimSizes ); + break; + case GDT_Byte: + default: + iSDS = SDcreate( poDS->hSD, pszSDSName, DFNT_UINT8, + poDS->iRank, aiDimSizes ); + break; + } + } + else // Should never happen + return NULL; + + if ( iSDS < 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't create SDS with rank %d for file %s", + poDS->iRank, pszFilename ); + return NULL; + } + + poDS->nRasterXSize = nXSize; + poDS->nRasterYSize = nYSize; + poDS->eAccess = GA_Update; + poDS->iDatasetType = HDF4_SDS; + poDS->iSubdatasetType = GDAL_HDF4; + poDS->nBands = nBands; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( iBand = 1; iBand <= nBands; iBand++ ) + poDS->SetBand( iBand, new HDF4ImageRasterBand( poDS, iBand, eType ) ); + + SDsetattr( poDS->hSD, "Signature", DFNT_CHAR8, strlen(pszGDALSignature) + 1, + pszGDALSignature ); + + return (GDALDataset *) poDS; +} + +/************************************************************************/ +/* GDALRegister_HDF4Image() */ +/************************************************************************/ + +void GDALRegister_HDF4Image() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "HDF4Image" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "HDF4Image" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "HDF4 Dataset" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_hdf4.html" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Int32 UInt32 Float32 Float64" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='RANK' type='int' description='Rank of output SDS'/>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = HDF4ImageDataset::Open; + poDriver->pfnCreate = HDF4ImageDataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/hdf4/makefile.vc b/Utilities/GDAL/frmts/hdf4/makefile.vc new file mode 100644 index 0000000000..6971e36e46 --- /dev/null +++ b/Utilities/GDAL/frmts/hdf4/makefile.vc @@ -0,0 +1,18 @@ +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +OBJ = hdf4dataset.obj hdf4imagedataset.obj + +EXTRAFLAGS = -I$(HDF4_DIR)\include -Ihdf-eos -DFRMT_hdf4 + +default: $(OBJ) + copy *.obj ..\o + cd hdf-eos + $(MAKE) /f makefile.vc + +clean: + -del *.obj + cd hdf-eos + $(MAKE) /f makefile.vc clean + cd .. diff --git a/Utilities/GDAL/frmts/hfa/.cvsignore b/Utilities/GDAL/frmts/hfa/.cvsignore new file mode 100644 index 0000000000..ecc42cc717 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/.cvsignore @@ -0,0 +1,3 @@ +hfatest +img2tif +*.lo diff --git a/Utilities/GDAL/frmts/hfa/BUILD.TXT b/Utilities/GDAL/frmts/hfa/BUILD.TXT new file mode 100644 index 0000000000..329eefd870 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/BUILD.TXT @@ -0,0 +1,34 @@ + Building img2tif + ================ + + +Windows (NT/2000/98/etc) +------------------------ + +Ensure that VC++ is installed properly. The appropriate path and environment +variables will need to be setup if they aren't already. This can usualy +be done by running C:\Program Files\Visual Stdio\VC98\VCVARS32.BAT or +something similar in the command window. + +Then just run buildwin.bat to build img2tif.exe and hfatest.exe + + + +Unix +---- + +Edit port/cpl_config.h and modify to be appropriate to your platform. The +most common change is to define WORDS_BIGENDIAN on big endian platforms like +Sun and SGI. Other changes may be needed to get large file support working +or deal with other quirks. + +Run build.sh and it should build img2tif and hfatest executables. + + +To use the Imagine library yourself just link against the object files +created from the port and hfa directories. + + + + + diff --git a/Utilities/GDAL/frmts/hfa/GNUmakefile b/Utilities/GDAL/frmts/hfa/GNUmakefile new file mode 100644 index 0000000000..91bb21077a --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/GNUmakefile @@ -0,0 +1,72 @@ + + +include ../../GDALmake.opt + +HFAOBJ = hfaopen.o hfaentry.o hfadictionary.o hfafield.o hfatype.o \ + hfaband.o hfacompress.o +OBJ = $(HFAOBJ) hfadataset.o hfa_overviews.o + +ALL_C_FLAGS = $(GDAL_INCLUDE) $(CFLAGS) + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +IMG_DATA_DIR = /usr2/data/imagine + +default: $(OBJ) + +clean: + rm -f *.o hfatest img2tif $(O_OBJ) + +%.o: addtiffo_src/%.cpp + $(CXX) -c -I../../gcore -I../../port $(ALL_C_FLAGS) \ + addtiffo_src/$*.cpp -o $*.o + + +hfatest: hfatest.o $(HFAOBJ) + $(LD) hfatest.o $(HFAOBJ) ../../port/*.o $(LIBS) -o hfatest + +img2tif: img2tif.cpp imggeotiff.c geoextra.c \ + tif_overview.o rawblockedimage.o $(HFAOBJ) + $(LD) $(ALL_C_FLAGS) -I../gtiff/libtiff -I../gtiff/libgeotiff \ + img2tif.cpp imggeotiff.c geoextra.c \ + $(HFAOBJ) ../../port/*.o $(LIBS) \ + tif_overview.o rawblockedimage.o\ + ../gtiff/libgeotiff/*.o \ + ../gtiff/libtiff/*.o \ + -o img2tif + +# +# This test just dumps the Imagine data dictionary and node trees, +# and compares to an existing set. +test: hfatest + ./tst_hfa.sh $(IMG_DATA_DIR)/*.img \ + $(IMG_DATA_DIR)/Eprj/*.img \ + $(IMG_DATA_DIR)/fire/*.img \ + $(IMG_DATA_DIR)/usf/*.img \ + $(IMG_DATA_DIR)/colorado/*.img + +test_img2tif: img2tif + ./tst_img2tif_1.sh + + +install-obj: $(O_OBJ) + +img2tif-dist: + rm -rf img2tif_dist + mkdir img2tif_dist + cp img2tif_build.sh img2tif_dist/build.sh + cp buildwin.bat img2tif_dist + mkdir img2tif_dist/port + cp ../../port/cpl_{config.h.vc,vsil_win32.cpp} img2tif_dist/port + cp ../../port/cpl_{path.cpp,conv.cpp,conv.h,error.cpp,error.h,port.h,string.cpp,string.h,vsi.h,vsisimple.cpp,config.h,cpl_csv.cpp,cpl_findfile.cpp} img2tif_dist/port + mkdir img2tif_dist/libtiff + cp ../gtiff/libtiff/*.{c,h} img2tif_dist/libtiff + mkdir img2tif_dist/libgeotiff + cp ../gtiff/libgeotiff/*.{c,h,inc} img2tif_dist/libgeotiff + mkdir img2tif_dist/hfa + cp hfaopen.cpp hfaentry.cpp hfadictionary.cpp hfafield.cpp \ + hfatype.cpp hfaband.cpp \ + hfa.h hfa_p.h img2tif_dist/hfa + cp BUILD.TXT hfatest.cpp img2tif.cpp imggeotiff.c \ + addtiffo_src/tif_overview.cpp addtiffo_src/rawblocked* \ + img2tif_dist diff --git a/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.cpp b/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.cpp new file mode 100644 index 0000000000..f63cfebca2 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.cpp @@ -0,0 +1,406 @@ +/****************************************************************************** + * $Id: rawblockedimage.cpp,v 1.1 1999/11/29 21:33:22 warmerda Exp $ + * + * Project: GeoTIFF Overview Builder + * Purpose: Implement the RawBlockedImage class, for holding ``under + * construction'' overviews in a temporary file. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: rawblockedimage.cpp,v $ + * Revision 1.1 1999/11/29 21:33:22 warmerda + * New + * + * Revision 1.1 1999/08/17 01:47:59 warmerda + * New + * + * Revision 1.2 1999/03/12 17:29:34 warmerda + * Use _WIN32 rather than WIN32. + * + */ + +#include <assert.h> +#include <string.h> + +#include <stdlib.h> + +#ifndef _WIN32 +# include <unistd.h> +#endif + +#include "rawblockedimage.h" + +#ifndef FALSE +# define FALSE 0 +# define TRUE 1 +#endif + +#ifndef MAX +# define MIN(a,b) ((a<b) ? a : b) +# define MAX(a,b) ((a>b) ? a : b) +#endif + +/************************************************************************/ +/* RawBlockedImage() */ +/************************************************************************/ + +RawBlockedImage::RawBlockedImage( int nXSizeIn, int nYSizeIn, + int nBlockXSizeIn, int nBlockYSizeIn, + int nBitsPerPixelIn ) + +{ + static int nTempCounter = 0; + char szFilename[128]; + +/* -------------------------------------------------------------------- */ +/* Initialize stuff. */ +/* -------------------------------------------------------------------- */ + nXSize = nXSizeIn; + nYSize = nYSizeIn; + nBlockXSize = nBlockXSizeIn; + nBlockYSize = nBlockYSizeIn; + nBitsPerPixel = nBitsPerPixelIn; + +/* -------------------------------------------------------------------- */ +/* Create the raw temporary file, trying to verify first that */ +/* it doesn't already exist. */ +/* -------------------------------------------------------------------- */ + fp = NULL; + while( fp == NULL ) + { + sprintf( szFilename, "temp_%d.rbi", nTempCounter++ ); + fp = fopen( szFilename, "r" ); + if( fp != NULL ) + fclose( fp ); + else + fp = fopen( szFilename, "w+b" ); + } + + pszFilename = strdup( szFilename ); + nCurFileSize = 0; + +/* -------------------------------------------------------------------- */ +/* Initialize other stuff. */ +/* -------------------------------------------------------------------- */ + nBlocksPerRow = (nXSize + nBlockXSize - 1) / nBlockXSize; + nBlocksPerColumn = (nYSize + nBlockYSize - 1) / nBlockYSize; + nBytesPerBlock = (nBlockXSize*nBlockYSize*nBitsPerPixel + 7) / 8; + + nBlocks = nBlocksPerRow * nBlocksPerColumn; + nBlocksInCache = 0; + nMaxBlocksInCache = MIN(nBlocks, 2*nBlocksPerRow); + + papoBlocks = (RawBlock **) calloc(sizeof(RawBlock*),nBlocks); + + poLRUHead = NULL; + poLRUTail = NULL; +} + +/************************************************************************/ +/* ~RawBlockedImage() */ +/************************************************************************/ + +RawBlockedImage::~RawBlockedImage() + +{ + int i; + + for( i = 0; i < nBlocks; i++ ) + { + if( papoBlocks[i] != NULL ) + { + if( papoBlocks[i]->pabyData != NULL ) + free( papoBlocks[i]->pabyData ); + + delete papoBlocks[i]; + } + } + + if( papoBlocks != NULL) + free( papoBlocks ); + + fclose( fp ); + + unlink( pszFilename ); /* wrap this? */ + + free( pszFilename ); +} + +/************************************************************************/ +/* InsertInLRUList() */ +/* */ +/* Insert this link at the beginning of the LRU list. First */ +/* removed from it's current position if it is in the list. */ +/************************************************************************/ + +void RawBlockedImage::InsertInLRUList( RawBlock * poBlock ) + +{ +/* -------------------------------------------------------------------- */ +/* Remove from list, if it is currently in it. */ +/* -------------------------------------------------------------------- */ + if( poBlock->poPrevLRU != NULL || poLRUHead == poBlock ) + RemoveFromLRUList( poBlock ); + +/* -------------------------------------------------------------------- */ +/* Add at the head. */ +/* -------------------------------------------------------------------- */ + if( poLRUHead != NULL ) + { + poLRUHead->poPrevLRU = poBlock; + } + + poBlock->poNextLRU = poLRUHead; + poLRUHead = poBlock; + + if( poLRUTail == NULL ) + poLRUTail = poBlock; +} + +/************************************************************************/ +/* RemoveFromLRUList() */ +/* */ +/* Remove this block from the LRU list, if present. */ +/************************************************************************/ + +void RawBlockedImage::RemoveFromLRUList( RawBlock * poBlock ) + +{ +/* -------------------------------------------------------------------- */ +/* Is it even in the list? */ +/* -------------------------------------------------------------------- */ + if( poBlock->poPrevLRU == NULL && poLRUHead != poBlock ) + return; + +/* -------------------------------------------------------------------- */ +/* Fix the link before this in the list (or head pointer). */ +/* -------------------------------------------------------------------- */ + if( poBlock->poPrevLRU == NULL ) + { + poLRUHead = poBlock->poNextLRU; + } + else + { + poBlock->poPrevLRU->poNextLRU = poBlock->poNextLRU; + } + +/* -------------------------------------------------------------------- */ +/* Fix the link after this one, or the tail pointer. */ +/* -------------------------------------------------------------------- */ + if( poBlock->poNextLRU == NULL ) + { + poLRUTail = poBlock->poPrevLRU; + } + else + { + poBlock->poNextLRU->poPrevLRU = poBlock->poPrevLRU; + } + +/* -------------------------------------------------------------------- */ +/* Update this link to indicate it isn't in the list now. */ +/* -------------------------------------------------------------------- */ + poBlock->poPrevLRU = poBlock->poNextLRU = NULL; +} + + +/************************************************************************/ +/* FlushBlock() */ +/************************************************************************/ + +void RawBlockedImage::FlushBlock( RawBlock * poBlock ) + +{ +/* -------------------------------------------------------------------- */ +/* If we aren't given a particular block to flush, then select */ +/* the lest recently used one from the LRU list. */ +/* -------------------------------------------------------------------- */ + if( poBlock == NULL ) + { + if( poLRUTail == NULL ) + return; + + poBlock = poLRUTail; + } + +/* -------------------------------------------------------------------- */ +/* Remove from the LRU list. */ +/* -------------------------------------------------------------------- */ + RemoveFromLRUList( poBlock ); + +/* -------------------------------------------------------------------- */ +/* If the block has no data, then it doesn't really need to be */ +/* flushed. */ +/* -------------------------------------------------------------------- */ + if( poBlock->pabyData == NULL ) + return; + +/* -------------------------------------------------------------------- */ +/* Is this block dirty? If so we will have to try and save it. */ +/* -------------------------------------------------------------------- */ + if( poBlock->nDirty ) + { + if( poBlock->nPositionInFile == -1 ) + poBlock->nPositionInFile = nCurFileSize; + + nCurFileSize += nBytesPerBlock; + if( fseek( fp, poBlock->nPositionInFile, SEEK_SET ) != 0 ) + { + fprintf( stderr, + "Seek to %d in overview spill file %s failed.\n", + poBlock->nPositionInFile, pszFilename ); + exit( 1 ); + } + + if( fwrite( poBlock->pabyData, 1, nBytesPerBlock, fp ) + != (size_t) nBytesPerBlock ) + { + fprintf( stderr, + "Write of %d bytes at %d in overview spill file %s.\n" + "Is the disk full?\n", + nBytesPerBlock, poBlock->nPositionInFile, pszFilename ); + exit( 1 ); + } + + poBlock->nDirty = FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Free the data block, and decrement used count. */ +/* -------------------------------------------------------------------- */ + nBlocksInCache--; + if( poBlock->pabyData != NULL ) + free( poBlock->pabyData ); + poBlock->pabyData = NULL; +} + + +/************************************************************************/ +/* GetRawBlock() */ +/************************************************************************/ + +RawBlock *RawBlockedImage::GetRawBlock( int nXOff, int nYOff ) + +{ + int nBlock = nXOff + nYOff * nBlocksPerRow; + RawBlock *poBlock; + + assert( nBlock >= 0 && nBlock < nBlocks ); + +/* -------------------------------------------------------------------- */ +/* Is this the first request? If so, create the block object, */ +/* initialize the data memory, and return it. */ +/* -------------------------------------------------------------------- */ + poBlock = papoBlocks[nBlock]; + if( poBlock == NULL ) + { + poBlock = papoBlocks[nBlock] = new RawBlock; + poBlock->nDirty = FALSE; + poBlock->poPrevLRU = poBlock->poNextLRU = NULL; + poBlock->nPositionInFile = -1; + poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock); + nBlocksInCache++; + + if( poBlock->pabyData == NULL ) + { + fprintf( stderr, + "RawBlockedImage::GetRawBlock() - out of memory\n" ); + exit( 1 ); + } + } + +/* -------------------------------------------------------------------- */ +/* Does this block need to be read off disk? */ +/* -------------------------------------------------------------------- */ + else if( poBlock->nPositionInFile >= 0 && poBlock->pabyData == NULL ) + { + nBlocksInCache++; + poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock); + fseek( fp, poBlock->nPositionInFile, SEEK_SET ); + fread( poBlock->pabyData, nBytesPerBlock, 1, fp ); + } + +/* -------------------------------------------------------------------- */ +/* Does the data need to be allocated? */ +/* -------------------------------------------------------------------- */ + else if( poBlock->pabyData == NULL ) + { + poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock); + if( poBlock->pabyData == NULL ) + { + fprintf( stderr, + "RawBlockedImage::GetRawBlock() - out of memory\n" ); + exit( 1 ); + } + } + +/* -------------------------------------------------------------------- */ +/* Push on the LRU stack, or pop it back to the top. */ +/* -------------------------------------------------------------------- */ + InsertInLRUList( poBlock ); + +/* -------------------------------------------------------------------- */ +/* If we have exceeded our self imposed caching limit, flush */ +/* one block. */ +/* -------------------------------------------------------------------- */ + if( nBlocksInCache > nMaxBlocksInCache ) + FlushBlock( NULL ); + + return( poBlock ); +} + +/************************************************************************/ +/* GetTile() */ +/************************************************************************/ + +unsigned char *RawBlockedImage::GetTile( int nXOff, int nYOff ) + +{ + RawBlock *poBlock; + + poBlock = GetRawBlock(nXOff,nYOff); + if( poBlock != NULL ) + return poBlock->pabyData; + else + return NULL; +} + +/************************************************************************/ +/* GetTileForUpdate() */ +/************************************************************************/ + +unsigned char *RawBlockedImage::GetTileForUpdate( int nXOff, int nYOff ) + +{ + RawBlock *poBlock; + + poBlock = GetRawBlock(nXOff,nYOff); + if( poBlock != NULL ) + { + poBlock->nDirty = TRUE; + + return poBlock->pabyData; + } + else + return NULL; +} diff --git a/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.h b/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.h new file mode 100644 index 0000000000..b1fc346fa1 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/addtiffo_src/rawblockedimage.h @@ -0,0 +1,108 @@ +/****************************************************************************** + * $Id$ + * + * Project: GeoTIFF Overview Builder + * Purpose: Implement the RawBlockedImage class, for holding ``under + * construction'' overviews in a temporary file. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: + */ + +#ifndef RAWBLOCKEDIMAGE_H_INCLUDED +#define RAWBLOCKEDIMAGE_H_INCLUDED + +#include <stdio.h> + +/************************************************************************/ +/* ==================================================================== */ +/* RawBlockedImage */ +/* */ +/* The RawBlockedImage class is used to maintain a single band */ +/* raster tiled image on disk. */ +/* ==================================================================== */ +/************************************************************************/ + +class RawBlock +{ +public: + RawBlock *poNextLRU; + RawBlock *poPrevLRU; + + int nDirty; + int nPositionInFile; + + unsigned char *pabyData; +}; + +class RawBlockedImage +{ + int nXSize; + int nYSize; + + int nBlockXSize; + int nBlockYSize; + int nBitsPerPixel; + int nBytesPerBlock; + + int nBlocksPerRow; + int nBlocksPerColumn; + + int nBlocks; + RawBlock **papoBlocks; + + int nBlocksInCache; + int nMaxBlocksInCache; + + FILE *fp; + int nCurFileSize; + char *pszFilename; + + RawBlock *GetRawBlock( int, int ); + void FlushBlock( RawBlock * ); + void InsertInLRUList( RawBlock * ); + void RemoveFromLRUList( RawBlock * ); + + RawBlock *poLRUHead; + RawBlock *poLRUTail; + +public: + RawBlockedImage( int nXSize, int nYSize, + int nBlockXSize, int nBlockYSize, + int nBitsPerPixel ); + + ~RawBlockedImage(); + + unsigned char*GetTile( int, int ); + unsigned char*GetTileForUpdate( int, int ); + + int GetBlockXSize() { return nBlockXSize; } + int GetBlockYSize() { return nBlockYSize; } + int GetXSize() { return nXSize; } + int GetYSize() { return nYSize; } + int GetBitsPerPixel() { return nBitsPerPixel; } +}; + +#endif /* ndef RAWBLOCKEDIMAGE_H_INCLUDED */ diff --git a/Utilities/GDAL/frmts/hfa/addtiffo_src/tif_overview.cpp b/Utilities/GDAL/frmts/hfa/addtiffo_src/tif_overview.cpp new file mode 100644 index 0000000000..c909154f8f --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/addtiffo_src/tif_overview.cpp @@ -0,0 +1,562 @@ +/****************************************************************************** + * $Id: tif_overview.cpp,v 1.1 1999/11/29 21:33:22 warmerda Exp $ + * + * Project: TIFF Overview Builder + * Purpose: Library function for building overviews in a TIFF file. + * Author: Frank Warmerdam, warmerda@home.com + * + * Notes: + * o This module uses the RawBlockedImage class to hold the overviews as + * they are being built since we can't easily be reading from one directory + * in a TIFF file, and writing to a bunch of others. + * + * o RawBlockedImage will create temporary files in the current directory + * to cache the overviews so it doesn't have to hold them all in memory. + * If the application crashes these will not be deleted (*.rbi). + * + * o Currently only images with bits_per_sample of a multiple of eight + * will work. + * + * o The downsampler currently just takes the top left pixel from the + * source rectangle. Eventually sampling options of averaging, mode, and + * ``center pixel'' should be offered. + * + * o The code will attempt to use the same kind of compression, + * photometric interpretation, and organization as the source image, but + * it doesn't copy geotiff tags to the reduced resolution images. + * + * o Reduced resolution overviews for multi-sample files will currently + * always be generated as PLANARCONFIG_SEPARATE. This could be fixed + * reasonable easily if needed to improve compatibility with other + * packages. Many don't properly support PLANARCONFIG_SEPARATE. + * + ****************************************************************************** + * Copyright (c) 1999, 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: tif_overview.cpp,v $ + * Revision 1.1 1999/11/29 21:33:22 warmerda + * New + * + * Revision 1.1 1999/08/17 01:47:59 warmerda + * New + * + * Revision 1.7 1999/03/12 17:47:26 warmerda + * made independent of CPL + * + * Revision 1.6 1999/02/24 16:24:00 warmerda + * Don't include cpl_string.h + * + * Revision 1.5 1999/02/11 22:27:12 warmerda + * Added multi-sample support + * + * Revision 1.4 1999/02/11 19:23:39 warmerda + * Only fix on multiples of 16 in block size if it is a tiled file. + * + * Revision 1.3 1999/02/11 19:21:14 warmerda + * Limit tile sizes to multiples of 16 + * + * Revision 1.2 1999/02/11 18:37:43 warmerda + * Removed debugging malloc stuff. + * + * Revision 1.1 1999/02/11 18:12:30 warmerda + * New + * + */ + +#include <stdio.h> +#include <assert.h> +#include <stdlib.h> + +#include "tiffio.h" +#include "rawblockedimage.h" + +#ifndef FALSE +# define FALSE 0 +# define TRUE 1 +#endif + +#ifndef MAX +# define MIN(a,b) ((a<b) ? a : b) +# define MAX(a,b) ((a>b) ? a : b) +#endif + +extern "C" { + void TIFFBuildOverviews( const char *, int, int *, int ); +} + +/************************************************************************/ +/* TIFF_WriteOverview() */ +/************************************************************************/ + +static +void TIFF_WriteOverview( TIFF *hTIFF, int nSamples, RawBlockedImage **papoRBI, + int bTiled, int nCompressFlag, int nPhotometric, + unsigned short *panRed, + unsigned short *panGreen, + unsigned short *panBlue, + int bUseSubIFDs ) + +{ + int iSample; + RawBlockedImage *poRBI = papoRBI[0]; + +/* -------------------------------------------------------------------- */ +/* Setup TIFF fields. */ +/* -------------------------------------------------------------------- */ + TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, poRBI->GetXSize() ); + TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, poRBI->GetYSize() ); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, + PLANARCONFIG_SEPARATE ); + + TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, poRBI->GetBitsPerPixel() ); + TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples ); + TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompressFlag ); + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometric ); + + if( bTiled ) + { + TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, poRBI->GetBlockXSize() ); + TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, poRBI->GetBlockYSize() ); + } + else + TIFFSetField( hTIFF, TIFFTAG_ROWSPERSTRIP, poRBI->GetBlockYSize() ); + + TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE ); + +/* -------------------------------------------------------------------- */ +/* Write color table if one is present. */ +/* -------------------------------------------------------------------- */ + if( panRed != NULL ) + { + TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panRed, panGreen, panBlue ); + } + +/* -------------------------------------------------------------------- */ +/* Write blocks to TIFF file. */ +/* -------------------------------------------------------------------- */ + for( iSample = 0; iSample < nSamples; iSample++ ) + { + int iTileX, iTileY; + + poRBI = papoRBI[iSample]; + + for( iTileY = 0; + iTileY*poRBI->GetBlockYSize() < poRBI->GetYSize(); + iTileY++ ) + { + for( iTileX = 0; + iTileX*poRBI->GetBlockXSize() < poRBI->GetXSize(); + iTileX++ ) + { + unsigned char *pabyData = poRBI->GetTile( iTileX, iTileY ); + int nTileID; + + if( bTiled ) + { + nTileID = + TIFFComputeTile(hTIFF, + iTileX * poRBI->GetBlockXSize(), + iTileY * poRBI->GetBlockYSize(), + 0, iSample ); + TIFFWriteEncodedTile( hTIFF, nTileID, + pabyData, TIFFTileSize(hTIFF) ); + } + else + { + nTileID = + TIFFComputeStrip(hTIFF, iTileY*poRBI->GetBlockYSize(), + iSample); + + TIFFWriteEncodedStrip( hTIFF, nTileID, + pabyData, TIFFStripSize( hTIFF ) ); + } + } + } + } + + TIFFWriteDirectory( hTIFF ); +} + +/************************************************************************/ +/* TIFF_DownSample() */ +/* */ +/* Down sample a tile of full res data into a window of a tile */ +/* of downsampled data. */ +/************************************************************************/ + +static +void TIFF_DownSample( unsigned char *pabySrcTile, + int nBlockXSize, int nBlockYSize, + int nPixelSkewBits, int nBitsPerPixel, + unsigned char * pabyOTile, + int nOBlockXSize, int nOBlockYSize, + int nTXOff, int nTYOff, int nOMult ) + +{ + int i, j, k, nPixelBytes = (nBitsPerPixel) / 8; + int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8; + unsigned char *pabySrc, *pabyDst; + + assert( nBitsPerPixel >= 8 ); + +/* -------------------------------------------------------------------- */ +/* Handle case of one or more whole bytes per sample. */ +/* -------------------------------------------------------------------- */ + for( j = 0; j*nOMult < nBlockYSize; j++ ) + { + if( j + nTYOff >= nOBlockYSize ) + break; + + pabySrc = pabySrcTile + j*nOMult*nBlockXSize * nPixelGroupBytes; + pabyDst = pabyOTile + + ((j+nTYOff)*nOBlockXSize + nTXOff) * nPixelBytes; + + for( i = 0; i*nOMult < nBlockXSize; i++ ) + { + if( i + nTXOff >= nOBlockXSize ) + break; + + /* + * For now use simple subsampling, from the top left corner + * of the source block of pixels. + */ + + for( k = 0; k < nPixelBytes; k++ ) + { + *(pabyDst++) = pabySrc[k]; + } + + pabySrc += nOMult * nPixelGroupBytes; + } + } +} + +/************************************************************************/ +/* TIFF_ProcessFullResBlock() */ +/* */ +/* Process one block of full res data, downsampling into each */ +/* of the overviews. */ +/************************************************************************/ + +void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, + int nOverviews, int * panOvList, + int nBitsPerPixel, + int nSamples, RawBlockedImage ** papoRawBIs, + int nSXOff, int nSYOff, + unsigned char *pabySrcTile, + int nBlockXSize, int nBlockYSize ) + +{ + int iOverview, iSample; + + for( iSample = 0; iSample < nSamples; iSample++ ) + { + /* + * We have to read a tile/strip for each sample for + * PLANARCONFIG_SEPARATE. Otherwise, we just read all the samples + * at once when handling the first sample. + */ + if( nPlanarConfig == PLANARCONFIG_SEPARATE || iSample == 0 ) + { + if( TIFFIsTiled(hTIFF) ) + { + TIFFReadEncodedTile( hTIFF, + TIFFComputeTile(hTIFF, nSXOff, nSYOff, + 0, iSample ), + pabySrcTile, + TIFFTileSize(hTIFF)); + } + else + { + TIFFReadEncodedStrip( hTIFF, + TIFFComputeStrip(hTIFF, nSYOff, iSample), + pabySrcTile, + TIFFStripSize(hTIFF) ); + } + } + + /* + * Loop over destination overview layers + */ + for( iOverview = 0; iOverview < nOverviews; iOverview++ ) + { + RawBlockedImage *poRBI = papoRawBIs[iOverview*nSamples + iSample]; + unsigned char *pabyOTile; + int nTXOff, nTYOff, nOXOff, nOYOff, nOMult; + int nOBlockXSize = poRBI->GetBlockXSize(); + int nOBlockYSize = poRBI->GetBlockYSize(); + int nSkewBits, nSampleByteOffset; + + /* + * Fetch the destination overview tile + */ + nOMult = panOvList[iOverview]; + nOXOff = (nSXOff/nOMult) / nOBlockXSize; + nOYOff = (nSYOff/nOMult) / nOBlockYSize; + pabyOTile = poRBI->GetTileForUpdate( nOXOff, nOYOff ); + + /* + * Establish the offset into this tile at which we should + * start placing data. + */ + nTXOff = (nSXOff - nOXOff*nOMult*nOBlockXSize) / nOMult; + nTYOff = (nSYOff - nOYOff*nOMult*nOBlockYSize) / nOMult; + + /* + * Figure out the skew (extra space between ``our samples'') and + * the byte offset to the first sample. + */ + assert( (nBitsPerPixel % 8) == 0 ); + if( nPlanarConfig == PLANARCONFIG_SEPARATE ) + { + nSkewBits = 0; + nSampleByteOffset = 0; + } + else + { + nSkewBits = nBitsPerPixel * (nSamples-1); + nSampleByteOffset = (nBitsPerPixel/8) * iSample; + } + + /* + * Perform the downsampling. + */ +#ifdef DBMALLOC + malloc_chain_check( 1 ); +#endif + TIFF_DownSample( pabySrcTile + nSampleByteOffset, + nBlockXSize, nBlockYSize, + nSkewBits, nBitsPerPixel, pabyOTile, + poRBI->GetBlockXSize(), + poRBI->GetBlockYSize(), + nTXOff, nTYOff, + nOMult ); +#ifdef DBMALLOC + malloc_chain_check( 1 ); +#endif + } + } +} + +/************************************************************************/ +/* TIFF_BuildOverviews() */ +/* */ +/* Build the requested list of overviews. Overviews are */ +/* maintained in a bunch of temporary files and then these are */ +/* written back to the TIFF file. Only one pass through the */ +/* source TIFF file is made for any number of output */ +/* overviews. */ +/************************************************************************/ + +void TIFFBuildOverviews( const char * pszTIFFFilename, + int nOverviews, int * panOvList, + int bUseSubIFDs ) + +{ + RawBlockedImage **papoRawBIs; + uint32 nXSize, nYSize, nBlockXSize, nBlockYSize; + uint16 nBitsPerPixel, nPhotometric, nCompressFlag, nSamples, + nPlanarConfig; + int bTiled, nSXOff, nSYOff, i, iSample; + unsigned char *pabySrcTile; + TIFF *hTIFF; + uint16 *panRedMap, *panGreenMap, *panBlueMap; + +/* -------------------------------------------------------------------- */ +/* Get the base raster size. */ +/* -------------------------------------------------------------------- */ + hTIFF = TIFFOpen( pszTIFFFilename, "r" ); + if( hTIFF == NULL ) + { + fprintf( stderr, "TIFFOpen(%s) failed.\n", pszTIFFFilename ); + exit( 1 ); + } + + TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize ); + TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize ); + + TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &nBitsPerPixel ); + TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &nSamples ); + TIFFGetField( hTIFF, TIFFTAG_PLANARCONFIG, &nPlanarConfig ); + + TIFFGetField( hTIFF, TIFFTAG_PHOTOMETRIC, &nPhotometric ); + TIFFGetField( hTIFF, TIFFTAG_COMPRESSION, &nCompressFlag ); + + if( nBitsPerPixel < 8 ) + { + TIFFError( "TIFFBuildOverviews", + "File `%s' has samples of %d bits per sample. Sample\n" + "sizes of less than 8 bits per sample are not supported.\n", + pszTIFFFilename, nBitsPerPixel ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Get the base raster block size. */ +/* -------------------------------------------------------------------- */ + if( TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(nBlockYSize) ) ) + { + nBlockXSize = nXSize; + bTiled = FALSE; + } + else + { + TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &nBlockXSize ); + TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &nBlockYSize ); + bTiled = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Capture the pallette if there is one. */ +/* -------------------------------------------------------------------- */ + if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP, + &panRedMap, &panGreenMap, &panBlueMap ) ) + { + uint16 *panRed2, *panGreen2, *panBlue2; + + panRed2 = (uint16 *) calloc(2,256); + panGreen2 = (uint16 *) calloc(2,256); + panBlue2 = (uint16 *) calloc(2,256); + + memcpy( panRed2, panRedMap, 512 ); + memcpy( panGreen2, panGreenMap, 512 ); + memcpy( panBlue2, panBlueMap, 512 ); + + panRedMap = panRed2; + panGreenMap = panGreen2; + panBlueMap = panBlue2; + } + else + { + panRedMap = panGreenMap = panBlueMap = NULL; + } + +/* -------------------------------------------------------------------- */ +/* Initialize the overview raw layers */ +/* -------------------------------------------------------------------- */ + papoRawBIs = (RawBlockedImage **) + calloc(nOverviews*nSamples,sizeof(void*)); + + for( i = 0; i < nOverviews; i++ ) + { + int nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; + + nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i]; + nOYSize = (nYSize + panOvList[i] - 1) / panOvList[i]; + + nOBlockXSize = MIN((int)nBlockXSize,nOXSize); + nOBlockYSize = MIN((int)nBlockYSize,nOYSize); + + if( bTiled ) + { + if( (nOBlockXSize % 16) != 0 ) + nOBlockXSize = nOBlockXSize + 16 - (nOBlockXSize % 16); + + if( (nOBlockYSize % 16) != 0 ) + nOBlockYSize = nOBlockYSize + 16 - (nOBlockYSize % 16); + } + + for( iSample = 0; iSample < nSamples; iSample++ ) + { + papoRawBIs[i*nSamples + iSample] = + new RawBlockedImage( nOXSize, nOYSize, + nOBlockXSize, nOBlockYSize, + nBitsPerPixel ); + } + } + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer to hold a source block. */ +/* -------------------------------------------------------------------- */ + if( bTiled ) + pabySrcTile = (unsigned char *) malloc(TIFFTileSize(hTIFF)); + else + pabySrcTile = (unsigned char *) malloc(TIFFStripSize(hTIFF)); + +/* -------------------------------------------------------------------- */ +/* Loop over the source raster, applying data to the */ +/* destination raster. */ +/* -------------------------------------------------------------------- */ + for( nSYOff = 0; nSYOff < (int) nYSize; nSYOff += nBlockYSize ) + { + for( nSXOff = 0; nSXOff < (int) nXSize; nSXOff += nBlockXSize ) + { + /* + * Read and resample into the various overview images. + */ + + TIFF_ProcessFullResBlock( hTIFF, nPlanarConfig, + nOverviews, panOvList, + nBitsPerPixel, nSamples, papoRawBIs, + nSXOff, nSYOff, pabySrcTile, + nBlockXSize, nBlockYSize ); + } + } + + free( pabySrcTile ); + + TIFFClose( hTIFF ); + +/* ==================================================================== */ +/* We now have the overview rasters built, and held as */ +/* RawBlockedImage's. Now we need to write them to new TIFF */ +/* layers. */ +/* ==================================================================== */ + hTIFF = TIFFOpen( pszTIFFFilename, "a" ); + if( hTIFF == NULL ) + { + fprintf( stderr, + "TIFFOpen(%s,\"a\") failed. No overviews written.\n" + "Do you have write permissions on that file?\n", + pszTIFFFilename ); + } + else + { + for( i = 0; i < nOverviews; i++ ) + { + TIFF_WriteOverview( hTIFF, nSamples, papoRawBIs + i*nSamples, + bTiled, nCompressFlag, nPhotometric, + panRedMap, panGreenMap, panBlueMap, + bUseSubIFDs ); + } + + TIFFClose( hTIFF ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup the rawblockedimage files. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nOverviews*nSamples; i++ ) + { + delete papoRawBIs[i]; + } + + if( papoRawBIs != NULL ) + free( papoRawBIs ); + + if( panRedMap != NULL ) + { + free( panRedMap ); + free( panGreenMap ); + free( panBlueMap ); + } +} diff --git a/Utilities/GDAL/frmts/hfa/buildwin.bat b/Utilities/GDAL/frmts/hfa/buildwin.bat new file mode 100755 index 0000000000..474b7d23c4 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/buildwin.bat @@ -0,0 +1,68 @@ +if exist port\cpl_config.h.vc del port\cpl_config.h +if exist port\cpl_config.h.vc move port\cpl_config.h.vc port\cpl_config.h + +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport imggeotiff.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfaband.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfadictionary.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfaentry.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfafield.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfaopen.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfa/hfatype.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport rawblockedimage.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport tif_overview.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_conv.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_error.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_string.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_vsisimple.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_vsil_win32.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport port/cpl_path.cpp +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_extra.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_free.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_get.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_names.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_new.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_print.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_set.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_tiffp.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/geo_write.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libgeotiff/xtiff.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_aux.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_close.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_codec.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_compress.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_dir.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_dirinfo.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_dirread.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_dirwrite.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_dumpmode.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_error.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_fax3.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_fax3sm.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_flush.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_getimage.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_jpeg.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_luv.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_lzw.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_next.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_open.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_packbits.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_pixarlog.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_predict.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_print.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_read.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_strip.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_swab.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_thunder.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_tile.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_vsi.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_version.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_warning.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_write.c +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport libtiff/tif_zip.c + +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport img2tif.cpp +cl *.obj /Feimg2tif.exe + +del img2tif.obj +cl /c /Ihfa /Ilibtiff /Ilibgeotiff /Iport hfatest.cpp +cl *.obj /Fehfatest.exe diff --git a/Utilities/GDAL/frmts/hfa/frmt_hfa.html b/Utilities/GDAL/frmts/hfa/frmt_hfa.html new file mode 100644 index 0000000000..a6116829e6 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/frmt_hfa.html @@ -0,0 +1,65 @@ +<html> +<head> +<title>HFA -- Erdas Imagine .img</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>HFA -- Erdas Imagine .img</h1> + +GDAL supports Erdas Imagine .img format for read access and write. The +driver supports reading overviews, palettes, and georeferencing. It +supports the erdas band types +u8, s8, u16, s16, u32, s32, f32, f64, c64 and c128.<p> + +Compressed and missing tiles in Erdas files should be handled properly on read. +Files between 2GiB and 4GiB in size should work on Windows NT, and may work +on some Unix platforms. Files with external spill files (needed for datasets +larger than 2GiB) are also support for reading and writing.<p> + +Metadata reading and writing is supported at the dataset level, and for +bands, but this is GDAL specific metadata - not metadata in an Imagine +recognised form. The metadata is stored in a table called GDAL_MetaData with +each column being a metadata item. The title is the key and the row 1 value +is the value.<p> + +<h2>Creation Issues</h2> + +Erdas Imagine files can be created with any GDAL defined band type, including +the complex types. Created files may have any number of bands. Pseudo-Color +tables will be written if using the GDALDriver::CreateCopy() methodology. +Most projections should be supported though translation of unusual datums +(other than WGS84, WGS72, NAD83, and NAD27) may be problematic. <p> + +If overviews are generated, they will be in an external .ovr (GeoTIFF file) +recognised only by GDAL, not in the .rrd format produced by Imagine.<p> + +Creation Options:<p> + +<ul> + <li> <b>SPILL_FILE=YES</b>: Force the generation of a spill file + (by default spill file created for images larger 2GiB only).<p> + <li> <b>COMPRESS=YES</b>: Create file as compressed. Use of spill file disables compression.<p> +</ul> + +Erdas Imagine supports external creation of overviews (with gdaladdo for +instance). To force them to be created in an .rrd file (rather than inside +the original .img) set the global config option HFA_USE_RRD=YES).<p> + +Layer names can be set and retrieved with the GDALSetDescription/GDALGetDescription calls on the Raster Band objects. <p> + +See Also:<p> + +<ul> +<li> Implemented as <tt>gdal/frmts/hfa/hfadataset.cpp</tt>.<p> + +<li> More information, and other tools are available on the +<a href="http://home.gdal.org/projects/imagine/hfa_index.html"> +Imagine (.img) Reader</a> page.<p> + +<li> <a href="http://www.erdas.com/">Erdas.com</a><p> + +</ul> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/hfa/geoextra.c b/Utilities/GDAL/frmts/hfa/geoextra.c new file mode 100644 index 0000000000..325a3066f0 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/geoextra.c @@ -0,0 +1,575 @@ +/********************************************************************** + * + * geoextra.c -- Public routines for GEOTIFF GeoKey access. + * + * Written By: Frank Warmerdam + * + * copyright (c) 1995 Frank Warmerdam + * + * Permission granted to use this software, so long as this copyright + * notice accompanies any products derived therefrom. + * + * $Log: geoextra.c,v $ + * Revision 1.1 1999/01/22 17:40:43 warmerda + * New + * + * Revision 60.5 1996/10/31 15:43:43 warmerda + * Fixed computing of SPCS zone when reading. + * + * Revision 60.4 1996/10/15 03:14:49 warmerda + * Avoid pci.h for CCL. + * + * Revision 60.3 1996/01/31 14:20:09 lim + * MacOS: Fixed compiler errors. + * + * Revision 60.2 1995/12/01 16:31:42 wilson + * Correct assignment found in boolean expression + * + * Revision 60.1 1995/11/17 18:50:40 warmerda + * Initial revision. + * + * + **********************************************************************/ + +#include "geotiff.h" +#include "geo_tiffp.h" +#include "geo_keyp.h" +#include "geovalues.h" + +#define MapSys_UTM_North -9001 +#define MapSys_UTM_South -9002 +#define MapSys_State_Plane -9003 + +static int StatePlaneTable[] = +{ + PCS_NAD83_Alabama_East, Proj_Alabama_CS83_East, + PCS_NAD83_Alabama_West, Proj_Alabama_CS83_West, + + PCS_NAD83_Alaska_zone_1, Proj_Alaska_CS83_1, + PCS_NAD83_Alaska_zone_2, Proj_Alaska_CS83_2, + PCS_NAD83_Alaska_zone_3, Proj_Alaska_CS83_3, + PCS_NAD83_Alaska_zone_4, Proj_Alaska_CS83_4, + PCS_NAD83_Alaska_zone_5, Proj_Alaska_CS83_5, + PCS_NAD83_Alaska_zone_6, Proj_Alaska_CS83_6, + PCS_NAD83_Alaska_zone_7, Proj_Alaska_CS83_7, + PCS_NAD83_Alaska_zone_8, Proj_Alaska_CS83_8, + PCS_NAD83_Alaska_zone_9, Proj_Alaska_CS83_9, + PCS_NAD83_Alaska_zone_10, Proj_Alaska_CS83_10, + + PCS_NAD83_California_1, Proj_California_CS83_1, + PCS_NAD83_California_2, Proj_California_CS83_2, + PCS_NAD83_California_3, Proj_California_CS83_3, + PCS_NAD83_California_4, Proj_California_CS83_4, + PCS_NAD83_California_5, Proj_California_CS83_5, + PCS_NAD83_California_6, Proj_California_CS83_6, + + PCS_NAD83_Arizona_East, Proj_Arizona_CS83_east, + PCS_NAD83_Arizona_Central, Proj_Arizona_CS83_Central, + PCS_NAD83_Arizona_West, Proj_Arizona_CS83_west, + + PCS_NAD83_Arkansas_North, Proj_Arkansas_CS83_North, + PCS_NAD83_Arkansas_South, Proj_Arkansas_CS83_South, + + PCS_NAD83_Colorado_North, Proj_Colorado_CS83_North, + PCS_NAD83_Colorado_Central, Proj_Colorado_CS83_Central, + PCS_NAD83_Colorado_South, Proj_Colorado_CS83_South, + + PCS_NAD83_Connecticut, Proj_Connecticut_CS83, + + PCS_NAD83_Delaware, Proj_Delaware_CS83, + + PCS_NAD83_Florida_East, Proj_Florida_CS83_East, + PCS_NAD83_Florida_North, Proj_Florida_CS83_North, + PCS_NAD83_Florida_West, Proj_Florida_CS83_West, + + PCS_NAD83_Hawaii_zone_1, Proj_Hawaii_CS83_1, + PCS_NAD83_Hawaii_zone_2, Proj_Hawaii_CS83_2, + PCS_NAD83_Hawaii_zone_3, Proj_Hawaii_CS83_3, + PCS_NAD83_Hawaii_zone_4, Proj_Hawaii_CS83_4, + PCS_NAD83_Hawaii_zone_5, Proj_Hawaii_CS83_5, + + PCS_NAD83_Georgia_East, Proj_Georgia_CS83_East, + PCS_NAD83_Georgia_West, Proj_Georgia_CS83_West, + + PCS_NAD83_Idaho_East, Proj_Idaho_CS83_East, + PCS_NAD83_Idaho_Central, Proj_Idaho_CS83_Central, + PCS_NAD83_Idaho_West, Proj_Idaho_CS83_West, + + PCS_NAD83_Illinois_East, Proj_Illinois_CS83_East, + PCS_NAD83_Illinois_West, Proj_Illinois_CS83_West, + + PCS_NAD83_Indiana_East, Proj_Indiana_CS83_East, + PCS_NAD83_Indiana_West, Proj_Indiana_CS83_West, + + PCS_NAD83_Iowa_North, Proj_Iowa_CS83_North, + PCS_NAD83_Iowa_South, Proj_Iowa_CS83_South, + + PCS_NAD83_Kansas_North, Proj_Kansas_CS83_North, + PCS_NAD83_Kansas_South, Proj_Kansas_CS83_South, + + PCS_NAD83_Kentucky_North, Proj_Kentucky_CS83_North, + PCS_NAD83_Kentucky_South, Proj_Kentucky_CS83_South, + + PCS_NAD83_Louisiana_North, Proj_Louisiana_CS83_North, + PCS_NAD83_Louisiana_South, Proj_Louisiana_CS83_South, + + PCS_NAD83_Maine_East, Proj_Maine_CS83_East, + PCS_NAD83_Maine_West, Proj_Maine_CS83_West, + + PCS_NAD83_Maryland, Proj_Maryland_CS83, + + PCS_NAD83_Massachusetts, Proj_Massachusetts_CS83_Mainland, + PCS_NAD83_Massachusetts_Is, Proj_Massachusetts_CS83_Island, + + PCS_NAD83_Michigan_North, Proj_Michigan_CS83_North, + PCS_NAD83_Michigan_Central, Proj_Michigan_CS83_Central, + PCS_NAD83_Michigan_South, Proj_Michigan_CS83_South, + + PCS_NAD83_Minnesota_North, Proj_Minnesota_CS83_North, + PCS_NAD83_Minnesota_Cent, Proj_Minnesota_CS83_Central, + PCS_NAD83_Minnesota_South, Proj_Minnesota_CS83_South, + + PCS_NAD83_Mississippi_East, Proj_Mississippi_CS83_East, + PCS_NAD83_Mississippi_West, Proj_Mississippi_CS83_West, + + PCS_NAD83_Missouri_East, Proj_Missouri_CS83_East, + PCS_NAD83_Missouri_Central, Proj_Missouri_CS83_Central, + PCS_NAD83_Missouri_West, Proj_Missouri_CS83_West, + + PCS_NAD83_Montana, Proj_Montana_CS83, + + PCS_NAD83_Nebraska, Proj_Nebraska_CS83, + + PCS_NAD83_Nevada_East, Proj_Nevada_CS83_East, + PCS_NAD83_Nevada_Central, Proj_Nevada_CS83_Central, + PCS_NAD83_Nevada_West, Proj_Nevada_CS83_West, + + PCS_NAD83_New_Hampshire, Proj_New_Hampshire_CS83, + + PCS_NAD83_New_Jersey, Proj_New_Jersey_CS83, + + PCS_NAD83_New_Mexico_East, Proj_New_Mexico_CS83_East, + PCS_NAD83_New_Mexico_Cent, Proj_New_Mexico_CS83_Central, + PCS_NAD83_New_Mexico_West, Proj_New_Mexico_CS83_West, + + PCS_NAD83_New_York_East, Proj_New_York_CS83_East, + PCS_NAD83_New_York_Central, Proj_New_York_CS83_Central, + PCS_NAD83_New_York_West, Proj_New_York_CS83_West, + PCS_NAD83_New_York_Long_Is, Proj_New_York_CS83_Long_Island, + + PCS_NAD83_North_Carolina, Proj_North_Carolina_CS83, + + PCS_NAD83_North_Dakota_N, Proj_North_Dakota_CS83_North, + PCS_NAD83_North_Dakota_S, Proj_North_Dakota_CS83_South, + + PCS_NAD83_Ohio_North, Proj_Ohio_CS83_North, + PCS_NAD83_Ohio_South, Proj_Ohio_CS83_South, + + PCS_NAD83_Oklahoma_North, Proj_Oklahoma_CS83_North, + PCS_NAD83_Oklahoma_South, Proj_Oklahoma_CS83_South, + + PCS_NAD83_Oregon_North, Proj_Oregon_CS83_North, + PCS_NAD83_Oregon_South, Proj_Oregon_CS83_South, + + PCS_NAD83_Pennsylvania_N, Proj_Pennsylvania_CS83_North, + PCS_NAD83_Pennsylvania_S, Proj_Pennsylvania_CS83_South, + + PCS_NAD83_Rhode_Island, Proj_Rhode_Island_CS83, + + PCS_NAD83_South_Carolina, Proj_South_Carolina_CS83, + + PCS_NAD83_South_Dakota_N, Proj_South_Dakota_CS83_North, + PCS_NAD83_South_Dakota_S, Proj_South_Dakota_CS83_South, + + PCS_NAD83_Tennessee, Proj_Tennessee_CS83, + + PCS_NAD83_Texas_North, Proj_Texas_CS83_North, + PCS_NAD83_Texas_North_Cen, Proj_Texas_CS83_North_Central, + PCS_NAD83_Texas_Central, Proj_Texas_CS83_Central, + PCS_NAD83_Texas_South_Cen, Proj_Texas_CS83_South_Central, + PCS_NAD83_Texas_South, Proj_Texas_CS83_South, + + PCS_NAD83_Utah_North, Proj_Utah_CS83_North, + PCS_NAD83_Utah_Central, Proj_Utah_CS83_Central, + PCS_NAD83_Utah_South, Proj_Utah_CS83_South, + + PCS_NAD83_Vermont, Proj_Vermont_CS83, + + PCS_NAD83_Virginia_North, Proj_Virginia_CS83_North, + PCS_NAD83_Virginia_South, Proj_Virginia_CS83_South, + + PCS_NAD83_Washington_North, Proj_Washington_CS83_North, + PCS_NAD83_Washington_South, Proj_Washington_CS83_South, + + PCS_NAD83_West_Virginia_N, Proj_West_Virginia_CS83_North, + PCS_NAD83_West_Virginia_S, Proj_West_Virginia_CS83_South, + + PCS_NAD83_Wisconsin_North, Proj_Wisconsin_CS83_North, + PCS_NAD83_Wisconsin_Cen, Proj_Wisconsin_CS83_Central, + PCS_NAD83_Wisconsin_South, Proj_Wisconsin_CS83_South, + + PCS_NAD83_Wyoming_East, Proj_Wyoming_CS83_East, + PCS_NAD83_Wyoming_E_Cen, Proj_Wyoming_CS83_East_Central, + PCS_NAD83_Wyoming_W_Cen, Proj_Wyoming_CS83_West_Central, + PCS_NAD83_Wyoming_West, Proj_Wyoming_CS83_West, + + PCS_NAD83_Puerto_Rico_Virgin_Is, Proj_Puerto_Rico_Virgin_Is, + + PCS_NAD27_Alabama_East, Proj_Alabama_CS27_East, + PCS_NAD27_Alabama_West, Proj_Alabama_CS27_West, + + PCS_NAD27_Alaska_zone_1, Proj_Alaska_CS27_1, + PCS_NAD27_Alaska_zone_2, Proj_Alaska_CS27_2, + PCS_NAD27_Alaska_zone_3, Proj_Alaska_CS27_3, + PCS_NAD27_Alaska_zone_4, Proj_Alaska_CS27_4, + PCS_NAD27_Alaska_zone_5, Proj_Alaska_CS27_5, + PCS_NAD27_Alaska_zone_6, Proj_Alaska_CS27_6, + PCS_NAD27_Alaska_zone_7, Proj_Alaska_CS27_7, + PCS_NAD27_Alaska_zone_8, Proj_Alaska_CS27_8, + PCS_NAD27_Alaska_zone_9, Proj_Alaska_CS27_9, + PCS_NAD27_Alaska_zone_10, Proj_Alaska_CS27_10, + + PCS_NAD27_California_I, Proj_California_CS27_I, + PCS_NAD27_California_II, Proj_California_CS27_II, + PCS_NAD27_California_III, Proj_California_CS27_III, + PCS_NAD27_California_IV, Proj_California_CS27_IV, + PCS_NAD27_California_V, Proj_California_CS27_V, + PCS_NAD27_California_VI, Proj_California_CS27_VI, + PCS_NAD27_California_VII, Proj_California_CS27_VII, + + PCS_NAD27_Arizona_East, Proj_Arizona_Coordinate_System_east, + PCS_NAD27_Arizona_Central, Proj_Arizona_Coordinate_System_Central, + PCS_NAD27_Arizona_West, Proj_Arizona_Coordinate_System_west, + + PCS_NAD27_Arkansas_North, Proj_Arkansas_CS27_North, + PCS_NAD27_Arkansas_South, Proj_Arkansas_CS27_South, + + PCS_NAD27_Colorado_North, Proj_Colorado_CS27_North, + PCS_NAD27_Colorado_Central, Proj_Colorado_CS27_Central, + PCS_NAD27_Colorado_South, Proj_Colorado_CS27_South, + + PCS_NAD27_Connecticut, Proj_Connecticut_CS27, + + PCS_NAD27_Delaware, Proj_Delaware_CS27, + + PCS_NAD27_Florida_East, Proj_Florida_CS27_East, + PCS_NAD27_Florida_North, Proj_Florida_CS27_North, + PCS_NAD27_Florida_West, Proj_Florida_CS27_West, + + PCS_NAD27_Hawaii_zone_1, Proj_Hawaii_CS27_1, + PCS_NAD27_Hawaii_zone_2, Proj_Hawaii_CS27_2, + PCS_NAD27_Hawaii_zone_3, Proj_Hawaii_CS27_3, + PCS_NAD27_Hawaii_zone_4, Proj_Hawaii_CS27_4, + PCS_NAD27_Hawaii_zone_5, Proj_Hawaii_CS27_5, + + PCS_NAD27_Georgia_East, Proj_Georgia_CS27_East, + PCS_NAD27_Georgia_West, Proj_Georgia_CS27_West, + + PCS_NAD27_Idaho_East, Proj_Idaho_CS27_East, + PCS_NAD27_Idaho_Central, Proj_Idaho_CS27_Central, + PCS_NAD27_Idaho_West, Proj_Idaho_CS27_West, + + PCS_NAD27_Illinois_East, Proj_Illinois_CS27_East, + PCS_NAD27_Illinois_West, Proj_Illinois_CS27_West, + + PCS_NAD27_Indiana_East, Proj_Indiana_CS27_East, + PCS_NAD27_Indiana_West, Proj_Indiana_CS27_West, + + PCS_NAD27_Iowa_North, Proj_Iowa_CS27_North, + PCS_NAD27_Iowa_South, Proj_Iowa_CS27_South, + + PCS_NAD27_Kansas_North, Proj_Kansas_CS27_North, + PCS_NAD27_Kansas_South, Proj_Kansas_CS27_South, + + PCS_NAD27_Kentucky_North, Proj_Kentucky_CS27_North, + PCS_NAD27_Kentucky_South, Proj_Kentucky_CS27_South, + + PCS_NAD27_Louisiana_North, Proj_Louisiana_CS27_North, + PCS_NAD27_Louisiana_South, Proj_Louisiana_CS27_South, + + PCS_NAD27_Maine_East, Proj_Maine_CS27_East, + PCS_NAD27_Maine_West, Proj_Maine_CS27_West, + + PCS_NAD27_Maryland, Proj_Maryland_CS27, + + PCS_NAD27_Massachusetts, Proj_Massachusetts_CS27_Mainland, + PCS_NAD27_Massachusetts_Is, Proj_Massachusetts_CS27_Island, + + PCS_NAD27_Michigan_North, Proj_Michigan_CS27_North, + PCS_NAD27_Michigan_Central, Proj_Michigan_CS27_Central, + PCS_NAD27_Michigan_South, Proj_Michigan_CS27_South, + + PCS_NAD27_Minnesota_North, Proj_Minnesota_CS27_North, + PCS_NAD27_Minnesota_Cent, Proj_Minnesota_CS27_Central, + PCS_NAD27_Minnesota_South, Proj_Minnesota_CS27_South, + + PCS_NAD27_Mississippi_East, Proj_Mississippi_CS27_East, + PCS_NAD27_Mississippi_West, Proj_Mississippi_CS27_West, + + PCS_NAD27_Missouri_East, Proj_Missouri_CS27_East, + PCS_NAD27_Missouri_Central, Proj_Missouri_CS27_Central, + PCS_NAD27_Missouri_West, Proj_Missouri_CS27_West, + + PCS_NAD27_Montana_North, Proj_Montana_CS27_North, + PCS_NAD27_Montana_Central, Proj_Montana_CS27_Central, + PCS_NAD27_Montana_South, Proj_Montana_CS27_South, + + PCS_NAD27_Nebraska_North, Proj_Nebraska_CS27_North, + PCS_NAD27_Nebraska_South, Proj_Nebraska_CS27_South, + + PCS_NAD27_Nevada_East, Proj_Nevada_CS27_East, + PCS_NAD27_Nevada_Central, Proj_Nevada_CS27_Central, + PCS_NAD27_Nevada_West, Proj_Nevada_CS27_West, + + PCS_NAD27_New_Hampshire, Proj_New_Hampshire_CS27, + + PCS_NAD27_New_Jersey, Proj_New_Jersey_CS27, + + PCS_NAD27_New_Mexico_East, Proj_New_Mexico_CS27_East, + PCS_NAD27_New_Mexico_Cent, Proj_New_Mexico_CS27_Central, + PCS_NAD27_New_Mexico_West, Proj_New_Mexico_CS27_West, + + PCS_NAD27_New_York_East, Proj_New_York_CS27_East, + PCS_NAD27_New_York_Central, Proj_New_York_CS27_Central, + PCS_NAD27_New_York_West, Proj_New_York_CS27_West, + PCS_NAD27_New_York_Long_Is, Proj_New_York_CS27_Long_Island, + + PCS_NAD27_North_Carolina, Proj_North_Carolina_CS27, + + PCS_NAD27_North_Dakota_N, Proj_North_Dakota_CS27_North, + PCS_NAD27_North_Dakota_S, Proj_North_Dakota_CS27_South, + + PCS_NAD27_Ohio_North, Proj_Ohio_CS27_North, + PCS_NAD27_Ohio_South, Proj_Ohio_CS27_South, + + PCS_NAD27_Oklahoma_North, Proj_Oklahoma_CS27_North, + PCS_NAD27_Oklahoma_South, Proj_Oklahoma_CS27_South, + + PCS_NAD27_Oregon_North, Proj_Oregon_CS27_North, + PCS_NAD27_Oregon_South, Proj_Oregon_CS27_South, + + PCS_NAD27_Pennsylvania_N, Proj_Pennsylvania_CS27_North, + PCS_NAD27_Pennsylvania_S, Proj_Pennsylvania_CS27_South, + + PCS_NAD27_Rhode_Island, Proj_Rhode_Island_CS27, + + PCS_NAD27_South_Carolina_N, Proj_South_Carolina_CS27_North, + PCS_NAD27_South_Carolina_S, Proj_South_Carolina_CS27_South, + + PCS_NAD27_South_Dakota_N, Proj_South_Dakota_CS27_North, + PCS_NAD27_South_Dakota_S, Proj_South_Dakota_CS27_South, + + PCS_NAD27_Tennessee, Proj_Tennessee_CS27, + + PCS_NAD27_Texas_North, Proj_Texas_CS27_North, + PCS_NAD27_Texas_North_Cen, Proj_Texas_CS27_North_Central, + PCS_NAD27_Texas_Central, Proj_Texas_CS27_Central, + PCS_NAD27_Texas_South_Cen, Proj_Texas_CS27_South_Central, + PCS_NAD27_Texas_South, Proj_Texas_CS27_South, + + PCS_NAD27_Utah_North, Proj_Utah_CS27_North, + PCS_NAD27_Utah_Central, Proj_Utah_CS27_Central, + PCS_NAD27_Utah_South, Proj_Utah_CS27_South, + + PCS_NAD27_Vermont, Proj_Vermont_CS27, + + PCS_NAD27_Virginia_North, Proj_Virginia_CS27_North, + PCS_NAD27_Virginia_South, Proj_Virginia_CS27_South, + + PCS_NAD27_Washington_North, Proj_Washington_CS27_North, + PCS_NAD27_Washington_South, Proj_Washington_CS27_South, + + PCS_NAD27_West_Virginia_N, Proj_West_Virginia_CS27_North, + PCS_NAD27_West_Virginia_S, Proj_West_Virginia_CS27_South, + + PCS_NAD27_Wisconsin_North, Proj_Wisconsin_CS27_North, + PCS_NAD27_Wisconsin_Cen, Proj_Wisconsin_CS27_Central, + PCS_NAD27_Wisconsin_South, Proj_Wisconsin_CS27_South, + + PCS_NAD27_Wyoming_East, Proj_Wyoming_CS27_East, + PCS_NAD27_Wyoming_E_Cen, Proj_Wyoming_CS27_East_Central, + PCS_NAD27_Wyoming_W_Cen, Proj_Wyoming_CS27_West_Central, + PCS_NAD27_Wyoming_West, Proj_Wyoming_CS27_West, + + PCS_NAD27_Puerto_Rico, Proj_Puerto_Rico_CS27, + + KvUserDefined +}; + +/************************************************************************/ +/* GTIFMapSysToPCS() */ +/* */ +/* Given a Datum, MapSys and zone value generate the best PCS */ +/* code possible. */ +/************************************************************************/ + +int GTIFMapSysToPCS( int MapSys, int Datum, int nZone ) + +{ + int PCSCode = KvUserDefined; + + if( MapSys == MapSys_UTM_North ) + { + if( Datum == GCS_NAD27 ) + PCSCode = PCS_NAD27_UTM_zone_3N + nZone - 3; + else if( Datum == GCS_NAD83 ) + PCSCode = PCS_NAD83_UTM_zone_3N + nZone - 3; + else if( Datum == GCS_WGS_72 ) + PCSCode = PCS_WGS72_UTM_zone_1N + nZone - 1; + else if( Datum == GCS_WGS_72BE ) + PCSCode = PCS_WGS72BE_UTM_zone_1N + nZone - 1; + else if( Datum == GCS_WGS_84 ) + PCSCode = PCS_WGS84_UTM_zone_1N + nZone - 1; + } + else if( MapSys == MapSys_UTM_South ) + { + if( Datum == GCS_WGS_72 ) + PCSCode = PCS_WGS72_UTM_zone_1S + nZone - 1; + else if( Datum == GCS_WGS_72BE ) + PCSCode = PCS_WGS72BE_UTM_zone_1S + nZone - 1; + else if( Datum == GCS_WGS_84 ) + PCSCode = PCS_WGS84_UTM_zone_1S + nZone - 1; + } + else if( MapSys == MapSys_State_Plane ) + { + int i; + + if( Datum == GCS_NAD27 ) + PCSCode = 10000 + nZone; + else if( Datum == GCS_NAD83 ) + PCSCode = 10000 + nZone + 30; + + for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 ) + { + if( StatePlaneTable[i+1] == PCSCode ) + PCSCode = StatePlaneTable[i]; + } + } + + return( PCSCode ); +} + +/************************************************************************/ +/* GTIFPCSToMapSys() */ +/* */ +/* Trnanslate a PCS code into a Map system code (eg */ +/* MapSys_UTM_North, MapSys_UTM_South, MapSys_State_Plane), Datum */ +/* (GCS_*) and a zone. */ +/************************************************************************/ + +int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone ) + +{ + int Datum = KvUserDefined, Proj = KvUserDefined; + int nZone = KvUserDefined, i; + +/* -------------------------------------------------------------------- */ +/* UTM with various datums. Note there are lots of PCS UTM */ +/* codes not done yet which use strange datums. */ +/* -------------------------------------------------------------------- */ + if( PCSCode >= PCS_NAD27_UTM_zone_3N && PCSCode <= PCS_NAD27_UTM_zone_22N ) + { + Datum = GCS_NAD27; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_NAD27_UTM_zone_3N + 3; + } + else if( PCSCode >= PCS_NAD83_UTM_zone_3N + && PCSCode <= PCS_NAD83_UTM_zone_23N ) + { + Datum = GCS_NAD83; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_NAD83_UTM_zone_3N + 3; + } + + else if( PCSCode >= PCS_WGS72_UTM_zone_1N + && PCSCode <= PCS_WGS72_UTM_zone_60N ) + { + Datum = GCS_WGS_72; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_WGS72_UTM_zone_1N + 1; + } + else if( PCSCode >= PCS_WGS72_UTM_zone_1S + && PCSCode <= PCS_WGS72_UTM_zone_60S ) + { + Datum = GCS_WGS_72; + Proj = MapSys_UTM_South; + nZone = PCSCode - PCS_WGS72_UTM_zone_1S + 1; + } + + else if( PCSCode >= PCS_WGS72BE_UTM_zone_1N + && PCSCode <= PCS_WGS72BE_UTM_zone_60N ) + { + Datum = GCS_WGS_72BE; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_WGS72BE_UTM_zone_1N + 1; + } + else if( PCSCode >= PCS_WGS72BE_UTM_zone_1S + && PCSCode <= PCS_WGS72BE_UTM_zone_60S ) + { + Datum = GCS_WGS_72BE; + Proj = MapSys_UTM_South; + nZone = PCSCode - PCS_WGS72BE_UTM_zone_1S + 1; + } + + else if( PCSCode >= PCS_WGS84_UTM_zone_1N + && PCSCode <= PCS_WGS84_UTM_zone_60N ) + { + Datum = GCS_WGS_84; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_WGS84_UTM_zone_1N + 1; + } + else if( PCSCode >= PCS_WGS84_UTM_zone_1S + && PCSCode <= PCS_WGS84_UTM_zone_60S ) + { + Datum = GCS_WGS_84; + Proj = MapSys_UTM_South; + nZone = PCSCode - PCS_WGS84_UTM_zone_1S + 1; + } + else if( PCSCode >= PCS_SAD69_UTM_zone_18N + && PCSCode <= PCS_SAD69_UTM_zone_22N ) + { + Datum = KvUserDefined; + Proj = MapSys_UTM_North; + nZone = PCSCode - PCS_SAD69_UTM_zone_18N + 18; + } + else if( PCSCode >= PCS_SAD69_UTM_zone_17S + && PCSCode <= PCS_SAD69_UTM_zone_25S ) + { + Datum = KvUserDefined; + Proj = MapSys_UTM_South; + nZone = PCSCode - PCS_SAD69_UTM_zone_17S + 17; + } + +/* -------------------------------------------------------------------- */ +/* State Plane zones, first we translate any PCS_ codes to */ +/* a Proj_ code that we can get a handle on. */ +/* -------------------------------------------------------------------- */ + for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 ) + { + if( StatePlaneTable[i] == PCSCode ) + PCSCode = StatePlaneTable[i+1]; + } + + if( PCSCode <= 15900 && PCSCode >= 10000 ) + { + Proj = MapSys_State_Plane; + + if( (PCSCode % 100) >= 30 ) + Datum = GCS_NAD83; + else + Datum = GCS_NAD27; + + nZone = PCSCode - 10000; + if( Datum == GCS_NAD83 ) + nZone -= 30; + } + + if( pDatum != NULL ) + *pDatum = Datum; + + if( pZone != NULL ) + *pZone = nZone; + + return( Proj ); +} + diff --git a/Utilities/GDAL/frmts/hfa/hfa.h b/Utilities/GDAL/frmts/hfa/hfa.h new file mode 100644 index 0000000000..3d7f4abbec --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfa.h @@ -0,0 +1,332 @@ +/****************************************************************************** + * $Id$ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Public (C callable) interface for the Erdas Imagine reading + * code. This include files, and it's implementing code depends + * on CPL, but not GDAL. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfa.h,v $ + * Revision 1.19 2006/04/03 04:34:19 fwarmerdam + * added support for reading affine polynomial transforms as geotransform + * + * Revision 1.18 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.17 2005/12/21 05:30:45 fwarmerdam + * return compression type as metadata + * + * Revision 1.16 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.15 2005/05/13 04:57:28 fwarmerdam + * fix handling of large offsets in ige file for HFACreateLayer() + * + * Revision 1.14 2005/05/13 02:05:54 fwarmerdam + * adjusted CreateLayer + * + * Revision 1.13 2005/05/10 00:57:40 fwarmerdam + * added HFACreateLayer, HFACreateOverview + * + * Revision 1.12 2005/04/04 13:14:00 fwarmerdam + * Added HFAGetClassNames() (bug 819). + * + * Revision 1.11 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.10 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.9 2003/03/18 21:06:07 dron + * Added HFADelete() function. + * + * Revision 1.8 2002/05/21 15:09:12 warmerda + * read/write support for GDAL_MetaData table now supported + * + * Revision 1.7 2000/10/20 04:18:15 warmerda + * added overviews, stateplane, and u4 + * + * Revision 1.6 2000/10/13 21:14:08 warmerda + * added more projection codes + * + * Revision 1.5 2000/10/12 19:30:31 warmerda + * substantially improved write support + * + * Revision 1.4 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.3 1999/01/22 17:39:09 warmerda + * Added projections structures, and various other calls + * + * Revision 1.2 1999/01/04 22:52:47 warmerda + * field access working + * + * Revision 1.1 1999/01/04 05:28:13 warmerda + * New + * + */ + +#ifndef _HFAOPEN_H_INCLUDED +#define _HFAOPEN_H_INCLUDED + +/* -------------------------------------------------------------------- */ +/* Include standard portability stuff. */ +/* -------------------------------------------------------------------- */ +#include "cpl_conv.h" +#include "cpl_string.h" + +#ifdef HFA_PRIVATE +typedef HFAInfo_t *HFAHandle; +#else +typedef void *HFAHandle; +#endif + +/* -------------------------------------------------------------------- */ +/* Structure definitions from eprj.h, with some type */ +/* simplifications. */ +/* -------------------------------------------------------------------- */ +typedef struct { + double x; /* coordinate x-value */ + double y; /* coordinate y-value */ +} Eprj_Coordinate; + + +typedef struct { + double width; /* pixelsize width */ + double height; /* pixelsize height */ +} Eprj_Size; + + +typedef struct { + char * proName; /* projection name */ + Eprj_Coordinate upperLeftCenter; /* map coordinates of center of + upper left pixel */ + Eprj_Coordinate lowerRightCenter; /* map coordinates of center of + lower right pixel */ + Eprj_Size pixelSize; /* pixel size in map units */ + char * units; /* units of the map */ +} Eprj_MapInfo; + +typedef enum { + EPRJ_INTERNAL, /* Indicates that the projection is built into + the eprj package as function calls */ + EPRJ_EXTERNAL /* Indicates that the projection is accessible + as an EXTERNal executable */ +} Eprj_ProType; + +typedef enum { + EPRJ_NAD27=1, /* Use the North America Datum 1927 */ + EPRJ_NAD83=2, /* Use the North America Datum 1983 */ + EPRJ_HARN /* Use the North America Datum High Accuracy + Reference Network */ +} Eprj_NAD; + +typedef enum { + EPRJ_DATUM_PARAMETRIC, /* The datum info is 7 doubles */ + EPRJ_DATUM_GRID, /* The datum info is a name */ + EPRJ_DATUM_REGRESSION, + EPRJ_DATUM_NONE +} Eprj_DatumType; + +typedef struct { + char * datumname; /* name of the datum */ + Eprj_DatumType type; /* The datum type */ + double params[7]; /* The parameters for type + EPRJ_DATUM_PARAMETRIC */ + char * gridname; /* name of the grid file */ +} Eprj_Datum; + +typedef struct { + char * sphereName; /* name of the ellipsoid */ + double a; /* semi-major axis of ellipsoid */ + double b; /* semi-minor axis of ellipsoid */ + double eSquared; /* eccentricity-squared */ + double radius; /* radius of the sphere */ +} Eprj_Spheroid; + +typedef struct { + Eprj_ProType proType; /* projection type */ + long proNumber; /* projection number for internal + projections */ + char * proExeName; /* projection executable name for + EXTERNal projections */ + char * proName; /* projection name */ + long proZone; /* projection zone (UTM, SP only) */ + double proParams[15]; /* projection parameters array in the + GCTP form */ + Eprj_Spheroid proSpheroid; /* projection spheroid */ +} Eprj_ProParameters; + +/* -------------------------------------------------------------------- */ +/* Prototypes */ +/* -------------------------------------------------------------------- */ + +CPL_C_START + +HFAHandle CPL_DLL HFAOpen( const char * pszFilename, const char * pszMode ); +void CPL_DLL HFAClose( HFAHandle ); +CPLErr HFADelete( const char *pszFilename ); + +HFAHandle CPL_DLL HFACreateLL( const char *pszFilename ); +HFAHandle CPL_DLL HFACreate( const char *pszFilename, int nXSize, int nYSize, + int nBands, int nDataType, char ** papszOptions ); +CPLErr CPL_DLL HFAFlush( HFAHandle ); +int CPL_DLL HFACreateOverview( HFAHandle hHFA, int nBand, int nOverviewLevel); + +const Eprj_MapInfo CPL_DLL *HFAGetMapInfo( HFAHandle ); +int CPL_DLL HFAGetGeoTransform( HFAHandle, double* ); +CPLErr CPL_DLL HFASetMapInfo( HFAHandle, const Eprj_MapInfo * ); +const Eprj_Datum CPL_DLL *HFAGetDatum( HFAHandle ); +CPLErr CPL_DLL HFASetDatum( HFAHandle, const Eprj_Datum * ); +const Eprj_ProParameters CPL_DLL *HFAGetProParameters( HFAHandle ); +CPLErr CPL_DLL HFASetProParameters( HFAHandle, const Eprj_ProParameters * ); + +CPLErr CPL_DLL HFAGetRasterInfo( HFAHandle hHFA, int *pnXSize, int *pnYSize, + int *pnBands ); +CPLErr CPL_DLL HFAGetBandInfo( HFAHandle hHFA, int nBand, int * pnDataType, + int * pnBlockXSize, int * pnBlockYSize, + int * pnOverviews, int *pnCompressionType ); +int CPL_DLL HFAGetBandNoData( HFAHandle hHFA, int nBand, double *pdfValue ); +CPLErr CPL_DLL HFAGetOverviewInfo( HFAHandle hHFA, int nBand, int nOverview, + int * pnXSize, int * pnYSize, + int * pnBlockXSize, int * pnBlockYSize ); +CPLErr CPL_DLL HFAGetRasterBlock( HFAHandle hHFA, int nBand, int nXBlock, + int nYBlock, void * pData ); +CPLErr CPL_DLL HFAGetOverviewRasterBlock( HFAHandle hHFA, int nBand, + int iOverview, + int nXBlock, int nYBlock, void * pData ); +CPLErr CPL_DLL HFASetRasterBlock( HFAHandle hHFA, int nBand, + int nXBlock, int nYBlock, + void * pData ); +CPLErr CPL_DLL HFASetOverviewRasterBlock( + HFAHandle hHFA, int nBand, int iOverview,int nXBlock, int nYBlock, + void * pData ); +const char * HFAGetBandName( HFAHandle hHFA, int nBand ); +void HFASetBandName( HFAHandle hHFA, int nBand, const char *pszName ); +int CPL_DLL HFAGetDataTypeBits( int ); +const char CPL_DLL *HFAGetDataTypeName( int ); +CPLErr CPL_DLL HFAGetPCT( HFAHandle, int, int *, + double **, double **, double ** , double **); +CPLErr CPL_DLL HFASetPCT( HFAHandle, int, int, double *, double *, double *, double * ); +void CPL_DLL HFADumpTree( HFAHandle, FILE * ); +void CPL_DLL HFADumpDictionary( HFAHandle, FILE * ); +CPLErr CPL_DLL HFAGetDataRange( HFAHandle, int, double *, double * ); +char CPL_DLL **HFAGetMetadata( HFAHandle hHFA, int nBand ); +CPLErr CPL_DLL HFASetMetadata( HFAHandle hHFA, int nBand, char ** ); +char CPL_DLL **HFAGetClassNames( HFAHandle hHFA, int nBand ); +int CPL_DLL +HFACreateLayer( HFAHandle psInfo, HFAEntry *poParent, + const char *pszLayerName, + int bOverview, int nBlockSize, + int bCreateCompressed, int bCreateLargeRaster, + int nXSize, int nYSize, int nDataType, + char **papszOptions, + + // these are only related to external (large) files + GIntBig nStackValidFlagsOffset, + GIntBig nStackDataOffset, + int nStackCount, int nStackIndex ); + +/* -------------------------------------------------------------------- */ +/* data types. */ +/* -------------------------------------------------------------------- */ +#define EPT_u1 0 +#define EPT_u2 1 +#define EPT_u4 2 +#define EPT_u8 3 +#define EPT_s8 4 +#define EPT_u16 5 +#define EPT_s16 6 +#define EPT_u32 7 +#define EPT_s32 8 +#define EPT_f32 9 +#define EPT_f64 10 +#define EPT_c64 11 +#define EPT_c128 12 + +/* -------------------------------------------------------------------- */ +/* Projection codes. */ +/* -------------------------------------------------------------------- */ +#define EPRJ_LATLONG 0 +#define EPRJ_UTM 1 +#define EPRJ_STATE_PLANE 2 +#define EPRJ_ALBERS_CONIC_EQUAL_AREA 3 +#define EPRJ_LAMBERT_CONFORMAL_CONIC 4 +#define EPRJ_MERCATOR 5 +#define EPRJ_POLAR_STEREOGRAPHIC 6 +#define EPRJ_POLYCONIC 7 +#define EPRJ_EQUIDISTANT_CONIC 8 +#define EPRJ_TRANSVERSE_MERCATOR 9 +#define EPRJ_STEREOGRAPHIC 10 +#define EPRJ_LAMBERT_AZIMUTHAL_EQUAL_AREA 11 +#define EPRJ_AZIMUTHAL_EQUIDISTANT 12 +#define EPRJ_GNOMONIC 13 +#define EPRJ_ORTHOGRAPHIC 14 +#define EPRJ_GENERAL_VERTICAL_NEAR_SIDE_PERSPECTIVE 15 +#define EPRJ_SINUSOIDAL 16 +#define EPRJ_EQUIRECTANGULAR 17 +#define EPRJ_MILLER_CYLINDRICAL 18 +#define EPRJ_VANDERGRINTEN 19 +#define EPRJ_HOTINE_OBLIQUE_MERCATOR 20 +#define EPRJ_SPACE_OBLIQUE_MERCATOR 21 +#define EPRJ_MODIFIED_TRANSVERSE_MERCATOR 22 +#define EPRJ_EOSAT_SOM 23 +#define EPRJ_ROBINSON 24 +#define EPRJ_SOM_A_AND_B 25 +#define EPRJ_ALASKA_CONFORMAL 26 +#define EPRJ_INTERRUPTED_GOODE_HOMOLOSINE 27 +#define EPRJ_MOLLWEIDE 28 +#define EPRJ_INTERRUPTED_MOLLWEIDE 29 +#define EPRJ_HAMMER 30 +#define EPRJ_WAGNER_IV 31 +#define EPRJ_WAGNER_VII 32 +#define EPRJ_OBLATED_EQUAL_AREA 33 +#define EPRJ_PLATE_CARREE 34 +#define EPRJ_EQUIDISTANT_CYLINDRICAL 35 +#define EPRJ_GAUSS_KRUGER 36 +#define EPRJ_ECKERT_VI 37 +#define EPRJ_ECKERT_V 38 +#define EPRJ_ECKERT_IV 39 +#define EPRJ_ECKERT_III 40 +#define EPRJ_ECKERT_II 41 +#define EPRJ_ECKERT_I 42 +#define EPRJ_GALL_STEREOGRAPHIC 43 +#define EPRJ_BEHRMANN 44 +#define EPRJ_WINKEL_I 45 +#define EPRJ_WINKEL_II 46 +#define EPRJ_QUARTIC_AUTHALIC 47 +#define EPRJ_LOXIMUTHAL 48 +#define EPRJ_BONNE 49 +#define EPRJ_STEREOGRAPHIC_EXTENDED 50 +#define EPRJ_CASSINI 51 +#define EPRJ_TWO_POINT_EQUIDISTANT 52 + +#define EPRJ_EXTERNAL_RSO "eprj_rso" +#define EPRJ_EXTERNAL_NZMG "nzmg" + +CPL_C_END + +#endif /* ndef _HFAOPEN_H_INCLUDED */ diff --git a/Utilities/GDAL/frmts/hfa/hfa_overviews.cpp b/Utilities/GDAL/frmts/hfa/hfa_overviews.cpp new file mode 100644 index 0000000000..27655623ee --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfa_overviews.cpp @@ -0,0 +1,127 @@ +/****************************************************************************** + * $Id: hfa_overviews.cpp,v 1.1 2005/09/17 03:47:41 fwarmerdam Exp $ + * + * Project: Erdas Imagine Driver + * Purpose: Entry point for building overviews, used by non-imagine formats. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, 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: hfa_overviews.cpp,v $ + * Revision 1.1 2005/09/17 03:47:41 fwarmerdam + * New + * + */ + +#include "gdal_pam.h" +#include "hfa_p.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: hfa_overviews.cpp,v 1.1 2005/09/17 03:47:41 fwarmerdam Exp $"); + +CPLErr HFAAuxBuildOverviews( const char *pszOvrFilename, + GDALDataset *poParentDS, + GDALDataset **ppoODS, + int nBands, int *panBandList, + int nNewOverviews, int *panNewOverviewList, + const char *pszResampling, + GDALProgressFunc pfnProgress, + void *pProgressData ) + +{ +/* ==================================================================== */ +/* If the .aux file doesn't exist yet then create it now. */ +/* ==================================================================== */ + if( *ppoODS == NULL ) + { + GDALDataType eDT = GDT_Unknown; +/* -------------------------------------------------------------------- */ +/* Determine the band datatype, and verify that all bands are */ +/* the same. */ +/* -------------------------------------------------------------------- */ + int iBand; + + for( iBand = 0; iBand < nBands; iBand++ ) + { + GDALRasterBand *poBand = + poParentDS->GetRasterBand( panBandList[iBand] ); + + if( iBand == 0 ) + eDT = poBand->GetRasterDataType(); + else + { + if( eDT != poBand->GetRasterDataType() ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "HFAAuxBuildOverviews() doesn't support a mixture of band" + " data types." ); + return CE_Failure; + } + } + } + +/* -------------------------------------------------------------------- */ +/* Create the HFA (.aux) file. We create it with */ +/* COMPRESSED=YES so that no space will be allocated for the */ +/* base band. */ +/* -------------------------------------------------------------------- */ + GDALDriver *poHFADriver = (GDALDriver *) GDALGetDriverByName("HFA"); + char *apszOptions[3] = { "COMPRESSED=YES", + NULL, + NULL }; + + CPLString osDepFileOpt = "DEPENDENT_FILE="; + osDepFileOpt += CPLGetFilename(poParentDS->GetDescription()); + apszOptions[1] = (char *) osDepFileOpt.c_str(); + + *ppoODS = + poHFADriver->Create( pszOvrFilename, + poParentDS->GetRasterXSize(), + poParentDS->GetRasterYSize(), + nBands, eDT, apszOptions ); + + if( *ppoODS == NULL ) + return CE_Failure; + } + +/* ==================================================================== */ +/* Create the layers. We depend on the normal buildoverviews */ +/* support for HFA to do this. But we disable the internal */ +/* computation of the imagery for these layers. */ +/* */ +/* We avoid regenerating the new layers here, because if we did */ +/* it would use the base layer from the .aux file as the source */ +/* data, and that is fake (all invalid tiles). */ +/* ==================================================================== */ + CPLString oAdjustedResampling = "NO_REGEN:"; + oAdjustedResampling += pszResampling; + + CPLErr eErr = + (*ppoODS)->BuildOverviews( oAdjustedResampling, + nNewOverviews, panNewOverviewList, + nBands, panBandList, + pfnProgress, pProgressData ); + + return eErr; +} + diff --git a/Utilities/GDAL/frmts/hfa/hfa_p.h b/Utilities/GDAL/frmts/hfa/hfa_p.h new file mode 100644 index 0000000000..5ddbfb7ca9 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfa_p.h @@ -0,0 +1,505 @@ +/****************************************************************************** + * $Id$ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Private class declarations for the HFA classes used to read + * Erdas Imagine (.img) files. Public (C callable) declarations + * are in hfa.h. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfa_p.h,v $ + * Revision 1.24 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.23 2005/09/15 20:36:42 fwarmerdam + * added HFACreateDependent + * + * Revision 1.22 2005/08/20 23:46:28 fwarmerdam + * bug 858: fix for double compression + * + * Revision 1.21 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.20 2005/05/13 02:05:25 fwarmerdam + * added HFACreateSpillStack + * + * Revision 1.19 2005/05/10 00:56:38 fwarmerdam + * added CreateOverview and GetInstCount methods + * + * Revision 1.18 2005/02/22 21:33:21 fwarmerdam + * added GetBigIntField method + * + * Revision 1.17 2005/01/10 17:41:27 fwarmerdam + * added HFA compression support: bug 664 + * + * Revision 1.16 2004/07/16 20:40:32 warmerda + * Added a series of patches from Andreas Wimmer which: + * o Add lots of improved support for metadata. + * o Use USE_SPILL only, instead of SPILL_FILE extra creation option. + * o Added ability to control block sizes. + * + * Revision 1.15 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.14 2003/04/29 08:53:45 dron + * In Get/SetRasterBlock calculate block offset in place when we have spill file. + * + * Revision 1.13 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.12 2003/02/25 18:03:20 warmerda + * added AddType() method to HFADictionary + * + * Revision 1.11 2003/02/21 15:40:58 dron + * Added support for writing large (>4 GB) Erdas Imagine files. + * + * Revision 1.10 2001/06/10 20:31:35 warmerda + * use vsi_l_offset for block offsets + * + * Revision 1.9 2000/12/29 16:37:32 warmerda + * Use GUInt32 for all file offsets + * + * Revision 1.8 2000/10/31 18:02:32 warmerda + * Added external and unnamed overview support + * + * Revision 1.7 2000/10/20 04:18:15 warmerda + * added overviews, stateplane, and u4 + * + * Revision 1.6 2000/10/12 19:30:32 warmerda + * substantially improved write support + * + * Revision 1.5 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.4 1999/01/28 16:24:09 warmerda + * Handle HFAStandardWord(). + * + * Revision 1.3 1999/01/22 17:39:26 warmerda + * Added HFABand, and other stuff + * + * Revision 1.2 1999/01/04 22:52:47 warmerda + * field access working + * + * Revision 1.1 1999/01/04 05:28:13 warmerda + * New + * + */ + +#ifndef _HFA_P_H_INCLUDED +#define _HFA_P_H_INCLUDED + +#include "cpl_port.h" +#include "cpl_error.h" +#include "cpl_vsi.h" + +#ifdef CPL_LSB +# define HFAStandard(n,p) {} +#else + void HFAStandard( int, void *); +#endif + +class HFAEntry; +class HFAType; +class HFADictionary; +class HFABand; +class HFASpillFile; + +/************************************************************************/ +/* Flag indicating read/write, or read-only access to data. */ +/************************************************************************/ +typedef enum { + /*! Read only (no update) access */ HFA_ReadOnly = 0, + /*! Read/write access. */ HFA_Update = 1 +} HFAAccess; + +/************************************************************************/ +/* HFAInfo_t */ +/* */ +/* This is just a structure, and used hold info about the whole */ +/* dataset within hfaopen.cpp */ +/************************************************************************/ +typedef struct hfainfo { + FILE *fp; + + char *pszPath; + char *pszFilename; /* sans path */ + char *pszIGEFilename; /* sans path */ + + HFAAccess eAccess; + + GUInt32 nEndOfFile; + GUInt32 nRootPos; + GUInt32 nDictionaryPos; + + GInt16 nEntryHeaderLength; + GInt32 nVersion; + + int bTreeDirty; + HFAEntry *poRoot; + + HFADictionary *poDictionary; + char *pszDictionary; + + int nXSize; + int nYSize; + + int nBands; + HFABand **papoBand; + + void *pMapInfo; + void *pDatum; + void *pProParameters; + + struct hfainfo *psDependent; +} HFAInfo_t; + +GUInt32 HFAAllocateSpace( HFAInfo_t *, GUInt32 ); +CPLErr HFAParseBandInfo( HFAInfo_t * ); +HFAInfo_t *HFAGetDependent( HFAInfo_t *, const char * ); +HFAInfo_t *HFACreateDependent( HFAInfo_t *psBase ); +int HFACreateSpillStack( HFAInfo_t *, int nXSize, int nYSize, int nLayers, + int nBlockSize, int nDataType, + GIntBig *pnValidFlagsOffset, + GIntBig *pnDataOffset ); + +char ** GetHFAAuxMetaDataList(); + +#define HFA_PRIVATE + +#include "hfa.h" + +/************************************************************************/ +/* HFABand */ +/************************************************************************/ + +class HFABand +{ + int nBlocks; + + // Used for single-file modification + vsi_l_offset *panBlockStart; + int *panBlockSize; + int *panBlockFlag; + + // Used for spill-file modification + vsi_l_offset nBlockStart; + vsi_l_offset nBlockSize; + int nLayerStackCount; + int nLayerStackIndex; + +#define BFLG_VALID 0x01 +#define BFLG_COMPRESSED 0x02 + + int nPCTColors; + double *apadfPCT[4]; + + CPLErr LoadBlockInfo(); + CPLErr LoadExternalBlockInfo(); + + void ReAllocBlock( int iBlock, int nSize ); + + public: + HFABand( HFAInfo_t *, HFAEntry * ); + ~HFABand(); + + HFAInfo_t *psInfo; + + FILE *fpExternal; + + int nDataType; + HFAEntry *poNode; + + int nBlockXSize; + int nBlockYSize; + + int nWidth; + int nHeight; + + int nBlocksPerRow; + int nBlocksPerColumn; + + int bNoDataSet; + double dfNoData; + + int nOverviews; + HFABand **papoOverviews; + + CPLErr GetRasterBlock( int nXBlock, int nYBlock, void * pData ); + CPLErr SetRasterBlock( int nXBlock, int nYBlock, void * pData ); + + const char * GetBandName(); + void SetBandName(const char *pszName); + + CPLErr GetPCT( int *, double **, double **, double **, double ** ); + CPLErr SetPCT( int, double *, double *, double *, double * ); + + int CreateOverview( int nOverviewLevel ); +}; + + +/************************************************************************/ +/* HFAEntry */ +/* */ +/* Base class for all entry types. Most entry types do not */ +/* have a subclass, and are just handled generically with this */ +/* class. */ +/************************************************************************/ +class HFAEntry +{ + int bDirty; + GUInt32 nFilePos; + + HFAInfo_t *psHFA; + HFAEntry *poParent; + HFAEntry *poPrev; + + GUInt32 nNextPos; + HFAEntry *poNext; + + GUInt32 nChildPos; + HFAEntry *poChild; + + char szName[64]; + char szType[32]; + + HFAType *poType; + + GUInt32 nDataPos; + GUInt32 nDataSize; + GByte *pabyData; + + void LoadData(); + + void *GetFieldValue( const char *, char ); + CPLErr SetFieldValue( const char *, char, void * ); + +public: + HFAEntry( HFAInfo_t * psHFA, GUInt32 nPos, + HFAEntry * poParent, HFAEntry *poPrev); + + HFAEntry( HFAInfo_t *psHFA, + const char *pszNodeName, + const char *pszTypeName, + HFAEntry *poParent ); + + virtual ~HFAEntry(); + + GUInt32 GetFilePos() { return nFilePos; } + + const char *GetName() { return szName; } + void SetName( const char *pszNodeName ); + + const char *GetType() { return szType; } + + GUInt32 GetDataPos() { return nDataPos; } + GUInt32 GetDataSize() { return nDataSize; } + + HFAEntry *GetChild(); + HFAEntry *GetNext(); + HFAEntry *GetNamedChild( const char * ); + + GInt32 GetIntField( const char *, CPLErr * = NULL ); + double GetDoubleField( const char *, CPLErr * = NULL ); + const char *GetStringField( const char *, CPLErr * = NULL ); + GIntBig GetBigIntField( const char *, CPLErr * = NULL ); + int GetFieldCount( const char *, CPLErr * = NULL ); + + CPLErr SetIntField( const char *, int ); + CPLErr SetDoubleField( const char *, double ); + CPLErr SetStringField( const char *, const char * ); + + void DumpFieldValues( FILE *, const char * = NULL ); + + void SetPosition(); + CPLErr FlushToDisk(); + + void MarkDirty(); + GByte *MakeData( int nSize = 0 ); +}; + +/************************************************************************/ +/* HFAField */ +/* */ +/* A field in a HFAType in the dictionary. */ +/************************************************************************/ + +class HFAField +{ + public: + int nBytes; + + int nItemCount; + char chPointer; /* '\0', '*' or 'p' */ + char chItemType; /* 1|2|4|e|... */ + + char *pszItemObjectType; /* if chItemType == 'o' */ + HFAType *poItemObjectType; + + char **papszEnumNames; /* normally NULL if not an enum */ + + char *pszFieldName; + + HFAField(); + ~HFAField(); + + const char *Initialize( const char * ); + + void CompleteDefn( HFADictionary * ); + + void Dump( FILE * ); + + void *ExtractInstValue( const char * pszField, int nIndexValue, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType ); + + CPLErr SetInstValue( const char * pszField, int nIndexValue, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType, void *pValue ); + + void DumpInstValue( FILE *fpOut, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + const char *pszPrefix = NULL ); + + int GetInstBytes( GByte * pabyData ); + int GetInstCount( GByte * pabyData ); +}; + + +/************************************************************************/ +/* HFAType */ +/* */ +/* A type in the dictionary. */ +/************************************************************************/ + +class HFAType +{ + public: + int nBytes; + + int nFields; + HFAField **papoFields; + + char *pszTypeName; + + HFAType(); + ~HFAType(); + + const char *Initialize( const char * ); + + void CompleteDefn( HFADictionary * ); + + void Dump( FILE * ); + + int GetInstBytes( GByte * pabyData ); + int GetInstCount( const char *pszField, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize); + void *ExtractInstValue( const char * pszField, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType ); + CPLErr SetInstValue( const char * pszField, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType, void * pValue ); + void DumpInstValue( FILE *fpOut, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + const char *pszPrefix = NULL ); +}; + +/************************************************************************/ +/* HFADictionary */ +/************************************************************************/ + +class HFADictionary +{ + public: + int nTypes; + int nTypesMax; + HFAType **papoTypes; + + HFADictionary( const char * ); + ~HFADictionary(); + + HFAType *FindType( const char * ); + void AddType( HFAType * ); + + static int GetItemSize( char ); + + void Dump( FILE * ); +}; + +/************************************************************************/ +/* HFACompress */ +/* */ +/* Class that given a block of memory compresses the contents */ +/* using run length encoding as used by Imagine. */ +/************************************************************************/ + +class HFACompress +{ +public: + HFACompress( void *pData, GUInt32 nBlockSize, int nDataType ); + ~HFACompress(); + + // This is the method that does the work. + bool compressBlock(); + + // static method to allow us to query whether HFA type supported + static bool QueryDataTypeSupported( int nHFADataType ); + + // Get methods - only valid after compressBlock has been called. + GByte* getCounts() { return m_pCounts; }; + GUInt32 getCountSize() { return m_nSizeCounts; }; + GByte* getValues() { return m_pValues; }; + GUInt32 getValueSize() { return m_nSizeValues; }; + GUInt32 getMin() { return m_nMin; }; + GUInt32 getNumRuns() { return m_nNumRuns; }; + GByte getNumBits() { return m_nNumBits; }; + +private: + void makeCount( GUInt32 count, GByte *pCounter, GUInt32 *pnSizeCount ); + GUInt32 findMin( GByte *pNumBits ); + GUInt32 valueAsUInt32( GUInt32 index ); + void encodeValue( GUInt32 val, GUInt32 repeat ); + + void *m_pData; + GUInt32 m_nBlockSize; + GUInt32 m_nBlockCount; + int m_nDataType; + int m_nDataTypeNumBits; // the number of bits the datatype we are trying to compress takes + + GByte *m_pCounts; + GByte *m_pCurrCount; + GUInt32 m_nSizeCounts; + + GByte *m_pValues; + GByte *m_pCurrValues; + GUInt32 m_nSizeValues; + + GUInt32 m_nMin; + GUInt32 m_nNumRuns; + GByte m_nNumBits; // the number of bits needed to compress the range of values in the block + +}; + +#endif /* ndef _HFA_P_H_INCLUDED */ diff --git a/Utilities/GDAL/frmts/hfa/hfaband.cpp b/Utilities/GDAL/frmts/hfa/hfaband.cpp new file mode 100644 index 0000000000..4b8c456ab8 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfaband.cpp @@ -0,0 +1,1716 @@ +/****************************************************************************** + * $Id: hfaband.cpp,v 1.53 2006/03/29 14:24:04 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Implementation of the HFABand, for accessing one Eimg_Layer. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfaband.cpp,v $ + * Revision 1.53 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.52 2006/03/09 03:12:16 fwarmerdam + * Increase default space for RRDNamesList. + * + * Revision 1.51 2005/12/23 19:40:28 fwarmerdam + * better error format + * + * Revision 1.50 2005/12/23 19:39:18 fwarmerdam + * fix write error formatting + * + * Revision 1.49 2005/11/17 20:50:45 fwarmerdam + * Fixed case where not all of red, green and blue columns + * are available for a color descriptor table. + * + * Revision 1.48 2005/10/12 18:23:01 fwarmerdam + * default to 64x64 blocks on overviews regardless of base layer + * + * Revision 1.47 2005/09/22 21:13:24 fwarmerdam + * Fixing writing of files with logvalid=false as is generated by the + * compresed case of the create code now. + * + * Revision 1.46 2005/09/15 20:37:15 fwarmerdam + * added HFA_USE_RRD support when creating overviews + * + * Revision 1.45 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.44 2005/05/13 02:45:05 fwarmerdam + * use spill file for overviews if .img will get too big + * + * Revision 1.43 2005/05/13 02:07:00 fwarmerdam + * generalized use of spill file, added HFACreateSpillStack + * + * Revision 1.42 2005/05/10 00:56:55 fwarmerdam + * added CreateOverview method + * + * Revision 1.41 2005/02/22 21:35:15 fwarmerdam + * fixed up bigint offset handling in ige file: bug 774 + * + * Revision 1.40 2005/01/10 17:41:27 fwarmerdam + * added HFA compression support: bug 664 + * + * Revision 1.39 2004/10/26 17:41:29 fwarmerdam + * call MakeData(30) for poDesc_BinFunction because of basedata + * + * Revision 1.38 2004/08/19 18:46:57 warmerda + * Fixed problem with compressed floating point layers. + * http://bugzilla.remotesensing.org/show_bug.cgi?id=596 + * + * Revision 1.37 2003/10/02 16:35:21 warmerda + * added logic to search for <basename>.rrd if overview file missing + * + * Revision 1.36 2003/09/22 05:27:55 warmerda + * yikes - fixed debugging hack that completely broke driver + * + * Revision 1.35 2003/09/10 19:37:12 warmerda + * improved error reporting for IO errors + * + * Revision 1.34 2003/07/29 10:09:43 dron + * Fixed problem with creation of ordinary files larger 2GB. + * + * Revision 1.33 2003/06/10 17:14:22 warmerda + * fixed setting of maxLimit and numBins in SetPCT when nColors!=256 + * + * Revision 1.32 2003/05/21 15:35:05 warmerda + * cleanup type conversion warnings + * + * Revision 1.31 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.30 2003/04/29 08:53:45 dron + * In Get/SetRasterBlock calculate block offset in place when we have spill file. + * + * Revision 1.29 2003/04/22 19:39:10 warmerda + * dont emit debug message on failed read unless it is not an external file + * + * Revision 1.28 2003/03/27 15:51:40 dron + * Improvements in update state handling in GetRasterBlock(). + * + * Revision 1.27 2003/03/22 13:17:16 dron + * Debugging messages enclosed with #ifdef statements. + * + * Revision 1.26 2003/03/03 16:53:07 dron + * GetRasterBlock() don't report error in case of incomplete input file. + * + * Revision 1.25 2003/02/25 17:33:40 warmerda + * Fixed support for uncompressed 1, 2 and 4 bit runs in compressed blocks. + * + * Revision 1.24 2003/02/21 15:40:58 dron + * Added support for writing large (>4 GB) Erdas Imagine files. + * + * Revision 1.23 2002/11/27 14:35:28 warmerda + * Added support for uncompressing 4bit images. + * + * Revision 1.22 2002/11/27 03:19:21 warmerda + * added support for uncompressing 1bit data + * + * Revision 1.21 2002/10/05 01:15:49 warmerda + * Fixed uncompress logic for nNumBits == 32 as per report from Michael Dougherty. + * + * Revision 1.20 2002/06/20 14:10:58 warmerda + * don't return CE_Failure for missing tiles, just zero quietly + * + * Revision 1.19 2002/05/21 15:09:12 warmerda + * read/write support for GDAL_MetaData table now supported + * + * Revision 1.18 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.17 2001/07/11 15:31:26 warmerda + * fixed problems with multi-band large spill files + * + * Revision 1.16 2001/06/10 20:32:06 warmerda + * added support for external large image files + * + * Revision 1.15 2001/05/31 15:46:09 warmerda + * added uncompress support for reduce precision, non-run length encoded data + * + * Revision 1.14 2001/01/03 16:20:10 warmerda + * Converted to large file API + * + * Revision 1.13 2000/12/29 16:37:32 warmerda + * Use GUInt32 for all file offsets + * + * Revision 1.12 2000/10/31 19:13:53 warmerda + * Look for overviews even if RRDNames exists and fails + * + * Revision 1.11 2000/10/31 18:02:32 warmerda + * Added external and unnamed overview support + * + * Revision 1.10 2000/10/31 14:41:30 warmerda + * avoid memory leaks and warnings + * + * Revision 1.9 2000/10/20 04:18:15 warmerda + * added overviews, stateplane, and u4 + * + * Revision 1.8 2000/10/12 19:30:32 warmerda + * substantially improved write support + * + * Revision 1.7 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.6 2000/08/10 14:39:47 warmerda + * implemented compressed block support + * + * Revision 1.5 1999/04/23 13:43:09 warmerda + * Fixed up MSB case + * + * Revision 1.4 1999/03/08 19:23:18 warmerda + * Added logic to byte swap block data on MSB systems. Note that only 16 bit + * data is currently handled. This should be extended to larger data types + * (32bit float, 64 bit float). + * + * Revision 1.3 1999/02/15 19:32:34 warmerda + * Zero out compressed or invalid blocks. + * + * Revision 1.2 1999/01/28 18:02:42 warmerda + * Byte swapping fix with PCTs + * + * Revision 1.1 1999/01/22 17:41:34 warmerda + * New + * + */ + +#include "hfa_p.h" +#include "cpl_conv.h" +/* include the compression code */ + +CPL_CVSID("$Id: hfaband.cpp,v 1.53 2006/03/29 14:24:04 fwarmerdam Exp $"); + +/************************************************************************/ +/* HFABand() */ +/************************************************************************/ + +HFABand::HFABand( HFAInfo_t * psInfoIn, HFAEntry * poNodeIn ) + +{ + psInfo = psInfoIn; + poNode = poNodeIn; + + nBlockXSize = poNodeIn->GetIntField( "blockWidth" ); + nBlockYSize = poNodeIn->GetIntField( "blockHeight" ); + nDataType = poNodeIn->GetIntField( "pixelType" ); + + nWidth = poNodeIn->GetIntField( "width" ); + nHeight = poNodeIn->GetIntField( "height" ); + + nBlocksPerRow = (nWidth + nBlockXSize - 1) / nBlockXSize; + nBlocksPerColumn = (nHeight + nBlockYSize - 1) / nBlockYSize; + + nBlocks = nBlocksPerRow * nBlocksPerColumn; + panBlockStart = NULL; + panBlockSize = NULL; + panBlockFlag = NULL; + + nPCTColors = -1; + apadfPCT[0] = apadfPCT[1] = apadfPCT[2] = apadfPCT[3] = NULL; + + nOverviews = 0; + papoOverviews = NULL; + + fpExternal = NULL; + +/* -------------------------------------------------------------------- */ +/* Check for nodata. This is really an RDO (ESRI Raster Data */ +/* Objects?), not used by Imagine itself. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poNDNode = poNode->GetNamedChild("Eimg_NonInitializedValue"); + + if( poNDNode != NULL ) + { + bNoDataSet = TRUE; + dfNoData = poNDNode->GetDoubleField( "valueBD" ); + } + else + { + bNoDataSet = FALSE; + dfNoData = 0.0; + } + +/* -------------------------------------------------------------------- */ +/* Does this band have overviews? Try to find them. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poRRDNames = poNode->GetNamedChild( "RRDNamesList" ); + + if( poRRDNames != NULL ) + { + for( int iName = 0; TRUE; iName++ ) + { + char szField[128], *pszPath, *pszFilename, *pszEnd; + const char *pszName; + CPLErr eErr; + HFAEntry *poOvEntry; + int i; + HFAInfo_t *psHFA; + + sprintf( szField, "nameList[%d].string", iName ); + + pszName = poRRDNames->GetStringField( szField, &eErr ); + if( pszName == NULL || eErr != CE_None ) + break; + + pszFilename = CPLStrdup(pszName); + pszEnd = strstr(pszFilename,"(:"); + if( pszEnd == NULL ) + { + CPLFree( pszFilename ); + continue; + } + + pszName = pszEnd + 2; + pszEnd[0] = '\0'; + + char *pszJustFilename; + + pszJustFilename = CPLStrdup(CPLGetFilename(pszFilename)); + psHFA = HFAGetDependent( psInfo, pszJustFilename ); + CPLFree( pszJustFilename ); + + // Try finding the dependent file as this file with the + // extension .rrd. This is intended to address problems + // with users changing the names of their files. + if( psHFA == NULL ) + { + char *pszBasename = + CPLStrdup(CPLGetBasename(psInfoIn->pszFilename)); + + pszJustFilename = + CPLStrdup(CPLFormFilename(NULL, pszBasename, "rrd")); + CPLDebug( "HFA", "Failed to find overview file with expected name,\ntry %s instead.", + pszJustFilename ); + psHFA = HFAGetDependent( psInfo, pszJustFilename ); + CPLFree( pszJustFilename ); + CPLFree( pszBasename ); + } + + if( psHFA == NULL ) + { + CPLFree( pszFilename ); + continue; + } + + pszPath = pszEnd + 2; + if( pszPath[strlen(pszPath)-1] == ')' ) + pszPath[strlen(pszPath)-1] = '\0'; + + for( i=0; pszPath[i] != '\0'; i++ ) + { + if( pszPath[i] == ':' ) + pszPath[i] = '.'; + } + + poOvEntry = psHFA->poRoot->GetNamedChild( pszPath ); + CPLFree( pszFilename ); + + if( poOvEntry == NULL ) + continue; + + /* + * We have an overview node. Instanatiate a HFABand from it, + * and add to the list. + */ + papoOverviews = (HFABand **) + CPLRealloc(papoOverviews, sizeof(void*) * ++nOverviews ); + papoOverviews[nOverviews-1] = new HFABand( psHFA, poOvEntry ); + } + } + +/* -------------------------------------------------------------------- */ +/* If there are no named overviews, try looking for unnamed */ +/* overviews within the same layer, as occurs in floodplain.img */ +/* for instance. */ +/* -------------------------------------------------------------------- */ + if( nOverviews == 0 ) + { + HFAEntry *poChild; + + for( poChild = poNode->GetChild(); + poChild != NULL; + poChild = poChild->GetNext() ) + { + if( EQUAL(poChild->GetType(),"Eimg_Layer_SubSample") ) + { + papoOverviews = (HFABand **) + CPLRealloc(papoOverviews, sizeof(void*) * ++nOverviews ); + papoOverviews[nOverviews-1] = new HFABand( psInfo, poChild ); + } + } + } +} + +/************************************************************************/ +/* ~HFABand() */ +/************************************************************************/ + +HFABand::~HFABand() + +{ + for( int iOverview = 0; iOverview < nOverviews; iOverview++ ) + delete papoOverviews[iOverview]; + + if( nOverviews > 0 ) + CPLFree( papoOverviews ); + + if ( panBlockStart ) + CPLFree( panBlockStart ); + if ( panBlockSize ) + CPLFree( panBlockSize ); + if ( panBlockFlag ) + CPLFree( panBlockFlag ); + + CPLFree( apadfPCT[0] ); + CPLFree( apadfPCT[1] ); + CPLFree( apadfPCT[2] ); + CPLFree( apadfPCT[3] ); + + if( fpExternal != NULL ) + VSIFCloseL( fpExternal ); +} + +/************************************************************************/ +/* LoadBlockInfo() */ +/************************************************************************/ + +CPLErr HFABand::LoadBlockInfo() + +{ + int iBlock; + HFAEntry *poDMS; + + if( panBlockFlag != NULL ) + return( CE_None ); + + poDMS = poNode->GetNamedChild( "RasterDMS" ); + if( poDMS == NULL ) + { + if( poNode->GetNamedChild( "ExternalRasterDMS" ) != NULL ) + return LoadExternalBlockInfo(); + + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find RasterDMS field in Eimg_Layer with block list.\n"); + + return CE_Failure; + } + + panBlockStart = (vsi_l_offset *) CPLMalloc(sizeof(vsi_l_offset) * nBlocks); + panBlockSize = (int *) CPLMalloc(sizeof(int) * nBlocks); + panBlockFlag = (int *) CPLMalloc(sizeof(int) * nBlocks); + + for( iBlock = 0; iBlock < nBlocks; iBlock++ ) + { + char szVarName[64]; + int nLogvalid, nCompressType; + + sprintf( szVarName, "blockinfo[%d].offset", iBlock ); + panBlockStart[iBlock] = (GUInt32)poDMS->GetIntField( szVarName ); + + sprintf( szVarName, "blockinfo[%d].size", iBlock ); + panBlockSize[iBlock] = poDMS->GetIntField( szVarName ); + + sprintf( szVarName, "blockinfo[%d].logvalid", iBlock ); + nLogvalid = poDMS->GetIntField( szVarName ); + + sprintf( szVarName, "blockinfo[%d].compressionType", iBlock ); + nCompressType = poDMS->GetIntField( szVarName ); + + panBlockFlag[iBlock] = 0; + if( nLogvalid ) + panBlockFlag[iBlock] |= BFLG_VALID; + if( nCompressType != 0 ) + panBlockFlag[iBlock] |= BFLG_COMPRESSED; + } + + return( CE_None ); +} + +/************************************************************************/ +/* LoadExternalBlockInfo() */ +/************************************************************************/ + +CPLErr HFABand::LoadExternalBlockInfo() + +{ + int iBlock; + HFAEntry *poDMS; + + if( panBlockFlag != NULL ) + return( CE_None ); + +/* -------------------------------------------------------------------- */ +/* Get the info structure. */ +/* -------------------------------------------------------------------- */ + poDMS = poNode->GetNamedChild( "ExternalRasterDMS" ); + CPLAssert( poDMS != NULL ); + + nLayerStackCount = poDMS->GetIntField( "layerStackCount" ); + nLayerStackIndex = poDMS->GetIntField( "layerStackIndex" ); + +/* -------------------------------------------------------------------- */ +/* Open raw data file. */ +/* -------------------------------------------------------------------- */ + const char *pszRawFilename = poDMS->GetStringField( "fileName.string" ); + const char *pszFullFilename; + + pszFullFilename = CPLFormFilename( psInfo->pszPath, pszRawFilename, NULL ); + + if( psInfo->eAccess == HFA_ReadOnly ) + fpExternal = VSIFOpenL( pszFullFilename, "rb" ); + else + fpExternal = VSIFOpenL( pszFullFilename, "r+b" ); + if( fpExternal == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open external data file:\n%s\n", + pszFullFilename ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Verify header. */ +/* -------------------------------------------------------------------- */ + char szHeader[49]; + + VSIFReadL( szHeader, 49, 1, fpExternal ); + + if( strncmp( szHeader, "ERDAS_IMG_EXTERNAL_RASTER", 26 ) != 0 ) + { + VSIFCloseL( fpExternal ); + CPLError( CE_Failure, CPLE_AppDefined, + "Raw data file %s appears to be corrupt.\n", + pszFullFilename ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate blockmap. */ +/* -------------------------------------------------------------------- */ + panBlockFlag = (int *) CPLMalloc(sizeof(int) * nBlocks); + +/* -------------------------------------------------------------------- */ +/* Load the validity bitmap. */ +/* -------------------------------------------------------------------- */ + unsigned char *pabyBlockMap; + int nBytesPerRow; + + nBytesPerRow = (nBlocksPerRow + 7) / 8; + pabyBlockMap = (unsigned char *) + CPLMalloc(nBytesPerRow*nBlocksPerColumn+20); + + VSIFSeekL( fpExternal, + poDMS->GetBigIntField( "layerStackValidFlagsOffset" ), + SEEK_SET ); + + if( VSIFReadL( pabyBlockMap, nBytesPerRow * nBlocksPerColumn + 20, 1, + fpExternal ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to read block validity map." ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Establish block information. Block position is computed */ +/* from data base address. Blocks are never compressed. */ +/* Validity is determined from the validity bitmap. */ +/* -------------------------------------------------------------------- */ + nBlockStart = poDMS->GetBigIntField( "layerStackDataOffset" ); + nBlockSize = (nBlockXSize*nBlockYSize*HFAGetDataTypeBits(nDataType)+7) / 8; + + for( iBlock = 0; iBlock < nBlocks; iBlock++ ) + { + int nRow, nColumn, nBit; + + nColumn = iBlock % nBlocksPerRow; + nRow = iBlock / nBlocksPerRow; + nBit = nRow * nBytesPerRow * 8 + nColumn + 20 * 8; + + if( (pabyBlockMap[nBit>>3] >> (nBit&7)) & 0x1 ) + panBlockFlag[iBlock] = BFLG_VALID; + else + panBlockFlag[iBlock] = 0; + } + + CPLFree( pabyBlockMap ); + + return( CE_None ); +} + +/************************************************************************/ +/* UncompressBlock() */ +/* */ +/* Uncompress ESRI Grid compression format block. */ +/************************************************************************/ + +static CPLErr UncompressBlock( GByte *pabyCData, int /* nSrcBytes */, + GByte *pabyDest, int nMaxPixels, + int nDataType ) + +{ + GUInt32 nDataMin, nDataOffset; + int nNumBits, nPixelsOutput=0; + GInt32 nNumRuns; + GByte *pabyCounter, *pabyValues; + int nValueBitOffset; + + memcpy( &nDataMin, pabyCData, 4 ); + nDataMin = CPL_LSBWORD32( nDataMin ); + + memcpy( &nNumRuns, pabyCData+4, 4 ); + nNumRuns = CPL_LSBWORD32( nNumRuns ); + + memcpy( &nDataOffset, pabyCData+8, 4 ); + nDataOffset = CPL_LSBWORD32( nDataOffset ); + + nNumBits = pabyCData[12]; + + +/* ==================================================================== */ +/* If this is not run length encoded, but just reduced */ +/* precision, handle it now. */ +/* ==================================================================== */ + if( nNumRuns == -1 ) + { + pabyValues = pabyCData + 13; + nValueBitOffset = 0; + + for( nPixelsOutput = 0; nPixelsOutput < nMaxPixels; nPixelsOutput++ ) + { + int nDataValue; + +/* -------------------------------------------------------------------- */ +/* Extract the data value in a way that depends on the number */ +/* of bits in it. */ +/* -------------------------------------------------------------------- */ + if( nNumBits == 0 ) + { + nDataValue = 0; + } + else if( nNumBits == 1 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0x1; + nValueBitOffset++; + } + else if( nNumBits == 2 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0x3; + nValueBitOffset += 2; + } + else if( nNumBits == 4 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0xf; + nValueBitOffset += 4; + } + else if( nNumBits == 8 ) + { + nDataValue = *pabyValues; + pabyValues++; + } + else if( nNumBits == 16 ) + { + nDataValue = 256 * *(pabyValues++); + nDataValue += *(pabyValues++); + } + else if( nNumBits == 32 ) + { + nDataValue = 256 * 256 * 256 * *(pabyValues++); + nDataValue += 256 * 256 * *(pabyValues++); + nDataValue += 256 * *(pabyValues++); + nDataValue += *(pabyValues++); + } + else + { + printf( "nNumBits = %d\n", nNumBits ); + CPLAssert( FALSE ); + nDataValue = 0; + } + +/* -------------------------------------------------------------------- */ +/* Offset by the minimum value. */ +/* -------------------------------------------------------------------- */ + nDataValue += nDataMin; + +/* -------------------------------------------------------------------- */ +/* Now apply to the output buffer in a type specific way. */ +/* -------------------------------------------------------------------- */ + if( nDataType == EPT_u8 || nDataType == EPT_u4 + || nDataType == EPT_u2 || nDataType == EPT_u1 ) + { + CPLAssert( nDataValue < 256 ); + ((GByte *) pabyDest)[nPixelsOutput] = (GByte) nDataValue; + } + else if( nDataType == EPT_u16 ) + { + ((GUInt16 *) pabyDest)[nPixelsOutput] = (GUInt16) nDataValue; + } + else if( nDataType == EPT_s16 ) + { + ((GInt16 *) pabyDest)[nPixelsOutput] = (GInt16) nDataValue; + } + else if( nDataType == EPT_f32 ) + { + ((float *) pabyDest)[nPixelsOutput] = (float) nDataValue; + } + else + { + CPLAssert( FALSE ); + } + } + + return CE_None; + } + +/* ==================================================================== */ +/* Establish data pointers for runs. */ +/* ==================================================================== */ + pabyCounter = pabyCData + 13; + pabyValues = pabyCData + nDataOffset; + nValueBitOffset = 0; + +/* -------------------------------------------------------------------- */ +/* Loop over runs. */ +/* -------------------------------------------------------------------- */ + int iRun; + + for( iRun = 0; iRun < nNumRuns; iRun++ ) + { + int nRepeatCount = 0; + int nDataValue; + +/* -------------------------------------------------------------------- */ +/* Get the repeat count. This can be stored as one, two, three */ +/* or four bytes depending on the low order two bits of the */ +/* first byte. */ +/* -------------------------------------------------------------------- */ + if( ((*pabyCounter) & 0xc0) == 0x00 ) + { + nRepeatCount = (*(pabyCounter++)) & 0x3f; + } + else if( ((*pabyCounter) & 0xc0) == 0x40 ) + { + nRepeatCount = (*(pabyCounter++)) & 0x3f; + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + } + else if( ((*pabyCounter) & 0xc0) == 0x80 ) + { + nRepeatCount = (*(pabyCounter++)) & 0x3f; + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + } + else if( ((*pabyCounter) & 0xc0) == 0xc0 ) + { + nRepeatCount = (*(pabyCounter++)) & 0x3f; + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + nRepeatCount = nRepeatCount * 256 + (*(pabyCounter++)); + } + +/* -------------------------------------------------------------------- */ +/* Extract the data value in a way that depends on the number */ +/* of bits in it. */ +/* -------------------------------------------------------------------- */ + if( nNumBits == 0 ) + { + nDataValue = 0; + } + else if( nNumBits == 1 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0x1; + nValueBitOffset++; + } + else if( nNumBits == 2 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0x3; + nValueBitOffset += 2; + } + else if( nNumBits == 4 ) + { + nDataValue = + (pabyValues[nValueBitOffset>>3] >> (nValueBitOffset&7)) & 0xf; + nValueBitOffset += 4; + } + else if( nNumBits == 8 ) + { + nDataValue = *pabyValues; + pabyValues++; + } + else if( nNumBits == 16 ) + { + nDataValue = 256 * *(pabyValues++); + nDataValue += *(pabyValues++); + } + else if( nNumBits == 32 ) + { + nDataValue = 256 * 256 * 256 * *(pabyValues++); + nDataValue += 256 * 256 * *(pabyValues++); + nDataValue += 256 * *(pabyValues++); + nDataValue += *(pabyValues++); + } + else + { + printf( "nNumBits = %d\n", nNumBits ); + CPLAssert( FALSE ); + nDataValue = 0; + } + +/* -------------------------------------------------------------------- */ +/* Offset by the minimum value. */ +/* -------------------------------------------------------------------- */ + nDataValue += nDataMin; + +/* -------------------------------------------------------------------- */ +/* Now apply to the output buffer in a type specific way. */ +/* -------------------------------------------------------------------- */ + if( nPixelsOutput + nRepeatCount > nMaxPixels ) + { + CPLAssert( FALSE ); + nRepeatCount = nMaxPixels - nPixelsOutput; + } + + if( nDataType == EPT_u8 ) + { + int i; + + for( i = 0; i < nRepeatCount; i++ ) + { + CPLAssert( nDataValue < 256 ); + ((GByte *) pabyDest)[nPixelsOutput++] = (GByte)nDataValue; + } + } + else if( nDataType == EPT_u16 ) + { + int i; + + for( i = 0; i < nRepeatCount; i++ ) + { + ((GUInt16 *) pabyDest)[nPixelsOutput++] = (GUInt16)nDataValue; + } + } + else if( nDataType == EPT_s16 ) + { + int i; + + for( i = 0; i < nRepeatCount; i++ ) + { + ((GInt16 *) pabyDest)[nPixelsOutput++] = (GInt16)nDataValue; + } + } + else if( nDataType == EPT_u32 ) + { + int i; + + for( i = 0; i < nRepeatCount; i++ ) + { + ((GUInt32 *) pabyDest)[nPixelsOutput++] = (GUInt32)nDataValue; + } + } + else if( nDataType == EPT_s32 ) + { + int i; + + for( i = 0; i < nRepeatCount; i++ ) + { + ((GInt32 *) pabyDest)[nPixelsOutput++] = (GInt32)nDataValue; + } + } + else if( nDataType == EPT_f32 ) + { + int i; + float fDataValue; + + memcpy( &fDataValue, &nDataValue, 4); + for( i = 0; i < nRepeatCount; i++ ) + { + ((float *) pabyDest)[nPixelsOutput++] = fDataValue; + } + } + else if( nDataType == EPT_u1 ) + { + int i; + + CPLAssert( nDataValue == 0 || nDataValue == 1 ); + + if( nDataValue == 1 ) + { + for( i = 0; i < nRepeatCount; i++ ) + { + pabyDest[nPixelsOutput>>3] |= (1 << (nPixelsOutput & 0x7)); + nPixelsOutput++; + } + } + else + { + for( i = 0; i < nRepeatCount; i++ ) + { + pabyDest[nPixelsOutput>>3] &= ~(1<<(nPixelsOutput & 0x7)); + nPixelsOutput++; + } + } + } + else if( nDataType == EPT_u4 ) + { + int i; + + CPLAssert( nDataValue >= 0 && nDataValue < 16 ); + + for( i = 0; i < nRepeatCount; i++ ) + { + if( (nPixelsOutput & 0x1) == 0 ) + pabyDest[nPixelsOutput>>1] = (GByte) nDataValue; + else + pabyDest[nPixelsOutput>>1] |= (GByte) (nDataValue<<4); + + nPixelsOutput++; + } + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to uncompress an unsupported pixel data type."); + return CE_Failure; + } + } + + return CE_None; +} + + +/************************************************************************/ +/* GetRasterBlock() */ +/************************************************************************/ + +CPLErr HFABand::GetRasterBlock( int nXBlock, int nYBlock, void * pData ) + +{ + int iBlock; + FILE *fpData; + + if( LoadBlockInfo() != CE_None ) + return CE_Failure; + + iBlock = nXBlock + nYBlock * nBlocksPerRow; + +/* -------------------------------------------------------------------- */ +/* If the block isn't valid, we just return all zeros, and an */ +/* indication of success. */ +/* -------------------------------------------------------------------- */ + if( !panBlockFlag[iBlock] & BFLG_VALID ) + { + memset( pData, 0, + HFAGetDataTypeBits(nDataType)*nBlockXSize*nBlockYSize/8 ); + + return( CE_None ); + } + +/* -------------------------------------------------------------------- */ +/* Otherwise we really read the data. */ +/* -------------------------------------------------------------------- */ + vsi_l_offset nBlockOffset; + + // Calculate block offset in case we have spill file. Use predefined + // block map otherwise. + if ( fpExternal ) + { + fpData = fpExternal; + nBlockOffset = nBlockStart + nBlockSize * iBlock * nLayerStackCount + + nLayerStackIndex * nBlockSize; + } + else + { + fpData = psInfo->fp; + nBlockOffset = panBlockStart[iBlock]; + nBlockSize = panBlockSize[iBlock]; + } + + if( VSIFSeekL( fpData, nBlockOffset, SEEK_SET ) != 0 ) + { + // XXX: We will not report error here, because file just may be + // in update state and data for this block will be available later + if ( psInfo->eAccess == HFA_Update ) + { + memset( pData, 0, + HFAGetDataTypeBits(nDataType)*nBlockXSize*nBlockYSize/8 ); + return CE_None; + } + else + { + CPLError( CE_Failure, CPLE_FileIO, + "Seek to %x:%08x on %p failed\n%s", + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* If the block is compressed, read into an intermediate buffer */ +/* and convert. */ +/* -------------------------------------------------------------------- */ + if( panBlockFlag[iBlock] & BFLG_COMPRESSED ) + { + GByte *pabyCData; + CPLErr eErr; + + pabyCData = (GByte *) CPLMalloc( (size_t) nBlockSize ); + + if( VSIFReadL( pabyCData, (size_t) nBlockSize, 1, fpData ) != 1 ) + { + CPLFree( pabyCData ); + + // XXX: Suppose that file in update state + if ( psInfo->eAccess == HFA_Update ) + { + memset( pData, 0, + HFAGetDataTypeBits(nDataType)*nBlockXSize*nBlockYSize/8 ); + return CE_None; + } + else + { + CPLError( CE_Failure, CPLE_FileIO, + "Read of %d bytes at %x:%08x on %p failed.\n%s", + (int) nBlockSize, + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + return CE_Failure; + } + } + + eErr = UncompressBlock( pabyCData, (int) nBlockSize, + (GByte *) pData, nBlockXSize*nBlockYSize, + nDataType ); + + CPLFree( pabyCData ); + + return eErr; + } + +/* -------------------------------------------------------------------- */ +/* Read uncompressed data directly into the return buffer. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( pData, (size_t) nBlockSize, 1, fpData ) != 1 ) + { + memset( pData, 0, + HFAGetDataTypeBits(nDataType)*nBlockXSize*nBlockYSize/8 ); + + if( fpData != fpExternal ) + CPLDebug( "HFABand", + "Read of %x:%08x bytes at %d on %p failed.\n%s", + (int) nBlockSize, + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap to local byte order if required. It appears that */ +/* raster data is always stored in Intel byte order in Imagine */ +/* files. */ +/* -------------------------------------------------------------------- */ + +#ifdef CPL_MSB + if( HFAGetDataTypeBits(nDataType) == 16 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP16PTR( ((unsigned char *) pData) + ii*2 ); + } + else if( HFAGetDataTypeBits(nDataType) == 32 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_f64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } + else if( nDataType == EPT_c64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_c128 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } +#endif /* def CPL_MSB */ + + return( CE_None ); +} + +/************************************************************************/ +/* ReAllocBlock() */ +/************************************************************************/ + +void HFABand::ReAllocBlock( int iBlock, int nSize ) +{ + /* For compressed files - need to realloc the space for the block */ + + // TODO: Should check to see if panBlockStart[iBlock] is not zero then do a HFAFreeSpace() + // but that doesn't exist yet. + // Instead as in interim measure it will reuse the existing block if + // the new data will fit in. + if( ( panBlockStart[iBlock] != 0 ) && ( nSize <= panBlockSize[iBlock] ) ) + { + panBlockSize[iBlock] = nSize; + //fprintf( stderr, "Reusing block %d\n", iBlock ); + } + else + { + panBlockStart[iBlock] = HFAAllocateSpace( psInfo, nSize ); + + panBlockSize[iBlock] = nSize; + + // need to re - write this info to the RasterDMS node + HFAEntry *poDMS = poNode->GetNamedChild( "RasterDMS" ); + + char szVarName[64]; + sprintf( szVarName, "blockinfo[%d].offset", iBlock ); + poDMS->SetIntField( szVarName, panBlockStart[iBlock] ); + + sprintf( szVarName, "blockinfo[%d].size", iBlock ); + poDMS->SetIntField( szVarName, panBlockSize[iBlock] ); + } + +} + + +/************************************************************************/ +/* SetRasterBlock() */ +/************************************************************************/ + +CPLErr HFABand::SetRasterBlock( int nXBlock, int nYBlock, void * pData ) + +{ + int iBlock; + FILE *fpData; + + if( LoadBlockInfo() != CE_None ) + return CE_Failure; + + iBlock = nXBlock + nYBlock * nBlocksPerRow; + +/* -------------------------------------------------------------------- */ +/* For now we don't support write invalid uncompressed blocks. */ +/* To do so we will need logic to make space at the end of the */ +/* file in the right size. */ +/* -------------------------------------------------------------------- */ + if( (panBlockFlag[iBlock] & BFLG_VALID) == 0 + && !(panBlockFlag[iBlock] & BFLG_COMPRESSED) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to write to invalid tile with number %d " + "(X position %d, Y position %d). This\n operation currently " + "unsupported by HFABand::SetRasterBlock().\n", + iBlock, nXBlock, nYBlock ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Move to the location that the data sits. */ +/* -------------------------------------------------------------------- */ + vsi_l_offset nBlockOffset; + + // Calculate block offset in case we have spill file. Use predefined + // block map otherwise. + if ( fpExternal ) + { + fpData = fpExternal; + nBlockOffset = nBlockStart + nBlockSize * iBlock * nLayerStackCount + + nLayerStackIndex * nBlockSize; + } + else + { + fpData = psInfo->fp; + nBlockOffset = panBlockStart[iBlock]; + nBlockSize = panBlockSize[iBlock]; + } + +/* ==================================================================== */ +/* Compressed Tile Handling. */ +/* ==================================================================== */ + if( panBlockFlag[iBlock] & BFLG_COMPRESSED ) + { + /* ------------------------------------------------------------ */ + /* Write compressed data. */ + /* ------------------------------------------------------------ */ + int nInBlockSize = (nBlockXSize * nBlockYSize * HFAGetDataTypeBits(nDataType) + 7 ) / 8; + + /* create the compressor object */ + HFACompress compress( pData, nInBlockSize, nDataType ); + + /* compress the data */ + if( compress.compressBlock() ) + { + /* get the data out of the object */ + GByte *pCounts = compress.getCounts(); + GUInt32 nSizeCount = compress.getCountSize(); + GByte *pValues = compress.getValues(); + GUInt32 nSizeValues = compress.getValueSize(); + GUInt32 nMin = compress.getMin(); + GUInt32 nNumRuns = compress.getNumRuns(); + GByte nNumBits = compress.getNumBits(); + + /* Compensate for the header info */ + GUInt32 nDataOffset = nSizeCount + 13; + int nTotalSize = nSizeCount + nSizeValues + 13; + + //fprintf( stderr, "sizecount = %d sizevalues = %d min = %d numruns = %d numbits = %d\n", nSizeCount, nSizeValues, nMin, nNumRuns, (int)nNumBits ); + + // Allocate space for the compressed block and seek to it. + ReAllocBlock( iBlock, nTotalSize ); + + nBlockOffset = panBlockStart[iBlock]; + nBlockSize = panBlockSize[iBlock]; + + // Seek to offset + if( VSIFSeekL( fpData, nBlockOffset, SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, "Seek to %x:%08x on %p failed\n%s", + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + return CE_Failure; + } + + /* -------------------------------------------------------------------- */ + /* Byte swap to local byte order if required. It appears that */ + /* raster data is always stored in Intel byte order in Imagine */ + /* files. */ + /* -------------------------------------------------------------------- */ + +#ifdef CPL_MSB + + CPL_SWAP32PTR( &nMin ); + CPL_SWAP32PTR( &nNumRuns ); + CPL_SWAP32PTR( &nDataOffset ); + +#endif /* def CPL_MSB */ + + /* Write out the Minimum value */ + VSIFWriteL( &nMin, (size_t) sizeof( nMin ), 1, fpData ); + + /* the number of runs */ + VSIFWriteL( &nNumRuns, (size_t) sizeof( nNumRuns ), 1, fpData ); + + /* The offset to the data */ + VSIFWriteL( &nDataOffset, (size_t) sizeof( nDataOffset ), 1, fpData ); + + /* The number of bits */ + VSIFWriteL( &nNumBits, (size_t) sizeof( nNumBits ), 1, fpData ); + + /* The counters - MSB stuff handled in HFACompress */ + VSIFWriteL( pCounts, (size_t) sizeof( GByte ), nSizeCount, fpData ); + + /* The values - MSB stuff handled in HFACompress */ + VSIFWriteL( pValues, (size_t) sizeof( GByte ), nSizeValues, fpData ); + + /* Compressed data is freed in the HFACompress destructor */ + } + else + { + /* If we have actually made the block bigger - ie does not compress well */ + panBlockFlag[iBlock] ^= BFLG_COMPRESSED; + // alloc more space for the uncompressed block + ReAllocBlock( iBlock, nInBlockSize ); + + nBlockOffset = panBlockStart[iBlock]; + nBlockSize = panBlockSize[iBlock]; + + /* Need to change the RasterDMS entry */ + HFAEntry *poDMS = poNode->GetNamedChild( "RasterDMS" ); + + char szVarName[64]; + sprintf( szVarName, "blockinfo[%d].compressionType", iBlock ); + poDMS->SetIntField( szVarName, 0 ); + } + +/* -------------------------------------------------------------------- */ +/* If the block was previously invalid, mark it as valid now. */ +/* -------------------------------------------------------------------- */ + if( (panBlockFlag[iBlock] & BFLG_VALID) == 0 ) + { + char szVarName[64]; + HFAEntry *poDMS = poNode->GetNamedChild( "RasterDMS" ); + + sprintf( szVarName, "blockinfo[%d].logvalid", iBlock ); + poDMS->SetStringField( szVarName, "true" ); + + panBlockFlag[iBlock] |= BFLG_VALID; + } + } + +/* ==================================================================== */ +/* Uncompressed TILE handling. */ +/* ==================================================================== */ + if( ( panBlockFlag[iBlock] & BFLG_COMPRESSED ) == 0 ) + { + + if( VSIFSeekL( fpData, nBlockOffset, SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, "Seek to %x:%08x on %p failed\n%s", + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap to local byte order if required. It appears that */ +/* raster data is always stored in Intel byte order in Imagine */ +/* files. */ +/* -------------------------------------------------------------------- */ + +#ifdef CPL_MSB + if( HFAGetDataTypeBits(nDataType) == 16 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP16PTR( ((unsigned char *) pData) + ii*2 ); + } + else if( HFAGetDataTypeBits(nDataType) == 32 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_f64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } + else if( nDataType == EPT_c64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_c128 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } +#endif /* def CPL_MSB */ + +/* -------------------------------------------------------------------- */ +/* Write uncompressed data. */ +/* -------------------------------------------------------------------- */ + if( VSIFWriteL( pData, (size_t) nBlockSize, 1, fpData ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Write of %d bytes at %x:%08x on %p failed.\n%s", + (int) nBlockSize, + (int) (nBlockOffset >> 32), + (int) (nBlockOffset & 0xffffffff), + fpData, VSIStrerror(errno) ); + return CE_Failure; + } + } +/* -------------------------------------------------------------------- */ +/* Swap back, since we don't really have permission to change */ +/* the callers buffer. */ +/* -------------------------------------------------------------------- */ + +#ifdef CPL_MSB + if( HFAGetDataTypeBits(nDataType) == 16 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP16PTR( ((unsigned char *) pData) + ii*2 ); + } + else if( HFAGetDataTypeBits(nDataType) == 32 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_f64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } + else if( nDataType == EPT_c64 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP32PTR( ((unsigned char *) pData) + ii*4 ); + } + else if( nDataType == EPT_c128 ) + { + for( int ii = 0; ii < nBlockXSize*nBlockYSize*2; ii++ ) + CPL_SWAP64PTR( ((unsigned char *) pData) + ii*8 ); + } +#endif /* def CPL_MSB */ + + return( CE_None ); +} + +/************************************************************************/ +/* GetBandName() */ +/* */ +/* Return the Layer Name */ +/************************************************************************/ + +const char * HFABand::GetBandName() +{ + return( poNode->GetName() ); +} + +/************************************************************************/ +/* SetBandName() */ +/* */ +/* Set the Layer Name */ +/************************************************************************/ + +void HFABand::SetBandName(const char *pszName) +{ + if( psInfo->eAccess == HFA_Update ) + { + poNode->SetName(pszName); + } +} + +/************************************************************************/ +/* GetPCT() */ +/* */ +/* Return PCT information, if any exists. */ +/************************************************************************/ + +CPLErr HFABand::GetPCT( int * pnColors, + double **ppadfRed, + double **ppadfGreen, + double **ppadfBlue, + double **ppadfAlpha ) + +{ + *pnColors = 0; + *ppadfRed = NULL; + *ppadfGreen = NULL; + *ppadfBlue = NULL; + *ppadfAlpha = NULL; + +/* -------------------------------------------------------------------- */ +/* If we haven't already tried to load the colors, do so now. */ +/* -------------------------------------------------------------------- */ + if( nPCTColors == -1 ) + { + HFAEntry *poColumnEntry; + int i, iColumn; + + nPCTColors = 0; + + poColumnEntry = poNode->GetNamedChild("Descriptor_Table.Red"); + if( poColumnEntry == NULL ) + return( CE_Failure ); + + nPCTColors = poColumnEntry->GetIntField( "numRows" ); + for( iColumn = 0; iColumn < 4; iColumn++ ) + { + apadfPCT[iColumn] = (double *)CPLMalloc(sizeof(double)*nPCTColors); + if( iColumn == 0 ) + poColumnEntry = poNode->GetNamedChild("Descriptor_Table.Red"); + else if( iColumn == 1 ) + poColumnEntry= poNode->GetNamedChild("Descriptor_Table.Green"); + else if( iColumn == 2 ) + poColumnEntry = poNode->GetNamedChild("Descriptor_Table.Blue"); + else if( iColumn == 3 ) { + poColumnEntry = poNode->GetNamedChild("Descriptor_Table.Opacity"); + } + + if( poColumnEntry == NULL ) + { + double *pdCol = apadfPCT[iColumn]; + for( i = 0; i < nPCTColors; i++ ) + pdCol[i] = 1.0; + } + else + { + VSIFSeekL( psInfo->fp, poColumnEntry->GetIntField("columnDataPtr"), + SEEK_SET ); + VSIFReadL( apadfPCT[iColumn], sizeof(double), nPCTColors, + psInfo->fp); + + for( i = 0; i < nPCTColors; i++ ) + HFAStandard( 8, apadfPCT[iColumn] + i ); + } + } + } + +/* -------------------------------------------------------------------- */ +/* Return the values. */ +/* -------------------------------------------------------------------- */ + if( nPCTColors == 0 ) + return( CE_Failure ); + + *pnColors = nPCTColors; + *ppadfRed = apadfPCT[0]; + *ppadfGreen = apadfPCT[1]; + *ppadfBlue = apadfPCT[2]; + *ppadfAlpha = apadfPCT[3]; + + return( CE_None ); +} + +/************************************************************************/ +/* SetPCT() */ +/* */ +/* Set the PCT information for this band. */ +/************************************************************************/ + +CPLErr HFABand::SetPCT( int nColors, + double *padfRed, + double *padfGreen, + double *padfBlue , + double *padfAlpha) + +{ + + if( nColors == 0 ) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* Create the Descriptor table. */ +/* -------------------------------------------------------------------- */ + if( TRUE ) + { + HFAEntry *poEdsc_Table; + + poEdsc_Table = new HFAEntry( psInfo, "Descriptor_Table", "Edsc_Table", + poNode ); + + poEdsc_Table->SetIntField( "numrows", nColors ); + +/* -------------------------------------------------------------------- */ +/* Create the Binning function node. I am not sure that we */ +/* really need this though. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poEdsc_BinFunction; + + poEdsc_BinFunction = + new HFAEntry( psInfo, "#Bin_Function#", "Edsc_BinFunction", + poEdsc_Table ); + + // Because of the BaseData we have to hardcode the size. + poEdsc_BinFunction->MakeData( 30 ); + + poEdsc_BinFunction->SetIntField( "numBins", nColors ); + poEdsc_BinFunction->SetStringField( "binFunction", "direct" ); + poEdsc_BinFunction->SetDoubleField( "minLimit", 0.0 ); + poEdsc_BinFunction->SetDoubleField( "maxLimit", nColors - 1.0 ); + +/* -------------------------------------------------------------------- */ +/* Process each color component */ +/* -------------------------------------------------------------------- */ + for( int iColumn = 0; iColumn < 4; iColumn++ ) + { + HFAEntry *poEdsc_Column; + double *padfValues=NULL; + const char *pszName=NULL; + + if( iColumn == 0 ) + { + pszName = "Red"; + padfValues = padfRed; + } + else if( iColumn == 1 ) + { + pszName = "Green"; + padfValues = padfGreen; + } + else if( iColumn == 2 ) + { + pszName = "Blue"; + padfValues = padfBlue; + } + else if( iColumn == 3 ) + { + pszName = "Opacity"; + padfValues = padfAlpha; + } + +/* -------------------------------------------------------------------- */ +/* Create the Edsc_Column. */ +/* -------------------------------------------------------------------- */ + poEdsc_Column = new HFAEntry( psInfo, pszName, "Edsc_Column", + poEdsc_Table ); + poEdsc_Column->SetIntField( "numRows", nColors ); + poEdsc_Column->SetStringField( "dataType", "real" ); + poEdsc_Column->SetIntField( "maxNumChars", 0 ); + +/* -------------------------------------------------------------------- */ +/* Write the data out. */ +/* -------------------------------------------------------------------- */ + int nOffset = HFAAllocateSpace( psInfo, 8*nColors); + double *padfFileData; + + poEdsc_Column->SetIntField( "columnDataPtr", nOffset ); + + padfFileData = (double *) CPLMalloc(nColors*sizeof(double)); + for( int iColor = 0; iColor < nColors; iColor++ ) + { + padfFileData[iColor] = padfValues[iColor]; + HFAStandard( 8, padfFileData + iColor ); + } + VSIFSeekL( psInfo->fp, nOffset, SEEK_SET ); + VSIFWriteL( padfFileData, 8, nColors, psInfo->fp ); + CPLFree( padfFileData ); + } + +/* -------------------------------------------------------------------- */ +/* Update the layer type to be thematic. */ +/* -------------------------------------------------------------------- */ + poNode->SetStringField( "layerType", "thematic" ); + } + + return( CE_None ); +} + +/************************************************************************/ +/* CreateOverview() */ +/************************************************************************/ + +int HFABand::CreateOverview( int nOverviewLevel ) + +{ + + char *pszLayerName; + int nOXSize, nOYSize; + + pszLayerName = (char *) CPLMalloc(strlen(psInfo->pszFilename) + 128); + + nOXSize = (psInfo->nXSize + nOverviewLevel - 1) / nOverviewLevel; + nOYSize = (psInfo->nYSize + nOverviewLevel - 1) / nOverviewLevel; + +/* -------------------------------------------------------------------- */ +/* Eventually we need to decide on the whether to use the spill */ +/* file, primarily on the basis of whether the new overview */ +/* will drive our .img file size near 4BG. For now, just base */ +/* it on the config options. */ +/* -------------------------------------------------------------------- */ + int bCreateLargeRaster = CSLTestBoolean( + CPLGetConfigOption("USE_SPILL","NO") ); + GIntBig nValidFlagsOffset = 0, nDataOffset = 0; + + if( (psInfo->nEndOfFile + + (nOXSize * (double) nOYSize) + * (HFAGetDataTypeBits(nDataType) / 8)) > 2000000000.0 ) + bCreateLargeRaster = TRUE; + + if( bCreateLargeRaster ) + { + if( !HFACreateSpillStack( psInfo, nOXSize, nOYSize, 1, + 64, nDataType, + &nValidFlagsOffset, &nDataOffset ) ) + { + return -1; + } + } + +/* -------------------------------------------------------------------- */ +/* Do we want to use a dependent file (.rrd) for the overviews? */ +/* Or just create them directly in this file? */ +/* -------------------------------------------------------------------- */ + HFAInfo_t *psRRDInfo = psInfo; + HFAEntry *poParent = poNode; + + if( !bCreateLargeRaster + && CSLTestBoolean( CPLGetConfigOption( "HFA_USE_RRD", "NO" ) ) ) + { + psRRDInfo = HFACreateDependent( psInfo ); + + poParent = psRRDInfo->poRoot->GetNamedChild( poNode->GetName() ); + + // Need to create layer object. + if( poParent == NULL ) + { + poParent = + new HFAEntry( psRRDInfo, poNode->GetName(), + "Eimg_Layer", psRRDInfo->poRoot ); + } + } + +/* -------------------------------------------------------------------- */ +/* Create the layer. */ +/* -------------------------------------------------------------------- */ + sprintf( pszLayerName, "_ss_%d_", nOverviewLevel ); + + if( !HFACreateLayer( psRRDInfo, poParent, pszLayerName, + TRUE, 64, FALSE, bCreateLargeRaster, + nOXSize, nOYSize, nDataType, NULL, + nValidFlagsOffset, nDataOffset, 1, 0 ) ) + return -1; + + HFAEntry *poOverLayer = poParent->GetNamedChild( pszLayerName ); + if( poOverLayer == NULL ) + return -1; + +/* -------------------------------------------------------------------- */ +/* Create RRDNamesList list if it does not yet exist. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poRRDNamesList = poNode->GetNamedChild("RRDNamesList"); + if( poRRDNamesList == NULL ) + { + poRRDNamesList = new HFAEntry( psInfo, "RRDNamesList", + "Eimg_RRDNamesList", + poNode ); + poRRDNamesList->MakeData( 23+16+8+ 3000 /* hack for growth room*/ ); + + /* we need to hardcode file offset into the data, so locate it now */ + poRRDNamesList->SetPosition(); + + poRRDNamesList->SetStringField( "algorithm.string", + "IMAGINE 2X2 Resampling" ); + } + +/* -------------------------------------------------------------------- */ +/* Add new overview layer to RRDNamesList. */ +/* -------------------------------------------------------------------- */ + int iNextName = poRRDNamesList->GetFieldCount( "nameList" ); + char szName[50]; + + sprintf( szName, "nameList[%d].string", iNextName ); + + sprintf( pszLayerName, "%s(:%s:_ss_%d_)", + psRRDInfo->pszFilename, poNode->GetName(), nOverviewLevel ); + + // TODO: Need to add to end of array. + // TODO: Need to check that this fits into the data area of this entry. + poRRDNamesList->SetStringField( szName, pszLayerName ); + + CPLFree( pszLayerName ); + +/* -------------------------------------------------------------------- */ +/* Add to the list of overviews for this band. */ +/* -------------------------------------------------------------------- */ + papoOverviews = (HFABand **) + CPLRealloc(papoOverviews, sizeof(void*) * ++nOverviews ); + papoOverviews[nOverviews-1] = new HFABand( psRRDInfo, poOverLayer ); + + return nOverviews-1; +} diff --git a/Utilities/GDAL/frmts/hfa/hfacompress.cpp b/Utilities/GDAL/frmts/hfa/hfacompress.cpp new file mode 100644 index 0000000000..d930eed3e5 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfacompress.cpp @@ -0,0 +1,288 @@ +/****************************************************************************** + * $Id: hfacompress.cpp,v 1.3 2005/09/23 14:53:48 fwarmerdam Exp $ + * + * Name: hfadataset.cpp + * Project: Erdas Imagine Driver + * Purpose: Imagine Compression code. + * Author: Sam Gillingham <sam.gillingham at nrm.qld.gov> + * + ****************************************************************************** + * Copyright (c) 2005, Sam Gillingham + * + * 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: hfacompress.cpp,v $ + * Revision 1.3 2005/09/23 14:53:48 fwarmerdam + * Bug 928: Fix initialization size of m_pCounts and m_pValues. + * + * Revision 1.2 2005/08/20 23:46:28 fwarmerdam + * bug 858: fix for double compression + * + * Revision 1.1 2005/01/10 17:40:40 fwarmerdam + * New + * + */ + +#include "hfa_p.h" + +CPL_CVSID("$Id: hfacompress.cpp,v 1.3 2005/09/23 14:53:48 fwarmerdam Exp $"); + +HFACompress::HFACompress( void *pData, GUInt32 nBlockSize, int nDataType ) +{ + m_pData = pData; + m_nDataType = nDataType; + m_nDataTypeNumBits = HFAGetDataTypeBits( m_nDataType ); + m_nBlockSize = nBlockSize; + m_nBlockCount = nBlockSize / ( m_nDataTypeNumBits / 8 ); + + /* Allocate some memory for the count and values - probably too big */ + /* About right for worst case scenario tho */ + m_pCounts = (GByte*)CPLMalloc( m_nBlockSize + sizeof(GUInt32) ); + m_nSizeCounts = 0; + + m_pValues = (GByte*)CPLMalloc( m_nBlockSize + sizeof(GUInt32) ); + m_nSizeValues = 0; + + m_nMin = 0; + m_nNumRuns = 0; + m_nNumBits = 0; +} + +HFACompress::~HFACompress() +{ + /* free the compressed data */ + CPLFree( m_pCounts ); + CPLFree( m_pValues ); +} + +/* returns the number of bits needed to encode a count */ +GByte _FindNumBits( GUInt32 range ) +{ + if( range < 0xff ) + { + return 8; + } + else if( range < 0xffff ) + { + return 16; + } + else + { + return 32; + } +} + +/* Gets the value from the uncompressed block as a GUInt32 no matter the data type */ +GUInt32 HFACompress::valueAsUInt32( GUInt32 index ) +{ +GUInt32 val = 0; + + if( m_nDataTypeNumBits == 8 ) + { + val = ((GByte*)m_pData)[index]; + } + else if( m_nDataTypeNumBits == 16 ) + { + val = ((GUInt16*)m_pData)[index]; + } + else if( m_nDataTypeNumBits == 32 ) + { + val = ((GUInt32*)m_pData)[index]; + } + else + { + /* Should not get to here - check in compressBlock() should return false if + we can't compress this blcok because we don't know about the type */ + CPLError( CE_Failure, CPLE_FileIO, "Imagine Datatype 0x%x (0x%x bits) not supported\n", + m_nDataType, + m_nDataTypeNumBits ); + CPLAssert( FALSE ); + } + + return val; +} + +/* Finds the minimum value in a type specific fashion. This value is + subtracted from each value in the compressed dataset. The maxmimum + value is also found and the number of bits that the range can be stored + is also returned. */ +/* TODO: Minimum value returned as pNumBits is now 8 - Imagine + can handle 1, 2, and 4 bits as well */ +GUInt32 HFACompress::findMin( GByte *pNumBits ) +{ +GUInt32 u32Val; +GUInt32 u32Min, u32Max; + + u32Min = valueAsUInt32( 0 ); + u32Max = u32Min; + + for( GUInt32 count = 1; count < m_nBlockCount; count++ ) + { + u32Val = valueAsUInt32( count ); + if( u32Val < u32Min ) + u32Min = u32Val; + else if( u32Val > u32Max ) + u32Max = u32Val; + } + + *pNumBits = _FindNumBits( u32Max - u32Min ); + + return u32Min; +} + +/* Codes the count in the way expected by Imagine - ie the lower 2 bits specify how many bytes + the count takes up */ +void HFACompress::makeCount( GUInt32 count, GByte *pCounter, GUInt32 *pnSizeCount ) +{ + /* Because Imagine stores the number of bits used in the + lower 2 bits of the data it restricts what we can use */ + if( count < 0x40 ) + { + pCounter[0] = count; + *pnSizeCount = 1; + } + else if( count < 0x8000 ) + { + pCounter[1] = count & 0xff; + count /= 256; + pCounter[0] = count | 0x40; + *pnSizeCount = 2; + } + else if( count < 0x800000 ) + { + pCounter[2] = count & 0xff; + count /= 256; + pCounter[1] = count & 0xff; + count /= 256; + pCounter[0] = count | 0x80; + *pnSizeCount = 3; + } + else + { + pCounter[3] = count & 0xff; + count /= 256; + pCounter[2] = count & 0xff; + count /= 256; + pCounter[1] = count & 0xff; + count /= 256; + pCounter[0] = count | 0xc0; + *pnSizeCount = 4; + } +} + +/* Encodes the value depending on the number of bits we are using */ +void HFACompress::encodeValue( GUInt32 val, GUInt32 repeat ) +{ +GUInt32 nSizeCount; + + makeCount( repeat, m_pCurrCount, &nSizeCount ); + m_pCurrCount += nSizeCount; + if( m_nNumBits == 8 ) + { + /* Only storing 8 bits per value as the range is small */ + *(GByte*)m_pCurrValues = GByte(val - m_nMin); + m_pCurrValues += sizeof( GByte ); + } + else if( m_nNumBits == 16 ) + { + /* Only storing 16 bits per value as the range is small */ + *(GUInt16*)m_pCurrValues = GUInt16(val - m_nMin); +#ifndef CPL_MSB + CPL_SWAP16PTR( m_pCurrValues ); +#endif /* ndef CPL_MSB */ + m_pCurrValues += sizeof( GUInt16 ); + } + else + { + *(GUInt32*)m_pCurrValues = GUInt32(val - m_nMin); +#ifndef CPL_MSB + CPL_SWAP32PTR( m_pCurrValues ); +#endif /* ndef CPL_MSB */ + m_pCurrValues += sizeof( GUInt32 ); + } +} + +/* This is the guts of the file - call this to compress the block */ +/* returns false if the compression fails - ie compressed block bigger than input */ +bool HFACompress::compressBlock() +{ +GUInt32 nLastUnique = 0; + + /* Check we know about the datatype to be compressed. + If we can't compress it we should return false so that + the block cannot be compressed (we can handle just about + any type uncompressed) */ + if( ! QueryDataTypeSupported( m_nDataType ) ) + { + CPLDebug( "HFA", "Cannot compress HFA datatype 0x%x (0x%x bits). Writing uncompressed instead.\n", + m_nDataType, + m_nDataTypeNumBits ); + return false; + } + + /* reset our pointers */ + m_pCurrCount = m_pCounts; + m_pCurrValues = m_pValues; + + /* Get the minimum value - this can be subtracted from each value in the image */ + m_nMin = findMin( &m_nNumBits ); + + /* Go thru the block */ + GUInt32 u32Last, u32Val; + u32Last = valueAsUInt32( 0 ); + u32Val = u32Last; + for( GUInt32 count = 1; count < m_nBlockCount; count++ ) + { + u32Val = valueAsUInt32( count ); + if( u32Val != u32Last ) + { + /* The values have changed - ie a run has come to and end */ + encodeValue( u32Last, count - nLastUnique ); + + if( ( m_pCurrValues - m_pValues ) > (int) m_nBlockSize ) + { + return false; + } + + m_nNumRuns++; + u32Last = u32Val; + nLastUnique = count; + } + } + + /* OK we have done the block but haven't got the last run because we were only looking for a change in values */ + encodeValue( u32Last, m_nBlockCount - nLastUnique ); + m_nNumRuns++; + + /* set the size variables */ + m_nSizeCounts = m_pCurrCount - m_pCounts; + m_nSizeValues = m_pCurrValues - m_pValues; + + // The 13 is for the header size - maybe this should live with some constants somewhere? + return ( m_nSizeCounts + m_nSizeValues + 13 ) < m_nBlockSize; +} + +bool HFACompress::QueryDataTypeSupported( int nHFADataType ) +{ + int nBits = HFAGetDataTypeBits( nHFADataType ); + + return ( nBits == 8 ) || ( nBits == 16 ) || ( nBits == 32 ); +} + diff --git a/Utilities/GDAL/frmts/hfa/hfadataset.cpp b/Utilities/GDAL/frmts/hfa/hfadataset.cpp new file mode 100644 index 0000000000..8c0d71368a --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfadataset.cpp @@ -0,0 +1,2915 @@ +/****************************************************************************** + * $Id: hfadataset.cpp,v 1.78 2006/04/20 19:14:22 fwarmerdam Exp $ + * + * Name: hfadataset.cpp + * Project: Erdas Imagine Driver + * Purpose: Main driver for Erdas Imagine format. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: hfadataset.cpp,v $ + * Revision 1.78 2006/04/20 19:14:22 fwarmerdam + * Don't return null transform as if it were a valid geotransform. + * + * Revision 1.77 2006/04/19 14:07:43 fwarmerdam + * do not create a dataset for a zero band or zero pixel file + * + * Revision 1.76 2006/04/10 14:34:06 fwarmerdam + * Make sure that overviews are treated according to their own intrinsic type, + * not just the type of the base band which may differ in some circumstances. + * + * Revision 1.75 2006/04/03 04:34:19 fwarmerdam + * added support for reading affine polynomial transforms as geotransform + * + * Revision 1.74 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.73 2006/02/13 22:42:35 fwarmerdam + * Fixed metadata related memory leak. + * + * Revision 1.72 2006/01/12 22:15:38 fwarmerdam + * Fix name of albers conical equal area when writing, bug 1035. + * + * Revision 1.71 2005/12/21 05:30:45 fwarmerdam + * return compression type as metadata + * + * Revision 1.70 2005/12/20 17:22:51 fwarmerdam + * Negative proZone values are apparently the FIPS code, instead of + * the ESRI zone numbers. Adjust ESRIToUSGSZone() accordingly. + * + * Revision 1.69 2005/10/24 14:29:58 fwarmerdam + * Ensure that metadata dirty flags are cleared after finisheding + * opening the dataset. + * + * Revision 1.68 2005/10/13 01:28:53 fwarmerdam + * Changed to use underlying multidomain metadata. + * + * Revision 1.67 2005/10/13 01:22:03 fwarmerdam + * Clear old cruft. + * + * Revision 1.66 2005/10/12 18:22:39 fwarmerdam + * ensure bNoRegen is initialized + * + * Revision 1.65 2005/10/05 20:39:10 fwarmerdam + * ensure HFADataset::GetMetadataItem() overridden even if PAM active + * + * Revision 1.64 2005/09/28 19:55:04 fwarmerdam + * Managed the HFA domain ourselves to avoid problems when PAM disabled. + * + * Revision 1.63 2005/09/27 22:11:48 fwarmerdam + * Added String column support for RAT. + * + * Revision 1.62 2005/09/27 18:00:59 fwarmerdam + * Cleanup memory leaks in RAT code. + * + * Revision 1.61 2005/09/24 19:04:48 fwarmerdam + * added preliminary RAT reading code + * + * Revision 1.60 2005/09/17 03:47:16 fwarmerdam + * added dependent overview creation + * + * Revision 1.59 2005/09/16 20:30:33 fwarmerdam + * return HFA_DEPENDENT_FILE in secret metadata, drop .ovr support + * + * Revision 1.58 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.57 2005/07/06 23:12:44 fwarmerdam + * Fixed up "ds" (digital seconds) units on mapinfo + * http://bugzilla.remotesensing.org/show_bug.cgi?id=883 + * + * Revision 1.56 2005/05/23 06:56:48 fwarmerdam + * delay metadata on band + * + * Revision 1.55 2005/05/22 16:32:07 fwarmerdam + * Fixed so that when we write .img files we translate the false easting + * and northing into meters if the source SRS is not in meters. + * + * Revision 1.54 2005/05/13 13:59:54 fwarmerdam + * Added GetDefaultHistogram() method. + * + * Revision 1.53 2005/05/10 00:58:22 fwarmerdam + * added preliminary overview within .img support + * + * Revision 1.52 2005/05/05 15:54:48 fwarmerdam + * PAM Enabled + * + * Revision 1.51 2005/03/06 19:54:12 fwarmerdam + * Make sure a fuller UTM projcs name gets set. + * + * Revision 1.50 2005/02/17 22:21:27 fwarmerdam + * avoid memory leak of bin values + * + * Revision 1.49 2005/01/29 00:58:38 fwarmerdam + * Fixed to use 0 for inv flattening of spherical ellipsoid. Bug 751. + * + * Revision 1.48 2005/01/28 03:42:05 fwarmerdam + * Fixed spelling of Azimuthal, per bug 751. + * http://bugzilla.remotesensing.org/show_bug.cgi?id=751 + * + * Revision 1.47 2005/01/10 18:25:06 fwarmerdam + * added support for getting/setting LAYER_TYPE metadata + * + * Revision 1.46 2005/01/10 17:41:27 fwarmerdam + * added HFA compression support: bug 664 + * + * Revision 1.45 2004/11/05 04:08:01 fwarmerdam + * Don't crash if access to the histogram table files for some reason. + * + * Revision 1.44 2004/10/27 18:06:45 fwarmerdam + * Avoid use of auto-sized arrays ... not really C++ standard. + * + * Revision 1.43 2004/10/26 22:47:23 fwarmerdam + * Fixed at least one botch in SetColorTable(). + * + * Revision 1.42 2004/10/26 17:42:02 fwarmerdam + * support writing color tables with other than 256 entries + * + * Revision 1.41 2004/08/27 03:22:28 warmerda + * hack to support IGNOREUTM option: bug 597 + * + * Revision 1.40 2004/07/16 20:40:32 warmerda + * Added a series of patches from Andreas Wimmer which: + * o Add lots of improved support for metadata. + * o Use USE_SPILL only, instead of SPILL_FILE extra creation option. + * o Added ability to control block sizes. + * + * Revision 1.39 2004/05/17 14:28:28 warmerda + * Added min/max support, and harvesting of other auxilary metadata + * from statistics node. + * + * Revision 1.38 2004/05/11 21:38:34 warmerda + * Handle NAD27 better. + * + * Revision 1.37 2004/05/10 16:59:54 warmerda + * improve EPSG info in coordinate system + * + * Revision 1.36 2003/06/10 16:58:57 warmerda + * Added check on failiure of Create in CreateCopy() + * + * Revision 1.35 2003/05/30 17:30:46 warmerda + * Avoid use of goto. + * + * Revision 1.34 2003/05/30 15:40:35 warmerda + * improved state plane handling with unusual units + * + * Revision 1.33 2003/05/21 17:04:57 warmerda + * significant improvements to reading and writing mapinfo units + * + * Revision 1.32 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.30 2003/04/28 20:50:18 warmerda + * implement dataset level IO, and attempt to optimization createcopy() + * + * Revision 1.29 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.28 2003/04/21 15:50:29 warmerda + * fixup generic overview reading support + * + * Revision 1.27 2003/04/14 19:06:02 warmerda + * Don't override a meaningful SRS name with the psPro->proName. + * + * Revision 1.26 2003/03/18 21:07:02 dron + * Added HFADataset::Delete() method. + * + * Revision 1.25 2003/02/20 14:43:14 warmerda + * fixed quirks in handling ungeoreferenced images + */ + +#include "gdal_pam.h" +#include "gdal_rat.h" +#include "hfa_p.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: hfadataset.cpp,v 1.78 2006/04/20 19:14:22 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_HFA(void); +CPL_C_END + +#ifndef PI +# define PI 3.14159265358979323846 +#endif + +#ifndef R2D +# define R2D (180/PI) +#endif +#ifndef D2R +# define D2R (PI/180) +#endif + +static const char *apszDatumMap[] = { + /* Imagine name, WKT name */ + "NAD27", "North_American_Datum_1927", + "NAD83", "North_American_Datum_1983", + "WGS 84", "WGS_1984", + NULL, NULL +}; + +static const char *apszUnitMap[] = { + "meters", "1.0", + "meter", "1.0", + "m", "1.0", + "centimeters", "0.01", + "centimeter", "0.01", + "cm", "0.01", + "millimeters", "0.001", + "millimeter", "0.001", + "mm", "0.001", + "kilometers", "1000.0", + "kilometer", "1000.0", + "km", "1000.0", + "us_survey_feet", "0.3048006096012192", + "us_survey_foot", "0.3048006096012192", + "feet", "0.3048006096012192", + "foot", "0.3048006096012192", + "ft", "0.3048006096012192", + "international_feet", "0.3048", + "international_foot", "0.3048", + "inches", "0.0254000508001", + "inch", "0.0254000508001", + "in", "0.0254000508001", + "yards", "0.9144", + "yard", "0.9144", + "yd", "0.9144", + "miles", "1304.544", + "mile", "1304.544", + "mi", "1304.544", + "modified_american_feet", "0.3048122530", + "modified_american_foot", "0.3048122530", + "clarke_feet", "0.3047972651", + "clarke_foot", "0.3047972651", + "indian_feet", "0.3047995142", + "indian_foot", "0.3047995142", + NULL, NULL +}; + + +/* ==================================================================== */ +/* Table relating USGS and ESRI state plane zones. */ +/* ==================================================================== */ +int anUsgsEsriZones[] = +{ + 101, 3101, + 102, 3126, + 201, 3151, + 202, 3176, + 203, 3201, + 301, 3226, + 302, 3251, + 401, 3276, + 402, 3301, + 403, 3326, + 404, 3351, + 405, 3376, + 406, 3401, + 407, 3426, + 501, 3451, + 502, 3476, + 503, 3501, + 600, 3526, + 700, 3551, + 901, 3601, + 902, 3626, + 903, 3576, + 1001, 3651, + 1002, 3676, + 1101, 3701, + 1102, 3726, + 1103, 3751, + 1201, 3776, + 1202, 3801, + 1301, 3826, + 1302, 3851, + 1401, 3876, + 1402, 3901, + 1501, 3926, + 1502, 3951, + 1601, 3976, + 1602, 4001, + 1701, 4026, + 1702, 4051, + 1703, 6426, + 1801, 4076, + 1802, 4101, + 1900, 4126, + 2001, 4151, + 2002, 4176, + 2101, 4201, + 2102, 4226, + 2103, 4251, + 2111, 6351, + 2112, 6376, + 2113, 6401, + 2201, 4276, + 2202, 4301, + 2203, 4326, + 2301, 4351, + 2302, 4376, + 2401, 4401, + 2402, 4426, + 2403, 4451, + 2500, 0, + 2501, 4476, + 2502, 4501, + 2503, 4526, + 2600, 0, + 2601, 4551, + 2602, 4576, + 2701, 4601, + 2702, 4626, + 2703, 4651, + 2800, 4676, + 2900, 4701, + 3001, 4726, + 3002, 4751, + 3003, 4776, + 3101, 4801, + 3102, 4826, + 3103, 4851, + 3104, 4876, + 3200, 4901, + 3301, 4926, + 3302, 4951, + 3401, 4976, + 3402, 5001, + 3501, 5026, + 3502, 5051, + 3601, 5076, + 3602, 5101, + 3701, 5126, + 3702, 5151, + 3800, 5176, + 3900, 0, + 3901, 5201, + 3902, 5226, + 4001, 5251, + 4002, 5276, + 4100, 5301, + 4201, 5326, + 4202, 5351, + 4203, 5376, + 4204, 5401, + 4205, 5426, + 4301, 5451, + 4302, 5476, + 4303, 5501, + 4400, 5526, + 4501, 5551, + 4502, 5576, + 4601, 5601, + 4602, 5626, + 4701, 5651, + 4702, 5676, + 4801, 5701, + 4802, 5726, + 4803, 5751, + 4901, 5776, + 4902, 5801, + 4903, 5826, + 4904, 5851, + 5001, 6101, + 5002, 6126, + 5003, 6151, + 5004, 6176, + 5005, 6201, + 5006, 6226, + 5007, 6251, + 5008, 6276, + 5009, 6301, + 5010, 6326, + 5101, 5876, + 5102, 5901, + 5103, 5926, + 5104, 5951, + 5105, 5976, + 5201, 6001, + 5200, 6026, + 5200, 6076, + 5201, 6051, + 5202, 6051, + 5300, 0, + 5400, 0 +}; + + +/************************************************************************/ +/* ==================================================================== */ +/* HFADataset */ +/* ==================================================================== */ +/************************************************************************/ + +class HFARasterBand; + +class CPL_DLL HFADataset : public GDALPamDataset +{ + friend class HFARasterBand; + + HFAHandle hHFA; + + int bMetadataDirty; + + int bGeoDirty; + double adfGeoTransform[6]; + char *pszProjection; + + int bIgnoreUTM; + + CPLErr ReadProjection(); + CPLErr WriteProjection(); + + protected: + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, int, int, int ); + + public: + HFADataset(); + ~HFADataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); + static GDALDataset *CreateCopy( const char * pszFilename, + GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressData ); + static CPLErr Delete( const char *pszFilename ); + + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual CPLErr SetMetadata( char **, const char * = "" ); + virtual CPLErr SetMetadataItem( const char *, const char *, const char * = "" ); + + virtual void FlushCache( void ); + virtual CPLErr IBuildOverviews( const char *pszResampling, + int nOverviews, int *panOverviewList, + int nListBands, int *panBandList, + GDALProgressFunc pfnProgress, + void * pProgressData ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* HFARasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class HFARasterBand : public GDALPamRasterBand +{ + friend class HFADataset; + + GDALColorTable *poCT; + + int nHFADataType; + + int nOverviews; + int nThisOverview; + HFARasterBand **papoOverviewBands; + + HFAHandle hHFA; + + int bMetadataDirty; + + GDALRasterAttributeTable *poDefaultRAT; + + void ReadAuxMetadata(); + + GDALRasterAttributeTable* ReadNamedRAT( const char *pszName ); + + public: + + HFARasterBand( HFADataset *, int, int ); + virtual ~HFARasterBand(); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual const char *GetDescription() const; + virtual void SetDescription( const char * ); + + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview( int ); + + virtual double GetMinimum( int *pbSuccess = NULL ); + virtual double GetMaximum(int *pbSuccess = NULL ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + + virtual CPLErr SetMetadata( char **, const char * = "" ); + virtual CPLErr SetMetadataItem( const char *, const char *, const char * = "" ); + virtual CPLErr BuildOverviews( const char *, int, int *, + GDALProgressFunc, void * ); + + virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, int ** ppanHistogram, + int bForce, + GDALProgressFunc, void *pProgressData); + + virtual const GDALRasterAttributeTable *GetDefaultRAT(); + virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); +}; + +/************************************************************************/ +/* HFARasterBand() */ +/************************************************************************/ + +HFARasterBand::HFARasterBand( HFADataset *poDS, int nBand, int iOverview ) + +{ + int nCompression; + + if( iOverview == -1 ) + this->poDS = poDS; + else + this->poDS = NULL; + + this->hHFA = poDS->hHFA; + this->nBand = nBand; + this->poCT = NULL; + this->nThisOverview = iOverview; + this->papoOverviewBands = NULL; + this->bMetadataDirty = FALSE; + this->poDefaultRAT = NULL; + + HFAGetBandInfo( hHFA, nBand, &nHFADataType, + &nBlockXSize, &nBlockYSize, &nOverviews, &nCompression ); + + if( nCompression != 0 ) + GDALMajorObject::SetMetadataItem( "COMPRESSION", "RLC", + "IMAGE_STRUCTURE" ); + + switch( nHFADataType ) + { + case EPT_u1: + case EPT_u4: + case EPT_u8: + case EPT_s8: + eDataType = GDT_Byte; + break; + + case EPT_u16: + eDataType = GDT_UInt16; + break; + + case EPT_s16: + eDataType = GDT_Int16; + break; + + case EPT_u32: + eDataType = GDT_UInt32; + break; + + case EPT_s32: + eDataType = GDT_Int32; + break; + + case EPT_f32: + eDataType = GDT_Float32; + break; + + case EPT_f64: + eDataType = GDT_Float64; + break; + + case EPT_c64: + eDataType = GDT_CFloat32; + break; + + case EPT_c128: + eDataType = GDT_CFloat64; + break; + + default: + eDataType = GDT_Byte; + /* notdef: this should really report an error, but this isn't + so easy from within constructors. */ + CPLDebug( "GDAL", "Unsupported pixel type in HFARasterBand: %d.", + (int) nHFADataType ); + break; + } + +/* -------------------------------------------------------------------- */ +/* If this is an overview, we need to fetch the actual size, */ +/* and block size. */ +/* -------------------------------------------------------------------- */ + if( iOverview > -1 ) + { + nOverviews = 0; + HFAGetOverviewInfo( hHFA, nBand, iOverview, + &nRasterXSize, &nRasterYSize, + &nBlockXSize, &nBlockYSize ); + } + +/* -------------------------------------------------------------------- */ +/* Collect color table if present. */ +/* -------------------------------------------------------------------- */ + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + int nColors; + + if( iOverview == -1 + && HFAGetPCT( hHFA, nBand, &nColors, + &padfRed, &padfGreen, &padfBlue, &padfAlpha ) == CE_None + && nColors > 0 ) + { + poCT = new GDALColorTable(); + for( int iColor = 0; iColor < nColors; iColor++ ) + { + GDALColorEntry sEntry; + + sEntry.c1 = (short) (padfRed[iColor] * 255); + sEntry.c2 = (short) (padfGreen[iColor] * 255); + sEntry.c3 = (short) (padfBlue[iColor] * 255); + sEntry.c4 = (short) (padfAlpha[iColor] * 255); + poCT->SetColorEntry( iColor, &sEntry ); + } + } + +/* -------------------------------------------------------------------- */ +/* Setup overviews if present */ +/* -------------------------------------------------------------------- */ + if( nThisOverview == -1 && nOverviews > 0 ) + { + papoOverviewBands = (HFARasterBand **) + CPLMalloc(sizeof(void*)*nOverviews); + + for( int iOvIndex = 0; iOvIndex < nOverviews; iOvIndex++ ) + { + papoOverviewBands[iOvIndex] = + new HFARasterBand( poDS, nBand, iOvIndex ); + } + } + + poDefaultRAT = ReadNamedRAT( "Descriptor_Table" ); +} + +/************************************************************************/ +/* ~HFARasterBand() */ +/************************************************************************/ + +HFARasterBand::~HFARasterBand() + +{ + FlushCache(); + + for( int iOvIndex = 0; iOvIndex < nOverviews; iOvIndex++ ) + { + delete papoOverviewBands[iOvIndex]; + } + CPLFree( papoOverviewBands ); + + if( poCT != NULL ) + delete poCT; + + if( poDefaultRAT ) + delete poDefaultRAT; +} + +/************************************************************************/ +/* ReadAuxMetadata() */ +/************************************************************************/ + +void HFARasterBand::ReadAuxMetadata() + +{ + int i; + HFABand *poBand = hHFA->papoBand[nBand-1]; + + // only load metadata for full resolution layer. + if( nThisOverview != -1 ) + return; + + char ** pszAuxMetaData = GetHFAAuxMetaDataList(); + for( i = 0; pszAuxMetaData[i] != NULL; i += 4 ) + { + HFAEntry *poEntry; + + if( strlen(pszAuxMetaData[i]) > 0 ) + poEntry = poBand->poNode->GetNamedChild( pszAuxMetaData[i] ); + else + poEntry = poBand->poNode; + + const char *pszFieldName = pszAuxMetaData[i+1] + 1; + CPLErr eErr = CE_None; + + if( poEntry == NULL ) + continue; + + switch( pszAuxMetaData[i+1][0] ) + { + case 'd': + { + double dfValue; + + dfValue = poEntry->GetDoubleField( pszFieldName, &eErr ); + if( eErr == CE_None ) + { + char szValueAsString[100]; + + sprintf( szValueAsString, "%.14g", dfValue ); + SetMetadataItem( pszAuxMetaData[i+2], + szValueAsString ); + } + } + break; + case 'i': + case 'l': + { + int nValue; + nValue = poEntry->GetIntField( pszFieldName, &eErr ); + if( eErr == CE_None ) + { + char szValueAsString[100]; + + sprintf( szValueAsString, "%d", nValue ); + SetMetadataItem( pszAuxMetaData[i+2], szValueAsString ); + } + } + break; + case 's': + case 'e': + { + const char *pszValue; + pszValue = poEntry->GetStringField( pszFieldName, &eErr ); + if( eErr == CE_None ) + SetMetadataItem( pszAuxMetaData[i+2], pszValue ); + } + break; + default: + CPLAssert( FALSE ); + } + } + // now try to read the histogram + HFAEntry *poEntry = poBand->poNode->GetNamedChild( "Descriptor_Table.Histogram" ); + if ( poEntry != NULL ) + { + int nNumBins = poEntry->GetIntField( "numRows" ); + int nOffset = poEntry->GetIntField( "columnDataPtr" ); + const char * pszType = poEntry->GetStringField( "dataType" ); + int nBinSize = 4; + + if( pszType != NULL && EQUALN( "real", pszType, 4 ) ) + { + nBinSize = 8; + } + unsigned int nBufSize = 1024; + char * pszBinValues = (char *)CPLMalloc( nBufSize ); + pszBinValues[0] = 0; + for ( int nBin = 0; nBin < nNumBins; ++nBin ) + { + VSIFSeekL( hHFA->fp, nOffset + nBin*nBinSize, SEEK_SET ); + char szBuf[32]; + if ( nBinSize == 8 ) + { + double dfValue; + VSIFReadL( &dfValue, nBinSize, 1, hHFA->fp ); + HFAStandard( nBinSize, &dfValue ); + snprintf( szBuf, 31, "%.14g", dfValue ); + } + else + { + int nValue; + VSIFReadL( &nValue, nBinSize, 1, hHFA->fp ); + HFAStandard( nBinSize, &nValue ); + snprintf( szBuf, 31, "%d", nValue ); + } + if ( ( strlen( pszBinValues ) + strlen( szBuf ) + 2 ) > nBufSize ) + { + nBufSize *= 2; + pszBinValues = (char *)realloc( pszBinValues, nBufSize ); + } + strcat( pszBinValues, szBuf ); + strcat( pszBinValues, "|" ); + } + SetMetadataItem( "STATISTICS_HISTOBINVALUES", pszBinValues ); + CPLFree( pszBinValues ); + } +} + +/************************************************************************/ +/* GetNoData() */ +/************************************************************************/ + +double HFARasterBand::GetNoDataValue( int *pbSuccess ) + +{ + double dfNoData; + + if( HFAGetBandNoData( hHFA, nBand, &dfNoData ) ) + { + *pbSuccess = TRUE; + return dfNoData; + } + else + return GDALPamRasterBand::GetNoDataValue( pbSuccess ); +} + +/************************************************************************/ +/* GetMinimum() */ +/************************************************************************/ + +double HFARasterBand::GetMinimum( int *pbSuccess ) + +{ + const char *pszValue = GetMetadataItem( "STATISTICS_MINIMUM" ); + + if( pszValue != NULL ) + { + *pbSuccess = TRUE; + return atof(pszValue); + } + else + { + return GDALRasterBand::GetMinimum( pbSuccess ); + } +} + +/************************************************************************/ +/* GetMaximum() */ +/************************************************************************/ + +double HFARasterBand::GetMaximum( int *pbSuccess ) + +{ + const char *pszValue = GetMetadataItem( "STATISTICS_MAXIMUM" ); + + if( pszValue != NULL ) + { + *pbSuccess = TRUE; + return atof(pszValue); + } + else + { + return GDALRasterBand::GetMaximum( pbSuccess ); + } +} + +/************************************************************************/ +/* GetOverviewCount() */ +/************************************************************************/ + +int HFARasterBand::GetOverviewCount() + +{ + if( nOverviews == 0 ) + return GDALRasterBand::GetOverviewCount(); + else + return nOverviews; +} + +/************************************************************************/ +/* GetOverview() */ +/************************************************************************/ + +GDALRasterBand *HFARasterBand::GetOverview( int i ) + +{ + if( nOverviews == 0 ) + return GDALRasterBand::GetOverview( i ); + else if( i < 0 || i >= nOverviews ) + return NULL; + else + return papoOverviewBands[i]; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr HFARasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + CPLErr eErr; + int nThisDataType = nHFADataType; // overview may differ. + + if( nThisOverview == -1 ) + eErr = HFAGetRasterBlock( hHFA, nBand, nBlockXOff, nBlockYOff, + pImage ); + else + { + eErr = HFAGetOverviewRasterBlock( hHFA, nBand, nThisOverview, + nBlockXOff, nBlockYOff, + pImage ); + nThisDataType = + hHFA->papoBand[nBand-1]->papoOverviews[nThisOverview]->nDataType; + } + + if( eErr == CE_None && nThisDataType == EPT_u4 ) + { + GByte *pabyData = (GByte *) pImage; + + for( int ii = nBlockXSize * nBlockYSize - 2; ii >= 0; ii -= 2 ) + { + pabyData[ii] = pabyData[ii>>1] & 0x0f; + pabyData[ii+1] = (pabyData[ii>>1] & 0xf0) >> 4; + } + } + if( eErr == CE_None && nThisDataType == EPT_u1) + { + GByte *pabyData = (GByte *) pImage; + + for( int ii = nBlockXSize * nBlockYSize - 1; ii >= 0; ii-- ) + { + if( (pabyData[ii>>3] & (1 << (ii & 0x7))) ) + pabyData[ii] = 1; + else + pabyData[ii] = 0; + } + } + + return eErr; +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr HFARasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + if( nThisOverview == -1 ) + return( HFASetRasterBlock( hHFA, nBand, nBlockXOff, nBlockYOff, + pImage ) ); + else + return( HFASetOverviewRasterBlock( hHFA, nBand, nThisOverview, + nBlockXOff, nBlockYOff, + pImage ) ); +} + +/************************************************************************/ +/* GetDescription() */ +/************************************************************************/ + +const char * HFARasterBand::GetDescription() const +{ + const char *pszName = HFAGetBandName( hHFA, nBand ); + + if( pszName == NULL ) + return GDALPamRasterBand::GetDescription(); + else + return pszName; +} + +/************************************************************************/ +/* SetDescription() */ +/************************************************************************/ +void HFARasterBand::SetDescription( const char *pszName ) +{ + HFASetBandName( hHFA, nBand, pszName ); +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp HFARasterBand::GetColorInterpretation() + +{ + if( poCT != NULL ) + return GCI_PaletteIndex; + else + return GCI_Undefined; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *HFARasterBand::GetColorTable() + +{ + return poCT; +} + +/************************************************************************/ +/* SetColorTable() */ +/************************************************************************/ + +CPLErr HFARasterBand::SetColorTable( GDALColorTable * poCTable ) + +{ + int nColors = poCTable->GetColorEntryCount(); + +/* -------------------------------------------------------------------- */ +/* Write out the colortable, and update the configuration. */ +/* -------------------------------------------------------------------- */ + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + + padfRed = (double *) CPLMalloc(sizeof(double) * nColors); + padfGreen = (double *) CPLMalloc(sizeof(double) * nColors); + padfBlue = (double *) CPLMalloc(sizeof(double) * nColors); + padfAlpha = (double *) CPLMalloc(sizeof(double) * nColors); + + for( int iColor = 0; iColor < nColors; iColor++ ) + { + GDALColorEntry sRGB; + + poCTable->GetColorEntryAsRGB( iColor, &sRGB ); + + padfRed[iColor] = sRGB.c1 / 255.0; + padfGreen[iColor] = sRGB.c2 / 255.0; + padfBlue[iColor] = sRGB.c3 / 255.0; + padfAlpha[iColor] = sRGB.c4 / 255.0; + } + + HFASetPCT( hHFA, nBand, nColors, + padfRed, padfGreen, padfBlue, padfAlpha); + + CPLFree( padfRed ); + CPLFree( padfGreen ); + CPLFree( padfBlue ); + CPLFree( padfAlpha ); + + if( poCT ) + delete poCT; + + poCT = poCTable->Clone(); + + return CE_None; +} + +/************************************************************************/ +/* SetMetadata() */ +/************************************************************************/ + +CPLErr HFARasterBand::SetMetadata( char **papszMDIn, const char *pszDomain ) + +{ + bMetadataDirty = TRUE; + + return GDALPamRasterBand::SetMetadata( papszMDIn, pszDomain ); +} + +/************************************************************************/ +/* SetMetadata() */ +/************************************************************************/ + +CPLErr HFARasterBand::SetMetadataItem( const char *pszTag, const char *pszValue, + const char *pszDomain ) + +{ + bMetadataDirty = TRUE; + + return GDALPamRasterBand::SetMetadataItem( pszTag, pszValue, pszDomain ); +} + +/************************************************************************/ +/* BuildOverviews() */ +/************************************************************************/ + +CPLErr HFARasterBand::BuildOverviews( const char *pszResampling, + int nReqOverviews, int *panOverviewList, + GDALProgressFunc pfnProgress, + void *pProgressData ) + +{ + int iOverview; + GDALRasterBand **papoOvBands; + int bNoRegen = FALSE; + + if( nThisOverview != -1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to build overviews on an overview layer." ); + + return CE_Failure; + } + + papoOvBands = (GDALRasterBand **) CPLCalloc(sizeof(void*),nReqOverviews); + + if( EQUALN(pszResampling,"NO_REGEN:",9) ) + { + pszResampling += 9; + bNoRegen = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Loop over overview levels requested. */ +/* -------------------------------------------------------------------- */ + for( iOverview = 0; iOverview < nReqOverviews; iOverview++ ) + { +/* -------------------------------------------------------------------- */ +/* Find this overview level. */ +/* -------------------------------------------------------------------- */ + int i, iResult = -1, nReqOvLevel; + + nReqOvLevel = + GDALOvLevelAdjust(panOverviewList[iOverview],nRasterXSize); + + for( i = 0; i < nOverviews && papoOvBands[iOverview] == NULL; i++ ) + { + int nThisOvLevel; + + nThisOvLevel = (int) (0.5 + GetXSize() + / (double) papoOverviewBands[i]->GetXSize()); + + if( nReqOvLevel == nThisOvLevel ) + papoOvBands[iOverview] = papoOverviewBands[i]; + } + +/* -------------------------------------------------------------------- */ +/* If this overview level does not yet exist, create it now. */ +/* -------------------------------------------------------------------- */ + if( papoOvBands[iOverview] == NULL ) + { + iResult = HFACreateOverview( hHFA, nBand, panOverviewList[iOverview] ); + if( iResult < 0 ) + return CE_Failure; + + nOverviews = iResult + 1; + papoOverviewBands = (HFARasterBand **) + CPLRealloc( papoOverviewBands, sizeof(void*) * nOverviews); + papoOverviewBands[iResult] = new HFARasterBand( + (HFADataset *) poDS, nBand, iResult ); + + papoOvBands[iOverview] = papoOverviewBands[iResult]; + } + + } + +/* -------------------------------------------------------------------- */ +/* Regenerate the overviews. */ +/* -------------------------------------------------------------------- */ + CPLErr eErr = CE_None; + + if( !bNoRegen ) + eErr = GDALRegenerateOverviews( this, nReqOverviews, papoOvBands, + pszResampling, + pfnProgress, pProgressData ); + + CPLFree( papoOvBands ); + + return CE_None; +} + +/************************************************************************/ +/* GetDefaultHistogram() */ +/************************************************************************/ + +CPLErr +HFARasterBand::GetDefaultHistogram( double *pdfMin, double *pdfMax, + int *pnBuckets, int ** ppanHistogram, + int bForce, + GDALProgressFunc pfnProgress, + void *pProgressData) + +{ + if( GetMetadataItem( "STATISTICS_HISTOBINVALUES" ) != NULL + && GetMetadataItem( "STATISTICS_MINIMUM" ) != NULL + && GetMetadataItem( "STATISTICS_MAXIMUM" ) != NULL ) + { + int i; + const char *pszNextBin; + const char *pszBinValues = + GetMetadataItem( "STATISTICS_HISTOBINVALUES" ); + + *pdfMin = atof(GetMetadataItem("STATISTICS_MINIMUM")); + *pdfMax = atof(GetMetadataItem("STATISTICS_MAXIMUM")); + + *pnBuckets = 0; + for( i = 0; pszBinValues[i] != '\0'; i++ ) + { + if( pszBinValues[i] == '|' ) + (*pnBuckets)++; + } + + *ppanHistogram = (int *) CPLCalloc(sizeof(int),*pnBuckets); + + pszNextBin = pszBinValues; + for( i = 0; i < *pnBuckets; i++ ) + { + (*ppanHistogram)[i] = atoi(pszNextBin); + + while( *pszNextBin != '|' && *pszNextBin != '\0' ) + pszNextBin++; + if( *pszNextBin == '|' ) + pszNextBin++; + } + + // Adjust min/max to reflect outer edges of buckets. + double dfBucketWidth = (*pdfMax - *pdfMin) / (*pnBuckets-1); + *pdfMax += 0.5 * dfBucketWidth; + *pdfMin -= 0.5 * dfBucketWidth; + + return CE_None; + } + else + return GDALPamRasterBand::GetDefaultHistogram( pdfMin, pdfMax, + pnBuckets,ppanHistogram, + bForce, + pfnProgress, + pProgressData ); +} + +/************************************************************************/ +/* SetDefaultRAT() */ +/************************************************************************/ + +CPLErr HFARasterBand::SetDefaultRAT( const GDALRasterAttributeTable * poRAT ) + +{ + return GDALPamRasterBand::SetDefaultRAT( poRAT ); +} + +/************************************************************************/ +/* GetDefaultRAT() */ +/************************************************************************/ + +const GDALRasterAttributeTable *HFARasterBand::GetDefaultRAT() + +{ + return poDefaultRAT; +} + +/************************************************************************/ +/* ReadNamedRAT() */ +/************************************************************************/ + +GDALRasterAttributeTable *HFARasterBand::ReadNamedRAT( const char *pszName ) + +{ +/* -------------------------------------------------------------------- */ +/* Find the requested table. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poDT = hHFA->papoBand[nBand-1]->poNode->GetNamedChild(pszName); + + if( poDT == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding RAT. */ +/* -------------------------------------------------------------------- */ + GDALRasterAttributeTable *poRAT = NULL; + int nRowCount = poDT->GetIntField( "numRows" ); + + poRAT = new GDALRasterAttributeTable(); + +/* -------------------------------------------------------------------- */ +/* Scan under table for columns. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poDTChild; + + for( poDTChild = poDT->GetChild(); + poDTChild != NULL; + poDTChild = poDTChild->GetNext() ) + { + if( EQUAL(poDTChild->GetType(),"Edsc_BinFunction") ) + { + double dfMax = poDTChild->GetDoubleField( "maxLimit" ); + double dfMin = poDTChild->GetDoubleField( "minLimit" ); + int nBinCount = poDTChild->GetIntField( "numBins" ); + + if( nBinCount == nRowCount + && dfMax != dfMin && nBinCount != 0 ) + poRAT->SetLinearBinning( dfMin, + (dfMax-dfMin) / (nBinCount-1) ); + } + + if( !EQUAL(poDTChild->GetType(),"Edsc_Column") ) + continue; + + int nOffset = poDTChild->GetIntField( "columnDataPtr" ); + const char * pszType = poDTChild->GetStringField( "dataType" ); + GDALRATFieldUsage eType = GFU_Generic; + int i; + + if( pszType == NULL || nOffset == 0 ) + continue; + + if( EQUAL(poDTChild->GetName(),"Histogram") ) + eType = GFU_Generic; + else if( EQUAL(poDTChild->GetName(),"Red") ) + eType = GFU_Red; + else if( EQUAL(poDTChild->GetName(),"Green") ) + eType = GFU_Green; + else if( EQUAL(poDTChild->GetName(),"Blue") ) + eType = GFU_Blue; + else if( EQUAL(poDTChild->GetName(),"Alpha") ) + eType = GFU_Alpha; + else if( EQUAL(poDTChild->GetName(),"Class_Names") ) + eType = GFU_Name; + + if( EQUAL(pszType,"real") ) + { + double *padfColData = (double*)CPLMalloc(nRowCount*sizeof(double)); + + VSIFSeekL( hHFA->fp, nOffset, SEEK_SET ); + VSIFReadL( padfColData, nRowCount, sizeof(double), hHFA->fp ); +#ifdef CPL_MSB + GDALSwapWords( padfColData, 8, nRowCount, 8 ); +#endif + poRAT->CreateColumn( poDTChild->GetName(), GFT_Real, eType ); + for( i = 0; i < nRowCount; i++ ) + poRAT->SetValue( i, poRAT->GetColumnCount()-1, padfColData[i]); + + CPLFree( padfColData ); + } + else if( EQUAL(pszType,"string") ) + { + int nMaxNumChars = poDTChild->GetIntField( "maxNumChars" ); + char *pachColData = (char*)CPLCalloc(nRowCount+1,nMaxNumChars); + + VSIFSeekL( hHFA->fp, nOffset, SEEK_SET ); + VSIFReadL( pachColData, nRowCount, nMaxNumChars, hHFA->fp ); + + poRAT->CreateColumn(poDTChild->GetName(),GFT_String,eType); + for( i = 0; i < nRowCount; i++ ) + { + CPLString oRowVal; + + oRowVal.assign( pachColData+nMaxNumChars*i, nMaxNumChars ); + poRAT->SetValue( i, poRAT->GetColumnCount()-1, + oRowVal.c_str() ); + } + + CPLFree( pachColData ); + } + else if( EQUALN(pszType,"int",3) ) + { + GInt32 *panColData = (GInt32*)CPLMalloc(nRowCount*sizeof(GInt32)); + + VSIFSeekL( hHFA->fp, nOffset, SEEK_SET ); + VSIFReadL( panColData, nRowCount, sizeof(GInt32), hHFA->fp ); +#ifdef CPL_MSB + GDALSwapWords( panColData, 4, nRowCount, 4 ); +#endif + poRAT->CreateColumn(poDTChild->GetName(),GFT_Integer,eType); + for( i = 0; i < nRowCount; i++ ) + poRAT->SetValue( i, poRAT->GetColumnCount()-1, panColData[i] ); + + CPLFree( panColData ); + } + } + + return poRAT; +} + +/************************************************************************/ +/* ==================================================================== */ +/* HFADataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HFADataset() */ +/************************************************************************/ + +HFADataset::HFADataset() + +{ + hHFA = NULL; + bGeoDirty = FALSE; + pszProjection = CPLStrdup(""); + this->bMetadataDirty = FALSE; + bIgnoreUTM = FALSE; +} + +/************************************************************************/ +/* ~HFADataset() */ +/************************************************************************/ + +HFADataset::~HFADataset() + +{ + FlushCache(); + + if( hHFA != NULL ) + HFAClose( hHFA ); + + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* FlushCache() */ +/************************************************************************/ + +void HFADataset::FlushCache() + +{ + GDALPamDataset::FlushCache(); + + if( eAccess != GA_Update ) + return; + + if( bGeoDirty ) + WriteProjection(); + + if( bMetadataDirty && GetMetadata() != NULL ) + { + HFASetMetadata( hHFA, 0, GetMetadata() ); + bMetadataDirty = FALSE; + } + + for( int iBand = 0; iBand < nBands; iBand++ ) + { + HFARasterBand *poBand = (HFARasterBand *) GetRasterBand(iBand+1); + if( poBand->bMetadataDirty && poBand->GetMetadata() != NULL ) + { + HFASetMetadata( hHFA, iBand+1, poBand->GetMetadata() ); + poBand->bMetadataDirty = FALSE; + } + } +} + +/************************************************************************/ +/* WriteProjection() */ +/************************************************************************/ + +CPLErr HFADataset::WriteProjection() + +{ + Eprj_Datum sDatum; + Eprj_ProParameters sPro; + Eprj_MapInfo sMapInfo; + OGRSpatialReference oSRS; + OGRSpatialReference *poGeogSRS = NULL; + int bHaveSRS; + char *pszP = pszProjection; + + bGeoDirty = FALSE; + + if( pszProjection != NULL && strlen(pszProjection) > 0 + && oSRS.importFromWkt( &pszP ) == OGRERR_NONE ) + bHaveSRS = TRUE; + else + bHaveSRS = FALSE; + +/* -------------------------------------------------------------------- */ +/* Initialize projection and datum. */ +/* -------------------------------------------------------------------- */ + memset( &sPro, 0, sizeof(sPro) ); + memset( &sDatum, 0, sizeof(sDatum) ); + memset( &sMapInfo, 0, sizeof(sMapInfo) ); + +/* -------------------------------------------------------------------- */ +/* Collect datum information. */ +/* -------------------------------------------------------------------- */ + if( bHaveSRS ) + { + poGeogSRS = oSRS.CloneGeogCS(); + } + + if( poGeogSRS ) + { + int i; + + sDatum.datumname = (char *) poGeogSRS->GetAttrValue( "GEOGCS|DATUM" ); + + /* WKT to Imagine translation */ + for( i = 0; apszDatumMap[i] != NULL; i += 2 ) + { + if( EQUAL(sDatum.datumname,apszDatumMap[i+1]) ) + { + sDatum.datumname = (char *) apszDatumMap[i]; + break; + } + } + + if( poGeogSRS->GetTOWGS84( sDatum.params ) == OGRERR_NONE ) + sDatum.type = EPRJ_DATUM_PARAMETRIC; + else if( EQUAL(sDatum.datumname,"NAD27") ) + { + sDatum.type = EPRJ_DATUM_GRID; + sDatum.gridname = "nadcon.dat"; + } + else + { + /* we will default to this (effectively WGS84) for now */ + sDatum.type = EPRJ_DATUM_PARAMETRIC; + } + + sPro.proSpheroid.sphereName = (char *) + poGeogSRS->GetAttrValue( "GEOGCS|DATUM|SPHEROID" ); + sPro.proSpheroid.a = poGeogSRS->GetSemiMajor(); + sPro.proSpheroid.b = poGeogSRS->GetSemiMinor(); + sPro.proSpheroid.radius = sPro.proSpheroid.a; + + double a2 = sPro.proSpheroid.a*sPro.proSpheroid.a; + double b2 = sPro.proSpheroid.b*sPro.proSpheroid.b; + + sPro.proSpheroid.eSquared = (a2-b2)/a2; + } + +/* -------------------------------------------------------------------- */ +/* Recognise various projections. */ +/* -------------------------------------------------------------------- */ + const char * pszProjName = NULL; + + if( bHaveSRS ) + pszProjName = oSRS.GetAttrValue( "PROJCS|PROJECTION" ); + + if( pszProjName == NULL ) + { + if( bHaveSRS && oSRS.IsGeographic() ) + { + sPro.proNumber = EPRJ_LATLONG; + sPro.proName = "Geographic (Lat/Lon)"; + } + } + + /* FIXME/NOTDEF/TODO: Add State Plane */ + else if( !bIgnoreUTM && oSRS.GetUTMZone( NULL ) != 0 ) + { + int bNorth, nZone; + + nZone = oSRS.GetUTMZone( &bNorth ); + sPro.proNumber = EPRJ_UTM; + sPro.proName = "UTM"; + sPro.proZone = nZone; + if( bNorth ) + sPro.proParams[3] = 1.0; + else + sPro.proParams[3] = -1.0; + } + + else if( EQUAL(pszProjName,SRS_PT_ALBERS_CONIC_EQUAL_AREA) ) + { + sPro.proNumber = EPRJ_ALBERS_CONIC_EQUAL_AREA; + sPro.proName = "Albers Conical Equal Area"; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_1)*D2R; + sPro.proParams[3] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_2)*D2R; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ) + { + sPro.proNumber = EPRJ_LAMBERT_CONFORMAL_CONIC; + sPro.proName = "Lambert Conformal Conic"; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_1)*D2R; + sPro.proParams[3] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_2)*D2R; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_MERCATOR_1SP) ) + { + sPro.proNumber = EPRJ_MERCATOR; + sPro.proName = "Mercator"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + /* hopefully the scale factor is 1.0! */ + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_POLAR_STEREOGRAPHIC) ) + { + sPro.proNumber = EPRJ_POLAR_STEREOGRAPHIC; + sPro.proName = "Polar Stereographic"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + /* hopefully the scale factor is 1.0! */ + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_POLYCONIC) ) + { + sPro.proNumber = EPRJ_POLYCONIC; + sPro.proName = "Polyconic"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_EQUIDISTANT_CONIC) ) + { + sPro.proNumber = EPRJ_EQUIDISTANT_CONIC; + sPro.proName = "Equidistant Conic"; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_1)*D2R; + sPro.proParams[3] = oSRS.GetProjParm(SRS_PP_STANDARD_PARALLEL_2)*D2R; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + sPro.proParams[8] = 1.0; + } + else if( EQUAL(pszProjName,SRS_PT_TRANSVERSE_MERCATOR) ) + { + sPro.proNumber = EPRJ_TRANSVERSE_MERCATOR; + sPro.proName = "Transverse Mercator"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_SCALE_FACTOR,1.0); + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_STEREOGRAPHIC) ) + { + sPro.proNumber = EPRJ_STEREOGRAPHIC_EXTENDED; + sPro.proName = "Stereographic (Extended)"; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_SCALE_FACTOR,1.0); + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) ) + { + sPro.proNumber = EPRJ_LAMBERT_AZIMUTHAL_EQUAL_AREA; + sPro.proName = "Lambert Azimuthal Equal-area"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_AZIMUTHAL_EQUIDISTANT) ) + { + sPro.proNumber = EPRJ_AZIMUTHAL_EQUIDISTANT; + sPro.proName = "Azimuthal Equidistant"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_GNOMONIC) ) + { + sPro.proNumber = EPRJ_GNOMONIC; + sPro.proName = "Gnomonic"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_ORTHOGRAPHIC) ) + { + sPro.proNumber = EPRJ_ORTHOGRAPHIC; + sPro.proName = "Orthographic"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_SINUSOIDAL) ) + { + sPro.proNumber = EPRJ_SINUSOIDAL; + sPro.proName = "Sinusoidal"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_EQUIRECTANGULAR) ) + { + sPro.proNumber = EPRJ_EQUIRECTANGULAR; + sPro.proName = "Equirectangular"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_MILLER_CYLINDRICAL) ) + { + sPro.proNumber = EPRJ_MILLER_CYLINDRICAL; + sPro.proName = "Miller Cylindrical"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + /* hopefully the latitude is zero! */ + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_VANDERGRINTEN) ) + { + sPro.proNumber = EPRJ_VANDERGRINTEN; + sPro.proName = "Van der Grinten"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_HOTINE_OBLIQUE_MERCATOR) ) + { + sPro.proNumber = EPRJ_HOTINE_OBLIQUE_MERCATOR; + sPro.proName = "Oblique Mercator (Hotine)"; + sPro.proParams[2] = oSRS.GetProjParm(SRS_PP_SCALE_FACTOR,1.0); + sPro.proParams[3] = oSRS.GetProjParm(SRS_PP_AZIMUTH)*D2R; + /* hopefully the rectified grid angle is zero */ + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + sPro.proParams[12] = 1.0; + } + else if( EQUAL(pszProjName,SRS_PT_ROBINSON) ) + { + sPro.proNumber = EPRJ_ROBINSON; + sPro.proName = "Robinson"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_LONGITUDE_OF_CENTER)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_MOLLWEIDE) ) + { + sPro.proNumber = EPRJ_MOLLWEIDE; + sPro.proName = "Mollweide"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_ECKERT_IV) ) + { + sPro.proNumber = EPRJ_ECKERT_IV; + sPro.proName = "Eckert IV"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_ECKERT_VI) ) + { + sPro.proNumber = EPRJ_ECKERT_VI; + sPro.proName = "Eckert VI"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_GALL_STEREOGRAPHIC) ) + { + sPro.proNumber = EPRJ_GALL_STEREOGRAPHIC; + sPro.proName = "Gall Stereographic"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else if( EQUAL(pszProjName,SRS_PT_CASSINI_SOLDNER) ) + { + sPro.proNumber = EPRJ_CASSINI; + sPro.proName = "Cassini"; + sPro.proParams[4] = oSRS.GetProjParm(SRS_PP_CENTRAL_MERIDIAN)*D2R; + sPro.proParams[5] = oSRS.GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN)*D2R; + sPro.proParams[6] = oSRS.GetProjParm(SRS_PP_FALSE_EASTING); + sPro.proParams[7] = oSRS.GetProjParm(SRS_PP_FALSE_NORTHING); + } + else + { + CPLError( CE_Warning, CPLE_NotSupported, + "Projection %s not supported for translation to Imagine.", + pszProjName ); + } + +/* -------------------------------------------------------------------- */ +/* MapInfo */ +/* -------------------------------------------------------------------- */ + + if( bHaveSRS && sPro.proName != NULL ) + sMapInfo.proName = sPro.proName; + else + sMapInfo.proName = "Unknown"; + + sMapInfo.upperLeftCenter.x = + adfGeoTransform[0] + adfGeoTransform[1]*0.5; + sMapInfo.upperLeftCenter.y = + adfGeoTransform[3] + adfGeoTransform[5]*0.5; + + sMapInfo.lowerRightCenter.x = + adfGeoTransform[0] + adfGeoTransform[1] * (GetRasterXSize()-0.5); + sMapInfo.lowerRightCenter.y = + adfGeoTransform[3] + adfGeoTransform[5] * (GetRasterYSize()-0.5); + + sMapInfo.pixelSize.width = ABS(adfGeoTransform[1]); + sMapInfo.pixelSize.height = ABS(adfGeoTransform[5]); + +/* -------------------------------------------------------------------- */ +/* Handle units. Try to match up with a known name. */ +/* -------------------------------------------------------------------- */ + sMapInfo.units = "meters"; + + if( bHaveSRS && oSRS.IsGeographic() ) + sMapInfo.units = "dd"; + else if( bHaveSRS && oSRS.GetLinearUnits() != 1.0 ) + { + double dfClosestDiff = 100.0; + int iClosest=-1, iUnit; + char *pszUnitName = NULL; + double dfActualSize = oSRS.GetLinearUnits( &pszUnitName ); + + for( iUnit = 0; apszUnitMap[iUnit] != NULL; iUnit += 2 ) + { + if( fabs(atof(apszUnitMap[iUnit+1]) - dfActualSize) < dfClosestDiff ) + { + iClosest = iUnit; + dfClosestDiff = fabs(atof(apszUnitMap[iUnit+1])-dfActualSize); + } + } + + if( iClosest == -1 || fabs(dfClosestDiff/dfActualSize) > 0.0001 ) + { + CPLError( CE_Warning, CPLE_NotSupported, + "Unable to identify Erdas units matching %s/%gm,\n" + "output units will be wrong.", + pszUnitName, dfActualSize ); + } + else + sMapInfo.units = (char *) apszUnitMap[iClosest]; + + /* We need to convert false easting and northing to meters. */ + sPro.proParams[6] *= dfActualSize; + sPro.proParams[7] *= dfActualSize; + } + +/* -------------------------------------------------------------------- */ +/* Write out definitions. */ +/* -------------------------------------------------------------------- */ + HFASetMapInfo( hHFA, &sMapInfo ); + + if( bHaveSRS && sPro.proName != NULL ) + { + HFASetProParameters( hHFA, &sPro ); + HFASetDatum( hHFA, &sDatum ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup */ +/* -------------------------------------------------------------------- */ + if( poGeogSRS != NULL ) + delete poGeogSRS; + + return CE_None; +} + +/************************************************************************/ +/* ESRIToUSGSZone() */ +/* */ +/* Convert ESRI style state plane zones to USGS style state */ +/* plane zones. */ +/************************************************************************/ + +static int ESRIToUSGSZone( int nESRIZone ) + +{ + int nPairs = sizeof(anUsgsEsriZones) / (2*sizeof(int)); + int i; + + if( nESRIZone < 0 ) + return ABS(nESRIZone); + + for( i = 0; i < nPairs; i++ ) + { + if( anUsgsEsriZones[i*2+1] == nESRIZone ) + return anUsgsEsriZones[i*2]; + } + + return 0; +} + +/************************************************************************/ +/* ReadProjection() */ +/************************************************************************/ + +CPLErr HFADataset::ReadProjection() + +{ + const Eprj_Datum *psDatum; + const Eprj_ProParameters *psPro; + const Eprj_MapInfo *psMapInfo; + OGRSpatialReference oSRS; + + psDatum = HFAGetDatum( hHFA ); + psPro = HFAGetProParameters( hHFA ); + psMapInfo = HFAGetMapInfo( hHFA ); + + if( psPro == NULL && psMapInfo != NULL ) + { + oSRS.SetLocalCS( psMapInfo->proName ); + } + + else if( psPro == NULL ) + { + return CE_Failure; + } + + else if( psPro->proType == EPRJ_EXTERNAL ) + { + oSRS.SetLocalCS( psPro->proName ); + } + + else if( psPro->proNumber != EPRJ_LATLONG ) + { + oSRS.SetProjCS( psPro->proName ); + } + +/* -------------------------------------------------------------------- */ +/* Handle units. It is important to deal with this first so */ +/* that the projection Set methods will automatically do */ +/* translation of linear values (like false easting) to PROJCS */ +/* units from meters. Erdas linear projection values are */ +/* always in meters. */ +/* -------------------------------------------------------------------- */ + int iUnitIndex = 0; + + if( oSRS.IsProjected() || oSRS.IsLocal() ) + { + if( psMapInfo ) + { + for( iUnitIndex = 0; + apszUnitMap[iUnitIndex] != NULL; + iUnitIndex += 2 ) + { + if( EQUAL(apszUnitMap[iUnitIndex], psMapInfo->units ) ) + break; + } + + if( apszUnitMap[iUnitIndex] == NULL ) + iUnitIndex = 0; + + oSRS.SetLinearUnits( psMapInfo->units, + atof(apszUnitMap[iUnitIndex+1]) ); + } + else + oSRS.SetLinearUnits( SRS_UL_METER, 1.0 ); + } + + if( psPro == NULL ) + { + if( oSRS.IsLocal() ) + { + CPLFree( pszProjection ); + pszProjection = NULL; + + if( oSRS.exportToWkt( &pszProjection ) == OGRERR_NONE ) + return CE_None; + else + { + pszProjection = NULL; + return CE_Failure; + } + } + else + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Try to work out ellipsoid and datum information. */ +/* -------------------------------------------------------------------- */ + const char *pszDatumName = psPro->proSpheroid.sphereName; + const char *pszEllipsoidName = psPro->proSpheroid.sphereName; + double dfInvFlattening; + + if( psDatum != NULL ) + { + int i; + + pszDatumName = psDatum->datumname; + + /* Imagine to WKT translation */ + for( i = 0; apszDatumMap[i] != NULL; i += 2 ) + { + if( EQUAL(pszDatumName,apszDatumMap[i]) ) + { + pszDatumName = apszDatumMap[i+1]; + break; + } + } + } + + if( psPro->proSpheroid.a == 0.0 ) + ((Eprj_ProParameters *) psPro)->proSpheroid.a = 6378137.0; + if( psPro->proSpheroid.b == 0.0 ) + ((Eprj_ProParameters *) psPro)->proSpheroid.b = 6356752.3; + + if( fabs(psPro->proSpheroid.b - psPro->proSpheroid.a) < 0.001 ) + dfInvFlattening = 0.0; /* special value for sphere. */ + else + dfInvFlattening = 1.0/(1.0-psPro->proSpheroid.b/psPro->proSpheroid.a); + +/* -------------------------------------------------------------------- */ +/* Handle different projection methods. */ +/* -------------------------------------------------------------------- */ + switch( psPro->proNumber ) + { + case EPRJ_LATLONG: + break; + + case EPRJ_UTM: + // We change this to unnamed so that SetUTM will set the long + // UTM description. + oSRS.SetProjCS( "unnamed" ); + oSRS.SetUTM( psPro->proZone, psPro->proParams[3] >= 0.0 ); + break; + + case EPRJ_STATE_PLANE: + { + char *pszUnitsName = NULL; + double dfLinearUnits = oSRS.GetLinearUnits( &pszUnitsName ); + + pszUnitsName = CPLStrdup( pszUnitsName ); + + /* Set state plane zone. Set NAD83/27 on basis of spheroid */ + oSRS.SetStatePlane( ESRIToUSGSZone(psPro->proZone), + fabs(psPro->proSpheroid.a - 6378137.0)< 1.0, + pszUnitsName, dfLinearUnits ); + + CPLFree( pszUnitsName ); + } + break; + + case EPRJ_ALBERS_CONIC_EQUAL_AREA: + oSRS.SetACEA( psPro->proParams[2]*R2D, psPro->proParams[3]*R2D, + psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_LAMBERT_CONFORMAL_CONIC: + oSRS.SetLCC( psPro->proParams[2]*R2D, psPro->proParams[3]*R2D, + psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_MERCATOR: + oSRS.SetMercator( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + 1.0, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_POLAR_STEREOGRAPHIC: + oSRS.SetPS( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + 1.0, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_POLYCONIC: + oSRS.SetPolyconic( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_EQUIDISTANT_CONIC: + double dfStdParallel2; + + if( psPro->proParams[8] != 0.0 ) + dfStdParallel2 = psPro->proParams[3]*R2D; + else + dfStdParallel2 = psPro->proParams[2]*R2D; + oSRS.SetEC( psPro->proParams[2]*R2D, dfStdParallel2, + psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_TRANSVERSE_MERCATOR: + oSRS.SetTM( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[2], + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_STEREOGRAPHIC: + oSRS.SetStereographic( psPro->proParams[5]*R2D,psPro->proParams[4]*R2D, + 1.0, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_LAMBERT_AZIMUTHAL_EQUAL_AREA: + oSRS.SetLAEA( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_AZIMUTHAL_EQUIDISTANT: + oSRS.SetAE( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_GNOMONIC: + oSRS.SetGnomonic( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_ORTHOGRAPHIC: + oSRS.SetOrthographic( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_SINUSOIDAL: + oSRS.SetSinusoidal( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_EQUIRECTANGULAR: + oSRS.SetEquirectangular( + psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_MILLER_CYLINDRICAL: + oSRS.SetMC( 0.0, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_VANDERGRINTEN: + oSRS.SetVDG( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_HOTINE_OBLIQUE_MERCATOR: + if( psPro->proParams[12] > 0.0 ) + oSRS.SetHOM( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[3]*R2D, 0.0, + psPro->proParams[2], + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_ROBINSON: + oSRS.SetRobinson( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_MOLLWEIDE: + oSRS.SetMollweide( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_ECKERT_IV: + oSRS.SetEckertIV( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_ECKERT_VI: + oSRS.SetEckertVI( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_GALL_STEREOGRAPHIC: + oSRS.SetGS( psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_CASSINI: + oSRS.SetCS( psPro->proParams[5]*R2D, psPro->proParams[4]*R2D, + psPro->proParams[6], psPro->proParams[7] ); + break; + + case EPRJ_STEREOGRAPHIC_EXTENDED: + oSRS.SetStereographic( psPro->proParams[5]*R2D,psPro->proParams[4]*R2D, + psPro->proParams[2], + psPro->proParams[6], psPro->proParams[7] ); + break; + + + default: + oSRS.SetLocalCS( psPro->proName ); + break; + } + +/* -------------------------------------------------------------------- */ +/* Try and set the GeogCS information. */ +/* -------------------------------------------------------------------- */ + if( oSRS.GetAttrNode("GEOGCS") == NULL + && oSRS.GetAttrNode("LOCAL_CS") == NULL ) + { + if( EQUAL(pszDatumName,"WGS 84") ) + oSRS.SetWellKnownGeogCS( "WGS84" ); + else if( strstr(pszDatumName,"NAD27") != NULL + || EQUAL(pszDatumName,"North_American_Datum_1927") ) + oSRS.SetWellKnownGeogCS( "NAD27" ); + else if( EQUAL(pszDatumName,"North_American_Datum_1983") + || strstr(pszDatumName,"NAD83") != NULL ) + oSRS.SetWellKnownGeogCS( "NAD83" ); + else + oSRS.SetGeogCS( pszDatumName, pszDatumName, pszEllipsoidName, + psPro->proSpheroid.a, dfInvFlattening ); + + if( psDatum != NULL && psDatum->type == EPRJ_DATUM_PARAMETRIC ) + { + oSRS.SetTOWGS84( psDatum->params[0], + psDatum->params[1], + psDatum->params[2], + psDatum->params[3], + psDatum->params[4], + psDatum->params[5], + psDatum->params[6] ); + } + } + +/* -------------------------------------------------------------------- */ +/* Try to insert authority information if possible. Fixup any */ +/* ordering oddities. */ +/* -------------------------------------------------------------------- */ + oSRS.AutoIdentifyEPSG(); + oSRS.Fixup(); + +/* -------------------------------------------------------------------- */ +/* Get the WKT representation of the coordinate system. */ +/* -------------------------------------------------------------------- */ + CPLFree( pszProjection ); + pszProjection = NULL; + + if( oSRS.exportToWkt( &pszProjection ) == OGRERR_NONE ) + return CE_None; + else + { + pszProjection = NULL; + return CE_Failure; + } +} + +/************************************************************************/ +/* IBuildOverviews() */ +/************************************************************************/ + +CPLErr HFADataset::IBuildOverviews( const char *pszResampling, + int nOverviews, int *panOverviewList, + int nListBands, int *panBandList, + GDALProgressFunc pfnProgress, + void * pProgressData ) + +{ + int i; + + if( GetAccess() == GA_ReadOnly ) + return GDALDataset::IBuildOverviews( pszResampling, + nOverviews, panOverviewList, + nListBands, panBandList, + pfnProgress, pProgressData ); + + for( i = 0; i < nListBands; i++ ) + { + CPLErr eErr; + GDALRasterBand *poBand; + + // TODO: We ought to used scaled progress monitors so we would get + // 0 to 100 progress out of the whole process ... later. + + poBand = GetRasterBand( panBandList[i] ); + eErr = + poBand->BuildOverviews( pszResampling, nOverviews, panOverviewList, + pfnProgress, pProgressData ); + if( eErr != CE_None ) + return eErr; + } + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *HFADataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + HFAHandle hHFA; + int i; + +/* -------------------------------------------------------------------- */ +/* Verify that this is a HFA file. */ +/* -------------------------------------------------------------------- */ + if( !poOpenInfo->bStatOK || poOpenInfo->nHeaderBytes < 15 + || !EQUALN((char *) poOpenInfo->pabyHeader,"EHFA_HEADER_TAG",15) ) + return( NULL ); + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_Update ) + hHFA = HFAOpen( poOpenInfo->pszFilename, "r+" ); + else + hHFA = HFAOpen( poOpenInfo->pszFilename, "r" ); + + if( hHFA == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + HFADataset *poDS; + + poDS = new HFADataset(); + + poDS->hHFA = hHFA; + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Establish raster info. */ +/* -------------------------------------------------------------------- */ + HFAGetRasterInfo( hHFA, &poDS->nRasterXSize, &poDS->nRasterYSize, + &poDS->nBands ); + + if( poDS->nBands == 0 ) + { + delete poDS; + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to open %s, it has zero usable bands.", + poOpenInfo->pszFilename ); + return NULL; + } + + if( poDS->nRasterXSize == 0 || poDS->nRasterYSize == 0 ) + { + delete poDS; + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to open %s, it has no pixels.", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Get geotransform. */ +/* -------------------------------------------------------------------- */ + HFAGetGeoTransform( hHFA, poDS->adfGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Get the projection. */ +/* -------------------------------------------------------------------- */ + poDS->ReadProjection(); + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < poDS->nBands; i++ ) + { + poDS->SetBand( i+1, new HFARasterBand( poDS, i+1, -1 ) ); + } + +/* -------------------------------------------------------------------- */ +/* Collect GDAL custom Metadata, and "auxilary" metadata from */ +/* well known HFA structures for the bands. We defer this till */ +/* now to ensure that the bands are properly setup before */ +/* interacting with PAM. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < poDS->nBands; i++ ) + { + HFARasterBand *poBand = (HFARasterBand *) poDS->GetRasterBand( i+1 ); + + char **papszMD = HFAGetMetadata( hHFA, i+1 ); + if( papszMD != NULL ) + { + poBand->SetMetadata( papszMD ); + CSLDestroy( papszMD ); + } + + poBand->ReadAuxMetadata(); + } + +/* -------------------------------------------------------------------- */ +/* Check for GDAL style metadata. */ +/* -------------------------------------------------------------------- */ + char **papszMD = HFAGetMetadata( hHFA, 0 ); + if( papszMD != NULL ) + { + poDS->SetMetadata( papszMD ); + CSLDestroy( papszMD ); + } + +/* -------------------------------------------------------------------- */ +/* Check for dependent dataset value. */ +/* -------------------------------------------------------------------- */ + HFAInfo_t *psInfo = (HFAInfo_t *) hHFA; + HFAEntry *poEntry = psInfo->poRoot->GetNamedChild("DependentFile"); + if( poEntry != NULL ) + { + poDS->SetMetadataItem( "HFA_DEPENDENT_FILE", + poEntry->GetStringField( "dependent.string" ), + "HFA" ); + } + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + +/* -------------------------------------------------------------------- */ +/* Clear dirty metadata flags. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < poDS->nBands; i++ ) + { + HFARasterBand *poBand = (HFARasterBand *) poDS->GetRasterBand( i+1 ); + poBand->bMetadataDirty = FALSE; + } + poDS->bMetadataDirty = FALSE; + + return( poDS ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *HFADataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr HFADataset::SetProjection( const char * pszNewProjection ) + +{ + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszNewProjection ); + bGeoDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* SetMetadata() */ +/************************************************************************/ + +CPLErr HFADataset::SetMetadata( char **papszMDIn, const char *pszDomain ) + +{ + bMetadataDirty = TRUE; + + return GDALPamDataset::SetMetadata( papszMDIn, pszDomain ); +} + +/************************************************************************/ +/* SetMetadata() */ +/************************************************************************/ + +CPLErr HFADataset::SetMetadataItem( const char *pszTag, const char *pszValue, + const char *pszDomain ) + +{ + bMetadataDirty = TRUE; + + return GDALPamDataset::SetMetadataItem( pszTag, pszValue, pszDomain ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr HFADataset::GetGeoTransform( double * padfTransform ) + +{ + if( adfGeoTransform[0] != 0.0 + || adfGeoTransform[1] != 1.0 + || adfGeoTransform[2] != 0.0 + || adfGeoTransform[3] != 0.0 + || adfGeoTransform[4] != 0.0 + || adfGeoTransform[5] != 1.0 ) + { + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + return CE_None; + } + else + return GDALPamDataset::GetGeoTransform( padfTransform ); +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr HFADataset::SetGeoTransform( double * padfTransform ) + +{ + memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 ); + bGeoDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* IRasterIO() */ +/* */ +/* Multi-band raster io handler. Here we ensure that the block */ +/* based loading is used for spill file rasters. That is */ +/* because they are effectively pixel interleaved, so */ +/* processing all bands for a given block together avoid extra */ +/* seeks. */ +/************************************************************************/ + +CPLErr HFADataset::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( hHFA->papoBand[panBandMap[0]-1]->fpExternal != NULL + && nBandCount > 1 ) + return GDALDataset::BlockBasedRasterIO( + eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, nPixelSpace, nLineSpace, nBandSpace ); + else + return + GDALDataset::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, + nPixelSpace, nLineSpace, nBandSpace ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *HFADataset::Create( const char * pszFilenameIn, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszParmList ) + +{ + int nHfaDataType; + +/* -------------------------------------------------------------------- */ +/* Translate the data type. */ +/* -------------------------------------------------------------------- */ + switch( eType ) + { + case GDT_Byte: + nHfaDataType = EPT_u8; + break; + + case GDT_UInt16: + nHfaDataType = EPT_u16; + break; + + case GDT_Int16: + nHfaDataType = EPT_s16; + break; + + case GDT_Int32: + nHfaDataType = EPT_s32; + break; + + case GDT_UInt32: + nHfaDataType = EPT_u32; + break; + + case GDT_Float32: + nHfaDataType = EPT_f32; + break; + + case GDT_Float64: + nHfaDataType = EPT_f64; + break; + + case GDT_CFloat32: + nHfaDataType = EPT_c64; + break; + + case GDT_CFloat64: + nHfaDataType = EPT_c128; + break; + + default: + CPLError( CE_Failure, CPLE_NotSupported, + "Data type %s not supported by Erdas Imagine (HFA) format.\n", + GDALGetDataTypeName( eType ) ); + return NULL; + + } + +/* -------------------------------------------------------------------- */ +/* Create the new file. */ +/* -------------------------------------------------------------------- */ + HFAHandle hHFA; + + hHFA = HFACreate( pszFilenameIn, nXSize, nYSize, nBands, + nHfaDataType, papszParmList ); + if( hHFA == NULL ) + return NULL; + + HFAClose( hHFA ); + +/* -------------------------------------------------------------------- */ +/* Open the dataset normally. */ +/* -------------------------------------------------------------------- */ + HFADataset *poDS = (HFADataset *) GDALOpen( pszFilenameIn, GA_Update ); + +/* -------------------------------------------------------------------- */ +/* Special creation option to disable checking for UTM */ +/* parameters when writing the projection. This is a special */ +/* hack for sam.gillingham@nrm.qld.gov.au. */ +/* -------------------------------------------------------------------- */ + if( poDS != NULL ) + { + poDS->bIgnoreUTM = CSLFetchBoolean( papszParmList, "IGNOREUTM", + FALSE ); + } + + return poDS; + +} + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +GDALDataset * +HFADataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + HFADataset *poDS; + GDALDataType eType = GDT_Byte; + int iBand; + int nBandCount = poSrcDS->GetRasterCount(); + + (void) bStrict; + + if( !pfnProgress( 0.0, NULL, pProgressData ) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create the basic dataset. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + GDALRasterBand *poBand = poSrcDS->GetRasterBand( iBand+1 ); + eType = GDALDataTypeUnion( eType, poBand->GetRasterDataType() ); + } + + poDS = (HFADataset *) Create( pszFilename, + poSrcDS->GetRasterXSize(), + poSrcDS->GetRasterYSize(), + nBandCount, + eType, papszOptions ); + + if( poDS == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Does the source have a PCT for any of the bands? If so, */ +/* copy it over. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + GDALRasterBand *poBand = poSrcDS->GetRasterBand( iBand+1 ); + GDALColorTable *poCT; + + poCT = poBand->GetColorTable(); + if( poCT != NULL ) + { + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + int nColors = poCT->GetColorEntryCount(), iColor; + + padfRed = (double *) CPLMalloc(sizeof(double) * nColors); + padfGreen = (double *) CPLMalloc(sizeof(double) * nColors); + padfBlue = (double *) CPLMalloc(sizeof(double) * nColors); + padfAlpha = (double *) CPLMalloc(sizeof(double) * nColors); + for( iColor = 0; iColor < nColors; iColor++ ) + { + GDALColorEntry sEntry; + + poCT->GetColorEntryAsRGB( iColor, &sEntry ); + padfRed[iColor] = sEntry.c1 / 255.0; + padfGreen[iColor] = sEntry.c2 / 255.0; + padfBlue[iColor] = sEntry.c3 / 255.0; + padfAlpha[iColor] = sEntry.c4 / 255.0; + } + + HFASetPCT( poDS->hHFA, iBand+1, nColors, + padfRed, padfGreen, padfBlue, padfAlpha ); + + CPLFree( padfRed ); + CPLFree( padfGreen ); + CPLFree( padfBlue ); + CPLFree( padfAlpha ); + } + } + +/* -------------------------------------------------------------------- */ +/* Do we have metadata for any of the bands or the dataset as a */ +/* whole? */ +/* -------------------------------------------------------------------- */ + if( poSrcDS->GetMetadata() != NULL ) + poDS->SetMetadata( poSrcDS->GetMetadata() ); + + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 ); + poDS->GetRasterBand(iBand+1)->SetMetadata( poSrcBand->GetMetadata() ); + } + +/* -------------------------------------------------------------------- */ +/* Copy projection information. */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + const char *pszProj; + + if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None + && (adfGeoTransform[0] != 0.0 || adfGeoTransform[1] != 1.0 + || adfGeoTransform[2] != 0.0 || adfGeoTransform[3] != 0.0 + || adfGeoTransform[4] != 0.0 || fabs(adfGeoTransform[5]) != 1.0)) + poDS->SetGeoTransform( adfGeoTransform ); + + pszProj = poSrcDS->GetProjectionRef(); + if( pszProj != NULL && strlen(pszProj) > 0 ) + poDS->SetProjection( pszProj ); + +/* -------------------------------------------------------------------- */ +/* Copy the image data. */ +/* -------------------------------------------------------------------- */ + int nXSize = poDS->GetRasterXSize(); + int nYSize = poDS->GetRasterYSize(); + int nBlockXSize, nBlockYSize, nBlockTotal, nBlocksDone; + + poDS->GetRasterBand(1)->GetBlockSize( &nBlockXSize, &nBlockYSize ); + + nBlockTotal = ((nXSize + nBlockXSize - 1) / nBlockXSize) + * ((nYSize + nBlockYSize - 1) / nBlockYSize) + * nBandCount; + + nBlocksDone = 0; + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 ); + GDALRasterBand *poDstBand = poDS->GetRasterBand( iBand+1 ); + int iYOffset; + void *pData; + CPLErr eErr; + int nMoveLines = nBlockYSize; + +#define TRANSFER_BY_BLOCK +#ifdef TRANSFER_BY_BLOCK + pData = CPLMalloc(nBlockXSize * nMoveLines + * GDALGetDataTypeSize(eType) / 8); +#else +xx + pData = CPLMalloc(nXSize * nMoveLines + * GDALGetDataTypeSize(eType) / 8); +#endif + + for( iYOffset = 0; iYOffset < nYSize; iYOffset += nMoveLines ) + { +#ifdef TRANSFER_BY_BLOCK + int iXOffset; + + for( iXOffset = 0; iXOffset < nXSize; iXOffset += nBlockXSize ) + { + int nTBXSize, nTBYSize; + + if( !pfnProgress( (nBlocksDone++) / (float) nBlockTotal, + NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poHFADriver = + (GDALDriver *) GDALGetDriverByName( "HFA" ); + poHFADriver->Delete( pszFilename ); + return NULL; + } + + nTBXSize = MIN(nBlockXSize,nXSize-iXOffset); + nTBYSize = MIN(nMoveLines,nYSize-iYOffset); + + eErr = poSrcBand->RasterIO( GF_Read, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + if( eErr != CE_None ) + { + return NULL; + } + + eErr = poDstBand->RasterIO( GF_Write, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + + if( eErr != CE_None ) + { + return NULL; + } + } +#else + if( !pfnProgress( (iYOffset + iBand*nYSize) + / (float) (nYSize * nBandCount), + NULL, pProgressData )) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poHFADriver = + (GDALDriver *) GDALGetDriverByName( "HFA" ); + poHFADriver->Delete( pszFilename ); + return NULL; + } + + int nTBYSize; + + nTBYSize = MIN(nMoveLines,nYSize-iYOffset); + eErr = poSrcBand->RasterIO( GF_Read, + 0, iYOffset, nXSize, nTBYSize, + pData, nXSize, nTBYSize, + eType, 0, 0 ); + if( eErr != CE_None ) + { + return NULL; + } + + eErr = poDstBand->RasterIO( GF_Write, + 0, iYOffset, nXSize, nTBYSize, + pData, nXSize, nTBYSize, + eType, 0, 0 ); + + if( eErr != CE_None ) + { + return NULL; + } + + poDstBand->FlushCache(); +#endif + } + + CPLFree( pData ); + } + + if( !pfnProgress( 1.0, NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poHFADriver = + (GDALDriver *) GDALGetDriverByName( "HFA" ); + poHFADriver->Delete( pszFilename ); + return NULL; + } + + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + +/************************************************************************/ +/* Delete() */ +/************************************************************************/ + +CPLErr HFADataset::Delete( const char *pszFilename ) + +{ + return HFADelete( pszFilename ); +} + + +/************************************************************************/ +/* GDALRegister_HFA() */ +/************************************************************************/ + +void GDALRegister_HFA() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "HFA" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "HFA" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Erdas Imagine Images (.img)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_hfa.html" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "img" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Int32 UInt32 Float32 Float64 CFloat32 CFloat64" ); + + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='BLOCKSIZE' type='integer' description='tile width/height (32-2048)'/>" +" <Option name='USE_SPILL' type='boolean' description='Force use of spill file'/>" +" <Option name='COMPRESSED' type='boolean' description='compress blocks, default NO'/>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = HFADataset::Open; + poDriver->pfnCreate = HFADataset::Create; + poDriver->pfnCreateCopy = HFADataset::CreateCopy; + poDriver->pfnDelete = HFADataset::Delete; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/hfa/hfadictionary.cpp b/Utilities/GDAL/frmts/hfa/hfadictionary.cpp new file mode 100644 index 0000000000..72487b7ce5 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfadictionary.cpp @@ -0,0 +1,275 @@ +/****************************************************************************** + * $Id: hfadictionary.cpp,v 1.8 2005/09/27 18:01:37 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Implementation of the HFADictionary class for managing the + * dictionary read from the HFA file. Most work done by the + * HFAType, and HFAField classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfadictionary.cpp,v $ + * Revision 1.8 2005/09/27 18:01:37 fwarmerdam + * Ensure Edsc_Table is defined, fixed default def support + * + * Revision 1.7 2004/01/26 18:28:32 warmerda + * provide default types if not defined in file + * + * Revision 1.6 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.5 2003/02/25 18:03:47 warmerda + * added support to auto-define Edsc_Column as the defn is sometimes missing + * + * Revision 1.4 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.3 1999/01/22 17:36:13 warmerda + * fixed return value + * + * Revision 1.2 1999/01/04 22:52:47 warmerda + * field access working + * + * Revision 1.1 1999/01/04 05:28:12 warmerda + * New + * + */ + +#include "hfa_p.h" +#include "cpl_conv.h" + +CPL_CVSID("$Id: hfadictionary.cpp,v 1.8 2005/09/27 18:01:37 fwarmerdam Exp $"); + +static char *apszDefDefn[] = { + + "Edsc_Table", + "{1:lnumrows,}Edsc_Table", + + "Edsc_Column", + "{1:lnumRows,1:LcolumnDataPtr,1:e4:integer,real,complex,string,dataType,1:lmaxNumChars,}Edsc_Column", + + "Eprj_Size", + "{1:dwidth,1:dheight,}Eprj_Size", + + "Eprj_Coordinate", + "{1:dx,1:dy,}Eprj_Coordinate", + + "Eprj_MapInfo", + "{0:pcproName,1:*oEprj_Coordinate,upperLeftCenter,1:*oEprj_Coordinate,lowerRightCenter,1:*oEprj_Size,pixelSize,0:pcunits,}Eprj_MapInfo", + + "Eimg_StatisticsParameters830", + "{0:poEmif_String,LayerNames,1:*bExcludedValues,1:oEmif_String,AOIname,1:lSkipFactorX,1:lSkipFactorY,1:*oEdsc_BinFunction,BinFunction,}Eimg_StatisticsParameters830", + + "Esta_Statistics", + "{1:dminimum,1:dmaximum,1:dmean,1:dmedian,1:dmode,1:dstddev,}Esta_Statistics", + + "Edsc_BinFunction", + "{1:lnumBins,1:e4:direct,linear,logarithmic,explicit,binFunctionType,1:dminLimit,1:dmaxLimit,1:*bbinLimits,}Edsc_BinFunction", + + "Eimg_NonInitializedValue", + "{1:*bvalueBD,}Eimg_NonInitializedValue", + + NULL, + NULL }; + + + +/************************************************************************/ +/* ==================================================================== */ +/* HFADictionary */ +/* ==================================================================== */ +/************************************************************************/ + + +/************************************************************************/ +/* HFADictionary() */ +/************************************************************************/ + +HFADictionary::HFADictionary( const char * pszString ) + +{ + int i; + + nTypes = 0; + nTypesMax = 0; + papoTypes = NULL; + +/* -------------------------------------------------------------------- */ +/* Read all the types. */ +/* -------------------------------------------------------------------- */ + while( pszString != NULL && *pszString != '.' ) + { + HFAType *poNewType; + + poNewType = new HFAType(); + pszString = poNewType->Initialize( pszString ); + + if( pszString != NULL ) + AddType( poNewType ); + else + delete poNewType; + } + + +/* -------------------------------------------------------------------- */ +/* Provide hardcoded values for some definitions that are */ +/* sometimes missing from the data dictionary for unknown */ +/* reasons. */ +/* -------------------------------------------------------------------- */ + for( i = 0; apszDefDefn[i] != NULL; i += 2 ) + { + if( FindType( apszDefDefn[i] ) == NULL ) + { + HFAType *poNewType = new HFAType(); + + poNewType->Initialize( apszDefDefn[i+1] ); + AddType( poNewType ); + } + } + +/* -------------------------------------------------------------------- */ +/* Complete the definitions. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nTypes; i++ ) + { + papoTypes[i]->CompleteDefn( this ); + } +} + +/************************************************************************/ +/* ~HFADictionary() */ +/************************************************************************/ + +HFADictionary::~HFADictionary() + +{ + int i; + + for( i = 0; i < nTypes; i++ ) + delete papoTypes[i]; + + CPLFree( papoTypes ); +} + +/************************************************************************/ +/* AddType() */ +/************************************************************************/ + +void HFADictionary::AddType( HFAType *poType ) + +{ + if( nTypes == nTypesMax ) + { + nTypesMax = nTypes * 2 + 10; + papoTypes = (HFAType **) CPLRealloc( papoTypes, + sizeof(void*) * nTypesMax ); + } + + papoTypes[nTypes++] = poType; +} + +/************************************************************************/ +/* FindType() */ +/************************************************************************/ + +HFAType * HFADictionary::FindType( const char * pszName ) + +{ + int i; + + for( i = 0; i < nTypes; i++ ) + { + if( strcmp(pszName,papoTypes[i]->pszTypeName) == 0 ) + return( papoTypes[i] ); + } + + return NULL; +} + +/************************************************************************/ +/* GetItemSize() */ +/* */ +/* Get the size of a basic (atomic) item. */ +/************************************************************************/ + +int HFADictionary::GetItemSize( char chType ) + +{ + switch( chType ) + { + case '1': + case '2': + case '4': + case 'c': + case 'C': + return 1; + + case 'e': + case 's': + case 'S': + return 2; + + case 't': + case 'l': + case 'L': + case 'f': + return 4; + + case 'd': + case 'm': + return 8; + + case 'M': + return 16; + + case 'b': + return -1; + + case 'o': + case 'x': + return 0; + + default: + CPLAssert( FALSE ); + } + + return 0; +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void HFADictionary::Dump( FILE * fp ) + +{ + int i; + + VSIFPrintf( fp, "\nHFADictionary:\n" ); + + for( i = 0; i < nTypes; i++ ) + { + papoTypes[i]->Dump( fp ); + } +} diff --git a/Utilities/GDAL/frmts/hfa/hfaentry.cpp b/Utilities/GDAL/frmts/hfa/hfaentry.cpp new file mode 100644 index 0000000000..041ea962b8 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfaentry.cpp @@ -0,0 +1,857 @@ +/****************************************************************************** + * $Id: hfaentry.cpp,v 1.13 2005/08/19 02:14:11 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Implementation of the HFAEntry class for reading and relating + * one node in the HFA object tree structure. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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. + ****************************************************************************** + * + * hfaentry.cpp + * + * Implementation of the HFAEntry class. + * + * $Log: hfaentry.cpp,v $ + * Revision 1.13 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.12 2005/05/10 00:55:46 fwarmerdam + * Added GetFieldCount method + * + * Revision 1.11 2005/02/22 21:34:47 fwarmerdam + * added GetBigIntField method + * + * Revision 1.10 2004/10/26 17:49:31 fwarmerdam + * Changed GetNamedChild() so that if there are multiple children with a + * search for a given child node will be applied to each till a match is found. + * This resolves the problem reading the histogram values for a file that + * also has a color table preceeding it and they are both called + * Descriptor_Table. + * + * Revision 1.9 2003/07/29 10:08:24 dron + * Fixed definition for GetIntField() method. + * + * Revision 1.8 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.7 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.6 2001/01/03 16:20:10 warmerda + * Converted to large file API + * + * Revision 1.5 2000/10/12 19:30:32 warmerda + * substantially improved write support + * + * Revision 1.4 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.3 1999/01/22 17:37:30 warmerda + * fixed types in GetFieldValue() calls + * + * Revision 1.2 1999/01/04 22:52:47 warmerda + * field access working + * + * Revision 1.1 1999/01/04 05:28:12 warmerda + * New + * + */ + +#include "hfa_p.h" +#include "cpl_conv.h" + +CPL_CVSID("$Id: hfaentry.cpp,v 1.13 2005/08/19 02:14:11 fwarmerdam Exp $"); + +/************************************************************************/ +/* HFAEntry() */ +/* */ +/* Construct an HFAEntry from the source file. */ +/************************************************************************/ + +HFAEntry::HFAEntry( HFAInfo_t * psHFAIn, GUInt32 nPos, + HFAEntry * poParentIn, HFAEntry * poPrevIn ) + +{ + psHFA = psHFAIn; + + nFilePos = nPos; + bDirty = FALSE; + + poParent = poParentIn; + poPrev = poPrevIn; + +/* -------------------------------------------------------------------- */ +/* Initialize fields to null values in case there is a read */ +/* error, so the entry will be in a harmless state. */ +/* -------------------------------------------------------------------- */ + poNext = poChild = NULL; + + nDataPos = nDataSize = 0; + nNextPos = nChildPos = 0; + + szName[0] = szType[0] = '\0'; + + pabyData = NULL; + + poType = NULL; + +/* -------------------------------------------------------------------- */ +/* Read the entry information from the file. */ +/* -------------------------------------------------------------------- */ + GInt32 anEntryNums[6]; + int i; + + if( VSIFSeekL( psHFA->fp, nFilePos, SEEK_SET ) == -1 + || VSIFReadL( anEntryNums, sizeof(GInt32), 6, psHFA->fp ) < 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "VSIFReadL() failed in HFAEntry()." ); + return; + } + + for( i = 0; i < 6; i++ ) + HFAStandard( 4, anEntryNums + i ); + + nNextPos = anEntryNums[0]; + nChildPos = anEntryNums[3]; + nDataPos = anEntryNums[4]; + nDataSize = anEntryNums[5]; + +/* -------------------------------------------------------------------- */ +/* Read the name, and type. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( szName, 1, 64, psHFA->fp ) < 1 + || VSIFReadL( szType, 1, 32, psHFA->fp ) < 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "VSIFReadL() failed in HFAEntry()." ); + return; + } +} + +/************************************************************************/ +/* HFAEntry() */ +/* */ +/* Construct an HFAEntry in memory, with the intention that it */ +/* would be written to disk later. */ +/************************************************************************/ + +HFAEntry::HFAEntry( HFAInfo_t * psHFAIn, + const char * pszNodeName, + const char * pszTypeName, + HFAEntry * poParentIn ) + +{ +/* -------------------------------------------------------------------- */ +/* Initialize Entry */ +/* -------------------------------------------------------------------- */ + psHFA = psHFAIn; + + nFilePos = 0; + + poParent = poParentIn; + poPrev = poNext = poChild = NULL; + + nDataPos = nDataSize = 0; + nNextPos = nChildPos = 0; + + SetName( pszNodeName ); + memset( szType, 0, 32 ); + strncpy( szType, pszTypeName, 32 ); + + pabyData = NULL; + poType = NULL; + +/* -------------------------------------------------------------------- */ +/* Update the previous or parent node to refer to this one. */ +/* -------------------------------------------------------------------- */ + if( poParent == NULL ) + { + /* do nothing */ + } + else if( poParent->poChild == NULL ) + { + poParent->poChild = this; + poParent->MarkDirty(); + } + else + { + poPrev = poParent->poChild; + while( poPrev->poNext != NULL ) + poPrev = poPrev->poNext; + + poPrev->poNext = this; + poPrev->MarkDirty(); + } + + MarkDirty(); +} + +/************************************************************************/ +/* ~HFAEntry() */ +/* */ +/* Ensure that children are cleaned up when this node is */ +/* cleaned up. */ +/************************************************************************/ + +HFAEntry::~HFAEntry() + +{ + CPLFree( pabyData ); + + if( poNext != NULL ) + delete poNext; + + if( poChild != NULL ) + delete poChild; +} + +/************************************************************************/ +/* SetName() */ +/* */ +/* Changes the name assigned to this node */ +/************************************************************************/ + +void HFAEntry::SetName( const char *pszNodeName ) +{ + memset( szName, 0, 64 ); + strncpy( szName, pszNodeName, 64 ); + + MarkDirty(); +} + +/************************************************************************/ +/* GetChild() */ +/************************************************************************/ + +HFAEntry *HFAEntry::GetChild() + +{ +/* -------------------------------------------------------------------- */ +/* Do we need to create the child node? */ +/* -------------------------------------------------------------------- */ + if( poChild == NULL && nChildPos != 0 ) + { + poChild = new HFAEntry( psHFA, nChildPos, this, NULL ); + } + + return( poChild ); +} + +/************************************************************************/ +/* GetNext() */ +/************************************************************************/ + +HFAEntry *HFAEntry::GetNext() + +{ +/* -------------------------------------------------------------------- */ +/* Do we need to create the next node? */ +/* -------------------------------------------------------------------- */ + if( poNext == NULL && nNextPos != 0 ) + { + poNext = new HFAEntry( psHFA, nNextPos, poParent, this ); + } + + return( poNext ); +} + +/************************************************************************/ +/* LoadData() */ +/* */ +/* Load the data for this entry, and build up the field */ +/* information for it. */ +/************************************************************************/ + +void HFAEntry::LoadData() + +{ + if( pabyData != NULL || nDataSize == 0 ) + return; + +/* -------------------------------------------------------------------- */ +/* Allocate buffer, and read data. */ +/* -------------------------------------------------------------------- */ + pabyData = (GByte *) CPLMalloc(nDataSize); + if( VSIFSeekL( psHFA->fp, nDataPos, SEEK_SET ) < 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "VSIFSeekL() failed in HFAEntry::LoadData()." ); + return; + } + + if( VSIFReadL( pabyData, 1, nDataSize, psHFA->fp ) < 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "VSIFReadL() failed in HFAEntry::LoadData()." ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Get the type corresponding to this entry. */ +/* -------------------------------------------------------------------- */ + poType = psHFA->poDictionary->FindType( szType ); + if( poType == NULL ) + return; +} + +/************************************************************************/ +/* MakeData() */ +/* */ +/* Create a data block on the this HFAEntry in memory. By */ +/* default it will create the data the correct size for fixed */ +/* sized types, or do nothing for variable length types. */ +/* However, the caller can supply a desired size for variable */ +/* sized fields. */ +/************************************************************************/ + +GByte *HFAEntry::MakeData( int nSize ) + +{ + if( poType == NULL ) + { + poType = psHFA->poDictionary->FindType( szType ); + if( poType == NULL ) + return NULL; + } + + if( nSize == 0 && poType->nBytes > 0 ) + nSize = poType->nBytes; + + if( (int) nDataSize < nSize && nSize > 0 ) + { + pabyData = (GByte *) CPLRealloc(pabyData, nSize); + memset( pabyData + nDataSize, 0, nSize - nDataSize ); + nDataSize = nSize; + + MarkDirty(); + } + + return pabyData; +} + + +/************************************************************************/ +/* DumpFieldValues() */ +/************************************************************************/ + +void HFAEntry::DumpFieldValues( FILE * fp, const char * pszPrefix ) + +{ + if( pszPrefix == NULL ) + pszPrefix = ""; + + LoadData(); + + if( poType == NULL ) + return; + + poType->DumpInstValue( fp, + pabyData, nDataPos, nDataSize, + pszPrefix ); +} + +/************************************************************************/ +/* GetNamedChild() */ +/************************************************************************/ + +HFAEntry *HFAEntry::GetNamedChild( const char * pszName ) + +{ + int nNameLen; + HFAEntry *poEntry; + +/* -------------------------------------------------------------------- */ +/* Establish how much of this name path is for the next child. */ +/* Up to the '.' or end of estring. */ +/* -------------------------------------------------------------------- */ + for( nNameLen = 0; + pszName[nNameLen] != '.' + && pszName[nNameLen] != '\0' + && pszName[nNameLen] != ':'; + nNameLen++ ) {} + +/* -------------------------------------------------------------------- */ +/* Scan children looking for this name. */ +/* -------------------------------------------------------------------- */ + for( poEntry = GetChild(); poEntry != NULL; poEntry = poEntry->GetNext() ) + { + if( EQUALN(poEntry->GetName(),pszName,nNameLen) + && (int) strlen(poEntry->GetName()) == nNameLen ) + { + if( pszName[nNameLen] == '.' ) + { + HFAEntry *poResult; + + poResult = poEntry->GetNamedChild( pszName+nNameLen+1 ); + if( poResult != NULL ) + return poResult; + } + else + return poEntry; + } + } + + return NULL; +} + +/************************************************************************/ +/* GetFieldValue() */ +/************************************************************************/ + +void *HFAEntry::GetFieldValue( const char * pszFieldPath, + char chReqType ) + +{ + HFAEntry *poEntry = this; + +/* -------------------------------------------------------------------- */ +/* Is there a node path in this string? */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,':') != NULL ) + { + poEntry = GetNamedChild( pszFieldPath ); + if( poEntry == NULL ) + return NULL; + + pszFieldPath = strchr(pszFieldPath,':') + 1; + } + +/* -------------------------------------------------------------------- */ +/* Do we have the data and type for this node? */ +/* -------------------------------------------------------------------- */ + LoadData(); + + if( pabyData == NULL ) + return NULL; + + if( poType == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Extract the instance information. */ +/* -------------------------------------------------------------------- */ + + return( poType->ExtractInstValue( pszFieldPath, + pabyData, nDataPos, nDataSize, + chReqType ) ); +} + +/************************************************************************/ +/* GetFieldCount() */ +/************************************************************************/ + +int HFAEntry::GetFieldCount( const char * pszFieldPath, CPLErr *peErr ) + +{ + HFAEntry *poEntry = this; + +/* -------------------------------------------------------------------- */ +/* Is there a node path in this string? */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,':') != NULL ) + { + poEntry = GetNamedChild( pszFieldPath ); + if( poEntry == NULL ) + return -1; + + pszFieldPath = strchr(pszFieldPath,':') + 1; + } + +/* -------------------------------------------------------------------- */ +/* Do we have the data and type for this node? */ +/* -------------------------------------------------------------------- */ + LoadData(); + + if( pabyData == NULL ) + return -1; + + if( poType == NULL ) + return -1; + +/* -------------------------------------------------------------------- */ +/* Extract the instance information. */ +/* -------------------------------------------------------------------- */ + + return( poType->GetInstCount( pszFieldPath, + pabyData, nDataPos, nDataSize ) ); +} + +/************************************************************************/ +/* GetIntField() */ +/************************************************************************/ + +GInt32 HFAEntry::GetIntField( const char * pszFieldPath, CPLErr *peErr ) + +{ + void *pRetData; + + pRetData = GetFieldValue( pszFieldPath, 'i' ); + if( pRetData == NULL ) + { + if( peErr != NULL ) + *peErr = CE_Failure; + + return 0; + } + else + { + if( peErr != NULL ) + *peErr = CE_None; + + return *((GInt32 *) pRetData); + } +} + +/************************************************************************/ +/* GetBigIntField() */ +/* */ +/* This is just a helper method that reads two ULONG array */ +/* entries as a GBigInt. The passed name should be the name of */ +/* the array with no array index. Array indexes 0 and 1 will */ +/* be concatenated. */ +/************************************************************************/ + +GIntBig HFAEntry::GetBigIntField( const char *pszFieldPath, CPLErr *peErr ) + +{ + GUInt32 nLower, nUpper; + char szFullFieldPath[1024]; + + sprintf( szFullFieldPath, "%s[0]", pszFieldPath ); + nLower = GetIntField( szFullFieldPath, peErr ); + if( peErr != NULL && *peErr != CE_None ) + return 0; + + sprintf( szFullFieldPath, "%s[1]", pszFieldPath ); + nUpper = GetIntField( szFullFieldPath, peErr ); + if( peErr != NULL && *peErr != CE_None ) + return 0; + + return nLower + (((GIntBig) nUpper) << 32); +} + +/************************************************************************/ +/* GetDoubleField() */ +/************************************************************************/ + +double HFAEntry::GetDoubleField( const char * pszFieldPath, CPLErr *peErr ) + +{ + void *pRetData; + + pRetData = GetFieldValue( pszFieldPath, 'd' ); + if( pRetData == NULL ) + { + if( peErr != NULL ) + *peErr = CE_Failure; + + return 0.0; + } + else + { + if( peErr != NULL ) + *peErr = CE_None; + + return *((double *) pRetData); + } +} + +/************************************************************************/ +/* GetStringField() */ +/************************************************************************/ + +const char *HFAEntry::GetStringField( const char * pszFieldPath, CPLErr *peErr) + +{ + void *pRetData; + + pRetData = GetFieldValue( pszFieldPath, 's' ); + if( pRetData == NULL ) + { + if( peErr != NULL ) + *peErr = CE_Failure; + + return NULL; + } + else + { + if( peErr != NULL ) + *peErr = CE_None; + + return (char *) pRetData; + } +} + +/************************************************************************/ +/* SetFieldValue() */ +/************************************************************************/ + +CPLErr HFAEntry::SetFieldValue( const char * pszFieldPath, + char chReqType, void *pValue ) + +{ + HFAEntry *poEntry = this; + +/* -------------------------------------------------------------------- */ +/* Is there a node path in this string? */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,':') != NULL ) + { + poEntry = GetNamedChild( pszFieldPath ); + if( poEntry == NULL ) + return CE_Failure; + + pszFieldPath = strchr(pszFieldPath,':') + 1; + } + +/* -------------------------------------------------------------------- */ +/* Do we have the data and type for this node? Try loading */ +/* from a file, or instantiating a new node. */ +/* -------------------------------------------------------------------- */ + LoadData(); + if( MakeData() == NULL + || pabyData == NULL + || poType == NULL ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Extract the instance information. */ +/* -------------------------------------------------------------------- */ + MarkDirty(); + + return( poType->SetInstValue( pszFieldPath, + pabyData, nDataPos, nDataSize, + chReqType, pValue ) ); +} + +/************************************************************************/ +/* SetStringField() */ +/************************************************************************/ + +CPLErr HFAEntry::SetStringField( const char * pszFieldPath, + const char * pszValue ) + +{ + return SetFieldValue( pszFieldPath, 's', (void *) pszValue ); +} + +/************************************************************************/ +/* SetIntField() */ +/************************************************************************/ + +CPLErr HFAEntry::SetIntField( const char * pszFieldPath, int nValue ) + +{ + return SetFieldValue( pszFieldPath, 'i', &nValue ); +} + +/************************************************************************/ +/* SetDoubleField() */ +/************************************************************************/ + +CPLErr HFAEntry::SetDoubleField( const char * pszFieldPath, + double dfValue ) + +{ + return SetFieldValue( pszFieldPath, 'd', &dfValue ); +} + +/************************************************************************/ +/* SetPosition() */ +/* */ +/* Set the disk position for this entry, and recursively apply */ +/* to any children of this node. The parent will take care of */ +/* our siblings. */ +/************************************************************************/ + +void HFAEntry::SetPosition() + +{ +/* -------------------------------------------------------------------- */ +/* Establish the location of this entry, and it's data. */ +/* -------------------------------------------------------------------- */ + if( nFilePos == 0 ) + { + nFilePos = HFAAllocateSpace( psHFA, + psHFA->nEntryHeaderLength + + nDataSize ); + + if( nDataSize > 0 ) + nDataPos = nFilePos + psHFA->nEntryHeaderLength; + } + +/* -------------------------------------------------------------------- */ +/* Force all children to set their position. */ +/* -------------------------------------------------------------------- */ + for( HFAEntry *poThisChild = poChild; + poThisChild != NULL; + poThisChild = poThisChild->poNext ) + { + poThisChild->SetPosition(); + } +} + +/************************************************************************/ +/* FlushToDisk() */ +/* */ +/* Write this entry, and it's data to disk if the entries */ +/* information is dirty. Also force children to do the same. */ +/************************************************************************/ + +CPLErr HFAEntry::FlushToDisk() + +{ + CPLErr eErr = CE_None; + +/* -------------------------------------------------------------------- */ +/* If we are the root node, call SetPosition() on the whole */ +/* tree to ensure that all entries have an allocated position. */ +/* -------------------------------------------------------------------- */ + if( poParent == NULL ) + SetPosition(); + +/* ==================================================================== */ +/* Only write this node out if it is dirty. */ +/* ==================================================================== */ + if( bDirty ) + { +/* -------------------------------------------------------------------- */ +/* Ensure we know where the relative entries are located. */ +/* -------------------------------------------------------------------- */ + if( poNext != NULL ) + nNextPos = poNext->nFilePos; + if( poChild != NULL ) + nChildPos = poChild->nFilePos; + +/* -------------------------------------------------------------------- */ +/* Write the Ehfa_Entry fields. */ +/* -------------------------------------------------------------------- */ + GUInt32 nLong; + + VSIFFlushL( psHFA->fp ); + if( VSIFSeekL( psHFA->fp, nFilePos, SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to seek to %d for writing, out of disk space?", + nFilePos ); + return CE_Failure; + } + + nLong = nNextPos; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + if( poPrev != NULL ) + nLong = poPrev->nFilePos; + else + nLong = 0; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + if( poParent != NULL ) + nLong = poParent->nFilePos; + else + nLong = 0; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + nLong = nChildPos; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + + nLong = nDataPos; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + nLong = nDataSize; + HFAStandard( 4, &nLong ); + VSIFWriteL( &nLong, 4, 1, psHFA->fp ); + + VSIFWriteL( szName, 1, 64, psHFA->fp ); + VSIFWriteL( szType, 1, 32, psHFA->fp ); + + nLong = 0; /* Should we keep the time, or set it more reasonably? */ + if( VSIFWriteL( &nLong, 4, 1, psHFA->fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to write HFAEntry %s(%s), out of disk space?", + szName, szType ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Write out the data. */ +/* -------------------------------------------------------------------- */ + VSIFFlushL( psHFA->fp ); + if( nDataSize > 0 && pabyData != NULL ) + { + if( VSIFSeekL( psHFA->fp, nDataPos, SEEK_SET ) != 0 + || VSIFWriteL( pabyData, nDataSize, 1, psHFA->fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to write %d bytes HFAEntry %s(%s) data,\n" + "out of disk space?", + nDataSize, szName, szType ); + return CE_Failure; + } + } + + VSIFFlushL( psHFA->fp ); + } + +/* -------------------------------------------------------------------- */ +/* Process all the children of this node */ +/* -------------------------------------------------------------------- */ + for( HFAEntry *poThisChild = poChild; + poThisChild != NULL; + poThisChild = poThisChild->poNext ) + { + eErr = poThisChild->FlushToDisk(); + if( eErr != CE_None ) + return eErr; + } + + bDirty = FALSE; + + return CE_None; +} + +/************************************************************************/ +/* MarkDirty() */ +/* */ +/* Mark this node as dirty (in need of writing to disk), and */ +/* also mark the tree as a whole as being dirty. */ +/************************************************************************/ + +void HFAEntry::MarkDirty() + +{ + bDirty = TRUE; + psHFA->bTreeDirty = TRUE; +} diff --git a/Utilities/GDAL/frmts/hfa/hfafield.cpp b/Utilities/GDAL/frmts/hfa/hfafield.cpp new file mode 100644 index 0000000000..965ac31d25 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfafield.cpp @@ -0,0 +1,1185 @@ +/****************************************************************************** + * $Id: hfafield.cpp,v 1.20 2006/04/03 04:33:16 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Implementation of the HFAField class for managing information + * about one field in a HFA dictionary type. Managed by HFAType. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfafield.cpp,v $ + * Revision 1.20 2006/04/03 04:33:16 fwarmerdam + * Report basedata type. Support reading basedata as a 1D array. Fix + * bug in basedata reading ... wasn't skippig 2 byte code before data. + * + * Revision 1.19 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.18 2005/10/02 15:14:48 fwarmerdam + * fixed size for <8bit basedata items + * + * Revision 1.17 2005/09/28 19:38:07 fwarmerdam + * Added partial support for inline defined types. + * + * Revision 1.16 2005/05/10 00:56:17 fwarmerdam + * fixed bug with setting entries in an array (with count setting) + * + * Revision 1.15 2004/02/13 15:58:11 warmerda + * Fixed serious bug with GetInstBytes() for BASEDATA * fields with + * a count of zero. Such as the Excluded field of most stats nodes! + * + * Revision 1.14 2003/12/08 19:09:34 warmerda + * implemented DumpInstValue and GetInstBytes for basedata + * + * Revision 1.13 2003/05/21 15:35:05 warmerda + * cleanup type conversion warnings + * + * Revision 1.12 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.11 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.10 2000/12/29 16:37:32 warmerda + * Use GUInt32 for all file offsets + * + * Revision 1.9 2000/10/12 19:30:32 warmerda + * substantially improved write support + * + * Revision 1.8 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.7 1999/06/01 13:07:59 warmerda + * added speed up for indexing into fixes size object arrays + * + * Revision 1.6 1999/02/15 19:06:18 warmerda + * Disable warning on field offsets for Intergraph delivery + * + * Revision 1.5 1999/01/28 18:28:28 warmerda + * minor simplification of code + * + * Revision 1.4 1999/01/28 18:03:07 warmerda + * Fixed some byte swapping problems, and problems with accessing data from + * the file that isn't on a word boundary. + * + * Revision 1.3 1999/01/22 19:23:11 warmerda + * Fixed bug with offset into arrays of structures. + * + * Revision 1.2 1999/01/22 17:37:59 warmerda + * Fixed up support for variable sizes, and arrays of variable sized objects + * + * Revision 1.1 1999/01/04 22:52:10 warmerda + * New + */ + +#include "hfa_p.h" + +CPL_CVSID("$Id: hfafield.cpp,v 1.20 2006/04/03 04:33:16 fwarmerdam Exp $"); + +#define MAX_ENTRY_REPORT 16 + +/************************************************************************/ +/* ==================================================================== */ +/* HFAField */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HFAField() */ +/************************************************************************/ + +HFAField::HFAField() + +{ + nBytes = 0; + + nItemCount = 0; + chPointer = '\0'; + chItemType = '\0'; + + pszItemObjectType = NULL; + poItemObjectType = NULL; + + papszEnumNames = NULL; + + pszFieldName = NULL; +} + +/************************************************************************/ +/* ~HFAField() */ +/************************************************************************/ + +HFAField::~HFAField() + +{ + CPLFree( pszItemObjectType ); + CSLDestroy( papszEnumNames ); + CPLFree( pszFieldName ); +} + +/************************************************************************/ +/* Initialize() */ +/************************************************************************/ + +const char *HFAField::Initialize( const char * pszInput ) + +{ + int i; + +/* -------------------------------------------------------------------- */ +/* Read the number. */ +/* -------------------------------------------------------------------- */ + nItemCount = atoi(pszInput); + + while( *pszInput != '\0' && *pszInput != ':' ) + pszInput++; + + if( *pszInput == '\0' ) + return NULL; + + pszInput++; + +/* -------------------------------------------------------------------- */ +/* Is this a pointer? */ +/* -------------------------------------------------------------------- */ + if( *pszInput == 'p' || *pszInput == '*' ) + chPointer = *(pszInput++); + +/* -------------------------------------------------------------------- */ +/* Get the general type */ +/* -------------------------------------------------------------------- */ + if( *pszInput == '\0' ) + return NULL; + + chItemType = *(pszInput++); + + CPLAssert( strchr( "124cCesStlLfdmMbox", chItemType) != NULL ); + +/* -------------------------------------------------------------------- */ +/* If this is an object, we extract the type of the object. */ +/* -------------------------------------------------------------------- */ + if( chItemType == 'o' ) + { + for( i = 0; pszInput[i] != '\0' && pszInput[i] != ','; i++ ) {} + + pszItemObjectType = (char *) CPLMalloc(i+1); + strncpy( pszItemObjectType, pszInput, i ); + pszItemObjectType[i] = '\0'; + + pszInput += i+1; + } + +/* -------------------------------------------------------------------- */ +/* If this is an inline object, we need to skip past the */ +/* definition, and then extract the object class name. */ +/* */ +/* We ignore the actual definition, so if the object type isn't */ +/* already defined, things will not work properly. See the */ +/* file lceugr250_00_pct.aux for an example of inline defs. */ +/* -------------------------------------------------------------------- */ + if( chItemType == 'x' && *pszInput == '{' ) + { + int nBraceDepth = 1; + pszInput++; + + // Skip past the definition. + while( nBraceDepth > 0 && *pszInput != '\0' ) + { + if( *pszInput == '{' ) + nBraceDepth++; + else if( *pszInput == '}' ) + nBraceDepth--; + + pszInput++; + } + + chItemType = 'o'; + + // find the comma terminating the type name. + for( i = 0; pszInput[i] != '\0' && pszInput[i] != ','; i++ ) {} + + pszItemObjectType = (char *) CPLMalloc(i+1); + strncpy( pszItemObjectType, pszInput, i ); + pszItemObjectType[i] = '\0'; + + pszInput += i+1; + } + +/* -------------------------------------------------------------------- */ +/* If this is an enumeration we have to extract all the */ +/* enumeration values. */ +/* -------------------------------------------------------------------- */ + if( chItemType == 'e' ) + { + int nEnumCount = atoi(pszInput); + int iEnum; + + pszInput = strchr(pszInput,':'); + if( pszInput == NULL ) + return NULL; + + pszInput++; + + papszEnumNames = (char **) CPLCalloc(sizeof(char *), nEnumCount+1); + + for( iEnum = 0; iEnum < nEnumCount; iEnum++ ) + { + char *pszToken; + + for( i = 0; pszInput[i] != '\0' && pszInput[i] != ','; i++ ) {} + + if( pszInput[i] != ',' ) + return NULL; + + pszToken = (char *) CPLMalloc(i+1); + strncpy( pszToken, pszInput, i ); + pszToken[i] = '\0'; + + papszEnumNames[iEnum] = pszToken; + + pszInput += i+1; + } + } + +/* -------------------------------------------------------------------- */ +/* Extract the field name. */ +/* -------------------------------------------------------------------- */ + for( i = 0; pszInput[i] != '\0' && pszInput[i] != ','; i++ ) {} + + pszFieldName = (char *) CPLMalloc(i+1); + strncpy( pszFieldName, pszInput, i ); + pszFieldName[i] = '\0'; + + pszInput += i+1; + + return( pszInput ); +} + +/************************************************************************/ +/* CompleteDefn() */ +/* */ +/* Establish size, and pointers to component types. */ +/************************************************************************/ + +void HFAField::CompleteDefn( HFADictionary * poDict ) + +{ +/* -------------------------------------------------------------------- */ +/* Get a reference to the type object if we have a type name */ +/* for this field (not a built in). */ +/* -------------------------------------------------------------------- */ + if( pszItemObjectType != NULL ) + poItemObjectType = poDict->FindType( pszItemObjectType ); + +/* -------------------------------------------------------------------- */ +/* Figure out the size. */ +/* -------------------------------------------------------------------- */ + if( chPointer == 'p' ) + { + nBytes = -1; /* we can't know the instance size */ + } + else if( poItemObjectType != NULL ) + { + poItemObjectType->CompleteDefn( poDict ); + if( poItemObjectType->nBytes == -1 ) + nBytes = -1; + else + nBytes = poItemObjectType->nBytes * nItemCount; + + if( chPointer == '*' && nBytes != -1 ) + nBytes += 8; /* count, and offset */ + } + else + { + nBytes = poDict->GetItemSize( chItemType ) * nItemCount; + } +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void HFAField::Dump( FILE * fp ) + +{ + const char *pszTypeName; + + switch( chItemType ) + { + case '1': + pszTypeName = "U1"; + break; + + case '2': + pszTypeName = "U2"; + break; + + case '4': + pszTypeName = "U4"; + break; + + case 'c': + pszTypeName = "UCHAR"; + break; + + case 'C': + pszTypeName = "CHAR"; + break; + + case 'e': + pszTypeName = "ENUM"; + break; + + case 's': + pszTypeName = "USHORT"; + break; + + case 'S': + pszTypeName = "SHORT"; + break; + + case 't': + pszTypeName = "TIME"; + break; + + case 'l': + pszTypeName = "ULONG"; + break; + + case 'L': + pszTypeName = "LONG"; + break; + + case 'f': + pszTypeName = "FLOAT"; + break; + + case 'd': + pszTypeName = "DOUBLE"; + break; + + case 'm': + pszTypeName = "COMPLEX"; + break; + + case 'M': + pszTypeName = "DCOMPLEX"; + break; + + case 'b': + pszTypeName = "BASEDATA"; + break; + + case 'o': + pszTypeName = pszItemObjectType; + break; + + case 'x': + pszTypeName = "InlineType"; + break; + + default: + CPLAssert( FALSE ); + pszTypeName = "Unknown"; + } + + VSIFPrintf( fp, " %-19s %c %s[%d];\n", + pszTypeName, + chPointer ? chPointer : ' ', + pszFieldName, nItemCount ); + + if( papszEnumNames != NULL ) + { + int i; + + for( i = 0; papszEnumNames[i] != NULL; i++ ) + { + VSIFPrintf( fp, " %s=%d\n", + papszEnumNames[i], i ); + } + } +} + +/************************************************************************/ +/* SetInstValue() */ +/************************************************************************/ + +CPLErr +HFAField::SetInstValue( const char * pszField, int nIndexValue, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType, void *pValue ) + +{ +/* -------------------------------------------------------------------- */ +/* If this field contains a pointer, then we will adjust the */ +/* data offset relative to it. */ +/* -------------------------------------------------------------------- */ + if( chPointer != '\0' ) + { + GUInt32 nCount; + GUInt32 nOffset; + + /* set the count for fixed sized arrays */ + if( nBytes > -1 ) + nCount = nItemCount; + + /* Set the size from string length */ + else if( chReqType == 's' && (chItemType == 'c' || chItemType == 'C')) + { + if( pValue == NULL ) + nCount = 0; + else + nCount = strlen((char *) pValue) + 1; + } + + /* set size based on index ... assumes in-order setting of array */ + else + nCount = nIndexValue+1; + + nOffset = nCount; + HFAStandard( 4, &nOffset ); + memcpy( pabyData, &nOffset, 4 ); + + if( pValue == NULL ) + nOffset = 0; + else + nOffset = nDataOffset + 8; + HFAStandard( 4, &nOffset ); + memcpy( pabyData+4, &nOffset, 4 ); + + pabyData += 8; + + nDataOffset += 8; + nDataSize -= 8; + } + +/* -------------------------------------------------------------------- */ +/* pointers to char or uchar arrays requested as strings are */ +/* handled as a special case. */ +/* -------------------------------------------------------------------- */ + if( (chItemType == 'c' || chItemType == 'C') && chReqType == 's' ) + { + int nBytesToCopy; + + if( nBytes == -1 ) + { + if( pValue == NULL ) + nBytesToCopy = 0; + else + nBytesToCopy = strlen((char *) pValue) + 1; + } + else + nBytesToCopy = nBytes; + + memset( pabyData, 0, nBytesToCopy ); + + if( pValue != NULL ) + strncpy( (char *) pabyData, (char *) pValue, nBytesToCopy ); + + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Translate the passed type into different representations. */ +/* -------------------------------------------------------------------- */ + int nIntValue; + double dfDoubleValue; + + if( chReqType == 's' ) + { + nIntValue = atoi((char *) pValue); + dfDoubleValue = atof((char *) pValue); + } + else if( chReqType == 'd' ) + { + dfDoubleValue = *((double *) pValue); + nIntValue = (int) dfDoubleValue; + } + else if( chReqType == 'i' ) + { + dfDoubleValue = *((int *) pValue); + nIntValue = *((int *) pValue); + } + else if( chReqType == 'p' ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "HFAField::SetInstValue() not supported yet for pointer values." ); + + return CE_Failure; + } + else + { + CPLAssert( FALSE ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Handle by type. */ +/* -------------------------------------------------------------------- */ + switch( chItemType ) + { + case 'c': + case 'C': + if( chReqType == 's' ) + pabyData[nIndexValue] = ((char *) pValue)[0]; + else + pabyData[nIndexValue] = (char) nIntValue; + break; + + case 'e': + case 's': + { + if( chItemType == 'e' && chReqType == 's' ) + { + nIntValue = CSLFindString( papszEnumNames, (char *) pValue ); + if( nIntValue == -1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to set enumerated field with unknown" + " value `%s'.", + (char *) pValue ); + return CE_Failure; + } + } + + unsigned short nNumber = (unsigned short) nIntValue; + + HFAStandard( 2, &nNumber ); + memcpy( pabyData + nIndexValue*2, &nNumber, 2 ); + } + break; + + case 'S': + { + short nNumber; + + nNumber = (short) nIntValue; + HFAStandard( 2, &nNumber ); + memcpy( pabyData + nIndexValue*2, &nNumber, 2 ); + } + break; + + case 't': + case 'l': + { + GUInt32 nNumber = nIntValue; + + HFAStandard( 4, &nNumber ); + memcpy( pabyData + nIndexValue*4, &nNumber, 4 ); + } + break; + + case 'L': + { + GInt32 nNumber = nIntValue; + + HFAStandard( 4, &nNumber ); + memcpy( pabyData + nIndexValue*4, &nNumber, 4 ); + } + break; + + case 'f': + { + float fNumber = (float) dfDoubleValue; + + HFAStandard( 4, &fNumber ); + memcpy( pabyData + nIndexValue*4, &fNumber, 4 ); + } + break; + + case 'd': + { + double dfNumber = dfDoubleValue; + + HFAStandard( 8, &dfNumber ); + memcpy( pabyData + nIndexValue*8, &dfNumber, 8 ); + } + break; + + case 'o': + if( poItemObjectType != NULL ) + { + int nExtraOffset = 0; + int iIndexCounter; + + if( poItemObjectType->nBytes > 0 ) + { + nExtraOffset = poItemObjectType->nBytes * nIndexValue; + } + else + { + for( iIndexCounter = 0; + iIndexCounter < nIndexValue; + iIndexCounter++ ) + { + nExtraOffset += + poItemObjectType->GetInstBytes(pabyData+nExtraOffset); + } + } + + if( pszField != NULL && strlen(pszField) > 0 ) + { + return( poItemObjectType-> + SetInstValue( pszField, pabyData + nExtraOffset, + nDataOffset + nExtraOffset, + nDataSize - nExtraOffset, + chReqType, pValue ) ); + } + } + break; + + default: + CPLAssert( FALSE ); + return CE_Failure; + break; + } + + return CE_None; +} + +/************************************************************************/ +/* ExtractInstValue() */ +/* */ +/* Extract the value of an instance of a field. */ +/* */ +/* pszField should be NULL if this field is not a */ +/* substructure. */ +/************************************************************************/ + +void * +HFAField::ExtractInstValue( const char * pszField, int nIndexValue, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType ) + +{ + char *pszStringRet = NULL; + static int nIntRet = 0; + static double dfDoubleRet = 0.0; + int nInstItemCount = GetInstCount( pabyData ); + GByte *pabyRawData = NULL; + +/* -------------------------------------------------------------------- */ +/* Check the index value is valid. */ +/* */ +/* Eventually this will have to account for variable fields. */ +/* -------------------------------------------------------------------- */ + if( nIndexValue < 0 || nIndexValue >= nInstItemCount ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* If this field contains a pointer, then we will adjust the */ +/* data offset relative to it. */ +/* -------------------------------------------------------------------- */ + if( chPointer != '\0' ) + { + GUInt32 nOffset; + + memcpy( &nOffset, pabyData+4, 4 ); + HFAStandard( 4, &nOffset ); + + if( nOffset != (GUInt32) (nDataOffset + 8) ) + { +#ifdef notdef + CPLError( CE_Warning, CPLE_AppDefined, + "%s.%s points at %d, not %d as expected\n", + pszFieldName, pszField ? pszField : "", + nOffset, nDataOffset+8 ); +#endif + } + + pabyData += 8; + + nDataOffset += 8; + nDataSize -= 8; + } + +/* -------------------------------------------------------------------- */ +/* pointers to char or uchar arrays requested as strings are */ +/* handled as a special case. */ +/* -------------------------------------------------------------------- */ + if( (chItemType == 'c' || chItemType == 'C') && chReqType == 's' ) + return( pabyData ); + +/* -------------------------------------------------------------------- */ +/* Handle by type. */ +/* -------------------------------------------------------------------- */ + switch( chItemType ) + { + case 'c': + case 'C': + nIntRet = pabyData[nIndexValue]; + dfDoubleRet = nIntRet; + break; + + case 'e': + case 's': + { + unsigned short nNumber; + + memcpy( &nNumber, pabyData + nIndexValue*2, 2 ); + HFAStandard( 2, &nNumber ); + nIntRet = nNumber; + dfDoubleRet = nIntRet; + + if( chItemType == 'e' + && nIntRet >= 0 && nIntRet < CSLCount(papszEnumNames) ) + { + pszStringRet = papszEnumNames[nIntRet]; + } + } + break; + + case 'S': + { + short nNumber; + + memcpy( &nNumber, pabyData + nIndexValue*2, 2 ); + HFAStandard( 2, &nNumber ); + nIntRet = nNumber; + dfDoubleRet = nIntRet; + } + break; + + case 't': + case 'l': + { + GUInt32 nNumber; + + memcpy( &nNumber, pabyData + nIndexValue*4, 4 ); + HFAStandard( 4, &nNumber ); + nIntRet = nNumber; + dfDoubleRet = nIntRet; + } + break; + + case 'L': + { + GInt32 nNumber; + + memcpy( &nNumber, pabyData + nIndexValue*4, 4 ); + HFAStandard( 4, &nNumber ); + nIntRet = nNumber; + dfDoubleRet = nIntRet; + } + break; + + case 'f': + { + float fNumber; + + memcpy( &fNumber, pabyData + nIndexValue*4, 4 ); + HFAStandard( 4, &fNumber ); + dfDoubleRet = fNumber; + nIntRet = (int) fNumber; + } + break; + + case 'd': + { + double dfNumber; + + memcpy( &dfNumber, pabyData + nIndexValue*8, 8 ); + HFAStandard( 8, &dfNumber ); + dfDoubleRet = dfNumber; + nIntRet = (int) dfNumber; + } + break; + + case 'b': + { + GInt32 nRows, nColumns; + GInt16 nBaseItemType; + + memcpy( &nRows, pabyData, 4 ); + HFAStandard( 4, &nRows ); + memcpy( &nColumns, pabyData+4, 4 ); + HFAStandard( 4, &nColumns ); + memcpy( &nBaseItemType, pabyData+8, 2 ); + HFAStandard( 2, &nBaseItemType ); + // We ignore the 2 byte objecttype value. + + if( nIndexValue < 0 || nIndexValue >= nRows * nColumns ) + return NULL; + + pabyData += 12; + + CPLAssert( nRows >= 1 && nColumns >= 1 ); + + if( nBaseItemType == EPT_u8 ) + { + dfDoubleRet = pabyData[nIndexValue]; + nIntRet = pabyData[nIndexValue]; + } + else if( nBaseItemType == EPT_s16 ) + { + GInt16 nValue; + + memcpy( &nValue, pabyData + 2*nIndexValue, 2 ); + HFAStandard( 2, &nValue ); + + dfDoubleRet = nValue; + nIntRet = nValue; + } + else if( nBaseItemType == EPT_u16 ) + { + GUInt16 nValue; + + memcpy( &nValue, pabyData + 2*nIndexValue, 2 ); + HFAStandard( 2, &nValue ); + + dfDoubleRet = nValue; + nIntRet = nValue; + } + else if( nBaseItemType == EPT_f32 ) + { + float fValue; + + memcpy( &fValue, pabyData + 4*nIndexValue, 4 ); + HFAStandard( 4, &fValue ); + + dfDoubleRet = fValue; + nIntRet = (int) fValue; + } + else if( nBaseItemType == EPT_f64 ) + { + double dfValue; + + memcpy( &dfValue, pabyData+8*nIndexValue, 8 ); + HFAStandard( 8, &dfValue ); + + dfDoubleRet = dfValue; + nIntRet = (int) dfValue; + } + else + { + CPLAssert( FALSE ); + return NULL; + } + } + break; + + case 'o': + if( poItemObjectType != NULL ) + { + int nExtraOffset = 0; + int iIndexCounter; + + if( poItemObjectType->nBytes > 0 ) + { + nExtraOffset = poItemObjectType->nBytes * nIndexValue; + } + else + { + for( iIndexCounter = 0; + iIndexCounter < nIndexValue; + iIndexCounter++ ) + { + nExtraOffset += + poItemObjectType->GetInstBytes(pabyData+nExtraOffset); + } + } + + pabyRawData = pabyData + nExtraOffset; + + if( pszField != NULL && strlen(pszField) > 0 ) + { + return( poItemObjectType-> + ExtractInstValue( pszField, pabyRawData, + nDataOffset + nExtraOffset, + nDataSize - nExtraOffset, + chReqType ) ); + } + } + break; + + default: + return NULL; + break; + } + +/* -------------------------------------------------------------------- */ +/* Return the appropriate representation. */ +/* -------------------------------------------------------------------- */ + if( chReqType == 's' ) + { + if( pszStringRet == NULL ) + { + static char szNumber[28]; + + sprintf( szNumber, "%d", nIntRet ); + pszStringRet = szNumber; + } + + return( pszStringRet ); + } + else if( chReqType == 'd' ) + return( &dfDoubleRet ); + else if( chReqType == 'i' ) + return( &nIntRet ); + else if( chReqType == 'p' ) + return( pabyRawData ); + else + { + CPLAssert( FALSE ); + return NULL; + } +} + +/************************************************************************/ +/* GetInstBytes() */ +/* */ +/* Get the number of bytes in a particular instance of a */ +/* field. This will normally be the fixed internal nBytes */ +/* value, but for pointer objects will include the variable */ +/* portion. */ +/************************************************************************/ + +int HFAField::GetInstBytes( GByte * pabyData ) + +{ + int nCount; + int nInstBytes = 0; + + if( nBytes > -1 ) + return nBytes; + + if( chPointer != '\0' ) + { + memcpy( &nCount, pabyData, 4 ); + HFAStandard( 4, &nCount ); + + pabyData += 8; + nInstBytes += 8; + } + else + nCount = 1; + + if( chItemType == 'b' && nCount != 0 ) // BASEDATA + { + GInt32 nRows, nColumns; + GInt16 nBaseItemType; + + memcpy( &nRows, pabyData, 4 ); + HFAStandard( 4, &nRows ); + memcpy( &nColumns, pabyData+4, 4 ); + HFAStandard( 4, &nColumns ); + memcpy( &nBaseItemType, pabyData+8, 2 ); + HFAStandard( 2, &nBaseItemType ); + + nInstBytes += 12; + + nInstBytes += + ((HFAGetDataTypeBits(nBaseItemType) + 7) / 8) * nRows * nColumns; + } + else if( poItemObjectType == NULL ) + { + nInstBytes += nCount * HFADictionary::GetItemSize(chItemType); + } + else + { + int i; + + for( i = 0; i < nCount; i++ ) + { + int nThisBytes; + + nThisBytes = poItemObjectType->GetInstBytes( pabyData ); + nInstBytes += nThisBytes; + pabyData += nThisBytes; + } + } + + return( nInstBytes ); +} + +/************************************************************************/ +/* GetInstCount() */ +/* */ +/* Get the count for a particular instance of a field. This */ +/* will normally be the built in value, but for variable fields */ +/* this is extracted from the data itself. */ +/************************************************************************/ + +int HFAField::GetInstCount( GByte * pabyData ) + +{ + if( chPointer == '\0' ) + return nItemCount; + else if( chItemType == 'b' ) + { + GInt32 nRows, nColumns; + + memcpy( &nRows, pabyData+8, 4 ); + HFAStandard( 4, &nRows ); + memcpy( &nColumns, pabyData+12, 4 ); + HFAStandard( 4, &nColumns ); + + return nRows * nColumns; + } + else + { + GInt32 nCount; + + memcpy( &nCount, pabyData, 4 ); + HFAStandard( 4, &nCount ); + return nCount; + } +} + +/************************************************************************/ +/* DumpInstValue() */ +/************************************************************************/ + +void HFAField::DumpInstValue( FILE *fpOut, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + const char *pszPrefix ) + +{ + int iEntry, nEntries; + void *pReturn; + char szLongFieldName[256]; + + nEntries = GetInstCount( pabyData ); + +/* -------------------------------------------------------------------- */ +/* Special case for arrays of chars or uchars which are printed */ +/* as a string. */ +/* -------------------------------------------------------------------- */ + if( (chItemType == 'c' || chItemType == 'C') && nEntries > 0 ) + { + pReturn = ExtractInstValue( NULL, 0, + pabyData, nDataOffset, nDataSize, + 's' ); + if( pReturn != NULL ) + VSIFPrintf( fpOut, "%s%s = `%s'\n", + pszPrefix, pszFieldName, + (char *) pReturn ); + else + VSIFPrintf( fpOut, "%s%s = (access failed)\n", + pszPrefix, pszFieldName ); + + return; + } + +/* -------------------------------------------------------------------- */ +/* Dump each entry in the field array. */ +/* -------------------------------------------------------------------- */ + for( iEntry = 0; iEntry < MIN(MAX_ENTRY_REPORT,nEntries); iEntry++ ) + { + if( nEntries == 1 ) + VSIFPrintf( fpOut, "%s%s = ", pszPrefix, pszFieldName ); + else + VSIFPrintf( fpOut, "%s%s[%d] = ", + pszPrefix, pszFieldName, iEntry ); + + switch( chItemType ) + { + case 'f': + case 'd': + pReturn = ExtractInstValue( NULL, iEntry, + pabyData, nDataOffset, nDataSize, + 'd' ); + if( pReturn != NULL ) + VSIFPrintf( fpOut, "%f\n", + *((double *) pReturn) ); + else + VSIFPrintf( fpOut, "(access failed)\n" ); + break; + + case 'b': + { + GInt32 nRows, nColumns; + + GInt16 nBaseItemType; + + memcpy( &nRows, pabyData+8, 4 ); + HFAStandard( 4, &nRows ); + memcpy( &nColumns, pabyData+12, 4 ); + HFAStandard( 4, &nColumns ); + memcpy( &nBaseItemType, pabyData+16, 2 ); + HFAStandard( 2, &nBaseItemType ); + + VSIFPrintf( fpOut, "%dx%d basedata of type %s\n", + nRows, nColumns, HFAGetDataTypeName(nBaseItemType) ); + } + break; + + case 'e': + pReturn = ExtractInstValue( NULL, iEntry, + pabyData, nDataOffset, nDataSize, + 's' ); + if( pReturn != NULL ) + VSIFPrintf( fpOut, "%s\n", + (char *) pReturn ); + else + VSIFPrintf( fpOut, "(access failed)\n" ); + break; + + case 'o': + pReturn = ExtractInstValue( NULL, iEntry, + pabyData, nDataOffset, nDataSize, + 'p' ); + + if( pReturn == NULL ) + { + VSIFPrintf( fpOut, "(access failed)\n" ); + } + else + { + int nByteOffset; + + VSIFPrintf( fpOut, "\n" ); + + nByteOffset = ((GByte *) pReturn) - pabyData; + + sprintf( szLongFieldName, "%s ", pszPrefix ); + + poItemObjectType->DumpInstValue( fpOut, + pabyData + nByteOffset, + nDataOffset + nByteOffset, + nDataSize - nByteOffset, + szLongFieldName ); + } + break; + + default: + pReturn = ExtractInstValue( NULL, iEntry, + pabyData, nDataOffset, nDataSize, + 'i' ); + if( pReturn != NULL ) + VSIFPrintf( fpOut, "%d\n", + *((int *) pReturn) ); + else + VSIFPrintf( fpOut, "(access failed)\n" ); + break; + } + } + + if( nEntries > MAX_ENTRY_REPORT ) + printf( "%s ... remaining instances omitted ...\n", pszPrefix ); + + if( nEntries == 0 ) + VSIFPrintf( fpOut, "%s%s = (no values)\n", pszPrefix, pszFieldName ); + +} diff --git a/Utilities/GDAL/frmts/hfa/hfaopen.cpp b/Utilities/GDAL/frmts/hfa/hfaopen.cpp new file mode 100644 index 0000000000..b2d96a5cf5 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfaopen.cpp @@ -0,0 +1,2618 @@ +/****************************************************************************** + * $Id: hfaopen.cpp,v 1.55 2006/04/19 14:07:03 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Supporting functions for HFA (.img) ... main (C callable) API + * that is not dependent on GDAL (just CPL). + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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. + ****************************************************************************** + * + * hfaopen.cpp + * + * Supporting routines for reading Erdas Imagine (.imf) Heirarchical + * File Architecture files. This is intended to be a library independent + * of the GDAL core, but dependent on the Common Portability Library. + * + * $Log: hfaopen.cpp,v $ + * Revision 1.55 2006/04/19 14:07:03 fwarmerdam + * do not attempt to use papoBand[0] if there are zero bands + * + * Revision 1.54 2006/04/04 17:10:07 fwarmerdam + * Figured out the proper way to use the MapToPixelXForm stuff. + * + * Revision 1.53 2006/04/03 04:34:19 fwarmerdam + * added support for reading affine polynomial transforms as geotransform + * + * Revision 1.52 2006/03/29 14:24:04 fwarmerdam + * added preliminary nodata support (readonly) + * + * Revision 1.51 2006/01/09 15:26:48 fwarmerdam + * fixed logic for computing spill file size + * + * Revision 1.50 2005/12/23 18:54:54 fwarmerdam + * fixed error message when creating big files + * + * Revision 1.49 2005/12/21 05:30:45 fwarmerdam + * return compression type as metadata + * + * Revision 1.48 2005/10/24 14:35:55 fwarmerdam + * Be careful not to generate a new histogram table in various + * degenerate situations like those of zonegimg.img. + * + * Revision 1.47 2005/09/17 03:47:16 fwarmerdam + * added dependent overview creation + * + * Revision 1.46 2005/09/16 23:10:52 fwarmerdam + * Docs talk about COMPRESSED, not COMPRESS. Support both. + * Set logvalid flag to false when creating compressed blockinfos + * since no space is allocated. + * + * Revision 1.45 2005/09/15 20:36:42 fwarmerdam + * added HFACreateDependent + * + * Revision 1.44 2005/08/20 23:43:37 fwarmerdam + * Better implementation of HFADelete(). + * + * Revision 1.43 2005/08/19 02:14:11 fwarmerdam + * bug 857: add ability to set layer names + * + * Revision 1.42 2005/05/13 05:19:53 fwarmerdam + * Fixed VSIFSeek that should have been VSIFSeekL(). + * + * Revision 1.41 2005/05/13 04:57:18 fwarmerdam + * fix handling of large offsets in ige file for HFACreateLayer() + * + * Revision 1.40 2005/05/13 02:07:20 fwarmerdam + * generalized use of spill file, added HFACreateSpillStack + * + * Revision 1.39 2005/05/10 00:57:17 fwarmerdam + * factored out CreateLayer code, added CreateOverview + * + * Revision 1.38 2005/02/22 21:34:18 fwarmerdam + * minor comment cleanup + * + * Revision 1.37 2005/02/17 22:21:49 fwarmerdam + * avoid memory leak + * + * Revision 1.36 2005/01/10 18:25:06 fwarmerdam + * added support for getting/setting LAYER_TYPE metadata + * + * Revision 1.35 2005/01/10 17:41:27 fwarmerdam + * added HFA compression support: bug 664 + */ + +#include "hfa_p.h" +#include "cpl_conv.h" +#include "gdal_alg.h" +#include <limits.h> + +CPL_CVSID("$Id: hfaopen.cpp,v 1.55 2006/04/19 14:07:03 fwarmerdam Exp $"); + + +static char *apszAuxMetadataItems[] = { + +// node/entry field_name metadata_key type + + "Statistics", "dminimum", "STATISTICS_MINIMUM", "Esta_Statistics", + "Statistics", "dmaximum", "STATISTICS_MAXIMUM", "Esta_Statistics", + "Statistics", "dmean", "STATISTICS_MEAN", "Esta_Statistics", + "Statistics", "dmedian", "STATISTICS_MEDIAN", "Esta_Statistics", + "Statistics", "dmode", "STATISTICS_MODE", "Esta_Statistics", + "Statistics", "dstddev", "STATISTICS_STDDEV", "Esta_Statistics", + "HistogramParameters", "lBinFunction.numBins", "STATISTICS_HISTONUMBINS", "Eimg_StatisticsParameters830", + "HistogramParameters", "dBinFunction.minLimit", "STATISTICS_HISTOMIN", "Eimg_StatisticsParameters830", + "HistogramParameters", "dBinFunction.maxLimit", "STATISTICS_HISTOMAX", "Eimg_StatisticsParameters830", + "", "elayerType", "LAYER_TYPE", "", + NULL +}; + + +char ** GetHFAAuxMetaDataList() +{ + return apszAuxMetadataItems; +} + + +/************************************************************************/ +/* HFAGetDictionary() */ +/************************************************************************/ + +static char * HFAGetDictionary( HFAHandle hHFA ) + +{ + int nDictMax = 100; + char *pszDictionary = (char *) CPLMalloc(nDictMax); + int nDictSize = 0; + + VSIFSeekL( hHFA->fp, hHFA->nDictionaryPos, SEEK_SET ); + + while( TRUE ) + { + if( nDictSize >= nDictMax-1 ) + { + nDictMax = nDictSize * 2 + 100; + pszDictionary = (char *) CPLRealloc(pszDictionary, nDictMax ); + } + + if( VSIFReadL( pszDictionary + nDictSize, 1, 1, hHFA->fp ) < 1 + || pszDictionary[nDictSize] == '\0' + || (nDictSize > 2 && pszDictionary[nDictSize-2] == ',' + && pszDictionary[nDictSize-1] == '.') ) + break; + + nDictSize++; + } + + pszDictionary[nDictSize] = '\0'; + + + return( pszDictionary ); +} + +/************************************************************************/ +/* HFAOpen() */ +/************************************************************************/ + +HFAHandle HFAOpen( const char * pszFilename, const char * pszAccess ) + +{ + FILE *fp; + char szHeader[16]; + HFAInfo_t *psInfo; + GUInt32 nHeaderPos; + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszAccess,"r") || EQUAL(pszAccess,"rb" ) ) + fp = VSIFOpenL( pszFilename, "rb" ); + else + fp = VSIFOpenL( pszFilename, "r+b" ); + + /* should this be changed to use some sort of CPLFOpen() which will + set the error? */ + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "File open of %s failed.", + pszFilename ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read and verify the header. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( szHeader, 16, 1, fp ) < 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to read 16 byte header failed for\n%s.", + pszFilename ); + + return NULL; + } + + if( !EQUALN(szHeader,"EHFA_HEADER_TAG",15) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "File %s is not an Imagine HFA file ... header wrong.", + pszFilename ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create the HFAInfo_t */ +/* -------------------------------------------------------------------- */ + psInfo = (HFAInfo_t *) CPLCalloc(sizeof(HFAInfo_t),1); + + psInfo->pszFilename = CPLStrdup(CPLGetFilename(pszFilename)); + psInfo->pszPath = CPLStrdup(CPLGetPath(pszFilename)); + psInfo->fp = fp; + if( EQUAL(pszAccess,"r") || EQUAL(pszAccess,"rb" ) ) + psInfo->eAccess = HFA_ReadOnly; + else + psInfo->eAccess = HFA_Update; + psInfo->bTreeDirty = FALSE; + +/* -------------------------------------------------------------------- */ +/* Where is the header? */ +/* -------------------------------------------------------------------- */ + VSIFReadL( &nHeaderPos, sizeof(GInt32), 1, fp ); + HFAStandard( 4, &nHeaderPos ); + +/* -------------------------------------------------------------------- */ +/* Read the header. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( fp, nHeaderPos, SEEK_SET ); + + VSIFReadL( &(psInfo->nVersion), sizeof(GInt32), 1, fp ); + HFAStandard( 4, &(psInfo->nVersion) ); + + VSIFReadL( szHeader, 4, 1, fp ); /* skip freeList */ + + VSIFReadL( &(psInfo->nRootPos), sizeof(GInt32), 1, fp ); + HFAStandard( 4, &(psInfo->nRootPos) ); + + VSIFReadL( &(psInfo->nEntryHeaderLength), sizeof(GInt16), 1, fp ); + HFAStandard( 2, &(psInfo->nEntryHeaderLength) ); + + VSIFReadL( &(psInfo->nDictionaryPos), sizeof(GInt32), 1, fp ); + HFAStandard( 4, &(psInfo->nDictionaryPos) ); + +/* -------------------------------------------------------------------- */ +/* Collect file size. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( fp, 0, SEEK_END ); + psInfo->nEndOfFile = (GUInt32) VSIFTellL( fp ); + +/* -------------------------------------------------------------------- */ +/* Instantiate the root entry. */ +/* -------------------------------------------------------------------- */ + psInfo->poRoot = new HFAEntry( psInfo, psInfo->nRootPos, NULL, NULL ); + +/* -------------------------------------------------------------------- */ +/* Read the dictionary */ +/* -------------------------------------------------------------------- */ + psInfo->pszDictionary = HFAGetDictionary( psInfo ); + psInfo->poDictionary = new HFADictionary( psInfo->pszDictionary ); + +/* -------------------------------------------------------------------- */ +/* Collect band definitions. */ +/* -------------------------------------------------------------------- */ + HFAParseBandInfo( psInfo ); + + return psInfo; +} + +/************************************************************************/ +/* HFACreateDependent() */ +/* */ +/* Create a .rrd file for the named file if it does not exist, */ +/* or return the existing dependent if it already exists. */ +/************************************************************************/ + +HFAInfo_t *HFACreateDependent( HFAInfo_t *psBase ) + +{ + if( psBase->psDependent != NULL ) + return psBase->psDependent; + +/* -------------------------------------------------------------------- */ +/* Create desired RRD filename. */ +/* -------------------------------------------------------------------- */ + CPLString oBasename = CPLGetBasename( psBase->pszFilename ); + CPLString oRRDFilename = + CPLFormFilename( psBase->pszPath, oBasename, "rrd" ); + +/* -------------------------------------------------------------------- */ +/* Does this file already exist? If so, re-use it. */ +/* -------------------------------------------------------------------- */ + FILE *fp = VSIFOpenL( oRRDFilename, "rb" ); + if( fp != NULL ) + { + VSIFCloseL( fp ); + psBase->psDependent = HFAOpen( oRRDFilename, "rb" ); + } + +/* -------------------------------------------------------------------- */ +/* Otherwise create it now. */ +/* -------------------------------------------------------------------- */ + HFAInfo_t *psDep; + psDep = psBase->psDependent = HFACreateLL( oRRDFilename ); + +/* -------------------------------------------------------------------- */ +/* Add the DependentFile node with the pointer back to the */ +/* parent. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poDF = new HFAEntry( psDep, "DependentFile", + "Eimg_DependentFile", psDep->poRoot ); + + poDF->MakeData( strlen(psBase->pszFilename) + 50 ); + poDF->SetPosition(); + poDF->SetStringField( "dependent.string", psBase->pszFilename ); + + return psDep; +} + +/************************************************************************/ +/* HFAGetDependent() */ +/************************************************************************/ + +HFAInfo_t *HFAGetDependent( HFAInfo_t *psBase, const char *pszFilename ) + +{ + if( EQUAL(pszFilename,psBase->pszFilename) ) + return psBase; + + if( psBase->psDependent != NULL ) + { + if( EQUAL(pszFilename,psBase->psDependent->pszFilename) ) + return psBase->psDependent; + else + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to open the dependent file. */ +/* -------------------------------------------------------------------- */ + char *pszDependent; + FILE *fp; + + pszDependent = CPLStrdup( + CPLFormFilename( psBase->pszPath, pszFilename, NULL ) ); + + fp = VSIFOpenL( pszDependent, "rb" ); + if( fp != NULL ) + { + VSIFCloseL( fp ); + psBase->psDependent = HFAOpen( pszDependent, "rb" ); + } + + CPLFree( pszDependent ); + + return psBase->psDependent; +} + + +/************************************************************************/ +/* HFAParseBandInfo() */ +/* */ +/* This is used by HFAOpen() and HFACreate() to initialize the */ +/* band structures. */ +/************************************************************************/ + +CPLErr HFAParseBandInfo( HFAInfo_t *psInfo ) + +{ + HFAEntry *poNode; + +/* -------------------------------------------------------------------- */ +/* Find the first band node. */ +/* -------------------------------------------------------------------- */ + psInfo->nBands = 0; + poNode = psInfo->poRoot->GetChild(); + while( poNode != NULL ) + { + if( EQUAL(poNode->GetType(),"Eimg_Layer") + && poNode->GetIntField("width") > 0 + && poNode->GetIntField("height") > 0 ) + { + if( psInfo->nBands == 0 ) + { + psInfo->nXSize = poNode->GetIntField("width"); + psInfo->nYSize = poNode->GetIntField("height"); + } + else if( poNode->GetIntField("width") != psInfo->nXSize + || poNode->GetIntField("height") != psInfo->nYSize ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + psInfo->papoBand = (HFABand **) + CPLRealloc(psInfo->papoBand, + sizeof(HFABand *) * (psInfo->nBands+1)); + psInfo->papoBand[psInfo->nBands] = new HFABand( psInfo, poNode ); + psInfo->nBands++; + } + + poNode = poNode->GetNext(); + } + + return CE_None; +} + +/************************************************************************/ +/* HFAClose() */ +/************************************************************************/ + +void HFAClose( HFAHandle hHFA ) + +{ + int i; + + if( hHFA->bTreeDirty ) + HFAFlush( hHFA ); + + if( hHFA->psDependent != NULL ) + HFAClose( hHFA->psDependent ); + + delete hHFA->poRoot; + + VSIFCloseL( hHFA->fp ); + + if( hHFA->poDictionary != NULL ) + delete hHFA->poDictionary; + + CPLFree( hHFA->pszDictionary ); + CPLFree( hHFA->pszFilename ); + CPLFree( hHFA->pszPath ); + + for( i = 0; i < hHFA->nBands; i++ ) + { + delete hHFA->papoBand[i]; + } + + CPLFree( hHFA->papoBand ); + + if( hHFA->pProParameters != NULL ) + { + Eprj_ProParameters *psProParms = (Eprj_ProParameters *) + hHFA->pProParameters; + + CPLFree( psProParms->proExeName ); + CPLFree( psProParms->proName ); + CPLFree( psProParms->proSpheroid.sphereName ); + + CPLFree( psProParms ); + } + + if( hHFA->pDatum != NULL ) + { + CPLFree( ((Eprj_Datum *) hHFA->pDatum)->datumname ); + CPLFree( ((Eprj_Datum *) hHFA->pDatum)->gridname ); + CPLFree( hHFA->pDatum ); + } + + if( hHFA->pMapInfo != NULL ) + { + CPLFree( ((Eprj_MapInfo *) hHFA->pMapInfo)->proName ); + CPLFree( ((Eprj_MapInfo *) hHFA->pMapInfo)->units ); + CPLFree( hHFA->pMapInfo ); + } + + CPLFree( hHFA ); +} + +/************************************************************************/ +/* HFARemove() */ +/* Used from HFADelete() function. */ +/************************************************************************/ + +CPLErr HFARemove( const char *pszFilename ) + +{ + VSIStatBuf sStat; + + if( VSIStat( pszFilename, &sStat ) == 0 && VSI_ISREG( sStat.st_mode ) ) + { + if( VSIUnlink( pszFilename ) == 0 ) + return CE_None; + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to unlink %s failed.\n", pszFilename ); + return CE_Failure; + } + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to delete %s, not a file.\n", pszFilename ); + return CE_Failure; + } +} + +/************************************************************************/ +/* HFADelete() */ +/************************************************************************/ + +CPLErr HFADelete( const char *pszFilename ) + +{ + HFAInfo_t *psInfo = HFAOpen( pszFilename, "rb" ); + HFAEntry *poDMS = NULL; + HFAEntry *poLayer = NULL; + HFAEntry *poNode = NULL; + + if( psInfo != NULL ) + { + poNode = psInfo->poRoot->GetChild(); + while( ( poNode != NULL ) && ( poLayer == NULL ) ) + { + if( EQUAL(poNode->GetType(),"Eimg_Layer") ) + { + poLayer = poNode; + } + poNode = poNode->GetNext(); + } + + if( poLayer != NULL ) + poDMS = poLayer->GetNamedChild( "ExternalRasterDMS" ); + + if ( poDMS ) + { + const char *pszRawFilename = + poDMS->GetStringField( "fileName.string" ); + + if( pszRawFilename != NULL ) + HFARemove( CPLFormFilename( psInfo->pszPath, + pszRawFilename, NULL ) ); + } + + HFAClose( psInfo ); + } + return HFARemove( pszFilename ); +} + +/************************************************************************/ +/* HFAGetRasterInfo() */ +/************************************************************************/ + +CPLErr HFAGetRasterInfo( HFAHandle hHFA, int * pnXSize, int * pnYSize, + int * pnBands ) + +{ + if( pnXSize != NULL ) + *pnXSize = hHFA->nXSize; + if( pnYSize != NULL ) + *pnYSize = hHFA->nYSize; + if( pnBands != NULL ) + *pnBands = hHFA->nBands; + return CE_None; +} + +/************************************************************************/ +/* HFAGetBandInfo() */ +/************************************************************************/ + +CPLErr HFAGetBandInfo( HFAHandle hHFA, int nBand, int * pnDataType, + int * pnBlockXSize, int * pnBlockYSize, + int * pnOverviews, int *pnCompressionType ) + +{ + if( nBand < 0 || nBand > hHFA->nBands ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + HFABand *poBand = hHFA->papoBand[nBand-1]; + + if( pnDataType != NULL ) + *pnDataType = poBand->nDataType; + + if( pnBlockXSize != NULL ) + *pnBlockXSize = poBand->nBlockXSize; + + if( pnBlockYSize != NULL ) + *pnBlockYSize = poBand->nBlockYSize; + + if( pnOverviews != NULL ) + *pnOverviews = poBand->nOverviews; + + +/* -------------------------------------------------------------------- */ +/* Get compression code from RasterDMS. */ +/* -------------------------------------------------------------------- */ + if( pnCompressionType != NULL ) + { + HFAEntry *poDMS; + + *pnCompressionType = 0; + + poDMS = poBand->poNode->GetNamedChild( "RasterDMS" ); + + if( poDMS != NULL ) + *pnCompressionType = poDMS->GetIntField( "compressionType" ); + } + + return( CE_None ); +} + +/************************************************************************/ +/* HFAGetBandNoData() */ +/* */ +/* returns TRUE if value is set, otherwise FALSE. */ +/************************************************************************/ + +int HFAGetBandNoData( HFAHandle hHFA, int nBand, double *pdfNoData ) + +{ + if( nBand < 0 || nBand > hHFA->nBands ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + HFABand *poBand = hHFA->papoBand[nBand-1]; + + *pdfNoData = poBand->dfNoData; + return poBand->bNoDataSet; +} + +/************************************************************************/ +/* HFAGetOverviewInfo() */ +/************************************************************************/ + +CPLErr HFAGetOverviewInfo( HFAHandle hHFA, int nBand, int iOverview, + int * pnXSize, int * pnYSize, + int * pnBlockXSize, int * pnBlockYSize ) + +{ + HFABand *poBand; + + if( nBand < 0 || nBand > hHFA->nBands ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + + poBand = hHFA->papoBand[nBand-1]; + + if( iOverview < 0 || iOverview >= poBand->nOverviews ) + { + CPLAssert( FALSE ); + return CE_Failure; + } + poBand = poBand->papoOverviews[iOverview]; + + if( pnXSize != NULL ) + *pnXSize = poBand->nWidth; + + if( pnYSize != NULL ) + *pnYSize = poBand->nHeight; + + if( pnBlockXSize != NULL ) + *pnBlockXSize = poBand->nBlockXSize; + + if( pnBlockYSize != NULL ) + *pnBlockYSize = poBand->nBlockYSize; + + return( CE_None ); +} + +/************************************************************************/ +/* HFAGetRasterBlock() */ +/************************************************************************/ + +CPLErr HFAGetRasterBlock( HFAHandle hHFA, int nBand, + int nXBlock, int nYBlock, void * pData ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->GetRasterBlock(nXBlock,nYBlock,pData) ); +} + +/************************************************************************/ +/* HFAGetOverviewRasterBlock() */ +/************************************************************************/ + +CPLErr HFAGetOverviewRasterBlock( HFAHandle hHFA, int nBand, int iOverview, + int nXBlock, int nYBlock, void * pData ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + if( iOverview < 0 || iOverview >= hHFA->papoBand[nBand-1]->nOverviews ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->papoOverviews[iOverview]-> + GetRasterBlock(nXBlock,nYBlock,pData) ); +} + +/************************************************************************/ +/* HFASetRasterBlock() */ +/************************************************************************/ + +CPLErr HFASetRasterBlock( HFAHandle hHFA, int nBand, + int nXBlock, int nYBlock, void * pData ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->SetRasterBlock(nXBlock,nYBlock,pData) ); +} + +/************************************************************************/ +/* HFASetRasterBlock() */ +/************************************************************************/ + +CPLErr HFASetOverviewRasterBlock( HFAHandle hHFA, int nBand, int iOverview, + int nXBlock, int nYBlock, void * pData ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + if( iOverview < 0 || iOverview >= hHFA->papoBand[nBand-1]->nOverviews ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->papoOverviews[iOverview]-> + SetRasterBlock(nXBlock,nYBlock,pData) ); +} + +/************************************************************************/ +/* HFAGetBandName() */ +/************************************************************************/ + +const char * HFAGetBandName( HFAHandle hHFA, int nBand ) +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return ""; + + return( hHFA->papoBand[nBand-1]->GetBandName() ); +} + +/************************************************************************/ +/* HFASetBandName() */ +/************************************************************************/ + +void HFASetBandName( HFAHandle hHFA, int nBand, const char *pszName ) +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return; + + hHFA->papoBand[nBand-1]->SetBandName( pszName ); +} + +/************************************************************************/ +/* HFAGetDataTypeBits() */ +/************************************************************************/ + +int HFAGetDataTypeBits( int nDataType ) + +{ + switch( nDataType ) + { + case EPT_u1: + return 1; + + case EPT_u2: + return 2; + + case EPT_u4: + return 4; + + case EPT_u8: + case EPT_s8: + return 8; + + case EPT_u16: + case EPT_s16: + return 16; + + case EPT_u32: + case EPT_s32: + case EPT_f32: + return 32; + + case EPT_f64: + case EPT_c64: + return 64; + + case EPT_c128: + return 128; + } + + return 0; +} + +/************************************************************************/ +/* HFAGetDataTypeName() */ +/************************************************************************/ + +const char *HFAGetDataTypeName( int nDataType ) + +{ + switch( nDataType ) + { + case EPT_u1: + return "u1"; + + case EPT_u2: + return "u2"; + + case EPT_u4: + return "u4"; + + case EPT_u8: + return "u8"; + + case EPT_s8: + return "s8"; + + case EPT_u16: + return "u16"; + + case EPT_s16: + return "s16"; + + case EPT_u32: + return "u32"; + + case EPT_s32: + return "s32"; + + case EPT_f32: + return "f32"; + + case EPT_f64: + return "f64"; + + case EPT_c64: + return "c64"; + + case EPT_c128: + return "c128"; + + default: + return "unknown"; + } +} + +/************************************************************************/ +/* HFAGetMapInfo() */ +/************************************************************************/ + +const Eprj_MapInfo *HFAGetMapInfo( HFAHandle hHFA ) + +{ + HFAEntry *poMIEntry; + Eprj_MapInfo *psMapInfo; + + if( hHFA->nBands < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Do we already have it? */ +/* -------------------------------------------------------------------- */ + if( hHFA->pMapInfo != NULL ) + return( (Eprj_MapInfo *) hHFA->pMapInfo ); + +/* -------------------------------------------------------------------- */ +/* Get the HFA node. */ +/* -------------------------------------------------------------------- */ + poMIEntry = hHFA->papoBand[0]->poNode->GetNamedChild( "Map_Info" ); + if( poMIEntry == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Allocate the structure. */ +/* -------------------------------------------------------------------- */ + psMapInfo = (Eprj_MapInfo *) CPLCalloc(sizeof(Eprj_MapInfo),1); + +/* -------------------------------------------------------------------- */ +/* Fetch the fields. */ +/* -------------------------------------------------------------------- */ + psMapInfo->proName = CPLStrdup(poMIEntry->GetStringField("proName")); + + psMapInfo->upperLeftCenter.x = + poMIEntry->GetDoubleField("upperLeftCenter.x"); + psMapInfo->upperLeftCenter.y = + poMIEntry->GetDoubleField("upperLeftCenter.y"); + + psMapInfo->lowerRightCenter.x = + poMIEntry->GetDoubleField("lowerRightCenter.x"); + psMapInfo->lowerRightCenter.y = + poMIEntry->GetDoubleField("lowerRightCenter.y"); + + psMapInfo->pixelSize.width = + poMIEntry->GetDoubleField("pixelSize.width"); + psMapInfo->pixelSize.height = + poMIEntry->GetDoubleField("pixelSize.height"); + + psMapInfo->units = CPLStrdup(poMIEntry->GetStringField("units")); + + hHFA->pMapInfo = (void *) psMapInfo; + + return psMapInfo; +} + +/************************************************************************/ +/* int HFAGetGeoTransform() */ +/************************************************************************/ + +int HFAGetGeoTransform( HFAHandle hHFA, double *padfGeoTransform ) + +{ + const Eprj_MapInfo *psMapInfo = HFAGetMapInfo( hHFA ); + + padfGeoTransform[0] = 0.0; + padfGeoTransform[1] = 1.0; + padfGeoTransform[2] = 0.0; + padfGeoTransform[3] = 0.0; + padfGeoTransform[4] = 0.0; + padfGeoTransform[5] = 1.0; + +/* -------------------------------------------------------------------- */ +/* Simple (north up) MapInfo approach. */ +/* -------------------------------------------------------------------- */ + if( psMapInfo != NULL ) + { + padfGeoTransform[0] = psMapInfo->upperLeftCenter.x + - psMapInfo->pixelSize.width*0.5; + padfGeoTransform[1] = psMapInfo->pixelSize.width; + padfGeoTransform[2] = 0.0; + if( psMapInfo->upperLeftCenter.y > psMapInfo->lowerRightCenter.y ) + padfGeoTransform[5] = - psMapInfo->pixelSize.height; + else + padfGeoTransform[5] = psMapInfo->pixelSize.height; + + padfGeoTransform[3] = psMapInfo->upperLeftCenter.y + - padfGeoTransform[5]*0.5; + padfGeoTransform[4] = 0.0; + + // special logic to fixup odd angular units. + if( EQUAL(psMapInfo->units,"ds") ) + { + padfGeoTransform[0] /= 3600.0; + padfGeoTransform[1] /= 3600.0; + padfGeoTransform[2] /= 3600.0; + padfGeoTransform[3] /= 3600.0; + padfGeoTransform[4] /= 3600.0; + padfGeoTransform[5] /= 3600.0; + } + + return TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Try for a MapToPixelXForm affine polynomial supporting */ +/* rotated and sheared affine transformations. */ +/* -------------------------------------------------------------------- */ + if( hHFA->nBands == 0 ) + return FALSE; + + HFAEntry *poXForm0 = + hHFA->papoBand[0]->poNode->GetNamedChild( "MapToPixelXForm.XForm0" ); + + if( poXForm0 == NULL ) + return FALSE; + + if( poXForm0->GetIntField( "order" ) != 1 + || poXForm0->GetIntField( "numdimtransform" ) != 2 + || poXForm0->GetIntField( "numdimpolynomial" ) != 2 + || poXForm0->GetIntField( "termcount" ) != 3 ) + return FALSE; + + // we should check that the exponent list is 0 0 1 0 0 1 but + // we don't because we are lazy + + // fetch geotransform values. + double adfXForm[6]; + + adfXForm[0] = poXForm0->GetDoubleField( "polycoefvector[0]" ); + adfXForm[1] = poXForm0->GetDoubleField( "polycoefmtx[0]" ); + adfXForm[4] = poXForm0->GetDoubleField( "polycoefmtx[1]" ); + adfXForm[3] = poXForm0->GetDoubleField( "polycoefvector[1]" ); + adfXForm[2] = poXForm0->GetDoubleField( "polycoefmtx[2]" ); + adfXForm[5] = poXForm0->GetDoubleField( "polycoefmtx[3]" ); + + // invert + + GDALInvGeoTransform( adfXForm, padfGeoTransform ); + + // Adjust origin from center of top left pixel to top left corner + // of top left pixel. + + padfGeoTransform[0] -= padfGeoTransform[1] * 0.5; + padfGeoTransform[0] -= padfGeoTransform[2] * 0.5; + padfGeoTransform[3] -= padfGeoTransform[4] * 0.5; + padfGeoTransform[3] -= padfGeoTransform[5] * 0.5; + + return TRUE; +} + +/************************************************************************/ +/* HFASetMapInfo() */ +/************************************************************************/ + +CPLErr HFASetMapInfo( HFAHandle hHFA, const Eprj_MapInfo *poMapInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Loop over bands, setting information on each one. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < hHFA->nBands; iBand++ ) + { + HFAEntry *poMIEntry; + +/* -------------------------------------------------------------------- */ +/* Create a new Map_Info if there isn't one present already. */ +/* -------------------------------------------------------------------- */ + poMIEntry = hHFA->papoBand[iBand]->poNode->GetNamedChild( "Map_Info" ); + if( poMIEntry == NULL ) + { + poMIEntry = new HFAEntry( hHFA, "Map_Info", "Eprj_MapInfo", + hHFA->papoBand[iBand]->poNode ); + } + + poMIEntry->MarkDirty(); + +/* -------------------------------------------------------------------- */ +/* Ensure we have enough space for all the data. */ +/* -------------------------------------------------------------------- */ + int nSize; + GByte *pabyData; + + nSize = 48 + 40 + + strlen(poMapInfo->proName) + 1 + + strlen(poMapInfo->units) + 1; + + pabyData = poMIEntry->MakeData( nSize ); + poMIEntry->SetPosition(); + +/* -------------------------------------------------------------------- */ +/* Write the various fields. */ +/* -------------------------------------------------------------------- */ + poMIEntry->SetStringField( "proName", poMapInfo->proName ); + + poMIEntry->SetDoubleField( "upperLeftCenter.x", + poMapInfo->upperLeftCenter.x ); + poMIEntry->SetDoubleField( "upperLeftCenter.y", + poMapInfo->upperLeftCenter.y ); + + poMIEntry->SetDoubleField( "lowerRightCenter.x", + poMapInfo->lowerRightCenter.x ); + poMIEntry->SetDoubleField( "lowerRightCenter.y", + poMapInfo->lowerRightCenter.y ); + + poMIEntry->SetDoubleField( "pixelSize.width", + poMapInfo->pixelSize.width ); + poMIEntry->SetDoubleField( "pixelSize.height", + poMapInfo->pixelSize.height ); + + poMIEntry->SetStringField( "units", poMapInfo->units ); + } + + return CE_None; +} + +/************************************************************************/ +/* HFAGetProParameters() */ +/************************************************************************/ + +const Eprj_ProParameters *HFAGetProParameters( HFAHandle hHFA ) + +{ + HFAEntry *poMIEntry; + Eprj_ProParameters *psProParms; + int i; + + if( hHFA->nBands < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Do we already have it? */ +/* -------------------------------------------------------------------- */ + if( hHFA->pProParameters != NULL ) + return( (Eprj_ProParameters *) hHFA->pProParameters ); + +/* -------------------------------------------------------------------- */ +/* Get the HFA node. */ +/* -------------------------------------------------------------------- */ + poMIEntry = hHFA->papoBand[0]->poNode->GetNamedChild( "Projection" ); + if( poMIEntry == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Allocate the structure. */ +/* -------------------------------------------------------------------- */ + psProParms = (Eprj_ProParameters *)CPLCalloc(sizeof(Eprj_ProParameters),1); + +/* -------------------------------------------------------------------- */ +/* Fetch the fields. */ +/* -------------------------------------------------------------------- */ + psProParms->proType = (Eprj_ProType) poMIEntry->GetIntField("proType"); + psProParms->proNumber = poMIEntry->GetIntField("proNumber"); + psProParms->proExeName =CPLStrdup(poMIEntry->GetStringField("proExeName")); + psProParms->proName = CPLStrdup(poMIEntry->GetStringField("proName")); + psProParms->proZone = poMIEntry->GetIntField("proZone"); + + for( i = 0; i < 15; i++ ) + { + char szFieldName[30]; + + sprintf( szFieldName, "proParams[%d]", i ); + psProParms->proParams[i] = poMIEntry->GetDoubleField(szFieldName); + } + + psProParms->proSpheroid.sphereName = + CPLStrdup(poMIEntry->GetStringField("proSpheroid.sphereName")); + psProParms->proSpheroid.a = poMIEntry->GetDoubleField("proSpheroid.a"); + psProParms->proSpheroid.b = poMIEntry->GetDoubleField("proSpheroid.b"); + psProParms->proSpheroid.eSquared = + poMIEntry->GetDoubleField("proSpheroid.eSquared"); + psProParms->proSpheroid.radius = + poMIEntry->GetDoubleField("proSpheroid.radius"); + + hHFA->pProParameters = (void *) psProParms; + + return psProParms; +} + +/************************************************************************/ +/* HFASetProParameters() */ +/************************************************************************/ + +CPLErr HFASetProParameters( HFAHandle hHFA, const Eprj_ProParameters *poPro ) + +{ +/* -------------------------------------------------------------------- */ +/* Loop over bands, setting information on each one. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < hHFA->nBands; iBand++ ) + { + HFAEntry *poMIEntry; + +/* -------------------------------------------------------------------- */ +/* Create a new Projection if there isn't one present already. */ +/* -------------------------------------------------------------------- */ + poMIEntry = hHFA->papoBand[iBand]->poNode->GetNamedChild("Projection"); + if( poMIEntry == NULL ) + { + poMIEntry = new HFAEntry( hHFA, "Projection","Eprj_ProParameters", + hHFA->papoBand[iBand]->poNode ); + } + + poMIEntry->MarkDirty(); + +/* -------------------------------------------------------------------- */ +/* Ensure we have enough space for all the data. */ +/* -------------------------------------------------------------------- */ + int nSize; + GByte *pabyData; + + nSize = 34 + 15 * 8 + + 8 + strlen(poPro->proName) + 1 + + 32 + 8 + strlen(poPro->proSpheroid.sphereName) + 1; + + if( poPro->proExeName != NULL ) + nSize += strlen(poPro->proExeName) + 1; + + pabyData = poMIEntry->MakeData( nSize ); + poMIEntry->SetPosition(); + +/* -------------------------------------------------------------------- */ +/* Write the various fields. */ +/* -------------------------------------------------------------------- */ + poMIEntry->SetIntField( "proType", poPro->proType ); + + poMIEntry->SetIntField( "proNumber", poPro->proNumber ); + + poMIEntry->SetStringField( "proExeName", poPro->proExeName ); + poMIEntry->SetStringField( "proName", poPro->proName ); + poMIEntry->SetIntField( "proZone", poPro->proZone ); + poMIEntry->SetDoubleField( "proParams[0]", poPro->proParams[0] ); + poMIEntry->SetDoubleField( "proParams[1]", poPro->proParams[1] ); + poMIEntry->SetDoubleField( "proParams[2]", poPro->proParams[2] ); + poMIEntry->SetDoubleField( "proParams[3]", poPro->proParams[3] ); + poMIEntry->SetDoubleField( "proParams[4]", poPro->proParams[4] ); + poMIEntry->SetDoubleField( "proParams[5]", poPro->proParams[5] ); + poMIEntry->SetDoubleField( "proParams[6]", poPro->proParams[6] ); + poMIEntry->SetDoubleField( "proParams[7]", poPro->proParams[7] ); + poMIEntry->SetDoubleField( "proParams[8]", poPro->proParams[8] ); + poMIEntry->SetDoubleField( "proParams[9]", poPro->proParams[9] ); + poMIEntry->SetDoubleField( "proParams[10]", poPro->proParams[10] ); + poMIEntry->SetDoubleField( "proParams[11]", poPro->proParams[11] ); + poMIEntry->SetDoubleField( "proParams[12]", poPro->proParams[12] ); + poMIEntry->SetDoubleField( "proParams[13]", poPro->proParams[13] ); + poMIEntry->SetDoubleField( "proParams[14]", poPro->proParams[14] ); + poMIEntry->SetStringField( "proSpheroid.sphereName", + poPro->proSpheroid.sphereName ); + poMIEntry->SetDoubleField( "proSpheroid.a", + poPro->proSpheroid.a ); + poMIEntry->SetDoubleField( "proSpheroid.b", + poPro->proSpheroid.b ); + poMIEntry->SetDoubleField( "proSpheroid.eSquared", + poPro->proSpheroid.eSquared ); + poMIEntry->SetDoubleField( "proSpheroid.radius", + poPro->proSpheroid.radius ); + } + + return CE_None; +} + +/************************************************************************/ +/* HFAGetDatum() */ +/************************************************************************/ + +const Eprj_Datum *HFAGetDatum( HFAHandle hHFA ) + +{ + HFAEntry *poMIEntry; + Eprj_Datum *psDatum; + int i; + + if( hHFA->nBands < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Do we already have it? */ +/* -------------------------------------------------------------------- */ + if( hHFA->pDatum != NULL ) + return( (Eprj_Datum *) hHFA->pDatum ); + +/* -------------------------------------------------------------------- */ +/* Get the HFA node. */ +/* -------------------------------------------------------------------- */ + poMIEntry = hHFA->papoBand[0]->poNode->GetNamedChild( "Projection.Datum" ); + if( poMIEntry == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Allocate the structure. */ +/* -------------------------------------------------------------------- */ + psDatum = (Eprj_Datum *) CPLCalloc(sizeof(Eprj_Datum),1); + +/* -------------------------------------------------------------------- */ +/* Fetch the fields. */ +/* -------------------------------------------------------------------- */ + psDatum->datumname = CPLStrdup(poMIEntry->GetStringField("datumname")); + psDatum->type = (Eprj_DatumType) poMIEntry->GetIntField("type"); + + for( i = 0; i < 7; i++ ) + { + char szFieldName[30]; + + sprintf( szFieldName, "params[%d]", i ); + psDatum->params[i] = poMIEntry->GetDoubleField(szFieldName); + } + + psDatum->gridname = CPLStrdup(poMIEntry->GetStringField("gridname")); + + hHFA->pDatum = (void *) psDatum; + + return psDatum; +} + +/************************************************************************/ +/* HFASetDatum() */ +/************************************************************************/ + +CPLErr HFASetDatum( HFAHandle hHFA, const Eprj_Datum *poDatum ) + +{ +/* -------------------------------------------------------------------- */ +/* Loop over bands, setting information on each one. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < hHFA->nBands; iBand++ ) + { + HFAEntry *poDatumEntry=NULL, *poProParms; + +/* -------------------------------------------------------------------- */ +/* Create a new Projection if there isn't one present already. */ +/* -------------------------------------------------------------------- */ + poProParms = + hHFA->papoBand[iBand]->poNode->GetNamedChild("Projection"); + if( poProParms == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't add Eprj_Datum with no Eprj_ProjParameters." ); + return CE_Failure; + } + + poDatumEntry = poProParms->GetNamedChild("Datum"); + if( poDatumEntry == NULL ) + { + poDatumEntry = new HFAEntry( hHFA, "Datum","Eprj_Datum", + poProParms ); + } + + poDatumEntry->MarkDirty(); + +/* -------------------------------------------------------------------- */ +/* Ensure we have enough space for all the data. */ +/* -------------------------------------------------------------------- */ + int nSize; + GByte *pabyData; + + nSize = 26 + strlen(poDatum->datumname) + 1 + 7*8; + + if( poDatum->gridname != NULL ) + nSize += strlen(poDatum->gridname) + 1; + + pabyData = poDatumEntry->MakeData( nSize ); + poDatumEntry->SetPosition(); + +/* -------------------------------------------------------------------- */ +/* Write the various fields. */ +/* -------------------------------------------------------------------- */ + poDatumEntry->SetStringField( "datumname", poDatum->datumname ); + poDatumEntry->SetIntField( "type", poDatum->type ); + + poDatumEntry->SetDoubleField( "params[0]", poDatum->params[0] ); + poDatumEntry->SetDoubleField( "params[1]", poDatum->params[1] ); + poDatumEntry->SetDoubleField( "params[2]", poDatum->params[2] ); + poDatumEntry->SetDoubleField( "params[3]", poDatum->params[3] ); + poDatumEntry->SetDoubleField( "params[4]", poDatum->params[4] ); + poDatumEntry->SetDoubleField( "params[5]", poDatum->params[5] ); + poDatumEntry->SetDoubleField( "params[6]", poDatum->params[6] ); + + poDatumEntry->SetStringField( "gridname", poDatum->gridname ); + } + + return CE_None; +} + +/************************************************************************/ +/* HFAGetPCT() */ +/* */ +/* Read the PCT from a band, if it has one. */ +/************************************************************************/ + +CPLErr HFAGetPCT( HFAHandle hHFA, int nBand, int *pnColors, + double **ppadfRed, double **ppadfGreen, + double **ppadfBlue , double **ppadfAlpha) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->GetPCT( pnColors, ppadfRed, + ppadfGreen, ppadfBlue, + ppadfAlpha) ); +} + +/************************************************************************/ +/* HFASetPCT() */ +/* */ +/* Set the PCT on a band. */ +/************************************************************************/ + +CPLErr HFASetPCT( HFAHandle hHFA, int nBand, int nColors, + double *padfRed, double *padfGreen, double *padfBlue, + double *padfAlpha ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + return( hHFA->papoBand[nBand-1]->SetPCT( nColors, padfRed, + padfGreen, padfBlue, padfAlpha ) ); +} + +/************************************************************************/ +/* HFAGetDataRange() */ +/************************************************************************/ + +CPLErr HFAGetDataRange( HFAHandle hHFA, int nBand, + double * pdfMin, double *pdfMax ) + +{ + HFAEntry *poBinInfo; + + if( nBand < 1 || nBand > hHFA->nBands ) + return CE_Failure; + + poBinInfo = hHFA->papoBand[nBand-1]->poNode->GetNamedChild("Statistics" ); + + if( poBinInfo == NULL ) + return( CE_Failure ); + + *pdfMin = poBinInfo->GetDoubleField( "minimum" ); + *pdfMax = poBinInfo->GetDoubleField( "maximum" ); + + if( *pdfMax > *pdfMin ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* HFADumpNode() */ +/************************************************************************/ + +static void HFADumpNode( HFAEntry *poEntry, int nIndent, int bVerbose, + FILE * fp ) + +{ + static char szSpaces[256]; + int i; + + for( i = 0; i < nIndent*2; i++ ) + szSpaces[i] = ' '; + szSpaces[nIndent*2] = '\0'; + + fprintf( fp, "%s%s(%s) @ %d + %d @ %d\n", szSpaces, + poEntry->GetName(), poEntry->GetType(), + poEntry->GetFilePos(), + poEntry->GetDataSize(), poEntry->GetDataPos() ); + + if( bVerbose ) + { + strcat( szSpaces, "+ " ); + poEntry->DumpFieldValues( fp, szSpaces ); + fprintf( fp, "\n" ); + } + + if( poEntry->GetChild() != NULL ) + HFADumpNode( poEntry->GetChild(), nIndent+1, bVerbose, fp ); + + if( poEntry->GetNext() != NULL ) + HFADumpNode( poEntry->GetNext(), nIndent, bVerbose, fp ); +} + +/************************************************************************/ +/* HFADumpTree() */ +/* */ +/* Dump the tree of information in a HFA file. */ +/************************************************************************/ + +void HFADumpTree( HFAHandle hHFA, FILE * fpOut ) + +{ + HFADumpNode( hHFA->poRoot, 0, TRUE, fpOut ); +} + +/************************************************************************/ +/* HFADumpDictionary() */ +/* */ +/* Dump the dictionary (in raw, and parsed form) to the named */ +/* device. */ +/************************************************************************/ + +void HFADumpDictionary( HFAHandle hHFA, FILE * fpOut ) + +{ + fprintf( fpOut, "%s\n", hHFA->pszDictionary ); + + hHFA->poDictionary->Dump( fpOut ); +} + +/************************************************************************/ +/* HFAStandard() */ +/* */ +/* Swap byte order on MSB systems. */ +/************************************************************************/ + +#ifdef CPL_MSB +void HFAStandard( int nBytes, void * pData ) + +{ + int i; + GByte *pabyData = (GByte *) pData; + + for( i = nBytes/2-1; i >= 0; i-- ) + { + GByte byTemp; + + byTemp = pabyData[i]; + pabyData[i] = pabyData[nBytes-i-1]; + pabyData[nBytes-i-1] = byTemp; + } +} +#endif + +/* ==================================================================== */ +/* Default data dictionary. Emitted verbatim into the imagine */ +/* file. */ +/* ==================================================================== */ + +static const char *aszDefaultDD[] = { +"{1:lversion,1:LfreeList,1:LrootEntryPtr,1:sentryHeaderLength,1:LdictionaryPtr,}Ehfa_File,{1:Lnext,1:Lprev,1:Lparent,1:Lchild,1:Ldata,1:ldataSize,64:cname,32:ctype,1:tmodTime,}Ehfa_Entry,{16:clabel,1:LheaderPtr,}Ehfa_HeaderTag,{1:LfreeList,1:lfreeSize,}Ehfa_FreeListNode,{1:lsize,1:Lptr,}Ehfa_Data,{1:lwidth,1:lheight,1:e3:thematic,athematic,fft of real-valued data,layerType,", +"1:e13:u1,u2,u4,u8,s8,u16,s16,u32,s32,f32,f64,c64,c128,pixelType,1:lblockWidth,1:lblockHeight,}Eimg_Layer,{1:lwidth,1:lheight,1:e3:thematic,athematic,fft of real-valued data,layerType,1:e13:u1,u2,u4,u8,s8,u16,s16,u32,s32,f32,f64,c64,c128,pixelType,1:lblockWidth,1:lblockHeight,}Eimg_Layer_SubSample,{1:e2:raster,vector,type,1:LdictionaryPtr,}Ehfa_Layer,{1:LspaceUsedForRasterData,}ImgFormatInfo831,{1:sfileCode,1:Loffset,1:lsize,1:e2:false,true,logvalid,", +"1:e2:no compression,ESRI GRID compression,compressionType,}Edms_VirtualBlockInfo,{1:lmin,1:lmax,}Edms_FreeIDList,{1:lnumvirtualblocks,1:lnumobjectsperblock,1:lnextobjectnum,1:e2:no compression,RLC compression,compressionType,0:poEdms_VirtualBlockInfo,blockinfo,0:poEdms_FreeIDList,freelist,1:tmodTime,}Edms_State,{0:pcstring,}Emif_String,{1:oEmif_String,fileName,2:LlayerStackValidFlagsOffset,2:LlayerStackDataOffset,1:LlayerStackCount,1:LlayerStackIndex,}ImgExternalRaster,{1:oEmif_String,algorithm,0:poEmif_String,nameList,}Eimg_RRDNamesList,{1:oEmif_String,projection,1:oEmif_String,units,}Eimg_MapInformation,", +"{1:oEmif_String,dependent,}Eimg_DependentFile,{1:oEmif_String,ImageLayerName,}Eimg_DependentLayerName,{1:lnumrows,1:lnumcolumns,1:e13:EGDA_TYPE_U1,EGDA_TYPE_U2,EGDA_TYPE_U4,EGDA_TYPE_U8,EGDA_TYPE_S8,EGDA_TYPE_U16,EGDA_TYPE_S16,EGDA_TYPE_U32,EGDA_TYPE_S32,EGDA_TYPE_F32,EGDA_TYPE_F64,EGDA_TYPE_C64,EGDA_TYPE_C128,datatype,1:e4:EGDA_SCALAR_OBJECT,EGDA_TABLE_OBJECT,EGDA_MATRIX_OBJECT,EGDA_RASTER_OBJECT,objecttype,}Egda_BaseData,{1:*bvalueBD,}Eimg_NonInitializedValue,{1:dx,1:dy,}Eprj_Coordinate,{1:dwidth,1:dheight,}Eprj_Size,{0:pcproName,1:*oEprj_Coordinate,upperLeftCenter,", +"1:*oEprj_Coordinate,lowerRightCenter,1:*oEprj_Size,pixelSize,0:pcunits,}Eprj_MapInfo,{0:pcdatumname,1:e3:EPRJ_DATUM_PARAMETRIC,EPRJ_DATUM_GRID,EPRJ_DATUM_REGRESSION,type,0:pdparams,0:pcgridname,}Eprj_Datum,{0:pcsphereName,1:da,1:db,1:deSquared,1:dradius,}Eprj_Spheroid,{1:e2:EPRJ_INTERNAL,EPRJ_EXTERNAL,proType,1:lproNumber,0:pcproExeName,0:pcproName,1:lproZone,0:pdproParams,1:*oEprj_Spheroid,proSpheroid,}Eprj_ProParameters,{1:dminimum,1:dmaximum,1:dmean,1:dmedian,1:dmode,1:dstddev,}Esta_Statistics,{1:lnumBins,1:e4:direct,linear,logarithmic,explicit,binFunctionType,1:dminLimit,1:dmaxLimit,1:*bbinLimits,}Edsc_BinFunction,{0:poEmif_String,LayerNames,1:*bExcludedValues,1:oEmif_String,AOIname,", +"1:lSkipFactorX,1:lSkipFactorY,1:*oEdsc_BinFunction,BinFunction,}Eimg_StatisticsParameters830,{1:lnumrows,}Edsc_Table,{1:lnumRows,1:LcolumnDataPtr,1:e4:integer,real,complex,string,dataType,1:lmaxNumChars,}Edsc_Column,{1:lposition,0:pcname,1:e2:EMSC_FALSE,EMSC_TRUE,editable,1:e3:LEFT,CENTER,RIGHT,alignment,0:pcformat,1:e3:DEFAULT,APPLY,AUTO-APPLY,formulamode,0:pcformula,1:dcolumnwidth,0:pcunits,1:e5:NO_COLOR,RED,GREEN,BLUE,COLOR,colorflag,0:pcgreenname,0:pcbluename,}Eded_ColumnAttributes_1,{1:lversion,1:lnumobjects,1:e2:EAOI_UNION,EAOI_INTERSECTION,operation,}Eaoi_AreaOfInterest,.", +NULL +}; + +/************************************************************************/ +/* HFACreateLL() */ +/* */ +/* Low level creation of an Imagine file. Writes out the */ +/* Ehfa_HeaderTag, dictionary and Ehfa_File. */ +/************************************************************************/ + +HFAHandle HFACreateLL( const char * pszFilename ) + +{ + FILE *fp; + HFAInfo_t *psInfo; + +/* -------------------------------------------------------------------- */ +/* Create the file in the file system. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpenL( pszFilename, "w+b" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Creation of file %s failed.", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create the HFAInfo_t */ +/* -------------------------------------------------------------------- */ + psInfo = (HFAInfo_t *) CPLCalloc(sizeof(HFAInfo_t),1); + + psInfo->fp = fp; + psInfo->eAccess = HFA_Update; + psInfo->nXSize = 0; + psInfo->nYSize = 0; + psInfo->nBands = 0; + psInfo->papoBand = NULL; + psInfo->pMapInfo = NULL; + psInfo->pDatum = NULL; + psInfo->pProParameters = NULL; + psInfo->bTreeDirty = FALSE; + psInfo->pszFilename = CPLStrdup(CPLGetFilename(pszFilename)); + psInfo->pszPath = CPLStrdup(CPLGetPath(pszFilename)); + +/* -------------------------------------------------------------------- */ +/* Write out the Ehfa_HeaderTag */ +/* -------------------------------------------------------------------- */ + GInt32 nHeaderPos; + + VSIFWriteL( (void *) "EHFA_HEADER_TAG", 1, 16, fp ); + + nHeaderPos = 20; + HFAStandard( 4, &nHeaderPos ); + VSIFWriteL( &nHeaderPos, 4, 1, fp ); + +/* -------------------------------------------------------------------- */ +/* Write the Ehfa_File node, locked in at offset 20. */ +/* -------------------------------------------------------------------- */ + GInt32 nVersion = 1, nFreeList = 0, nRootEntry = 0; + GInt16 nEntryHeaderLength = 128; + GInt32 nDictionaryPtr = 38; + + psInfo->nEntryHeaderLength = nEntryHeaderLength; + psInfo->nRootPos = 0; + psInfo->nDictionaryPos = nDictionaryPtr; + psInfo->nVersion = nVersion; + + HFAStandard( 4, &nVersion ); + HFAStandard( 4, &nFreeList ); + HFAStandard( 4, &nRootEntry ); + HFAStandard( 2, &nEntryHeaderLength ); + HFAStandard( 4, &nDictionaryPtr ); + + VSIFWriteL( &nVersion, 4, 1, fp ); + VSIFWriteL( &nFreeList, 4, 1, fp ); + VSIFWriteL( &nRootEntry, 4, 1, fp ); + VSIFWriteL( &nEntryHeaderLength, 2, 1, fp ); + VSIFWriteL( &nDictionaryPtr, 4, 1, fp ); + +/* -------------------------------------------------------------------- */ +/* Write the dictionary, locked in at location 38. Note that */ +/* we jump through a bunch of hoops to operate on the */ +/* dictionary in chunks because some compiles (such as VC++) */ +/* don't allow particularly large static strings. */ +/* -------------------------------------------------------------------- */ + int nDictLen = 0, iChunk; + + for( iChunk = 0; aszDefaultDD[iChunk] != NULL; iChunk++ ) + nDictLen += strlen(aszDefaultDD[iChunk]); + + psInfo->pszDictionary = (char *) CPLMalloc(nDictLen+1); + psInfo->pszDictionary[0] = '\0'; + + for( iChunk = 0; aszDefaultDD[iChunk] != NULL; iChunk++ ) + strcat( psInfo->pszDictionary, aszDefaultDD[iChunk] ); + + VSIFWriteL( (void *) psInfo->pszDictionary, 1, + strlen(psInfo->pszDictionary)+1, fp ); + + psInfo->poDictionary = new HFADictionary( psInfo->pszDictionary ); + + psInfo->nEndOfFile = (GUInt32) VSIFTellL( fp ); + +/* -------------------------------------------------------------------- */ +/* Create a root entry. */ +/* -------------------------------------------------------------------- */ + psInfo->poRoot = new HFAEntry( psInfo, "root", "root", NULL ); + + return psInfo; +} + +/************************************************************************/ +/* HFAAllocateSpace() */ +/* */ +/* Return an area in the file to the caller to write the */ +/* requested number of bytes. Currently this is always at the */ +/* end of the file, but eventually we might actually keep track */ +/* of free space. The HFAInfo_t's concept of file size is */ +/* updated, even if nothing ever gets written to this region. */ +/* */ +/* Returns the offset to the requested space, or zero one */ +/* failure. */ +/************************************************************************/ + +GUInt32 HFAAllocateSpace( HFAInfo_t *psInfo, GUInt32 nBytes ) + +{ + /* should check if this will wrap over 2GB limit */ + + psInfo->nEndOfFile += nBytes; + return psInfo->nEndOfFile - nBytes; +} + +/************************************************************************/ +/* HFAFlush() */ +/* */ +/* Write out any dirty tree information to disk, putting the */ +/* disk file in a consistent state. */ +/************************************************************************/ + +CPLErr HFAFlush( HFAHandle hHFA ) + +{ + CPLErr eErr; + + if( !hHFA->bTreeDirty ) + return CE_None; + + CPLAssert( hHFA->poRoot != NULL ); + +/* -------------------------------------------------------------------- */ +/* Flush HFAEntry tree to disk. */ +/* -------------------------------------------------------------------- */ + eErr = hHFA->poRoot->FlushToDisk(); + if( eErr != CE_None ) + return eErr; + + hHFA->bTreeDirty = FALSE; + +/* -------------------------------------------------------------------- */ +/* do we need to update the Ehfa_File pointer to the root node? */ +/* -------------------------------------------------------------------- */ + if( hHFA->nRootPos != hHFA->poRoot->GetFilePos() ) + { + GUInt32 nRootPos; + + nRootPos = hHFA->nRootPos = hHFA->poRoot->GetFilePos(); + HFAStandard( 4, &nRootPos ); + VSIFSeekL( hHFA->fp, 20 + 8, SEEK_SET ); + VSIFWriteL( &nRootPos, 4, 1, hHFA->fp ); + } + + return CE_None; +} + +/************************************************************************/ +/* HFACreateLayer() */ +/* */ +/* Create a layer object, and corresponding RasterDMS. */ +/* Suitable for use with primary layers, and overviews. */ +/************************************************************************/ + +int +HFACreateLayer( HFAHandle psInfo, HFAEntry *poParent, + const char *pszLayerName, + int bOverview, int nBlockSize, + int bCreateCompressed, int bCreateLargeRaster, + int nXSize, int nYSize, int nDataType, + char **papszOptions, + + // these are only related to external (large) files + GIntBig nStackValidFlagsOffset, + GIntBig nStackDataOffset, + int nStackCount, int nStackIndex ) + +{ + + HFAEntry *poEimg_Layer; + const char *pszLayerType; + + if( bOverview ) + pszLayerType = "Eimg_Layer_SubSample"; + else + pszLayerType = "Eimg_Layer"; + +/* -------------------------------------------------------------------- */ +/* Work out some details about the tiling scheme. */ +/* -------------------------------------------------------------------- */ + int nBlocksPerRow, nBlocksPerColumn, nBlocks, nBytesPerBlock; + + nBlocksPerRow = (nXSize + nBlockSize - 1) / nBlockSize; + nBlocksPerColumn = (nYSize + nBlockSize - 1) / nBlockSize; + nBlocks = nBlocksPerRow * nBlocksPerColumn; + nBytesPerBlock = (nBlockSize * nBlockSize + * HFAGetDataTypeBits(nDataType) + 7) / 8; + +/* -------------------------------------------------------------------- */ +/* Create the Eimg_Layer for the band. */ +/* -------------------------------------------------------------------- */ + poEimg_Layer = + new HFAEntry( psInfo, pszLayerName, pszLayerType, poParent ); + + poEimg_Layer->SetIntField( "width", nXSize ); + poEimg_Layer->SetIntField( "height", nYSize ); + poEimg_Layer->SetStringField( "layerType", "athematic" ); + poEimg_Layer->SetIntField( "pixelType", nDataType ); + poEimg_Layer->SetIntField( "blockWidth", nBlockSize ); + poEimg_Layer->SetIntField( "blockHeight", nBlockSize ); + +/* -------------------------------------------------------------------- */ +/* Create the RasterDMS (block list). This is a complex type */ +/* with pointers, and variable size. We set the superstructure */ +/* ourselves rather than trying to have the HFA type management */ +/* system do it for us (since this would be hard to implement). */ +/* -------------------------------------------------------------------- */ + if ( !bCreateLargeRaster ) + { + int nDmsSize; + HFAEntry *poEdms_State; + GByte *pabyData; + + poEdms_State = + new HFAEntry( psInfo, "RasterDMS", "Edms_State", poEimg_Layer ); + + nDmsSize = 14 * nBlocks + 38; + pabyData = poEdms_State->MakeData( nDmsSize ); + + /* set some simple values */ + poEdms_State->SetIntField( "numvirtualblocks", nBlocks ); + poEdms_State->SetIntField( "numobjectsperblock", + nBlockSize*nBlockSize ); + poEdms_State->SetIntField( "nextobjectnum", + nBlockSize*nBlockSize*nBlocks ); + + /* Is file compressed or not? */ + if( bCreateCompressed ) + { + poEdms_State->SetStringField( "compressionType", "RLC compression" ); + } + else + { + poEdms_State->SetStringField( "compressionType", "no compression" ); + } + + /* we need to hardcode file offset into the data, so locate it now */ + poEdms_State->SetPosition(); + + /* Set block info headers */ + GUInt32 nValue; + + /* blockinfo count */ + nValue = nBlocks; + HFAStandard( 4, &nValue ); + memcpy( pabyData + 14, &nValue, 4 ); + + /* blockinfo position */ + nValue = poEdms_State->GetDataPos() + 22; + HFAStandard( 4, &nValue ); + memcpy( pabyData + 18, &nValue, 4 ); + + /* Set each blockinfo */ + for( int iBlock = 0; iBlock < nBlocks; iBlock++ ) + { + GInt16 nValue16; + int nOffset = 22 + 14 * iBlock; + + /* fileCode */ + nValue16 = 0; + HFAStandard( 2, &nValue16 ); + memcpy( pabyData + nOffset, &nValue16, 2 ); + + /* offset */ + if( bCreateCompressed ) + { + /* flag it with zero offset - will allocate space when we compress it */ + nValue = 0; + } + else + { + nValue = HFAAllocateSpace( psInfo, nBytesPerBlock ); + } + HFAStandard( 4, &nValue ); + memcpy( pabyData + nOffset + 2, &nValue, 4 ); + + /* size */ + if( bCreateCompressed ) + { + /* flag it with zero size - don't know until we compress it */ + nValue = 0; + } + else + { + nValue = nBytesPerBlock; + } + HFAStandard( 4, &nValue ); + memcpy( pabyData + nOffset + 6, &nValue, 4 ); + + /* logValid (true/false) */ + if( bCreateCompressed ) + nValue16 = 0; + else + nValue16 = 1; + HFAStandard( 2, &nValue16 ); + memcpy( pabyData + nOffset + 10, &nValue16, 2 ); + + /* compressionType */ + if( bCreateCompressed ) + nValue16 = 1; + else + nValue16 = 0; + + HFAStandard( 2, &nValue16 ); + memcpy( pabyData + nOffset + 12, &nValue16, 2 ); + } + + } + else + { +/* -------------------------------------------------------------------- */ +/* Create ExternalRasterDMS object. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poEdms_State; + + poEdms_State = + new HFAEntry( psInfo, "ExternalRasterDMS", + "ImgExternalRaster", poEimg_Layer ); + poEdms_State->MakeData( 8 + strlen(psInfo->pszIGEFilename) + 1 + 6 * 4 ); + + poEdms_State->SetStringField( "fileName.string", + psInfo->pszIGEFilename ); + + poEdms_State->SetIntField( "layerStackValidFlagsOffset[0]", + (int) (nStackValidFlagsOffset & 0xFFFFFFFF)); + poEdms_State->SetIntField( "layerStackValidFlagsOffset[1]", + (int) (nStackValidFlagsOffset >> 32) ); + + poEdms_State->SetIntField( "layerStackDataOffset[0]", + (int) (nStackDataOffset & 0xFFFFFFFF) ); + poEdms_State->SetIntField( "layerStackDataOffset[1]", + (int) (nStackDataOffset >> 32 ) ); + poEdms_State->SetIntField( "layerStackCount", nStackCount ); + poEdms_State->SetIntField( "layerStackIndex", nStackIndex ); + } + +/* -------------------------------------------------------------------- */ +/* Create the Ehfa_Layer. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poEhfa_Layer; + GUInt32 nLDict; + char szLDict[128], chBandType; + + if( nDataType == EPT_u1 ) + chBandType = '1'; + else if( nDataType == EPT_u2 ) + chBandType = '2'; + else if( nDataType == EPT_u4 ) + chBandType = '4'; + else if( nDataType == EPT_u8 ) + chBandType = 'c'; + else if( nDataType == EPT_s8 ) + chBandType = 'C'; + else if( nDataType == EPT_u16 ) + chBandType = 's'; + else if( nDataType == EPT_s16 ) + chBandType = 'S'; + else if( nDataType == EPT_u32 ) + // for some reason erdas imagine expects an L for unsinged 32 bit ints + // otherwise it gives strange "out of memory errors" + chBandType = 'L'; + else if( nDataType == EPT_s32 ) + chBandType = 'L'; + else if( nDataType == EPT_f32 ) + chBandType = 'f'; + else if( nDataType == EPT_f64 ) + chBandType = 'd'; + else if( nDataType == EPT_c64 ) + chBandType = 'm'; + else if( nDataType == EPT_c128 ) + chBandType = 'M'; + else + { + CPLAssert( FALSE ); + chBandType = 'c'; + } + + // the first value in the entry below gives the number of pixels within a block + sprintf( szLDict, "{%d:%cdata,}RasterDMS,.", nBlockSize*nBlockSize, chBandType ); + + poEhfa_Layer = new HFAEntry( psInfo, "Ehfa_Layer", "Ehfa_Layer", + poEimg_Layer ); + poEhfa_Layer->MakeData(); + poEhfa_Layer->SetPosition(); + nLDict = HFAAllocateSpace( psInfo, strlen(szLDict) + 1 ); + + poEhfa_Layer->SetStringField( "type", "raster" ); + poEhfa_Layer->SetIntField( "dictionaryPtr", nLDict ); + + VSIFSeekL( psInfo->fp, nLDict, SEEK_SET ); + VSIFWriteL( (void *) szLDict, strlen(szLDict) + 1, 1, psInfo->fp ); + + return TRUE; +} + + +/************************************************************************/ +/* HFACreate() */ +/************************************************************************/ + +HFAHandle HFACreate( const char * pszFilename, + int nXSize, int nYSize, int nBands, + int nDataType, char ** papszOptions ) + +{ + HFAHandle psInfo; + int nBlockSize = 64; + const char * pszValue = CSLFetchNameValue( papszOptions, "BLOCKSIZE" ); + + if ( pszValue != NULL ) + { + nBlockSize = atoi( pszValue ); + // check for sane values + if ( ( nBlockSize < 32 ) || (nBlockSize > 2048) ) + { + nBlockSize = 64; + } + } + int bCreateLargeRaster = CSLFetchBoolean(papszOptions,"USE_SPILL", + FALSE); + int bCreateCompressed = + CSLFetchBoolean(papszOptions,"COMPRESS", FALSE) + || CSLFetchBoolean(papszOptions,"COMPRESSED", FALSE); + char *pszFullFilename = NULL, *pszRawFilename = NULL; + +/* -------------------------------------------------------------------- */ +/* Create the low level structure. */ +/* -------------------------------------------------------------------- */ + psInfo = HFACreateLL( pszFilename ); + if( psInfo == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create the DependentFile node if requested. */ +/* -------------------------------------------------------------------- */ + const char *pszDependentFile = + CSLFetchNameValue( papszOptions, "DEPENDENT_FILE" ); + + if( pszDependentFile != NULL ) + { + HFAEntry *poDF = new HFAEntry( psInfo, "DependentFile", + "Eimg_DependentFile", psInfo->poRoot ); + + poDF->MakeData( strlen(pszDependentFile) + 50 ); + poDF->SetPosition(); + poDF->SetStringField( "dependent.string", pszDependentFile ); + } + +/* -------------------------------------------------------------------- */ +/* Work out some details about the tiling scheme. */ +/* -------------------------------------------------------------------- */ + int nBlocksPerRow, nBlocksPerColumn, nBlocks, nBytesPerBlock; + + nBlocksPerRow = (nXSize + nBlockSize - 1) / nBlockSize; + nBlocksPerColumn = (nYSize + nBlockSize - 1) / nBlockSize; + nBlocks = nBlocksPerRow * nBlocksPerColumn; + nBytesPerBlock = (nBlockSize * nBlockSize + * HFAGetDataTypeBits(nDataType) + 7) / 8; + + CPLDebug( "HFACreate", "Blocks per row %d, blocks per column %d, " + "total number of blocks %d, bytes per block %d.", + nBlocksPerRow, nBlocksPerColumn, nBlocks, nBytesPerBlock ); + +/* -------------------------------------------------------------------- */ +/* Check whether we should create external large file with */ +/* image. We create a spill file if the amount of imagery is */ +/* close to 2GB. We don't check the amount of auxilary */ +/* information, so in theory if there were an awful lot of */ +/* non-imagery data our approximate size could be smaller than */ +/* the file will actually we be. We leave room for 10MB of */ +/* auxilary data. */ +/* We can also force spill file creation using option */ +/* SPILL_FILE=YES. */ +/* -------------------------------------------------------------------- */ + double dfApproxSize = (double)nBytesPerBlock * (double)nBlocks * + (double)nBands + 10000000.0; + + if( dfApproxSize > 2147483648.0 ) + bCreateLargeRaster = TRUE; + + // erdas imagine always creates this entry no matter if an external + // spill file is used or not + HFAEntry *poImgFormat; + poImgFormat = new HFAEntry( psInfo, "IMGFormatInfo", + "ImgFormatInfo831", psInfo->poRoot ); + poImgFormat->MakeData(); + if ( bCreateLargeRaster ) + { + poImgFormat->SetIntField( "spaceUsedForRasterData", 0 ); + bCreateCompressed = FALSE; // Can't be compressed if we are creating a spillfile + } + else + { + poImgFormat->SetIntField( "spaceUsedForRasterData", + nBytesPerBlock*nBlocks*nBands ); + } + +/* -------------------------------------------------------------------- */ +/* Create external file and write its header. */ +/* -------------------------------------------------------------------- */ + GIntBig nValidFlagsOffset = 0, nDataOffset = 0; + + if( bCreateLargeRaster ) + { + if( !HFACreateSpillStack( psInfo, nXSize, nYSize, nBands, + nBlockSize, nDataType, + &nValidFlagsOffset, &nDataOffset ) ) + { + CPLFree( pszRawFilename ); + CPLFree( pszFullFilename ); + return NULL; + } + } + +/* ==================================================================== */ +/* Create each band (layer) */ +/* ==================================================================== */ + int iBand; + + for( iBand = 0; iBand < nBands; iBand++ ) + { + char szName[128]; + + sprintf( szName, "Layer_%d", iBand + 1 ); + + if( !HFACreateLayer( psInfo, psInfo->poRoot, szName, FALSE, nBlockSize, + bCreateCompressed, bCreateLargeRaster, + nXSize, nYSize, nDataType, papszOptions, + nValidFlagsOffset, nDataOffset, + nBands, iBand ) ) + { + HFAClose( psInfo ); + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Initialize the band information. */ +/* -------------------------------------------------------------------- */ + HFAParseBandInfo( psInfo ); + + return psInfo; +} + +/************************************************************************/ +/* HFACreateOverview() */ +/* */ +/* Create an overview layer object for a band. */ +/************************************************************************/ + +int HFACreateOverview( HFAHandle hHFA, int nBand, int nOverviewLevel ) + +{ + if( nBand < 1 || nBand > hHFA->nBands ) + return -1; + else + { + HFABand *poBand = hHFA->papoBand[nBand-1]; + return poBand->CreateOverview( nOverviewLevel ); + } +} + +/************************************************************************/ +/* HFAGetMetadata() */ +/* */ +/* Read metadata structured in a table called GDAL_MetaData. */ +/************************************************************************/ + +char ** HFAGetMetadata( HFAHandle hHFA, int nBand ) + +{ + HFAEntry *poTable; + + if( nBand > 0 && nBand <= hHFA->nBands ) + poTable = hHFA->papoBand[nBand - 1]->poNode->GetChild(); + else if( nBand == 0 ) + poTable = hHFA->poRoot->GetChild(); + else + return NULL; + + for( ; poTable != NULL && !EQUAL(poTable->GetName(),"GDAL_MetaData"); + poTable = poTable->GetNext() ) {} + + if( poTable == NULL || !EQUAL(poTable->GetType(),"Edsc_Table") ) + return NULL; + + if( poTable->GetIntField( "numRows" ) != 1 ) + { + CPLDebug( "HFADataset", "GDAL_MetaData.numRows = %d, expected 1!", + poTable->GetIntField( "numRows" ) ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Loop over each column. Each column will be one metadata */ +/* entry, with the title being the key, and the row value being */ +/* the value. There is only ever one row in GDAL_MetaData */ +/* tables. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poColumn; + char **papszMD = NULL; + + for( poColumn = poTable->GetChild(); + poColumn != NULL; + poColumn = poColumn->GetNext() ) + { + const char *pszValue; + int columnDataPtr; + + // Skip the #Bin_Function# entry. + if( EQUALN(poColumn->GetName(),"#",1) ) + continue; + + pszValue = poColumn->GetStringField( "dataType" ); + if( pszValue == NULL || !EQUAL(pszValue,"string") ) + continue; + + columnDataPtr = poColumn->GetIntField( "columnDataPtr" ); + if( columnDataPtr == 0 ) + continue; + +/* -------------------------------------------------------------------- */ +/* read up to 500 bytes from the indicated location. */ +/* -------------------------------------------------------------------- */ + char szMDValue[501]; + int nMDBytes = sizeof(szMDValue)-1; + + if( VSIFSeekL( hHFA->fp, columnDataPtr, SEEK_SET ) != 0 ) + continue; + + nMDBytes = VSIFReadL( szMDValue, 1, nMDBytes, hHFA->fp ); + if( nMDBytes == 0 ) + continue; + + szMDValue[nMDBytes] = '\0'; + + papszMD = CSLSetNameValue( papszMD, poColumn->GetName(), szMDValue ); + } + + return papszMD; +} + +/************************************************************************/ +/* HFASetGDALMetadata() */ +/* */ +/* This function is used to set metadata in a table called */ +/* GDAL_MetaData. It is called by HFASetMetadata() for all */ +/* metadata items that aren't some specific supported */ +/* information (like histogram or stats info). */ +/************************************************************************/ + +static CPLErr +HFASetGDALMetadata( HFAHandle hHFA, int nBand, char **papszMD ) + +{ + if( papszMD == NULL ) + return CE_None; + + HFAEntry *poNode; + + if( nBand > 0 && nBand <= hHFA->nBands ) + poNode = hHFA->papoBand[nBand - 1]->poNode; + else if( nBand == 0 ) + poNode = hHFA->poRoot; + else + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Create the Descriptor table. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poEdsc_Table; + + poEdsc_Table = new HFAEntry( hHFA, "GDAL_MetaData", "Edsc_Table", + poNode ); + + poEdsc_Table->SetIntField( "numrows", 1 ); + +/* -------------------------------------------------------------------- */ +/* Create the Binning function node. I am not sure that we */ +/* really need this though. */ +/* -------------------------------------------------------------------- */ + HFAEntry *poEdsc_BinFunction; + + poEdsc_BinFunction = + new HFAEntry( hHFA, "#Bin_Function#", "Edsc_BinFunction", + poEdsc_Table ); + + // Because of the BaseData we have to hardcode the size. + poEdsc_BinFunction->MakeData( 30 ); + + poEdsc_BinFunction->SetIntField( "numBins", 1 ); + poEdsc_BinFunction->SetStringField( "binFunction", "direct" ); + poEdsc_BinFunction->SetDoubleField( "minLimit", 0.0 ); + poEdsc_BinFunction->SetDoubleField( "maxLimit", 0.0 ); + +/* -------------------------------------------------------------------- */ +/* Process each metadata item as a separate column. */ +/* -------------------------------------------------------------------- */ + for( int iColumn = 0; papszMD[iColumn] != NULL; iColumn++ ) + { + HFAEntry *poEdsc_Column; + char *pszKey = NULL; + const char *pszValue; + + pszValue = CPLParseNameValue( papszMD[iColumn], &pszKey ); + if( pszValue == NULL ) + continue; + +/* -------------------------------------------------------------------- */ +/* Create the Edsc_Column. */ +/* -------------------------------------------------------------------- */ + poEdsc_Column = new HFAEntry( hHFA, pszKey, "Edsc_Column", + poEdsc_Table ); + poEdsc_Column->SetIntField( "numRows", 1 ); + poEdsc_Column->SetStringField( "dataType", "string" ); + poEdsc_Column->SetIntField( "maxNumChars", strlen(pszValue)+1 ); + +/* -------------------------------------------------------------------- */ +/* Write the data out. */ +/* -------------------------------------------------------------------- */ + int nOffset = HFAAllocateSpace( hHFA, strlen(pszValue)+1); + + poEdsc_Column->SetIntField( "columnDataPtr", nOffset ); + + VSIFSeekL( hHFA->fp, nOffset, SEEK_SET ); + VSIFWriteL( (void *) pszValue, 1, strlen(pszValue)+1, hHFA->fp ); + + CPLFree( pszKey ); + } + + return CE_Failure; +} + +/************************************************************************/ +/* HFASetMetadata() */ +/************************************************************************/ + +CPLErr HFASetMetadata( HFAHandle hHFA, int nBand, char **papszMD ) + +{ + char **papszGDALMD = NULL; + + if( CSLCount(papszMD) == 0 ) + return CE_None; + + HFAEntry *poNode; + + if( nBand > 0 && nBand <= hHFA->nBands ) + poNode = hHFA->papoBand[nBand - 1]->poNode; + else if( nBand == 0 ) + poNode = hHFA->poRoot; + else + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Check if the Metadata is an "known" entity which should be */ +/* stored in a better place. */ +/* -------------------------------------------------------------------- */ + char * pszBinValues = NULL; + int bCreatedHistogramParameters = FALSE; + char ** pszAuxMetaData = GetHFAAuxMetaDataList(); + // check each metadata item + for( int iColumn = 0; papszMD[iColumn] != NULL; iColumn++ ) + { + char *pszKey = NULL; + const char *pszValue; + + pszValue = CPLParseNameValue( papszMD[iColumn], &pszKey ); + if( pszValue == NULL ) + continue; + + // know look if its known + int i; + for( i = 0; pszAuxMetaData[i] != NULL; i += 4 ) + { + if ( EQUALN( pszAuxMetaData[i + 2], pszKey, strlen(pszKey) ) ) + break; + } + if ( pszAuxMetaData[i] != NULL ) + { + // found one, get the right entry + HFAEntry *poEntry; + + if( strlen(pszAuxMetaData[i]) > 0 ) + poEntry = poNode->GetNamedChild( pszAuxMetaData[i] ); + else + poEntry = poNode; + + if( poEntry == NULL && strlen(pszAuxMetaData[i+3]) > 0 ) + { + // child does not yet exist --> create it + poEntry = new HFAEntry( hHFA, pszAuxMetaData[i], pszAuxMetaData[i+3], + poNode ); + if ( EQUALN( "HistogramParameters", pszAuxMetaData[i], 19 ) ) + { + // this is a bit nasty I need to set the string field for the object + // first because the SetStringField sets the count for the object + // BinFunction to the length of the string + poEntry->MakeData( 70 ); + poEntry->SetStringField( "BinFunction.binFunctionType", "linear" ); + + bCreatedHistogramParameters = TRUE; + } + } + if ( poEntry == NULL ) + continue; + + const char *pszFieldName = pszAuxMetaData[i+1] + 1; + switch( pszAuxMetaData[i+1][0] ) + { + case 'd': + { + double dfValue = atof( pszValue ); + poEntry->SetDoubleField( pszFieldName, dfValue ); + } + break; + case 'i': + case 'l': + { + int nValue = atoi( pszValue ); + poEntry->SetIntField( pszFieldName, nValue ); + } + break; + case 's': + case 'e': + { + poEntry->SetStringField( pszFieldName, pszValue ); + } + break; + default: + CPLAssert( FALSE ); + } + } + else if ( EQUALN( "STATISTICS_HISTOBINVALUES", pszKey, strlen(pszKey) ) ) + { + pszBinValues = strdup( pszValue ); + } + else + papszGDALMD = CSLAddString( papszGDALMD, papszMD[iColumn] ); + + CPLFree( pszKey ); + } + +/* -------------------------------------------------------------------- */ +/* Special case to write out the histogram. */ +/* -------------------------------------------------------------------- */ + if ( pszBinValues != NULL ) + { + HFAEntry * poEntry = poNode->GetNamedChild( "HistogramParameters" ); + if ( poEntry != NULL && bCreatedHistogramParameters ) + { + // if this node exists we have added Histogram data -- complete with some defaults + poEntry->SetIntField( "SkipFactorX", 1 ); + poEntry->SetIntField( "SkipFactorY", 1 ); + + int nNumBins = poEntry->GetIntField( "BinFunction.numBins" ); + double dMinLimit = poEntry->GetDoubleField( "BinFunction.minLimit" ); + double dMaxLimit = poEntry->GetDoubleField( "BinFunction.maxLimit" ); + // fill the descriptor table + poEntry = new HFAEntry( hHFA, "Descriptor_Table", "Edsc_Table", poNode ); + poEntry->SetIntField( "numRows", nNumBins ); + // bin function + HFAEntry * poBinFunc = new HFAEntry( hHFA, "#Bin_Function#", "Edsc_BinFunction", + poEntry ); + poBinFunc->MakeData( 30 ); + poBinFunc->SetIntField( "numBins", nNumBins ); + poBinFunc->SetDoubleField( "minLimit", dMinLimit ); + poBinFunc->SetDoubleField( "maxLimit", dMaxLimit ); + poBinFunc->SetStringField( "binFunctionType", "linear" ); // we use always a linear + + // we need a child named histogram + HFAEntry * poHisto = new HFAEntry( hHFA, "Histogram", "Edsc_Column", + poEntry ); + poHisto->SetIntField( "numRows", nNumBins ); + // allocate space for the bin values + GUInt32 nOffset = HFAAllocateSpace( hHFA, nNumBins*4 ); + poHisto->SetIntField( "columnDataPtr", nOffset ); + poHisto->SetStringField( "dataType", "integer" ); + poHisto->SetIntField( "maxNumChars", 0 ); + // write out histogram data + char * pszWork = pszBinValues; + for ( int nBin = 0; nBin < nNumBins; ++nBin ) + { + char * pszEnd = strchr( pszWork, '|' ); + if ( pszEnd != NULL ) + { + *pszEnd = 0; + VSIFSeekL( hHFA->fp, nOffset + 4*nBin, SEEK_SET ); + int nValue = atoi( pszWork ); + HFAStandard( 4, &nValue ); + + VSIFWriteL( (void *)&nValue, 1, 4, hHFA->fp ); + pszWork = pszEnd + 1; + } + } + free( pszBinValues ); + } + } + +/* -------------------------------------------------------------------- */ +/* Write out metadata items without a special place. */ +/* -------------------------------------------------------------------- */ + if( CSLCount( papszGDALMD) != 0 ) + { + CPLErr eErr = HFASetGDALMetadata( hHFA, nBand, papszGDALMD ); + + CSLDestroy( papszGDALMD ); + return eErr; + } + else + return CE_Failure; +} + +/************************************************************************/ +/* HFACreateSpillStack() */ +/* */ +/* Create a new stack of raster layers in the spill (.ige) */ +/* file. Create the spill file if it didn't exist before. */ +/************************************************************************/ + +int HFACreateSpillStack( HFAInfo_t *psInfo, int nXSize, int nYSize, + int nLayers, int nBlockSize, int nDataType, + GIntBig *pnValidFlagsOffset, + GIntBig *pnDataOffset ) + +{ +/* -------------------------------------------------------------------- */ +/* Form .ige filename. */ +/* -------------------------------------------------------------------- */ + char *pszFullFilename; + + if( psInfo->pszIGEFilename == NULL ) + psInfo->pszIGEFilename = + CPLStrdup( CPLResetExtension( psInfo->pszFilename, "ige" ) ); + + pszFullFilename = + CPLStrdup( CPLFormFilename( psInfo->pszPath, psInfo->pszIGEFilename, NULL ) ); + +/* -------------------------------------------------------------------- */ +/* Try and open it. If we fail, create it and write the magic */ +/* header. */ +/* -------------------------------------------------------------------- */ + static const char *pszMagick = "ERDAS_IMG_EXTERNAL_RASTER"; + FILE *fpVSIL; + + fpVSIL = VSIFOpenL( pszFullFilename, "r+b" ); + if( fpVSIL == NULL ) + { + fpVSIL = VSIFOpenL( pszFullFilename, "w+" ); + if( fpVSIL == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to create spill file %s.\n%s", + psInfo->pszIGEFilename, VSIStrerror( errno ) ); + return FALSE; + } + + VSIFWriteL( (void *) pszMagick, 1, strlen(pszMagick)+1, fpVSIL ); + } + + CPLFree( pszFullFilename ); + +/* -------------------------------------------------------------------- */ +/* Work out some details about the tiling scheme. */ +/* -------------------------------------------------------------------- */ + int nBlocksPerRow, nBlocksPerColumn, nBlocks, nBytesPerBlock; + int nBytesPerRow, nBlockMapSize, iFlagsSize; + + nBlocksPerRow = (nXSize + nBlockSize - 1) / nBlockSize; + nBlocksPerColumn = (nYSize + nBlockSize - 1) / nBlockSize; + nBlocks = nBlocksPerRow * nBlocksPerColumn; + nBytesPerBlock = (nBlockSize * nBlockSize + * HFAGetDataTypeBits(nDataType) + 7) / 8; + + nBytesPerRow = ( nBlocksPerRow + 7 ) / 8; + nBlockMapSize = nBytesPerRow * nBlocksPerColumn; + iFlagsSize = nBlockMapSize + 20; + +/* -------------------------------------------------------------------- */ +/* Write stack prefix information. */ +/* -------------------------------------------------------------------- */ + GByte bUnknown; + GInt32 nValue32; + + VSIFSeekL( fpVSIL, 0, SEEK_END ); + + bUnknown = 1; + VSIFWriteL( &bUnknown, 1, 1, fpVSIL ); + nValue32 = nLayers; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = nXSize; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = nYSize; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = nBlockSize; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + bUnknown = 3; + VSIFWriteL( &bUnknown, 1, 1, fpVSIL ); + bUnknown = 0; + VSIFWriteL( &bUnknown, 1, 1, fpVSIL ); + +/* -------------------------------------------------------------------- */ +/* Write out ValidFlags section(s). */ +/* -------------------------------------------------------------------- */ + unsigned char *pabyBlockMap; + int iBand; + + *pnValidFlagsOffset = VSIFTellL( fpVSIL ); + + pabyBlockMap = (unsigned char *) CPLMalloc( nBlockMapSize ); + memset( pabyBlockMap, 0xff, nBlockMapSize ); + for ( iBand = 0; iBand < nLayers; iBand++ ) + { + int i, iRemainder; + + nValue32 = 1; // Unknown + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = 0; // Unknown + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = nBlocksPerColumn; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = nBlocksPerRow; + HFAStandard( 4, &nValue32 ); + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + nValue32 = 0x30000; // Unknown + VSIFWriteL( &nValue32, 4, 1, fpVSIL ); + + iRemainder = nBlocksPerRow % 8; + CPLDebug( "HFACreate", + "Block map size %d, bytes per row %d, remainder %d.", + nBlockMapSize, nBytesPerRow, iRemainder ); + if ( iRemainder ) + { + for ( i = nBytesPerRow - 1; i < nBlockMapSize; i+=nBytesPerRow ) + pabyBlockMap[i] = (GByte) ((1<<iRemainder) - 1); + } + + VSIFWriteL( pabyBlockMap, 1, nBlockMapSize, fpVSIL ); + } + +/* -------------------------------------------------------------------- */ +/* Extend the file to account for all the imagery space. */ +/* -------------------------------------------------------------------- */ + GIntBig nTileDataSize = ((GIntBig) nBytesPerBlock) + * nBlocksPerRow * nBlocksPerColumn * nLayers; + + *pnDataOffset = VSIFTellL( fpVSIL ); + + if( VSIFSeekL( fpVSIL, nTileDataSize - 1 + *pnDataOffset, SEEK_SET ) != 0 + || VSIFWriteL( (void *) "", 1, 1, fpVSIL ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to extend %s to full size (%g bytes),\n" + "likely out of disk space.\n%s", + psInfo->pszIGEFilename, + (double) nTileDataSize - 1 + *pnDataOffset, + VSIStrerror( errno ) ); + + VSIFCloseL( fpVSIL ); + return FALSE; + } + + VSIFCloseL( fpVSIL ); + + return TRUE; +} diff --git a/Utilities/GDAL/frmts/hfa/hfatest.cpp b/Utilities/GDAL/frmts/hfa/hfatest.cpp new file mode 100644 index 0000000000..c8d048572c --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfatest.cpp @@ -0,0 +1,242 @@ +/****************************************************************************** + * $Id: hfatest.cpp,v 1.10 2006/02/22 14:48:46 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Testing mainline for HFA services - transitory. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfatest.cpp,v $ + * Revision 1.10 2006/02/22 14:48:46 fwarmerdam + * Added compression type to HFAGetBandInfo + * + * Revision 1.9 2003/09/15 20:48:40 warmerda + * added demonstration of direct access + * + * Revision 1.8 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.7 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.6 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.5 2000/10/20 04:18:15 warmerda + * added overviews, stateplane, and u4 + * + * Revision 1.4 2000/10/12 19:31:01 warmerda + * fixed usage + * + * Revision 1.3 1999/01/22 17:40:05 warmerda + * Added projections, moved debugging stuff out + * + * Revision 1.2 1999/01/04 22:52:47 warmerda + * field access working + * + * Revision 1.1 1999/01/04 05:28:13 warmerda + * New + * + */ + +#include "hfa_p.h" + +CPL_CVSID("$Id: hfatest.cpp,v 1.10 2006/02/22 14:48:46 fwarmerdam Exp $"); + +/************************************************************************/ +/* Usage() */ +/************************************************************************/ + +static void Usage() + +{ + printf( "hfatest [-dd] [-dt] [-dr] filename\n" ); +} + +/************************************************************************/ +/* main() */ +/************************************************************************/ + +int main( int argc, char ** argv ) + +{ + const char *pszFilename = NULL; + int nDumpTree = FALSE; + int nDumpDict = FALSE; + int nRastReport = FALSE; + int i, nXSize, nYSize, nBands; + HFAHandle hHFA; + const Eprj_MapInfo *psMapInfo; + const Eprj_ProParameters *psProParameters; + const Eprj_Datum *psDatum; + +/* -------------------------------------------------------------------- */ +/* Handle arguments. */ +/* -------------------------------------------------------------------- */ + for( i = 1; i < argc; i++ ) + { + if( EQUAL(argv[i],"-dd") ) + nDumpDict = TRUE; + else if( EQUAL(argv[i],"-dt") ) + nDumpTree = TRUE; + else if( EQUAL(argv[i],"-dr") ) + nRastReport = TRUE; + else if( pszFilename == NULL ) + pszFilename = argv[i]; + else + { + Usage(); + exit( 1 ); + } + } + + if( pszFilename == NULL ) + { + Usage(); + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + hHFA = HFAOpen( pszFilename, "r" ); + + if( hHFA == NULL ) + { + printf( "HFAOpen() failed.\n" ); + exit( 100 ); + } + +/* -------------------------------------------------------------------- */ +/* Do we want to walk the tree dumping out general information? */ +/* -------------------------------------------------------------------- */ + if( nDumpDict ) + { + HFADumpDictionary( hHFA, stdout ); + } + +/* -------------------------------------------------------------------- */ +/* Do we want to walk the tree dumping out general information? */ +/* -------------------------------------------------------------------- */ + if( nDumpTree ) + { + HFADumpTree( hHFA, stdout ); + } + +/* -------------------------------------------------------------------- */ +/* Dump indirectly collected data about bands. */ +/* -------------------------------------------------------------------- */ + HFAGetRasterInfo( hHFA, &nXSize, &nYSize, &nBands ); + + if( nRastReport ) + { + printf( "Raster Size = %d x %d\n", nXSize, nYSize ); + + for( i = 1; i <= nBands; i++ ) + { + int nDataType, nColors, nOverviews, iOverview; + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + int nBlockXSize, nBlockYSize, nCompressionType; + + HFAGetBandInfo( hHFA, i, &nDataType, &nBlockXSize, &nBlockYSize, + &nOverviews, &nCompressionType ); + printf( "Band %d: %dx%d tiles, type = %d\n", + i, nBlockXSize, nBlockYSize, nDataType ); + + for( iOverview=0; iOverview < nOverviews; iOverview++ ) + { + HFAGetOverviewInfo( hHFA, i, iOverview, + &nXSize, &nYSize, + &nBlockXSize, &nBlockYSize ); + printf( " Overview: %dx%d (blocksize %dx%d)\n", + nXSize, nYSize, nBlockXSize, nBlockYSize ); + } + + if( HFAGetPCT( hHFA, i, &nColors, &padfRed, &padfGreen, + &padfBlue, &padfAlpha ) + == CE_None ) + { + int j; + + for( j = 0; j < nColors; j++ ) + { + printf( "PCT[%d] = %f,%f,%f %f\n", + j, padfRed[j], padfGreen[j], + padfBlue[j], padfAlpha[j]); + } + } + +/* -------------------------------------------------------------------- */ +/* Report statistics. We need to dig directly into the C++ API. */ +/* -------------------------------------------------------------------- */ + HFABand *poBand = hHFA->papoBand[i-1]; + HFAEntry *poStats = poBand->poNode->GetNamedChild( "Statistics" ); + + if( poStats != NULL ) + { + printf( " Min: %g Max: %g Mean: %g\n", + poStats->GetDoubleField( "minimum" ), + poStats->GetDoubleField( "maximum" ), + poStats->GetDoubleField( "mean" ) ); + printf( " Median: %g Mode: %g Stddev: %g\n", + poStats->GetDoubleField( "median" ), + poStats->GetDoubleField( "mode" ), + poStats->GetDoubleField( "stddev" ) ); + } + else + printf( " No Statistics found.\n" ); + } + +/* -------------------------------------------------------------------- */ +/* Dump the map info structure. */ +/* -------------------------------------------------------------------- */ + psMapInfo = HFAGetMapInfo( hHFA ); + + if( psMapInfo != NULL ) + { + printf( "MapInfo.proName = %s\n", psMapInfo->proName ); + printf( "MapInfo.upperLeftCenter.x = %.2f\n", + psMapInfo->upperLeftCenter.x ); + printf( "MapInfo.upperLeftCenter.y = %.2f\n", + psMapInfo->upperLeftCenter.y ); + } + else + { + printf( "No Map Info found\n" ); + } + + } + + psProParameters = HFAGetProParameters( hHFA ); + + psDatum = HFAGetDatum( hHFA ); + + HFAClose( hHFA ); + +#ifdef DBMALLOC + malloc_dump(1); +#endif + + exit( 0 ); +} diff --git a/Utilities/GDAL/frmts/hfa/hfatype.cpp b/Utilities/GDAL/frmts/hfa/hfatype.cpp new file mode 100644 index 0000000000..bc32a46866 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/hfatype.cpp @@ -0,0 +1,502 @@ +/****************************************************************************** + * $Id: hfatype.cpp,v 1.10 2005/05/13 02:45:16 fwarmerdam Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Implementation of the HFAType class, for managing one type + * defined in the HFA data dictionary. Managed by HFADictionary. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: hfatype.cpp,v $ + * Revision 1.10 2005/05/13 02:45:16 fwarmerdam + * fixed GetInstCount() error return + * + * Revision 1.9 2005/05/10 00:55:30 fwarmerdam + * Added GetInstCount method + * + * Revision 1.8 2004/01/26 18:28:51 warmerda + * added error recover after corrupt/unrecognised entries - bug 411 + * + * Revision 1.7 2003/04/22 19:40:36 warmerda + * fixed email address + * + * Revision 1.6 2003/02/21 15:40:58 dron + * Added support for writing large (>4 GB) Erdas Imagine files. + * + * Revision 1.5 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.4 2000/12/29 16:37:32 warmerda + * Use GUInt32 for all file offsets + * + * Revision 1.3 2000/09/29 21:42:38 warmerda + * preliminary write support implemented + * + * Revision 1.2 1999/01/22 17:36:47 warmerda + * Added GetInstBytes(), track unknown sizes properly + * + * Revision 1.1 1999/01/04 22:52:10 warmerda + * New + * + */ + +#include "hfa_p.h" + +CPL_CVSID("$Id: hfatype.cpp,v 1.10 2005/05/13 02:45:16 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* HFAType */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HFAType() */ +/************************************************************************/ + +HFAType::HFAType() + +{ + nBytes = 0; + nFields = 0; + papoFields = NULL; + pszTypeName = NULL; +} + +/************************************************************************/ +/* ~HFAType() */ +/************************************************************************/ + +HFAType::~HFAType() + +{ + int i; + + for( i = 0; i < nFields; i++ ) + { + delete papoFields[i]; + } + + CPLFree( papoFields ); + + CPLFree( pszTypeName ); +} + +/************************************************************************/ +/* Initialize() */ +/************************************************************************/ + +const char *HFAType::Initialize( const char * pszInput ) + +{ + int i; + + + if( *pszInput != '{' ) + { + if( *pszInput != '\0' ) + CPLDebug( "HFAType", "Initialize(%60.60s) - unexpected input.", + pszInput ); + + while( *pszInput != '{' && *pszInput != '\0' ) + pszInput++; + + if( *pszInput == '\0' ) + return NULL; + } + + pszInput++; + +/* -------------------------------------------------------------------- */ +/* Read the field definitions. */ +/* -------------------------------------------------------------------- */ + while( pszInput != NULL && *pszInput != '}' ) + { + HFAField *poNewField = new HFAField(); + + pszInput = poNewField->Initialize( pszInput ); + if( pszInput != NULL ) + { + papoFields = (HFAField **) + CPLRealloc(papoFields, sizeof(void*) * (nFields+1) ); + papoFields[nFields++] = poNewField; + } + else + delete poNewField; + } + + if( pszInput == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Collect the name. */ +/* -------------------------------------------------------------------- */ + pszInput++; /* skip `}' */ + + for( i = 0; pszInput[i] != '\0' && pszInput[i] != ','; i++ ) {} + + pszTypeName = (char *) CPLMalloc(i+1); + strncpy( pszTypeName, pszInput, i ); + pszTypeName[i] = '\0'; + + pszInput += i+1; + + return( pszInput ); +} + +/************************************************************************/ +/* CompleteDefn() */ +/************************************************************************/ + +void HFAType::CompleteDefn( HFADictionary * poDict ) + +{ + int i; + +/* -------------------------------------------------------------------- */ +/* This may already be done, if an earlier object required this */ +/* object (as a field), and forced an early computation of the */ +/* size. */ +/* -------------------------------------------------------------------- */ + if( nBytes != 0 ) + return; + +/* -------------------------------------------------------------------- */ +/* Complete each of the fields, totaling up the sizes. This */ +/* isn't really accurate for object with variable sized */ +/* subobjects. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nFields; i++ ) + { + papoFields[i]->CompleteDefn( poDict ); + if( papoFields[i]->nBytes < 0 || nBytes == -1 ) + nBytes = -1; + else + nBytes += papoFields[i]->nBytes; + } +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void HFAType::Dump( FILE * fp ) + +{ + int i; + + VSIFPrintf( fp, "HFAType %s/%d bytes\n", pszTypeName, nBytes ); + + for( i = 0; i < nFields; i++ ) + { + papoFields[i]->Dump( fp ); + } + + VSIFPrintf( fp, "\n" ); +} + +/************************************************************************/ +/* SetInstValue() */ +/************************************************************************/ + +CPLErr +HFAType::SetInstValue( const char * pszFieldPath, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType, void *pValue ) + +{ + int nArrayIndex = 0, nNameLen, iField, nByteOffset; + const char *pszRemainder; + +/* -------------------------------------------------------------------- */ +/* Parse end of field name, possible index value and */ +/* establish where the remaining fields (if any) would start. */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,'[') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'['); + + nArrayIndex = atoi(pszEnd+1); + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = strchr(pszFieldPath,'.'); + if( pszRemainder != NULL ) + pszRemainder++; + } + + else if( strchr(pszFieldPath,'.') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'.'); + + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = pszEnd + 1; + } + + else + { + nNameLen = strlen(pszFieldPath); + pszRemainder = pszFieldPath/*NULL*/; + } + +/* -------------------------------------------------------------------- */ +/* Find this field within this type, if possible. */ +/* -------------------------------------------------------------------- */ + nByteOffset = 0; + for( iField = 0; iField < nFields; iField++ ) + { + if( EQUALN(pszFieldPath,papoFields[iField]->pszFieldName,nNameLen) + && papoFields[iField]->pszFieldName[nNameLen] == '\0' ) + { + break; + } + + nByteOffset += papoFields[iField]->GetInstBytes(pabyData+nByteOffset); + } + + if( iField == nFields ) + return CE_Failure; + +/* -------------------------------------------------------------------- */ +/* Extract this field value, and return. */ +/* -------------------------------------------------------------------- */ + return( papoFields[iField]->SetInstValue( pszRemainder, nArrayIndex, + pabyData + nByteOffset, + nDataOffset + nByteOffset, + nDataSize - nByteOffset, + chReqType, pValue ) ); +} + +/************************************************************************/ +/* GetInstCount() */ +/************************************************************************/ + +int +HFAType::GetInstCount( const char * pszFieldPath, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize ) + +{ + int nArrayIndex = 0, nNameLen, iField, nByteOffset; + const char *pszRemainder; + +/* -------------------------------------------------------------------- */ +/* Parse end of field name, possible index value and */ +/* establish where the remaining fields (if any) would start. */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,'[') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'['); + + nArrayIndex = atoi(pszEnd+1); + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = strchr(pszFieldPath,'.'); + if( pszRemainder != NULL ) + pszRemainder++; + } + + else if( strchr(pszFieldPath,'.') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'.'); + + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = pszEnd + 1; + } + + else + { + nNameLen = strlen(pszFieldPath); + pszRemainder = NULL; + } + +/* -------------------------------------------------------------------- */ +/* Find this field within this type, if possible. */ +/* -------------------------------------------------------------------- */ + nByteOffset = 0; + for( iField = 0; iField < nFields; iField++ ) + { + if( EQUALN(pszFieldPath,papoFields[iField]->pszFieldName,nNameLen) + && papoFields[iField]->pszFieldName[nNameLen] == '\0' ) + { + break; + } + + nByteOffset += papoFields[iField]->GetInstBytes(pabyData+nByteOffset); + } + + if( iField == nFields ) + return -1; + +/* -------------------------------------------------------------------- */ +/* Extract this field value, and return. */ +/* -------------------------------------------------------------------- */ + return( papoFields[iField]->GetInstCount( pabyData + nByteOffset ) ); +} + +/************************************************************************/ +/* ExtractInstValue() */ +/* */ +/* Extract the value of a field instance within this type. */ +/* Most of the work is done by the ExtractInstValue() for the */ +/* HFAField, but this methond does the field name parsing. */ +/* */ +/* field names have the form: */ +/* */ +/* fieldname{[index]}{.fieldname...} */ +/* */ +/* eg. */ +/* abc - field abc[0] */ +/* abc[3] - field abc[3] */ +/* abc[2].def - field def[0] of */ +/* the third abc struct. */ +/************************************************************************/ + +void * +HFAType::ExtractInstValue( const char * pszFieldPath, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + char chReqType ) + +{ + int nArrayIndex = 0, nNameLen, iField, nByteOffset; + const char *pszRemainder; + +/* -------------------------------------------------------------------- */ +/* Parse end of field name, possible index value and */ +/* establish where the remaining fields (if any) would start. */ +/* -------------------------------------------------------------------- */ + if( strchr(pszFieldPath,'[') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'['); + + nArrayIndex = atoi(pszEnd+1); + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = strchr(pszFieldPath,'.'); + if( pszRemainder != NULL ) + pszRemainder++; + } + + else if( strchr(pszFieldPath,'.') != NULL ) + { + const char *pszEnd = strchr(pszFieldPath,'.'); + + nNameLen = pszEnd - pszFieldPath; + + pszRemainder = pszEnd + 1; + } + + else + { + nNameLen = strlen(pszFieldPath); + pszRemainder = NULL; + } + +/* -------------------------------------------------------------------- */ +/* Find this field within this type, if possible. */ +/* -------------------------------------------------------------------- */ + nByteOffset = 0; + for( iField = 0; iField < nFields; iField++ ) + { + if( EQUALN(pszFieldPath,papoFields[iField]->pszFieldName,nNameLen) + && papoFields[iField]->pszFieldName[nNameLen] == '\0' ) + { + break; + } + + nByteOffset += papoFields[iField]->GetInstBytes(pabyData+nByteOffset); + } + + if( iField == nFields ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Extract this field value, and return. */ +/* -------------------------------------------------------------------- */ + return( papoFields[iField]-> + ExtractInstValue( pszRemainder, nArrayIndex, + pabyData + nByteOffset, + nDataOffset + nByteOffset, + nDataSize - nByteOffset, + chReqType ) ); +} + + +/************************************************************************/ +/* DumpInstValue() */ +/************************************************************************/ + +void HFAType::DumpInstValue( FILE * fpOut, + GByte *pabyData, GUInt32 nDataOffset, int nDataSize, + const char * pszPrefix ) + +{ + int iField; + + for( iField = 0; iField < nFields; iField++ ) + { + HFAField *poField = papoFields[iField]; + int nInstBytes; + + poField->DumpInstValue( fpOut, pabyData, nDataOffset, + nDataSize, pszPrefix ); + + nInstBytes = poField->GetInstBytes( pabyData ); + + pabyData += nInstBytes; + nDataOffset += nInstBytes; + nDataSize -= nInstBytes; + } +} + +/************************************************************************/ +/* GetInstBytes() */ +/* */ +/* How many bytes in this particular instance of this type? */ +/************************************************************************/ + +int HFAType::GetInstBytes( GByte * pabyData ) + +{ + if( nBytes >= 0 ) + return( nBytes ); + else + { + int nTotal = 0; + int iField; + + for( iField = 0; iField < nFields; iField++ ) + { + HFAField *poField = papoFields[iField]; + int nInstBytes; + + nInstBytes = poField->GetInstBytes( pabyData ); + + pabyData += nInstBytes; + nTotal += nInstBytes; + } + + return( nTotal ); + } +} diff --git a/Utilities/GDAL/frmts/hfa/img2tif.cpp b/Utilities/GDAL/frmts/hfa/img2tif.cpp new file mode 100644 index 0000000000..3f07763190 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/img2tif.cpp @@ -0,0 +1,1137 @@ +/****************************************************************************** + * $Id: img2tif.cpp,v 1.20 2003/05/13 19:32:10 warmerda Exp $ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Mainline for Imagine to TIFF translation. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: img2tif.cpp,v $ + * Revision 1.20 2003/05/13 19:32:10 warmerda + * support for reading and writing opacity provided by Diana Esch-Mosher + * + * Revision 1.19 2002/07/19 15:37:43 warmerda + * Fixed type of nRowsPerstrip as per bug report from Pete (qaz7@mindspring.com) + * + * Revision 1.18 2001/07/25 15:36:34 warmerda + * fixed bug with last band when writing one file per band + * + * Revision 1.17 2001/07/25 14:26:44 warmerda + * various source dist related changes + * + * Revision 1.16 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.15 1999/12/30 02:41:21 warmerda + * Added support for generating TIFF files of other than 1 or 3 bands. + * + * Revision 1.14 1999/06/01 12:49:04 warmerda + * Add error check of tile size, abort if not multiple of 16. + * + * Revision 1.13 1999/04/21 04:18:32 warmerda + * updated usage + * + * Revision 1.12 1999/03/21 21:32:45 warmerda + * added -s strip support + * + * Revision 1.11 1999/03/15 20:18:29 warmerda + * Fixed data range function. + * + * Revision 1.10 1999/03/15 20:06:36 warmerda + * Changed TIFF_BuildOverviews() to TIFFBuildOverviews(). + * + * Revision 1.9 1999/03/11 20:56:34 warmerda + * Patched up Usage a bit. + * + * Revision 1.8 1999/03/08 19:22:31 warmerda + * Added support to set TIFFTAG_SAMPLEFORMAT. Removed all byte swapping logic. + * + * Revision 1.7 1999/03/02 16:19:06 warmerda + * Fixed bug with -v list termination, and added support for ``-v 0''. + * + * Revision 1.6 1999/03/02 14:18:32 warmerda + * Fixed bug with writing min/max sample value + * + * Revision 1.5 1999/02/15 19:33:05 warmerda + * Added reporting, and logic to -v 98 and -v 99. + * + * Revision 1.3 1999/01/28 16:25:46 warmerda + * Added compression, usage message, error checking and other cleanup. + * + * Revision 1.2 1999/01/27 16:22:19 warmerda + * Added RGB Support + * + * Revision 1.1 1999/01/22 17:45:13 warmerda + * New + */ + +#include "hfa_p.h" + +#include "tiffiop.h" +#include "xtiffio.h" +#include <ctype.h> +#include <assert.h> + +CPL_CVSID("$Id: img2tif.cpp,v 1.20 2003/05/13 19:32:10 warmerda Exp $"); + +CPL_C_START +CPLErr ImagineToGeoTIFFProjection( HFAHandle hHFA, TIFF * hTIFF ); +CPLErr CopyPyramidsToTiff( HFAHandle, HFABand *, TIFF *, int ); +void TIFFBuildOverviews( const char *, int, int * ); +CPL_C_END + +static void ImagineToGeoTIFF( HFAHandle, HFABand **, int, int *, + const char *, int, int, int ); +static CPLErr RGBComboValidate( HFAHandle, HFABand **, int, int * ); +static int ValidateDataType( HFAHandle, int ); +static void ReportOnBand( HFABand * poBand ); +static void ReportOnProjection( HFABand * poBand ); + +int gnReportOn = TRUE; + +/************************************************************************/ +/* Usage() */ +/************************************************************************/ + +void Usage() + +{ + printf( +"Usage: img2tif [-i img_filename] [-o tif_basename] [-c] [-v n...]\n" +" [-rgb [red_band green_band blue_band]] [-?] [-quiet]\n" +"\n" +"Arguments:\n" +" -i <input .img file>\n" +" -o <output base file name>\n" +" Output files will be named base_name1.tif ... base_nameN.tif,\n" +" where N = no. of bands.\n" +" -rgb produce an RGB image file from the indicated band numbers\n" +" within an existing imagine file.\n" +" -s output file is in strips (tiles is default)\n" +" -c packbits compress flag (def=uncompressed)\n" +" -v overview sampling increment(s) (0=single, 98=full set minus 2x,\n" +" 99=full set) Examples: -v 2 4 8 -v 0 -v 99\n" +" -quiet Don't produce a translation report.\n" +" -? Print this explanation of command line arguments\n" +"\n" +"Visit http://gdal.velocet.ca/projects/imagine/hfa_index.html for more info.\n" +"\n" +"Author: Frank Warmerdam (warmerdam@pobox.com)\n" +"Special thanks to Intergraph Corporation for funding this project\n" ); + exit( 1 ); +} + +/************************************************************************/ +/* main() */ +/************************************************************************/ + +int main( int nArgc, char ** papszArgv ) + +{ + int i, nHFABandCount, nBand; + const char *pszSrcFilename = NULL; + const char *pszDstBasename = NULL; + HFAHandle hHFA; + int nCompressFlag = COMPRESSION_NONE; + int nOverviewCount=0, anOverviews[100]; + int bDictDump = FALSE, bTreeDump = FALSE, bWriteInStrips = FALSE; + int nBandCount=0, anBandList[512]; + +/* -------------------------------------------------------------------- */ +/* Parse commandline options. */ +/* -------------------------------------------------------------------- */ + for( i = 1; i < nArgc; i++ ) + { + if( EQUAL(papszArgv[i],"-i") && i+1 < nArgc ) + { + pszSrcFilename = papszArgv[i+1]; + i++; + } + else if( EQUAL(papszArgv[i],"-o") && i+1 < nArgc ) + { + pszDstBasename = papszArgv[i+1]; + i++; + } + else if( EQUAL(papszArgv[i],"-c") ) + { + nCompressFlag = COMPRESSION_PACKBITS; + } + else if( EQUAL(papszArgv[i],"-v") ) + { + while( i+1 < nArgc + && isdigit(papszArgv[i+1][0]) > 0 ) + { + anOverviews[nOverviewCount++] = atoi(papszArgv[i+1]); + i++; + } + } + else if( EQUAL(papszArgv[i],"-s") ) + { + bWriteInStrips = TRUE; + } + else if( EQUAL(papszArgv[i],"-quiet") ) + { + gnReportOn = FALSE; + } + else if( EQUAL(papszArgv[i],"-dd") ) + { + bDictDump = TRUE; + } + else if( EQUAL(papszArgv[i],"-dt") ) + { + bTreeDump = TRUE; + } + else if( EQUAL(papszArgv[i],"-rgb") && i+3 < nArgc ) + { + nBandCount = 3; + anBandList[0] = atoi(papszArgv[++i]) - 1; + anBandList[1] = atoi(papszArgv[++i]) - 1; + anBandList[2] = atoi(papszArgv[++i]) - 1; + } + else if( EQUAL(papszArgv[i],"-rgbn") && i+3 < nArgc ) + { + while( i+1 < nArgc && atoi(papszArgv[i+1]) > 0 ) + anBandList[nBandCount++] = atoi(papszArgv[++i]) - 1; + } + else if( EQUAL(papszArgv[i],"-?") ) + { + Usage(); + } + else + { + printf( "Unexpected argument: %s\n\n", papszArgv[i] ); + Usage(); + } + } + + if( pszSrcFilename == NULL ) + { + printf( "No source file provided.\n\n" ); + Usage(); + } + +/* -------------------------------------------------------------------- */ +/* Open the imagine file. */ +/* -------------------------------------------------------------------- */ + hHFA = HFAOpen( pszSrcFilename, "r" ); + + if( hHFA == NULL ) + { + exit( 100 ); + } + +/* -------------------------------------------------------------------- */ +/* Do we want to walk the tree dumping out general information? */ +/* -------------------------------------------------------------------- */ + if( bDictDump ) + { + HFADumpDictionary( hHFA, stdout ); + } + +/* -------------------------------------------------------------------- */ +/* Do we want to walk the tree dumping out general information? */ +/* -------------------------------------------------------------------- */ + if( bTreeDump ) + { + HFADumpTree( hHFA, stdout ); + } + +/* -------------------------------------------------------------------- */ +/* Report general information on the source file. */ +/* -------------------------------------------------------------------- */ + if( gnReportOn ) + { + printf( "Imagine file: %s Raster Size: %dP x %dL x %dB\n", + pszSrcFilename, hHFA->nXSize, hHFA->nYSize, hHFA->nBands ); + } + +/* -------------------------------------------------------------------- */ +/* If the user has requested `98', or `99' for the overviews, */ +/* figure out how many that will be. */ +/* -------------------------------------------------------------------- */ + if( nOverviewCount == 1 + && (anOverviews[0] == 98 || anOverviews[0] == 99) ) + { + int nXSize = hHFA->nXSize; + int nYSize = hHFA->nYSize; + int nRes = 2; + + nOverviewCount = 0; + if( anOverviews[0] == 98 ) + { + nXSize /= 2; + nYSize /= 2; + nRes = 4; + } + + while( nXSize > 30 || nYSize > 30 ) + { + anOverviews[nOverviewCount++] = nRes; + nRes = nRes * 2; + nXSize = nXSize / 2; + nYSize = nYSize / 2; + } + } + +/* -------------------------------------------------------------------- */ +/* A zero is translated into the largest integer downsampled */ +/* overview smaller than 1 million pixels. */ +/* -------------------------------------------------------------------- */ + if( nOverviewCount == 1 && anOverviews[0] == 0 ) + { + int nXSize = hHFA->nXSize/2; + int nYSize = hHFA->nYSize/2; + int nRes = 2; + + while( nXSize * nYSize > 1000000 ) + { + nRes += 1; + nXSize = hHFA->nXSize / nRes; + nYSize = hHFA->nYSize / nRes; + } + + if( hHFA->nXSize * hHFA->nYSize < 1000000 ) + { + nOverviewCount = 0; + } + else + { + nOverviewCount = 1; + anOverviews[0] = nRes; + } + } + +/* -------------------------------------------------------------------- */ +/* If there is no specified destination file, then report a */ +/* report on the input file. */ +/* -------------------------------------------------------------------- */ + if( pszDstBasename == NULL ) + { + if( !gnReportOn ) + exit( 0 ); + + for( i = 0; i < hHFA->nBands; i++ ) + { + printf( "Band %d\n", i+1 ); + ReportOnBand( hHFA->papoBand[i] ); + } + ReportOnProjection( hHFA->papoBand[0] ); + + exit( 0 ); + } + +/* -------------------------------------------------------------------- */ +/* Loop over all bands, generating each TIFF file. */ +/* -------------------------------------------------------------------- */ + HFAGetRasterInfo( hHFA, NULL, NULL, &nHFABandCount ); + +/* -------------------------------------------------------------------- */ +/* Has the user requested an RGB image? */ +/* -------------------------------------------------------------------- */ + if( nBandCount > 0 ) + { + char szFilename[512]; + + if( RGBComboValidate( hHFA, hHFA->papoBand, + nBandCount, anBandList ) == CE_Failure ) + exit( 1 ); + + if( strstr(pszDstBasename,".") == NULL ) + sprintf( szFilename, "%s.tif", pszDstBasename ); + else + sprintf( szFilename, "%s", pszDstBasename ); + + if( gnReportOn ) + { + printf( "Translating bands " ); + for( i = 0; i < nBandCount; i++ ) + { + if( i != 0 ) + printf( "," ); + printf( "%d", anBandList[i]+1 ); + } + + printf( " to an RGB TIFF file %s.\n", + szFilename ); + } + + ImagineToGeoTIFF( hHFA, hHFA->papoBand, nBandCount, anBandList, + szFilename, + nCompressFlag, + nOverviewCount == 0, + bWriteInStrips ); + + if( nOverviewCount > 0 ) + { + if( gnReportOn ) + printf( " Building %d overviews.\n", nOverviewCount ); + + TIFFBuildOverviews( szFilename, nOverviewCount, anOverviews ); + } + } + +/* -------------------------------------------------------------------- */ +/* Otherwise we translate each band. */ +/* -------------------------------------------------------------------- */ + else + { + for( nBand = 1; nBand <= nHFABandCount; nBand++ ) + { + char szFilename[512]; + + if( !ValidateDataType( hHFA, nBand ) ) + continue; + + if( nHFABandCount == 1 && strstr(pszDstBasename,".tif") != NULL ) + sprintf( szFilename, "%s", pszDstBasename ); + else if( nHFABandCount == 1 ) + sprintf( szFilename, "%s.tif", pszDstBasename ); + else + sprintf( szFilename, "%s%d.tif", pszDstBasename, nBand ); + + if( gnReportOn ) + printf( "Translating band %d to an TIFF file %s.\n", + nBand, szFilename ); + + anBandList[0] = nBand - 1; + ImagineToGeoTIFF( hHFA, hHFA->papoBand, 1, anBandList, + szFilename, nCompressFlag, + nOverviewCount == 0, + bWriteInStrips ); + + if( nOverviewCount > 0 ) + { + if( gnReportOn ) + printf( " Building %d overviews.\n", nOverviewCount ); + + TIFFBuildOverviews( szFilename, nOverviewCount, anOverviews ); + } + } + } + + HFAClose( hHFA ); + + return 0; +} + +/************************************************************************/ +/* ReportOnBand() */ +/************************************************************************/ + +static void ReportOnBand( HFABand * poBand ) + +{ + HFAEntry *poBinInfo, *poSubNode; + + printf( " Data Type: %s Raster Size: %dx%d\n", + poBand->poNode->GetStringField( "pixelType" ), + poBand->poNode->GetIntField( "width" ), + poBand->poNode->GetIntField( "height" ) ); + +/* -------------------------------------------------------------------- */ +/* Report min/max */ +/* -------------------------------------------------------------------- */ + poBinInfo = poBand->poNode->GetNamedChild("Statistics" ); + if( poBinInfo != NULL ) + { + printf( " Pixel Values - Minimum=%g, Maximum=%g\n", + poBinInfo->GetDoubleField( "minimum" ), + poBinInfo->GetDoubleField( "maximum" ) ); + } + +/* -------------------------------------------------------------------- */ +/* Report overviews. */ +/* -------------------------------------------------------------------- */ + for( poSubNode = poBand->poNode->GetChild(); + poSubNode != NULL; + poSubNode = poSubNode->GetNext() ) + { + if( !EQUAL(poSubNode->GetType(),"Eimg_Layer_SubSample") ) + continue; + + printf( " Overview: %s\n", poSubNode->GetName() ); + } +} + +/************************************************************************/ +/* ReportOnProjection() */ +/* */ +/* Report on the projection of a given band. */ +/************************************************************************/ + +static void ReportOnProjection( HFABand * poBand ) + +{ + HFAEntry *poDatum, *poProParameters; + + poProParameters = poBand->poNode->GetNamedChild( "Projection" ); + if( poProParameters == NULL ) + return; + + printf( "\n" ); + printf( " ProjectionName = %s\n", + poProParameters->GetStringField( "proName" ) ); + printf( " ProjectionZone = %d\n", + poProParameters->GetIntField( "proZone" ) ); + + printf( " Spheroid = %s (major=%.2f, minor=%.2f)\n", + poProParameters->GetStringField( "proSpheroid.sphereName" ), + poProParameters->GetDoubleField( "proSpheroid.a" ), + poProParameters->GetDoubleField( "proSpheroid.b" ) ); + +/* -------------------------------------------------------------------- */ +/* Report on datum. */ +/* -------------------------------------------------------------------- */ + poDatum = poProParameters->GetNamedChild( "Datum" ); + if( poDatum == NULL ) + return; + + printf( " Datum Name = %s\n", + poDatum->GetStringField( "datumname" ) ); +} + +/************************************************************************/ +/* ValidateDataType() */ +/* */ +/* Will we write this dataset to TIFF? Some that are */ +/* considered illegal could be done, but are outside the scope */ +/* of what Intergraph wants. */ +/************************************************************************/ + +static int ValidateDataType( HFAHandle hHFA, int nBand ) + +{ + HFABand *poBand; + + poBand = hHFA->papoBand[nBand-1]; + + if( poBand->nDataType == EPT_f32 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Band %d is of type `float', and is not supported for translation.\n", + nBand ); + return FALSE; + } + else if( poBand->nDataType == EPT_f64 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Band %d is of type `double', and is not supported for translation.\n", + nBand ); + return FALSE; + } + else if( poBand->nDataType == EPT_c128 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Band %d is of type `complex', and is not supported for translation.\n", + nBand ); + return FALSE; + } + + return TRUE; +} + + +/************************************************************************/ +/* ImagineToGeoTIFFPalette() */ +/************************************************************************/ + +static +void ImagineToGeoTIFFPalette( HFABand *poBand, TIFF * hTIFF ) + +{ + unsigned short anTRed[256], anTGreen[256], anTBlue[256]; + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + int nColors, i; + + poBand->GetPCT( &nColors, &padfRed, &padfGreen, &padfBlue, &padfAlpha ); + CPLAssert( nColors > 0 ); + + for( i = 0; i < 256; i++ ) + { + if( i < nColors ) + { + anTRed[i] = (unsigned short) (65535 * padfRed[i]); + anTGreen[i] = (unsigned short) (65535 * padfGreen[i]); + anTBlue[i] = (unsigned short) (65535 * padfBlue[i]); + } + else + { + anTRed[i] = 0; + anTGreen[i] = 0; + anTBlue[i] = 0; + } + } + + TIFFSetField( hTIFF, TIFFTAG_COLORMAP, anTRed, anTGreen, anTBlue ); +} + +/************************************************************************/ +/* ImagineToGeoTIFFDataRange() */ +/************************************************************************/ + +static CPLErr ImagineToGeoTIFFDataRange( HFABand * poBand, TIFF *hTIFF) + +{ + double dfMin, dfMax; + unsigned short nTMin, nTMax; + HFAEntry *poBinInfo; + + poBinInfo = poBand->poNode->GetNamedChild("Statistics" ); + + if( poBinInfo == NULL ) + return( CE_Failure ); + + dfMin = poBinInfo->GetDoubleField( "minimum" ); + dfMax = poBinInfo->GetDoubleField( "maximum" ); + + if( dfMax < dfMin ) + return CE_Failure; + + if( dfMin < 0 || dfMin > 65536 || dfMax < 0 || dfMax > 65535 + || dfMin >= dfMax ) + return( CE_Failure ); + + nTMin = (unsigned short) dfMin; + nTMax = (unsigned short) dfMax; + + TIFFSetField( hTIFF, TIFFTAG_MINSAMPLEVALUE, nTMin ); + TIFFSetField( hTIFF, TIFFTAG_MAXSAMPLEVALUE, nTMax ); + + return( CE_None ); +} + +/************************************************************************/ +/* LoadRowOfTiles() */ +/* */ +/* Helper function for CopyOneBandToStrips() to load a row of */ +/* tiles into a line (rather than tile) interleaved strip but */ +/* with the height of a tile rather than the eventual strip */ +/* size. Note that unneeded data in the last tile is */ +/* discarded. */ +/************************************************************************/ + +static CPLErr LoadRowOfTiles( HFABand * poBand, unsigned char * pabyRowOfTiles, + int nTileXSize, int nTileYSize, + int nStripWidth, int nDataBits, int nTileRow, + int nSample ) + +{ + unsigned char *pabyTile; + int iTileX; + + pabyTile = (unsigned char *) VSIMalloc(nTileXSize*nTileYSize*nDataBits/8); + if( pabyTile == NULL ) + return CE_Failure; + + for( iTileX = 0; iTileX*nTileXSize < nStripWidth; iTileX++ ) + { + int nCopyBytes, nRowOffset, iTileLine; + + if( poBand->GetRasterBlock( iTileX, nTileRow, pabyTile ) != CE_None ) + return( CE_Failure ); + + if( (iTileX+1) * nTileXSize > nStripWidth ) + nCopyBytes = (nStripWidth - iTileX * nTileXSize) * nDataBits / 8; + else + nCopyBytes = nTileXSize * nDataBits / 8; + + nRowOffset = iTileX * nTileXSize * nDataBits / 8; + + for( iTileLine = 0; iTileLine < nTileYSize; iTileLine++ ) + { + memcpy( pabyRowOfTiles + nRowOffset + + iTileLine * nStripWidth * nDataBits / 8, + pabyTile + iTileLine * nTileXSize * nDataBits / 8, + nCopyBytes ); + } + } + + VSIFree( pabyTile ); + + return( CE_None ); +} + + +/************************************************************************/ +/* CopyOneBandToStrips() */ +/* */ +/* copy just the imagery tiles from an Imagine band (full res, */ +/* or overview) to a sample of a TIFF file with stripped, */ +/* rather than tiled organization.. */ +/************************************************************************/ + +static CPLErr CopyOneBandToStrips( HFABand * poBand, TIFF * hTIFF, int nSample) + +{ + unsigned char *pabyRowOfTiles; + unsigned char *pabyStrip; + int nTileXSize, nTileYSize, nStripWidth, nDataBits, iStrip; + int nLoadedTileRow; + uint32 nRowsPerStrip; + +/* -------------------------------------------------------------------- */ +/* Collect various information in local variables. */ +/* -------------------------------------------------------------------- */ + nTileXSize = poBand->nBlockXSize; + nTileYSize = poBand->nBlockYSize; + nStripWidth = poBand->nWidth; + nDataBits = HFAGetDataTypeBits( poBand->nDataType ); + + TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(nRowsPerStrip) ); + +/* -------------------------------------------------------------------- */ +/* Verify that scanlines in tiles, and strips fall on byte */ +/* boundaries. */ +/* -------------------------------------------------------------------- */ + assert( (nTileXSize * nDataBits) % 8 == 0 ); + assert( (nStripWidth * nDataBits) % 8 == 0 ); + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer big enough to hold a whole row of tiles, */ +/* and another big enough to hold a strip on the output file. */ +/* -------------------------------------------------------------------- */ + pabyRowOfTiles = (unsigned char *) + VSIMalloc((nStripWidth * nTileYSize * nDataBits) / 8); + pabyStrip = (unsigned char *) + VSIMalloc((nStripWidth * nRowsPerStrip * nDataBits) / 8); + + if( pabyRowOfTiles == NULL || pabyStrip == NULL ) + { + fprintf( stderr, + "Out of memory allocating working buffer(s).\n" ); + return( CE_Failure ); + } + +/* -------------------------------------------------------------------- */ +/* Loop through image one strip at a time. */ +/* -------------------------------------------------------------------- */ + nLoadedTileRow = -1; + for( iStrip = 0; iStrip * nRowsPerStrip < poBand->nHeight; iStrip++ ) + { + int iStripLine, nStripLines, iStripOffset; + int iStripId; + + iStripOffset = iStrip * nRowsPerStrip; + nStripLines = nRowsPerStrip; + if( iStrip + nRowsPerStrip > poBand->nHeight ) + nStripLines = poBand->nHeight - iStrip; + +/* -------------------------------------------------------------------- */ +/* Fill in the strip one line at a time, triggering the load of */ +/* a new row of tiles when a tile boundary is crossed. */ +/* -------------------------------------------------------------------- */ + for( iStripLine = 0; iStripLine < nStripLines; iStripLine++ ) + { + int iLineWithinTiles; + + iLineWithinTiles = + iStripLine + iStripOffset - nLoadedTileRow * nTileYSize; + + if( iStripLine + iStripOffset >= (nLoadedTileRow+1) * nTileYSize ) + { + nLoadedTileRow++; + iLineWithinTiles = 0; + LoadRowOfTiles( poBand, pabyRowOfTiles, nTileXSize, nTileYSize, + nStripWidth, nDataBits, nLoadedTileRow, + nSample ); + } + + memcpy( pabyStrip + (iStripLine * nStripWidth * nDataBits)/8, + pabyRowOfTiles + + (iLineWithinTiles * nStripWidth * nDataBits)/8, + nStripWidth * nDataBits / 8 ); + } + +/* -------------------------------------------------------------------- */ +/* Write out the strip. */ +/* -------------------------------------------------------------------- */ + iStripId = TIFFComputeStrip( hTIFF, iStrip * nRowsPerStrip, nSample ); + + if( TIFFWriteEncodedStrip( hTIFF, iStripId, pabyStrip, + (nStripLines * nStripWidth * nDataBits)/ 8) < 0 ) + return( CE_Failure ); + } + + VSIFree( pabyStrip ); + VSIFree( pabyRowOfTiles ); + + return( CE_None ); +} + +/************************************************************************/ +/* CopyOneBand() */ +/* */ +/* copy just the imagery tiles from an Imagine band (full res, */ +/* or overview) to a sample of a TIFF file. */ +/************************************************************************/ + +static CPLErr CopyOneBand( HFABand * poBand, TIFF * hTIFF, int nSample ) + +{ + void *pData; + int nTileSize; + +/* -------------------------------------------------------------------- */ +/* Allocate a block buffer. */ +/* -------------------------------------------------------------------- */ + nTileSize = TIFFTileSize( hTIFF ); + pData = VSIMalloc(nTileSize); + if( pData == NULL ) + { + printf( "Out of memory allocating working tile of %d bytes.\n", + nTileSize ); + return( CE_Failure ); + } + +/* -------------------------------------------------------------------- */ +/* Write each of the tiles. */ +/* -------------------------------------------------------------------- */ + int iBlockX, iBlockY; + + for( iBlockY = 0; iBlockY < poBand->nBlocksPerColumn; iBlockY++ ) + { + for( iBlockX = 0; iBlockX < poBand->nBlocksPerRow; iBlockX++ ) + { + int iTile; + + if( poBand->GetRasterBlock( iBlockX, iBlockY, pData ) != CE_None ) + return( CE_Failure ); + + iTile = TIFFComputeTile( hTIFF, + iBlockX*poBand->nBlockXSize, + iBlockY*poBand->nBlockYSize, + 0, nSample ); + + if( TIFFWriteEncodedTile( hTIFF, iTile, pData, nTileSize ) < 1 ) + return( CE_Failure ); + } + } + + VSIFree( pData ); + + return( CE_None ); +} + +/************************************************************************/ +/* ImagineToGeoTIFF() */ +/************************************************************************/ + +static void ImagineToGeoTIFF( HFAHandle hHFA, + HFABand ** papoBandList, + int nBandCount, int * panBandList, + const char * pszDstFilename, + int nCompressFlag, int bCopyOverviews, + int bWriteInStrips ) + +{ + TIFF *hTIFF; + int nXSize, nYSize, nBlockXSize, nBlockYSize, nDataType; + int nBlocksPerRow, nBlocksPerColumn; + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + int nColors; + + HFAGetRasterInfo( hHFA, &nXSize, &nYSize, NULL ); + + nDataType = papoBandList[panBandList[0]]->nDataType; + nBlockXSize = papoBandList[panBandList[0]]->nBlockXSize; + nBlockYSize = papoBandList[panBandList[0]]->nBlockYSize; + +/* -------------------------------------------------------------------- */ +/* Tile sizes must be a multiple of 16. */ +/* -------------------------------------------------------------------- */ + if( (nBlockXSize % 16) != 0 || (nBlockYSize % 16) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Tile sizes must be multiple of 16. Imagine file tile size\n" + "of %dx%d is not. Translation aborted.\n", + nBlockXSize, nBlockYSize ); + + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* Fetch PCT, if available. */ +/* -------------------------------------------------------------------- */ + if( nBandCount == 1 ) + papoBandList[panBandList[0]]->GetPCT( &nColors, &padfRed, + &padfGreen, &padfBlue, &padfAlpha ); + else + nColors = 0; + + nBlocksPerRow = (nXSize + nBlockXSize - 1) / nBlockXSize; + nBlocksPerColumn = (nYSize + nBlockYSize - 1) / nBlockYSize; + +/* -------------------------------------------------------------------- */ +/* Create the new file. */ +/* -------------------------------------------------------------------- */ + hTIFF = XTIFFOpen( pszDstFilename, "w+" ); + +/* -------------------------------------------------------------------- */ +/* Write standard header fields. */ +/* -------------------------------------------------------------------- */ + TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, nXSize ); + TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, nYSize ); + TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompressFlag ); + TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, + HFAGetDataTypeBits(nDataType) ); + + if( nDataType == EPT_s16 || nDataType == EPT_s8 ) + TIFFSetField( hTIFF, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT ); + + if( nBandCount == 1 ) + { + TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, 1 ); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); + } + else + { + TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nBandCount ); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE ); + } + + TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, 0 ); + + if( bWriteInStrips ) + { + TIFFSetField( hTIFF, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize( hTIFF, 0 ) ); + } + else + { + TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, nBlockXSize ); + TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, nBlockYSize ); + } + + if( nColors > 0 ) + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE ); + else if( nBandCount < 3 ) + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK ); + else + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB ); + +/* -------------------------------------------------------------------- */ +/* Do we have min/max value information? */ +/* -------------------------------------------------------------------- */ + if( nBandCount == 1 ) + ImagineToGeoTIFFDataRange( papoBandList[panBandList[0]], hTIFF ); + +/* -------------------------------------------------------------------- */ +/* Copy over one, or three bands of raster data. */ +/* -------------------------------------------------------------------- */ + + if( bWriteInStrips ) + { + int iBand; + + for( iBand = 0; iBand < nBandCount; iBand++ ) + CopyOneBandToStrips( papoBandList[panBandList[iBand]], hTIFF, + iBand ); + } + else + { + int iBand; + + for( iBand = 0; iBand < nBandCount; iBand++ ) + CopyOneBand( papoBandList[panBandList[iBand]], hTIFF, iBand ); + } + +/* -------------------------------------------------------------------- */ +/* Write Geotiff information. */ +/* -------------------------------------------------------------------- */ + ImagineToGeoTIFFProjection( hHFA, hTIFF ); + +/* -------------------------------------------------------------------- */ +/* Write Palette */ +/* -------------------------------------------------------------------- */ + if( nColors > 0 ) + ImagineToGeoTIFFPalette( papoBandList[panBandList[0]], hTIFF ); + +/* -------------------------------------------------------------------- */ +/* Write overviews */ +/* -------------------------------------------------------------------- */ + if( bCopyOverviews ) + CopyPyramidsToTiff( hHFA, papoBandList[panBandList[0]], hTIFF, + nCompressFlag ); + + XTIFFClose( hTIFF ); +} + +/************************************************************************/ +/* RRD2Tiff() */ +/* */ +/* Copy one reduced resolution layer to a TIFF file. */ +/************************************************************************/ + +static +CPLErr RRD2Tiff( HFABand * poBand, TIFF * hTIFF, + int nPhotometricInterp, + int nCompression ) + +{ + if( poBand->nBlockXSize % 16 != 0 || poBand->nBlockYSize % 16 != 0 ) + return( CE_Failure ); + + TIFFWriteDirectory( hTIFF ); + + TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, poBand->nWidth ); + TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, poBand->nHeight ); + TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, + HFAGetDataTypeBits(poBand->nDataType) ); + + TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, 1 ); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); + + TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, poBand->nBlockXSize ); + TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, poBand->nBlockYSize ); + + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometricInterp ); + TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompression ); + + TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE ); + + return( CopyOneBand( poBand, hTIFF, 0 ) ); +} + + +/************************************************************************/ +/* CopyPyramidsToTiff() */ +/* */ +/* Copy reduced resolution layers to the TIFF file as */ +/* overviews. */ +/************************************************************************/ + +CPLErr CopyPyramidsToTiff( HFAHandle psInfo, HFABand *poBand, TIFF * hTIFF, + int nCompressFlag ) + +{ + HFAEntry *poBandNode = poBand->poNode; + HFAEntry *poSubNode; + int nColors, nPhotometric; + double *padfRed, *padfGreen, *padfBlue, *padfAlpha; + + poBand->GetPCT( &nColors, &padfRed, &padfGreen, &padfBlue, &padfAlpha ); + if( nColors == 0 ) + nPhotometric = PHOTOMETRIC_MINISBLACK; + else + nPhotometric = PHOTOMETRIC_PALETTE; + + for( poSubNode = poBandNode->GetChild(); + poSubNode != NULL; + poSubNode = poSubNode->GetNext() ) + { + HFABand *poOverviewBand; + + if( !EQUAL(poSubNode->GetType(),"Eimg_Layer_SubSample") ) + continue; + + poOverviewBand = new HFABand( psInfo, poSubNode ); + + if( RRD2Tiff( poOverviewBand, hTIFF, nPhotometric, nCompressFlag ) + == CE_None + && nColors > 0 ) + ImagineToGeoTIFFPalette( poBand, hTIFF ); + + delete poOverviewBand; + } + + return CE_None; +} + +/************************************************************************/ +/* RGBComboValidate() */ +/* */ +/* Validate the users selection of band numbers for an RGB */ +/* image. */ +/************************************************************************/ + +static CPLErr RGBComboValidate( HFAHandle hHFA, + HFABand ** papoBands, + int nBandCount, int * panBandList ) + +{ + int nHFABandCount, iBand; + + HFAGetRasterInfo( hHFA, NULL, NULL, &nHFABandCount ); + +/* -------------------------------------------------------------------- */ +/* Check that band numbers exist. */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nBandCount; iBand++ ) + { + if( panBandList[iBand] < 0 || panBandList[iBand] >= nHFABandCount ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Selected band (%d) not legal. Only %d bands are " + "available.\n", panBandList[iBand]+1, nHFABandCount ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Verify that all the bands have the same datatype, tile size, */ +/* and so forth. */ +/* -------------------------------------------------------------------- */ + int bBandsMatch = TRUE; + + for( iBand = 1; iBand < nBandCount; iBand++ ) + { + HFABand *poBandTest = papoBands[panBandList[iBand]]; + HFABand *poBandBase = papoBands[panBandList[iBand]]; + + if( poBandTest->nDataType != poBandBase->nDataType ) + bBandsMatch = FALSE; + } + + if( !bBandsMatch ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Datatypes of different bands do not match.\n" ); + return CE_Failure; + } + + for( iBand = 1; iBand < nBandCount; iBand++ ) + { + HFABand *poBandTest = papoBands[panBandList[iBand]]; + HFABand *poBandBase = papoBands[panBandList[iBand]]; + + if( poBandTest->nBlockXSize != poBandBase->nBlockXSize + || poBandTest->nBlockYSize != poBandBase->nBlockYSize ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Tile sizes of different bands do not match.\n" ); + return CE_Failure; + } + } + +/* -------------------------------------------------------------------- */ +/* Verify that each of the bands is legal. */ +/* -------------------------------------------------------------------- */ + for( iBand = 1; iBand < nBandCount; iBand++ ) + { + if( !ValidateDataType( hHFA, panBandList[iBand]+1 ) ) + return CE_Failure; + } + + return CE_None; +} diff --git a/Utilities/GDAL/frmts/hfa/img2tif.txt b/Utilities/GDAL/frmts/hfa/img2tif.txt new file mode 100644 index 0000000000..87d0c1c8b8 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/img2tif.txt @@ -0,0 +1,38 @@ + +Usage: img2tif [-i img_filename] [-o tif_basename] [-c] + [-rgb [red green blue]] [-v n...] [-?] [-quiet] + +Arguments: + -i <input .img file> + -o <output base file name> + Output files will be named base_name1.tif ... base_nameN.tif, + where N = no. of bands. + -rgb produce an RGB image file from the indicated red, green and blue + bands. + -c [packbits compress flag (def=uncompressed)] + -v [overview sampling increment(s) (0=single, 98=full set minus 2x, + 99=full set, def=98) Examples: -v 2 4 8 -v 0 -v 99] + -quiet Don't produce a translation report. + -? Print explanation of command line arguments + +Other notes: + o If the -rgb switch isn't given then a greyscale, or pseudocolored TIFF + file will be generated for each band in the source file. + + o If the source file has no image bands an error message will be produced + and execution stopped. + + o The translation report (on by default) would indicate the source + projection, total number of bands and their types, and any other meta + information I judge to be potentially useful. + + o As discussed, I will extract the image pyramids and write them to the + GeoTIFF file if they are available. If the -v flag is given existing + pyramids will be ignored, and new ones generated on the fly. + + o The output file would always be tiled, with the same tiling arrangement + as the source Imagine file. + + o The .img Descriptor_Table.Statistics.minimum, and maximum fields will be + used to set the MinSampleValue, and MaxSampleValue fields in the TIFF file + if they are available. diff --git a/Utilities/GDAL/frmts/hfa/img2tif_build.sh b/Utilities/GDAL/frmts/hfa/img2tif_build.sh new file mode 100755 index 0000000000..a996c5378d --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/img2tif_build.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +BLDDIR=`pwd` +CC=gcc +CPPC=gcc +CFLAGS="-O -I$BLDDIR/hfa -I$BLDDIR/libtiff -I$BLDDIR/libgeotiff -I$BLDDIR/port" + +LINK=gcc +XTRALIBS="-lm" + + +for FILE in *.c */*.c ; do + echo cd `dirname $FILE`\; $CC -c $CFLAGS `basename $FILE` + (cd `dirname $FILE`; $CC -c $CFLAGS `basename $FILE`) +done +for FILE in *.cpp */*.cpp ; do + echo cd `dirname $FILE`\; $CPPC -c $CFLAGS `basename $FILE` + (cd `dirname $FILE`; $CPPC -c $CFLAGS `basename $FILE`) +done + +$LINK img2tif.o imggeotiff.o tif_overview.o rawblockedimage.o hfa/*.o libgeotiff/*.o libtiff/*.o port/*.o $XTRALIBS -o img2tif + +$LINK hfatest.o hfa/*.o libgeotiff/*.o libtiff/*.o port/*.o $XTRALIBS -o hfatest + diff --git a/Utilities/GDAL/frmts/hfa/imggeotiff.c b/Utilities/GDAL/frmts/hfa/imggeotiff.c new file mode 100644 index 0000000000..8a0eeb4c21 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/imggeotiff.c @@ -0,0 +1,881 @@ +/****************************************************************************** + * $Id$ + * + * Project: Erdas Imagine (.img) Translator + * Purpose: Mapping Imagine georeferencing to GeoTIFF georeferencing. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Intergraph Corporation + * + * 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: imggeotiff.c,v $ + * Revision 1.6 2006/04/04 03:31:13 fwarmerdam + * Fixed contact info. + * + * Revision 1.5 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.4 1999/06/01 12:29:51 warmerda + * Ensure ImagineToGeoTIFFProjection() has C linkaged even if compiled with c++. + * + * Revision 1.3 1999/03/02 14:18:09 warmerda + * Don't write geotiff info if no mapinfo + * + * Revision 1.2 1999/01/28 16:21:24 warmerda + * defined PI if needed + * + * Revision 1.1 1999/01/22 17:40:43 warmerda + * New + * + */ + +#include "hfa.h" + +#include "cpl_conv.h" + +#include "geotiff.h" +#include "geo_tiffp.h" +#include "geo_keyp.h" +#include "geovalues.h" + +CPL_CVSID("$Id$"); + +#ifndef PI +# define PI 3.14159265358979323846 +#endif + +#define RAD_TO_DEG (180/PI) +#define MapSys_State_Plane -9003 + +int GTIFMapSysToPCS( int MapSys, int Datum, int nZone ); + +CPL_C_START +CPLErr ImagineToGeoTIFFProjection( HFAHandle hHFA, TIFF * hTIFF ); +CPL_C_END + +/* ==================================================================== */ +/* Table relating USGS and ESRI state plane zones. */ +/* ==================================================================== */ +int anUsgsEsriZones[] = +{ + 101, 3101, + 102, 3126, + 201, 3151, + 202, 3176, + 203, 3201, + 301, 3226, + 302, 3251, + 401, 3276, + 402, 3301, + 403, 3326, + 404, 3351, + 405, 3376, + 406, 3401, + 407, 3426, + 501, 3451, + 502, 3476, + 503, 3501, + 600, 3526, + 700, 3551, + 901, 3601, + 902, 3626, + 903, 3576, + 1001, 3651, + 1002, 3676, + 1101, 3701, + 1102, 3726, + 1103, 3751, + 1201, 3776, + 1202, 3801, + 1301, 3826, + 1302, 3851, + 1401, 3876, + 1402, 3901, + 1501, 3926, + 1502, 3951, + 1601, 3976, + 1602, 4001, + 1701, 4026, + 1702, 4051, + 1703, 6426, + 1801, 4076, + 1802, 4101, + 1900, 4126, + 2001, 4151, + 2002, 4176, + 2101, 4201, + 2102, 4226, + 2103, 4251, + 2111, 6351, + 2112, 6376, + 2113, 6401, + 2201, 4276, + 2202, 4301, + 2203, 4326, + 2301, 4351, + 2302, 4376, + 2401, 4401, + 2402, 4426, + 2403, 4451, + 2500, 0, + 2501, 4476, + 2502, 4501, + 2503, 4526, + 2600, 0, + 2601, 4551, + 2602, 4576, + 2701, 4601, + 2702, 4626, + 2703, 4651, + 2800, 4676, + 2900, 4701, + 3001, 4726, + 3002, 4751, + 3003, 4776, + 3101, 4801, + 3102, 4826, + 3103, 4851, + 3104, 4876, + 3200, 4901, + 3301, 4926, + 3302, 4951, + 3401, 4976, + 3402, 5001, + 3501, 5026, + 3502, 5051, + 3601, 5076, + 3602, 5101, + 3701, 5126, + 3702, 5151, + 3800, 5176, + 3900, 0, + 3901, 5201, + 3902, 5226, + 4001, 5251, + 4002, 5276, + 4100, 5301, + 4201, 5326, + 4202, 5351, + 4203, 5376, + 4204, 5401, + 4205, 5426, + 4301, 5451, + 4302, 5476, + 4303, 5501, + 4400, 5526, + 4501, 5551, + 4502, 5576, + 4601, 5601, + 4602, 5626, + 4701, 5651, + 4702, 5676, + 4801, 5701, + 4802, 5726, + 4803, 5751, + 4901, 5776, + 4902, 5801, + 4903, 5826, + 4904, 5851, + 5001, 6101, + 5002, 6126, + 5003, 6151, + 5004, 6176, + 5005, 6201, + 5006, 6226, + 5007, 6251, + 5008, 6276, + 5009, 6301, + 5010, 6326, + 5101, 5876, + 5102, 5901, + 5103, 5926, + 5104, 5951, + 5105, 5976, + 5201, 6001, + 5200, 6026, + 5200, 6076, + 5201, 6051, + 5202, 6051, + 5300, 0, + 5400, 0 +}; + +/************************************************************************/ +/* ESRIToUSGSZone() */ +/* */ +/* Convert ESRI style state plane zones to USGS style state */ +/* plane zones. */ +/************************************************************************/ + +static int ESRIToUSGSZone( int nESRIZone ) + +{ + int nPairs = sizeof(anUsgsEsriZones) / (2*sizeof(int)); + int i; + + for( i = 0; i < nPairs; i++ ) + { + if( anUsgsEsriZones[i*2+1] == nESRIZone ) + return anUsgsEsriZones[i*2]; + } + + return 0; +} + +/************************************************************************/ +/* ImagineToGeoTIFFProjection() */ +/* */ +/* Apply ``Geo'' information to the GeoTIFF file based on the */ +/* source Imagine file. */ +/************************************************************************/ + +CPLErr ImagineToGeoTIFFProjection( HFAHandle hHFA, TIFF * hTIFF ) + +{ + GTIF *hGTiff; + const Eprj_Datum *psDatum; + const Eprj_ProParameters *psProParameters; + const Eprj_MapInfo *psMapInfo; + int16 nPCS = KvUserDefined; + +/* -------------------------------------------------------------------- */ +/* Get info on Imagine file projection. */ +/* -------------------------------------------------------------------- */ + psMapInfo = HFAGetMapInfo( hHFA ); + psProParameters = HFAGetProParameters( hHFA ); + psDatum = HFAGetDatum( hHFA ); + + if( psMapInfo == NULL ) + return CE_None; + + hGTiff = GTIFNew( hTIFF ); + +/* -------------------------------------------------------------------- */ +/* Write out the pixelisarea marker. */ +/* -------------------------------------------------------------------- */ + GTIFKeySet(hGTiff, GTRasterTypeGeoKey, TYPE_SHORT, 1, + RasterPixelIsArea ); + +/* -------------------------------------------------------------------- */ +/* Write out the corner coordinates. */ +/* -------------------------------------------------------------------- */ + if( psMapInfo != NULL ) + { + double adfPixelScale[3], adfTiePoints[6]; + + adfPixelScale[0] = psMapInfo->pixelSize.width; + adfPixelScale[1] = psMapInfo->pixelSize.height; + adfPixelScale[2] = 0.0; + + TIFFSetField( hTIFF, TIFFTAG_GEOPIXELSCALE, 3, adfPixelScale ); + + adfTiePoints[0] = 0.5; + adfTiePoints[1] = 0.5; + adfTiePoints[2] = 0.0; + adfTiePoints[3] = psMapInfo->upperLeftCenter.x; + adfTiePoints[4] = psMapInfo->upperLeftCenter.y; + adfTiePoints[5] = 0.0; + + TIFFSetField( hTIFF, TIFFTAG_GEOTIEPOINTS, 6, adfTiePoints ); + } + +/* -------------------------------------------------------------------- */ +/* Try to write out units information. */ +/* -------------------------------------------------------------------- */ + if( psMapInfo != NULL ) + { + if( EQUAL(psMapInfo->units,"meters") ) + { + GTIFKeySet(hGTiff, ProjLinearUnitsGeoKey, TYPE_SHORT, 1, + Linear_Meter ); + } + else if( EQUAL(psMapInfo->units,"feet") ) + { + GTIFKeySet(hGTiff, ProjLinearUnitsGeoKey, TYPE_SHORT, 1, + Linear_Foot_US_Survey); + } + else if( EQUAL(psMapInfo->units,"dd") ) + { + GTIFKeySet(hGTiff, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Degree); + } + } + +/* -------------------------------------------------------------------- */ +/* If this is not geographic, write out the model type as */ +/* projected. Note that this will get written even if we end */ +/* up not translating the projection which may be unwise. */ +/* -------------------------------------------------------------------- */ + if( psProParameters != NULL ) + { + if( psProParameters->proNumber == 0 ) + GTIFKeySet(hGTiff, GTModelTypeGeoKey, TYPE_SHORT, 1, + ModelTypeGeographic ); + else + GTIFKeySet(hGTiff, GTModelTypeGeoKey, TYPE_SHORT, 1, + ModelTypeProjected ); + } + +/* -------------------------------------------------------------------- */ +/* Do we have a ``nice'' UTM PCS situation? */ +/* -------------------------------------------------------------------- */ + if( psProParameters != NULL + && psProParameters->proNumber == 1 /* UTM */ + && psProParameters->proParams[3] >= 0.0 /* north */ + && psDatum != NULL + && EQUAL(psDatum->datumname,"NAD27") ) + { + nPCS = 26700 + psProParameters->proZone; + } + + if( psProParameters != NULL + && psProParameters->proNumber == 1 /* UTM */ + && psProParameters->proParams[3] >= 0.0 /* north */ + && psDatum != NULL + && EQUAL(psDatum->datumname,"NAD83") ) + { + nPCS = 26800 + psProParameters->proZone; + } + + if( psProParameters != NULL + && psProParameters->proNumber == 1 /* UTM */ + && psProParameters->proParams[3] >= 0.0 /* north */ + && psDatum != NULL + && EQUAL(psDatum->datumname,"WGS 84") ) + { + /* I don't know if the above datum names really work ... just a guess*/ + nPCS = 32600 + psProParameters->proZone; + } + + if( psProParameters != NULL + && psProParameters->proNumber == 1 /* UTM */ + && psProParameters->proParams[3] < 0.0 /* south */ + && psDatum != NULL + && EQUAL(psDatum->datumname,"WGS 84") ) + { + /* I don't know if the above datum names really work ... just a guess*/ + nPCS = 32700 + psProParameters->proZone; + } + +/* -------------------------------------------------------------------- */ +/* Do we have a nice State Plane situation? */ +/* */ +/* For this we have to translate the Erdas (ESRI) zone number */ +/* to a USGS zone number. This we pass to GTIFMapSysToPCS() */ +/* which turns it into a Proj_ code, and then it does a lookup */ +/* to map this to a PCS_ number. Oiii! */ +/* -------------------------------------------------------------------- */ + if( psProParameters != NULL + && psProParameters->proNumber == 2 ) + { + if( psProParameters->proParams[0] == 0.0 ) /* NAD27 */ + { + nPCS = GTIFMapSysToPCS( MapSys_State_Plane, GCS_NAD27, + ESRIToUSGSZone(psProParameters->proZone)); + } + else + { + nPCS = GTIFMapSysToPCS( MapSys_State_Plane, GCS_NAD83, + ESRIToUSGSZone(psProParameters->proZone)); + } + } + +/* -------------------------------------------------------------------- */ +/* Write with a PCS if we have one. */ +/* -------------------------------------------------------------------- */ + if( nPCS != KvUserDefined ) + { + GTIFKeySet(hGTiff, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, + nPCS ); + } + else if( psProParameters != NULL + && psProParameters->proNumber != 0 ) + { + GTIFKeySet(hGTiff, ProjectedCSTypeGeoKey, TYPE_SHORT, 1, + KvUserDefined ); + GTIFKeySet(hGTiff, ProjectionGeoKey, TYPE_SHORT, 1, + KvUserDefined ); + } + +/* ==================================================================== */ +/* Handle various non-PCS situations */ +/* ==================================================================== */ + if( nPCS != KvUserDefined ) + { + /* already handled */ + } + else if( psProParameters == NULL ) + { + /* do nothing */ + } + +/* -------------------------------------------------------------------- */ +/* Lat/long. */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 0 ) + { + /* GTModelType and GeogLinearUnits already written */ + } + +/* -------------------------------------------------------------------- */ +/* UTM */ +/* */ +/* If we didn't match to a particular PCS we are just going to */ +/* fallback to the TM definition of this zone. */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 1 ) + { + /* notdef: + if( psProParameters->proParams[3] < 0.0 / * south * / + ... */ + } + +/* -------------------------------------------------------------------- */ +/* State Plane */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 2 ) + { + /* notdef: this is complicated by the translation of ESRI state + plane numbers to USGS (GeoTIFF) numbering */ + } + +/* -------------------------------------------------------------------- */ +/* Albers Conic Equal Area */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 3 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_AlbersEqualArea ); + GTIFKeySet( hGTiff, ProjStdParallelGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjStdParallel2GeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[3] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Lambert Conformal Conic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 4 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_LambertConfConic_2SP ); + GTIFKeySet( hGTiff, ProjStdParallelGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjStdParallel2GeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[3] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseOriginLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Mercator */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 5 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Mercator ); + GTIFKeySet( hGTiff, ProjNatOriginLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Polar Stereographic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 6 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_PolarStereographic ); + GTIFKeySet( hGTiff, ProjStraightVertPoleLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Polyconic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 7 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Polyconic ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Equidistant Conic */ +/* */ +/* Note that Imagine files have two cases (keyed off param 8 */ +/* being zero or one) indicating whether a second standard */ +/* parallel is present. */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 8 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_EquidistantConic ); + GTIFKeySet( hGTiff, ProjStdParallelGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] * RAD_TO_DEG ); + + if( psProParameters->proParams[8] != 0.0 ) + GTIFKeySet( hGTiff, ProjStdParallel2GeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[3] * RAD_TO_DEG ); + + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Transverse Mercator */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 9 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_TransverseMercator ); + GTIFKeySet( hGTiff, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] ); + GTIFKeySet( hGTiff, ProjNatOriginLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjNatOriginLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Stereographic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 10 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Stereographic ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + + +/* -------------------------------------------------------------------- */ +/* Lambert Azimuthal Equal-Area */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 11 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_LambertAzimEqualArea ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Azimuthal Equidistant */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 12 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_AzimuthalEquidistant ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Gnomonic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 13 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Gnomonic ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Orthographic */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 14 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Orthographic ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* General Vertical Near-Side Perspective */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 15 ) + { + /* no mapping! */ + } + +/* -------------------------------------------------------------------- */ +/* Sinusoidal */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 16 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Sinusoidal ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Equirectangular */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 17 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_Equirectangular ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Miller Cylindrical */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 18 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_MillerCylindrical ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Van der Grinten I */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 19 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_VanDerGrinten ); + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Oblique Mercator (Hotine) - Case 0 */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 20 + && psProParameters->proParams[12] == 0.0 ) + { +#ifdef notdef + /* This does not appear to be a supported formulation for + GeoTIFF, but I will write out the parameters and hope */ + + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_ObliqueMercator ); + GTIFKeySet( hGTiff, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] ); + + /* proParams[8-11] also existing in this case */ + + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); +#endif + } + +/* -------------------------------------------------------------------- */ +/* Oblique Mercator (Hotine) - Case 1 */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 20 + && psProParameters->proParams[12] > 0.0 ) + { + GTIFKeySet( hGTiff, ProjCoordTransGeoKey, TYPE_SHORT, 1, + CT_ObliqueMercator ); + GTIFKeySet( hGTiff, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[2] ); + GTIFKeySet( hGTiff, ProjAzimuthAngleGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[3] * RAD_TO_DEG ); + + GTIFKeySet( hGTiff, ProjCenterLongGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[4] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjCenterLatGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[5] * RAD_TO_DEG ); + GTIFKeySet( hGTiff, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[6] ); + GTIFKeySet( hGTiff, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1, + psProParameters->proParams[7] ); + } + +/* -------------------------------------------------------------------- */ +/* Space Oblique Mercator */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 21 ) + { + /* not supported by GeoTIFF */ + } + +/* -------------------------------------------------------------------- */ +/* Modified Transverse Mercator (MTM) */ +/* -------------------------------------------------------------------- */ + else if( psProParameters->proNumber == 22 ) + { + /* not supported by GeoTIFF */ + } + +/* -------------------------------------------------------------------- */ +/* Ellipsoid */ +/* -------------------------------------------------------------------- */ + if( psProParameters != NULL ) + { + int nEllipsoid = KvUserDefined; + + if( EQUAL(psProParameters->proSpheroid.sphereName,"WGS 84") ) + nEllipsoid = Ellipse_WGS_84; + else if( EQUAL(psProParameters->proSpheroid.sphereName,"GRS 80") ) + nEllipsoid = Ellipse_GRS_1980; + else if( EQUAL(psProParameters->proSpheroid.sphereName,"Clarke 1866") ) + nEllipsoid = Ellipse_Clarke_1866; + else if( EQUAL(psProParameters->proSpheroid.sphereName,"Clarke 1880") ) + nEllipsoid = Ellipse_Clarke_1880; + + GTIFKeySet( hGTiff, GeogEllipsoidGeoKey, TYPE_SHORT, 1, + nEllipsoid ); + + GTIFKeySet( hGTiff, GeogCitationGeoKey, TYPE_ASCII, 0, + psProParameters->proSpheroid.sphereName ); + + GTIFKeySet( hGTiff, GeogSemiMajorAxisGeoKey, TYPE_DOUBLE, 1, + psProParameters->proSpheroid.a ); + GTIFKeySet( hGTiff, GeogSemiMinorAxisGeoKey, TYPE_DOUBLE, 1, + psProParameters->proSpheroid.b ); + } + +/* -------------------------------------------------------------------- */ +/* Datum (GCS) - We always assume Greenwich */ +/* */ +/* If we used the parameter information available through the */ +/* EPSG tables we could likely find an appropriate name for */ +/* this datum if it has a seven term (or three term) Molondosky */ +/* transform. */ +/* -------------------------------------------------------------------- */ + if( psDatum != NULL ) + { + int nGCS = KvUserDefined; + + if( EQUAL(psDatum->datumname,"NAD27") ) + nGCS = GCS_NAD27; + else if( EQUAL(psDatum->datumname,"NAD83") ) + nGCS = GCS_NAD83; + else if( EQUAL(psDatum->datumname,"WGS 84") ) + nGCS = GCS_WGS_84; + else if( EQUAL(psDatum->datumname,"WGS 72") ) + nGCS = GCS_WGS_72; + + GTIFKeySet( hGTiff, GeographicTypeGeoKey, TYPE_SHORT, 1, + nGCS ); + } + +/* -------------------------------------------------------------------- */ +/* Write information to header and clean up. */ +/* -------------------------------------------------------------------- */ + + GTIFWriteKeys( hGTiff ); + GTIFFree( hGTiff ); + + return CE_None; +} diff --git a/Utilities/GDAL/frmts/hfa/makefile.vc b/Utilities/GDAL/frmts/hfa/makefile.vc new file mode 100644 index 0000000000..c83fb126f7 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/makefile.vc @@ -0,0 +1,17 @@ + +OBJ = hfaband.obj hfadataset.obj hfadictionary.obj hfaentry.obj \ + hfafield.obj hfaopen.obj hfatype.obj hfacompress.obj \ + hfa_overviews.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + +hfatest.exe: hfatest.cpp $(GDALLIB) + $(CC) $(CFLAGS) hfatest.cpp $(OBJ) $(GDALLIB) diff --git a/Utilities/GDAL/frmts/hfa/tst1tif.sh b/Utilities/GDAL/frmts/hfa/tst1tif.sh new file mode 100755 index 0000000000..8775624648 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/tst1tif.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +TIF_FILE=$1 +LOG_FILE=$2 + +if test "$LOG_FILE" = "" ; then + echo "Usage: tst1tif.sh tif_file log_file" + exit 1 +fi + +rm -f _tmptif.log + +if test \! -r $TIF_FILE ; then + echo $TIF_FILE not found. + exit 1 +fi + +tiffinfo $TIF_FILE > _tmptif.log 2> /dev/null +tiffdump $TIF_FILE >> _tmptif.log +listgeo $TIF_FILE >> _tmptif.log + +if test \! -r $LOG_FILE ; then + echo "No existing log $LOG_FILE found, using newly generated log." + cp _tmptif.log $LOG_FILE + rm -f _tmptif.log + exit 0 +fi + +if diff $LOG_FILE _tmptif.log ; then + rm -f _tmptif.log + exit 0 +else + echo Difference found between ${LOG_FILE}.new and $LOG_FILE + cp _tmptif.log ${LOG_FILE}.new + rm -f _tmptif.log + exit 1 +fi + + + + + diff --git a/Utilities/GDAL/frmts/hfa/tst_hfa.sh b/Utilities/GDAL/frmts/hfa/tst_hfa.sh new file mode 100755 index 0000000000..062f419954 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/tst_hfa.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# +# The -f force flag will force new logs to overwrite existing ones. +# +FORCE=0 +if test "$1" = "-f" ; then + FORCE=1 + shift +fi + +# +# Loop over all passed imagine files. +# +for a in $* ; do + BASE=`dirname $a`/`basename $a .img` + hfatest -dt -dd $a > ${BASE}.rpt.new + + if test $FORCE = 1 ; then + mv ${BASE}.rpt.new ${BASE}.rpt + continue; + fi + + if diff ${BASE}.rpt ${BASE}.rpt.new ; then + rm ${BASE}.rpt.new + else + echo Differences between ${BASE}.rpt and ${BASE}.rpt.new + fi +done diff --git a/Utilities/GDAL/frmts/hfa/tst_img2tif_1.sh b/Utilities/GDAL/frmts/hfa/tst_img2tif_1.sh new file mode 100755 index 0000000000..f0b45ee2f9 --- /dev/null +++ b/Utilities/GDAL/frmts/hfa/tst_img2tif_1.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# +# Test stream for img2tif +# + +IMG_DATA_DIR=/usr2/data/imagine + +# +# Create a local directory to do the test operations in, so it +# is easy to cleanup. +# +TST_DIR=img2tif_work + +if test -d $TST_DIR ; then + rm -rf $TST_DIR +fi + +mkdir $TST_DIR + +# +# Do each of the projection files +# + +for IMG in $IMG_DATA_DIR/Eprj/*.img ; do + BASE=`basename $IMG .img` + img2tif -i $IMG -o $TST_DIR/$BASE + + if test -r $TST_DIR/$BASE.tif ; then + tst1tif.sh $TST_DIR/${BASE}.tif $IMG_DATA_DIR/Eprj/${BASE}.tlg + else + tst1tif.sh $TST_DIR/${BASE}1.tif $IMG_DATA_DIR/Eprj/${BASE}1.tlg + tst1tif.sh $TST_DIR/${BASE}2.tif $IMG_DATA_DIR/Eprj/${BASE}2.tlg + tst1tif.sh $TST_DIR/${BASE}3.tif $IMG_DATA_DIR/Eprj/${BASE}3.tlg + fi + rm $TST_DIR/${BASE}*.tif +done + +# +# Do all of irvine2.img, small_tm.img, springs.img and irvlong2.img +# +img2tif -i $IMG_DATA_DIR/irvine2.img -o $TST_DIR/irvine2 +for i in 1 2 3 4 5 6 7 8 9 10 11 ; do + tst1tif.sh $TST_DIR/irvine2${i}.tif $IMG_DATA_DIR/irvine2${i}.tlg +done +rm -f $TST_DIR/*.tif + +img2tif -i $IMG_DATA_DIR/small_tm.img -o $TST_DIR/small_tm +for i in 1 2 3 4 5 ; do + tst1tif.sh $TST_DIR/small_tm${i}.tif $IMG_DATA_DIR/small_tm${i}.tlg +done + +img2tif -i $IMG_DATA_DIR/springs1.img -o $TST_DIR/springs1 +for i in 1 2 3 ; do + tst1tif.sh $TST_DIR/springs1${i}.tif $IMG_DATA_DIR/springs1${i}.tlg +done + +img2tif -i $IMG_DATA_DIR/irvlong2.img -o $TST_DIR/irvlong2 +tst1tif.sh $TST_DIR/irvlong2.tif $IMG_DATA_DIR/irvlong2.tlg + + +#rn -rf $TST_DIR diff --git a/Utilities/GDAL/frmts/idrisi/GNUmakefile b/Utilities/GDAL/frmts/idrisi/GNUmakefile new file mode 100644 index 0000000000..8f8fe87f6a --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/GNUmakefile @@ -0,0 +1,15 @@ +GDAL_ROOT = ../.. + +include $(GDAL_ROOT)/GDALmake.opt + +OBJ = IdrisiDataset.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + +install-obj: $(O_OBJ) + diff --git a/Utilities/GDAL/frmts/idrisi/IdrisiDataset.cpp b/Utilities/GDAL/frmts/idrisi/IdrisiDataset.cpp new file mode 100644 index 0000000000..c6231dcddc --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/IdrisiDataset.cpp @@ -0,0 +1,2084 @@ +/***************************************************************************** +* +* Project: Idrisi Raster Image File Driver +* Purpose: Read/write Idrisi Raster Image Format RST +* Author: Ivan Lucena, ivan@ilucena.net +* +****************************************************************************** +* Copyright (c) 2006, Ivan Lucena +* +* 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. +****************************************************************************** +* +*/ + +typedef unsigned char uint8; +typedef signed short int16; +typedef unsigned short uint16; +typedef float float32; +typedef long int32; +typedef unsigned long uint32; + +#include "gdal_priv.h" +#include "cpl_conv.h" +#include "cpl_string.h" +#include "cpl_csv.h" +#include "ogr_spatialref.h" +#include "gdal_pam.h" + +CPL_C_START +void GDALRegister_IDRISI(void); +CPL_C_END + +//----- Safe numeric conversion, NULL as zero +#define atoi_nz(s) (s == NULL ? (int) 0 : atoi(s)) +#define atof_nz(s) (s == NULL ? (double) 0.0 : atof(s)) + +//----- file extensions: +#define extRST "rst" +#define extRDC "rdc" +#define extSMP "smp" +#define extREF "ref" + +//----- field names on rdc file: +#define rdcFILE_FORMAT "file format " +#define rdcFILE_TITLE "file title " +#define rdcDATA_TYPE "data type " +#define rdcFILE_TYPE "file type " +#define rdcCOLUMNS "columns " +#define rdcROWS "rows " +#define rdcREF_SYSTEM "ref. system " +#define rdcREF_UNITS "ref. units " +#define rdcUNIT_DIST "unit dist. " +#define rdcMIN_X "min. X " +#define rdcMAX_X "max. X " +#define rdcMIN_Y "min. Y " +#define rdcMAX_Y "max. Y " +#define rdcPOSN_ERROR "pos'n error " +#define rdcRESOLUTION "resolution " +#define rdcMIN_VALUE "min. value " +#define rdcMAX_VALUE "max. value " +#define rdcDISPLAY_MIN "display min " +#define rdcDISPLAY_MAX "display max " +#define rdcVALUE_UNITS "value units " +#define rdcVALUE_ERROR "value error " +#define rdcFLAG_VALUE "flag value " +#define rdcFLAG_DEFN "flag def'n " +#define rdcFLAG_DEFN2 "flag def`n " +#define rdcLEGEND_CATS "legend cats " +#define rdcLINEAGES "lineage " +#define rdcCOMMENTS "comment " +#define rdcCODE_N "code %6d " + +//----- ".ref" file field names: +#define refREF_SYSTEM "ref. system " +#define refPROJECTION "projection " +#define refDATUM "datum " +#define refDELTA_WGS84 "delta WGS84 " +#define refELLIPSOID "ellipsoid " +#define refMAJOR_SAX "major s-ax " +#define refMINOR_SAX "minor s-ax " +#define refORIGIN_LONG "origin long " +#define refORIGIN_LAT "origin lat " +#define refORIGIN_X "origin X " +#define refORIGIN_Y "origin Y " +#define refSCALE_FAC "scale fac " +#define refUNITS "units " +#define refPARAMETERS "parameters " +#define refSTANDL_1 "stand ln 1 " +#define refSTANDL_2 "stand ln 2 " + +//----- standard values: +#define rstVERSION "Idrisi Raster A.1" +#define rstBYTE "byte" +#define rstINTEGER "integer" +#define rstREAL "real" +#define rstRGB24 "rgb24" +#define rstDEGREE "degree" +#define rstMETER "meter" +#define rstLATLONG "latlong" +#define rstPLANE "plane" +#define rstUTM "utm-%d%c" +#define rstSPC "spc%2d%2s%d" + +//----- palette file (.smp) header size: +#define smpHEADERSIZE 18 + +//----- check if file exists: +bool FileExists(const char *pszFilename); + +//----- Reference Table +struct ReferenceTab { + int nCode; + char *pszName; +}; + +//----- USA State's reference table to EPSG PCS Code +static ReferenceTab aoUSStateTable[] = { + {101, "AL"}, + {201, "AZ"}, + {301, "AR"}, + {401, "CA"}, + {501, "CO"}, + {600, "CT"}, + {700, "DE"}, + {901, "FL"}, + {1001, "GA"}, + {1101, "ID"}, + {1201, "IL"}, + {1301, "IN"}, + {1401, "IA"}, + {1501, "KS"}, + {1601, "KY"}, + {1701, "LA"}, + {1801, "ME"}, + {1900, "MD"}, + {2001, "MA"}, + {2111, "MI"}, + {2201, "MN"}, + {2301, "MS"}, + {2401, "MO"}, + {2500, "MT"}, + {2600, "NE"}, + {2701, "NV"}, + {2800, "NH"}, + {2900, "NJ"}, + {3001, "NM"}, + {3101, "NY"}, + {3200, "NC"}, + {3301, "ND"}, + {3401, "OH"}, + {3501, "OK"}, + {3601, "OR"}, + {3701, "PA"}, + {3800, "RI"}, + {3900, "SC"}, + {4001, "SD"}, + {4100, "TN"}, + {4201, "TX"}, + {4301, "UT"}, + {4400, "VT"}, + {4501, "VA"}, + {4601, "WA"}, + {4701, "WV"}, + {4801, "WV"}, + {4901, "WY"}, + {5001, "AK"}, + {5101, "HI"}, + {5200, "PR"} +}; +#define US_STATE_COUNT (sizeof(aoUSStateTable) / sizeof(ReferenceTab)) + +//----- Import geo reference from Idrisi +OGRErr CPL_DLL OSRImportFromIdrisi(OGRSpatialReferenceH hSRS, + const char *pszRefSystem, + const char *pszRefUnits, + char **papszRefFile = NULL); + +//----- Export geo reference to Idrisi +OGRErr CPL_DLL OSRExportToIdrisi(OGRSpatialReferenceH hSRS, + char **pszRefSystem, + char **pszRefUnit, + char ***papszRefFile); + +//----- Specialized version of SetAuthority that accept non-numeric codes +OGRErr OSRSetAuthorityLabel( OGRSpatialReferenceH hSRS, + const char *pszTargetKey, + const char *pszAuthority, + const char *pszLabel ); + +//----- Classes pre-definition: +class IdrisiDataset; +class IdrisiRasterBand; + +// ---------------------------------------------------------------------------- +// Idrisi GDALDataset +// ---------------------------------------------------------------------------- + +class IdrisiDataset : public GDALPamDataset +{ + friend class IdrisiRasterBand; + +private: + FILE *fp; + + char *pszFilename; + char *pszDocFilename; + char **papszRDC; + double adfGeoTransform[6]; + + char *pszProjection; + char **papszCategories; + char *pszUnitType; + +protected: + GDALColorTable *poColorTable; + +public: + IdrisiDataset(); + ~IdrisiDataset(); + + static GDALDataset *Open(GDALOpenInfo *poOpenInfo); + static GDALDataset *Create(const char *pszFilename, + int nXSize, + int nYSize, + int nBands, + GDALDataType eType, + char **papszParmList); + static GDALDataset *CreateCopy(const char *pszFilename, + GDALDataset *poSrcDS, + int bStrict, + char **papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressData); + + virtual CPLErr GetGeoTransform(double *padfTransform); + virtual CPLErr SetGeoTransform(double *padfTransform); + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection(const char *pszProjString); +}; + +// ---------------------------------------------------------------------------- +// Idrisi GDALPamRasterBand +// ---------------------------------------------------------------------------- + +class IdrisiRasterBand : public GDALPamRasterBand +{ + friend class IdrisiDataset; + +private: + int nRecordSize; + GByte *pabyScanLine; + +public: + IdrisiRasterBand(IdrisiDataset *poDS, + int nBand, + GDALDataType eDataType); + ~IdrisiRasterBand(); + + virtual double GetNoDataValue(int *pbSuccess = NULL); + virtual double GetMinimum(int *pbSuccess = NULL); + virtual double GetMaximum(int *pbSuccess = NULL); + virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage); + virtual CPLErr IWriteBlock(int nBlockXOff, int nBlockYOff, void *pImage); + virtual GDALColorTable *GetColorTable(); + virtual GDALColorInterp GetColorInterpretation(); + virtual char **GetCategoryNames(); + virtual const char *GetUnitType(); + + virtual CPLErr SetCategoryNames(char **papszCategoryNames); + virtual CPLErr SetNoDataValue(double dfNoDataValue); + virtual CPLErr SetColorTable(GDALColorTable *poColorTable); + virtual CPLErr SetUnitType(const char *pszUnitType); + virtual CPLErr SetStatistics(double dfMin, double dfMax, + double dfMean, double dfStdDev); +}; + +// ------------------------------------------------------------------------ // +// Implementation of IdrisiDataset // +// ------------------------------------------------------------------------ // + +/************************************************************************/ +/* IdrisiDataset() */ +/************************************************************************/ + +IdrisiDataset::IdrisiDataset() +{ + pszFilename = NULL; + fp = NULL; + papszRDC = NULL; + pszDocFilename = NULL; + pszProjection = NULL; + poColorTable = new GDALColorTable(); + papszCategories = NULL; + pszUnitType = 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; +} + +/************************************************************************/ +/* ~IdrisiDataset() */ +/************************************************************************/ + +IdrisiDataset::~IdrisiDataset() +{ + FlushCache(); + + if (papszRDC != NULL) + { + if (eAccess == GA_Update) + { + CSLSetNameValueSeparator(papszRDC, ": "); + CSLSave(papszRDC, pszDocFilename); + } + CSLDestroy(papszRDC); + } + + if (poColorTable) + delete poColorTable; + + CPLFree(pszFilename); + CPLFree(pszDocFilename); + CPLFree(pszProjection); + CSLDestroy(papszCategories); + CPLFree(pszUnitType); + + if (fp != NULL) + VSIFCloseL(fp); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *IdrisiDataset::Open(GDALOpenInfo *poOpenInfo) +{ + if ((poOpenInfo->fp == NULL) || + (EQUAL(CPLGetExtension(poOpenInfo->pszFilename), extRST) == FALSE)) + return NULL; + + // -------------------------------------------------------------------- + // Check the documentation file .rdc + // -------------------------------------------------------------------- + + const char *pszLDocFilename = CPLResetExtension(poOpenInfo->pszFilename, extRDC); + + char **papszLRDC = CSLLoad(pszLDocFilename); + + CSLSetNameValueSeparator(papszLRDC, ":"); + + const char *pszVersion = CSLFetchNameValue(papszLRDC, rdcFILE_FORMAT); + + if (EQUAL(pszVersion, rstVERSION) == FALSE) + { + CSLDestroy(papszLRDC); + return NULL; + } + + // -------------------------------------------------------------------- + // Create a corresponding GDALDataset + // -------------------------------------------------------------------- + + IdrisiDataset *poDS; + + poDS = new IdrisiDataset(); + poDS->eAccess = poOpenInfo->eAccess; + poDS->pszFilename = CPLStrdup(poOpenInfo->pszFilename); + + if (poOpenInfo->eAccess == GA_ReadOnly ) + { + poDS->fp = VSIFOpenL(poDS->pszFilename, "rb"); + } + else + { + poDS->fp = VSIFOpenL(poDS->pszFilename, "r+b"); + } + + if (poDS->fp == NULL) + { + CSLDestroy(papszLRDC); + return NULL; + } + + poDS->pszDocFilename = CPLStrdup(pszLDocFilename); + poDS->papszRDC = CSLDuplicate(papszLRDC); + CSLDestroy(papszLRDC); + + // -------------------------------------------------------------------- + // Load information from rdc + // -------------------------------------------------------------------- + + poDS->nRasterXSize = atoi_nz(CSLFetchNameValue(poDS->papszRDC, rdcCOLUMNS)); + poDS->nRasterYSize = atoi_nz(CSLFetchNameValue(poDS->papszRDC, rdcROWS)); + + // -------------------------------------------------------------------- + // Create band information + // -------------------------------------------------------------------- + + const char *pszDataType = CSLFetchNameValue(poDS->papszRDC, rdcDATA_TYPE); + + if (EQUAL(pszDataType, rstBYTE)) + { + poDS->nBands = 1; + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Byte)); + } + if (EQUAL(pszDataType, rstINTEGER)) + { + poDS->nBands = 1; + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Int16)); + } + if (EQUAL(pszDataType, rstREAL)) + { + poDS->nBands = 1; + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Float32)); + } + if (EQUAL(pszDataType, rstRGB24)) + { + poDS->nBands = 3; + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Byte)); + poDS->SetBand(2, new IdrisiRasterBand(poDS, 2, GDT_Byte)); + poDS->SetBand(3, new IdrisiRasterBand(poDS, 3, GDT_Byte)); + } + + // -------------------------------------------------------------------- + // Load the transformation matrix + // -------------------------------------------------------------------- + + const char *pszMinX = CSLFetchNameValue(poDS->papszRDC, rdcMIN_X); + + if (strlen(pszMinX) > 0) + { + double dfMinX, dfMaxX, dfMinY, dfMaxY, dfUnit, dfXPixSz, dfYPixSz; + + dfMinX = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcMIN_X)); + dfMaxX = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcMAX_X)); + dfMinY = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcMIN_Y)); + dfMaxY = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcMAX_Y)); + dfUnit = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcUNIT_DIST)); + + dfMinX = dfMinX * dfUnit; + dfMaxX = dfMaxX * dfUnit; + dfMinY = dfMinY * dfUnit; + dfMaxY = dfMaxY * dfUnit; + + dfYPixSz = (dfMinY - dfMaxY) / poDS->nRasterYSize; + dfXPixSz = (dfMaxX - dfMinX) / poDS->nRasterXSize; + + poDS->adfGeoTransform[0] = dfMinX - (dfXPixSz / 2); + poDS->adfGeoTransform[1] = dfXPixSz; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfMaxY + (dfYPixSz / 2); + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = dfYPixSz; + } + + // -------------------------------------------------------------------- + // Set Color Table in the presence of a smp file + // -------------------------------------------------------------------- + + if (poDS->nBands != 3) + { + const char *pszSMPFilename = CPLResetExtension(poDS->pszFilename, extSMP); + FILE *fpSMP; + if ((fpSMP = VSIFOpenL(pszSMPFilename, "rb")) != NULL ) + { + double dfMaxValue = atof_nz(CSLFetchNameValue(poDS->papszRDC, rdcMAX_VALUE)); + VSIFSeekL(fpSMP, smpHEADERSIZE, SEEK_SET); + GDALColorEntry oEntry; + unsigned char aucRGB[3]; + int i = 0; + while ((VSIFReadL(&aucRGB, sizeof(aucRGB), 1, fpSMP)) && (i <= dfMaxValue)) + { + oEntry.c1 = (short) aucRGB[0]; + oEntry.c2 = (short) aucRGB[1]; + oEntry.c3 = (short) aucRGB[2]; + oEntry.c4 = (short) 255; + poDS->poColorTable->SetColorEntry(i, &oEntry); + i++; + } + VSIFCloseL(fpSMP); + } + } + + // -------------------------------------------------------------------- + // Check for Unit Type + // -------------------------------------------------------------------- + + const char *pszValueUnit = CSLFetchNameValue(poDS->papszRDC, rdcVALUE_UNITS); + + if (pszValueUnit == NULL) + poDS->pszUnitType = CPLStrdup("unspecified"); + else + { + if (EQUALN(pszValueUnit, "meter", 4)) + { + poDS->pszUnitType = CPLStrdup("m"); + } + else if (EQUALN(pszValueUnit, "feet", 4)) + { + poDS->pszUnitType = CPLStrdup("ft"); + } + else + poDS->pszUnitType = CPLStrdup(pszValueUnit); + } + + // -------------------------------------------------------------------- + // Check for category names. + // -------------------------------------------------------------------- + + int nCatCount = atoi_nz(CSLFetchNameValue(poDS->papszRDC, rdcLEGEND_CATS)); + + if (nCatCount > 0) + { + // ---------------------------------------------------------------- + // Sequentialize categories names, from 0 to the last "code n" + // ---------------------------------------------------------------- + + int nCode = 0; + int nCount = 0; + int nLine = -1; + for (int i = 0; (i < CSLCount(poDS->papszRDC)) && (nLine == -1); i++) + if (EQUALN(poDS->papszRDC[i], rdcLEGEND_CATS, 11)) + nLine = i; + if (nLine > 0) + { + sscanf(poDS->papszRDC[++nLine], rdcCODE_N, &nCode); + for (int i = 0; (i < 255) && (nCount < nCatCount); i++) + { + if (i == nCode) + { + poDS->papszCategories = CSLAddString(poDS->papszCategories, + CPLParseNameValue(poDS->papszRDC[nLine], NULL)); + nCount++; + if (nCount < nCatCount) + sscanf(poDS->papszRDC[++nLine], rdcCODE_N, &nCode); + } + else + poDS->papszCategories = CSLAddString(poDS->papszCategories, ""); + } + } + } + + /* -------------------------------------------------------------------- */ + /* Check for external overviews. */ + /* -------------------------------------------------------------------- */ + + poDS->oOvManager.Initialize(poDS, poOpenInfo->pszFilename); + + /* -------------------------------------------------------------------- */ + /* Initialize any PAM information. */ + /* -------------------------------------------------------------------- */ + + poDS->SetDescription(poOpenInfo->pszFilename); + poDS->TryLoadXML(); + + return (poDS); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *IdrisiDataset::Create(const char *pszFilename, + int nXSize, + int nYSize, + int nBands, + GDALDataType eType, + char** papszOptions) +{ + // -------------------------------------------------------------------- + // Check input options + // -------------------------------------------------------------------- + + if (nBands != 1) + { + if (! (nBands == 3 && eType == GDT_Byte)) + { + CPLError(CE_Failure, CPLE_AppDefined, + "Attempt to create IDRISI dataset with an illegal\n" + "number of bands (%d) to data type (%s).\n", + nBands, GDALGetDataTypeName(eType)); + return NULL; + } + } + + // ---------------------------------------------------------------- + // Create the header file with minimun information + // ---------------------------------------------------------------- + + const char *pszLDataType; + + switch (eType) + { + case GDT_Byte: + if (nBands == 1) + pszLDataType = rstBYTE; + else + pszLDataType = rstRGB24; + break; + case GDT_Int16: + pszLDataType = rstINTEGER; + break; + case GDT_Float32: + pszLDataType = rstREAL; + break; + default: + CPLError(CE_Failure, CPLE_AppDefined, + "Attempt to create IDRISI dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType)); + return NULL; + + }; + + char **papszLRDC; + + papszLRDC = NULL; + papszLRDC = CSLAddNameValue(papszLRDC, rdcFILE_FORMAT, rstVERSION); + papszLRDC = CSLAddNameValue(papszLRDC, rdcFILE_TITLE, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcDATA_TYPE, pszLDataType); + papszLRDC = CSLAddNameValue(papszLRDC, rdcFILE_TYPE, "binary"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcCOLUMNS, CPLSPrintf("%d", nXSize)); + papszLRDC = CSLAddNameValue(papszLRDC, rdcROWS, CPLSPrintf("%d", nYSize)); + papszLRDC = CSLAddNameValue(papszLRDC, rdcREF_SYSTEM, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcREF_UNITS, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcUNIT_DIST, "1"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMIN_X, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMAX_X, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMIN_Y, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMAX_Y, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcPOSN_ERROR, "unspecified"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcRESOLUTION, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMIN_VALUE, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcMAX_VALUE, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcDISPLAY_MIN, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcDISPLAY_MAX, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcVALUE_UNITS, "unspecified"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcVALUE_ERROR, "unspecified"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcFLAG_VALUE, "none"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcFLAG_DEFN, "none"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcLEGEND_CATS, "0"); + papszLRDC = CSLAddNameValue(papszLRDC, rdcLINEAGES, ""); + papszLRDC = CSLAddNameValue(papszLRDC, rdcCOMMENTS, ""); + + const char *pszLDocFilename; + pszLDocFilename = CPLResetExtension(pszFilename, extRDC); + + CSLSetNameValueSeparator(papszLRDC, ": "); + CSLSave(papszLRDC, pszLDocFilename); + CSLDestroy(papszLRDC); + + // ---------------------------------------------------------------- + // Create an empty data file + // ---------------------------------------------------------------- + + FILE *fp; + + fp = VSIFOpenL(pszFilename, "wb+"); + + if (fp == NULL) + { + CPLError(CE_Failure, CPLE_OpenFailed, + "Attempt to create file %s' failed.\n", pszFilename); + return NULL; + } + VSIFCloseL(fp); + + return (IdrisiDataset *) GDALOpen(pszFilename, GA_Update); +} + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +GDALDataset *IdrisiDataset::CreateCopy(const char *pszFilename, + GDALDataset *poSrcDS, + int bStrict, + char **papszOptions, + GDALProgressFunc pfnProgress, + void *pProgressData) +{ + if (!pfnProgress( 0.0, NULL, pProgressData)) + return NULL; + + // ------------------------------------------------------------------------- + // Check number of bands + // ------------------------------------------------------------------------- + + if (((poSrcDS->GetRasterCount() == 1) || + ((poSrcDS->GetRasterCount() == 3) && + ((poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_Byte) && + (poSrcDS->GetRasterBand(2)->GetRasterDataType() == GDT_Byte) && + (poSrcDS->GetRasterBand(3)->GetRasterDataType() == GDT_Byte)))) == FALSE) + { + + CPLError(CE_Failure, CPLE_AppDefined, + "Attempt IDRISI dataset with an illegal\n" + "number of bands (%s).\n", + poSrcDS->GetRasterCount()); + return NULL; + } + + // ------------------------------------------------------------------------- + // Check Data types + // ------------------------------------------------------------------------- + + for (int i = 1; i <= poSrcDS->GetRasterCount(); i++) + { + GDALDataType eType = poSrcDS->GetRasterBand(i)->GetRasterDataType(); + + if (eType != GDT_Byte && + eType != GDT_Int16 && + eType != GDT_UInt16 && + eType != GDT_UInt32 && + eType != GDT_Int32 && + eType != GDT_Float32 && + eType != GDT_Float64) + { + CPLError(CE_Failure, CPLE_AppDefined, + "Attempt to create IDRISI dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType)); + return NULL; + } + } + + // -------------------------------------------------------------------- + // Define data type + // -------------------------------------------------------------------- + + GDALRasterBand *poBand = poSrcDS->GetRasterBand(1); + GDALDataType eType = poBand->GetRasterDataType(); + + double dfMin; + double dfMax; + double dfMean; + double dfStdDev = -1; + + if (bStrict == TRUE) + { + poBand->GetStatistics(FALSE, TRUE, &dfMin, &dfMax, &dfMean, &dfStdDev); + } + else + { + dfMin = poBand->GetMinimum(); + dfMax = poBand->GetMaximum(); + } + + if ( ! ((eType == GDT_Byte) || + (eType == GDT_Int16) || + (eType == GDT_Float32))) + { + if (eType == GDT_Float64) + { + eType = GDT_Float32; + } + else + { + if ((dfMin < (double) SHRT_MIN) || + (dfMax > (double) SHRT_MAX)) + { + eType = GDT_Float32; + } + else + { + eType = GDT_Int16; + } + } + } + + // -------------------------------------------------------------------- + // Create the dataset + // -------------------------------------------------------------------- + + IdrisiDataset *poDS; + + poDS = (IdrisiDataset *) IdrisiDataset::Create(pszFilename, + poSrcDS->GetRasterXSize(), + poSrcDS->GetRasterYSize(), + poSrcDS->GetRasterCount(), + eType, + papszOptions); + + if (poDS == NULL) + return NULL; + + // -------------------------------------------------------------------- + // Copy information to the dataset + // -------------------------------------------------------------------- + + double adfGeoTransform[6]; + + poDS->SetProjection(poSrcDS->GetProjectionRef()); + poSrcDS->GetGeoTransform(adfGeoTransform); + poDS->SetGeoTransform(adfGeoTransform); + + // -------------------------------------------------------------------- + // Copy information to the raster band + // -------------------------------------------------------------------- + + GDALRasterBand *poSrcBand; + int bHasNoDataValue; + double dfNoDataValue; + + for (int i = 1; i <= poDS->nBands; i++) + { + poSrcBand = poSrcDS->GetRasterBand(i); + poBand = poDS->GetRasterBand(i); + + if (i == 1) + { + poBand->SetCategoryNames(poSrcBand->GetCategoryNames()); + poBand->SetUnitType(poSrcBand->GetUnitType()); + poBand->SetColorTable(poSrcBand->GetColorTable()); + } + poSrcBand->GetStatistics(false, true, &dfMin, &dfMax, &dfMean, &dfStdDev); + poBand->SetStatistics(dfMin, dfMax, dfMean, dfStdDev); + dfNoDataValue = poSrcBand->GetNoDataValue(&bHasNoDataValue); + if (bHasNoDataValue) + poBand->SetNoDataValue(dfNoDataValue); + } + + // -------------------------------------------------------------------- + // Copy image data + // -------------------------------------------------------------------- + + int nXSize = poDS->GetRasterXSize(); + int nYSize = poDS->GetRasterYSize(); + int nBlockXSize, nBlockYSize; + + poDS->GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize); + + for (int iBand = 1; iBand <= poSrcDS->GetRasterCount(); iBand++) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand(iBand); + GDALRasterBand *poDstBand = poDS->GetRasterBand(iBand); + + int iYOffset, iXOffset; + void *pData; + CPLErr eErr = CE_None; + + pData = CPLMalloc(nBlockXSize * nBlockYSize * GDALGetDataTypeSize(eType) / 8); + + for (iYOffset = 0; iYOffset < nYSize; iYOffset += nBlockYSize) + { + for (iXOffset = 0; iXOffset < nXSize; iXOffset += nBlockXSize) + { + eErr = poSrcBand->RasterIO(GF_Read, + iXOffset, iYOffset, + nBlockXSize, nBlockYSize, + pData, nBlockXSize, nBlockYSize, + eType, 0, 0); + if (eErr != CE_None) + { + return NULL; + } + eErr = poDstBand->RasterIO(GF_Write, + iXOffset, iYOffset, + nBlockXSize, nBlockYSize, + pData, nBlockXSize, nBlockYSize, + eType, 0, 0); + if (eErr != CE_None) + { + return NULL; + } + } + if ((eErr == CE_None) && (! pfnProgress( + (iYOffset + 1) / (double) nYSize, NULL, pProgressData))) + { + eErr = CE_Failure; + CPLError(CE_Failure, CPLE_UserInterrupt, "User terminated CreateCopy()"); + } + } + CPLFree(pData); + } + + // -------------------------------------------------------------------- + // Save Lineage information + // -------------------------------------------------------------------- + + poDS->papszRDC = CSLSetNameValue(poDS->papszRDC, rdcLINEAGES, + CPLSPrintf("Generated by GDAL, source = (%s)", poSrcDS->GetDescription())); + + // -------------------------------------------------------------------- + // Finalize + // -------------------------------------------------------------------- + + poDS->FlushCache(); + + return poDS; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr IdrisiDataset::GetGeoTransform(double * padfTransform) +{ + if (GDALPamDataset::GetGeoTransform(padfTransform) != CE_None) + memcpy(padfTransform, adfGeoTransform, sizeof(double) * 6); + + return CE_None; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr IdrisiDataset::SetGeoTransform(double * padfGeoTransform) +{ + if (padfGeoTransform[2] != 0.0 || padfGeoTransform[4] != 0.0) + { + CPLError(CE_Failure, CPLE_AppDefined, + "Attempt to set rotated geotransform on Idrisi Raster file.\n" + "Idrisi Raster does not support rotation.\n"); + return CE_Failure; + } + + double dfMinX, dfMaxX, dfMinY, dfMaxY, dfXPixSz, dfYPixSz; + + dfXPixSz = padfGeoTransform[1]; + dfYPixSz = padfGeoTransform[5]; + dfMinX = padfGeoTransform[0] + (dfXPixSz / 2); + dfMaxX = (dfXPixSz * nRasterXSize) + dfMinX; + dfMaxY = padfGeoTransform[3] - (dfYPixSz / 2); + dfMinY = (dfYPixSz * nRasterYSize) + dfMaxY; + + CSLSetNameValue(papszRDC, rdcMIN_X, CPLSPrintf("%.8g", dfMinX)); + CSLSetNameValue(papszRDC, rdcMAX_X, CPLSPrintf("%.8g", dfMaxX)); + CSLSetNameValue(papszRDC, rdcMIN_Y, CPLSPrintf("%.8g", dfMinY)); + CSLSetNameValue(papszRDC, rdcMAX_Y, CPLSPrintf("%.8g", dfMaxY)); + CSLSetNameValue(papszRDC, rdcRESOLUTION, CPLSPrintf("%.8g", -dfYPixSz)); + + return CE_None; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *IdrisiDataset::GetProjectionRef(void) +{ + const char *pszPamSRS = GDALPamDataset::GetProjectionRef(); + + if (pszPamSRS != NULL && strlen(pszPamSRS) > 0) + return pszPamSRS; + + if (pszProjection == NULL) + { + const char *pszRefSystem = CSLFetchNameValue(papszRDC, rdcREF_SYSTEM); + const char *pszRefUnit = CSLFetchNameValue(papszRDC, rdcREF_UNITS); + const char *pszFName = CPLSPrintf("%s/%s.ref", CPLGetDirname(pszFilename), pszRefSystem); + char **papszRefFile; + + // ------------------------------------------------------------------ + // Check if the Projection name refers to the name of a ".ref" file. + // ------------------------------------------------------------------ + + if (FileExists(pszFName) == FALSE) + { + pszFName = NULL; + const char *pszIdrisiDir = CPLGetConfigOption("IDRISIDIR", NULL); + if ((pszIdrisiDir) != NULL) + { + pszFName = CPLSPrintf("%s/georef/%s.ref", pszIdrisiDir, pszRefSystem); + if (FileExists(pszFName) == FALSE) + pszFName = NULL; + } + } + + // ------------------------------------------------------------------ + // Reads the reference file + // ------------------------------------------------------------------ + + if (pszFName != NULL) + { + papszRefFile = CSLLoad(pszFName); + CSLSetNameValueSeparator(papszRefFile, ":"); + } + else + papszRefFile = NULL; + + OGRSpatialReference oSRS; + OSRImportFromIdrisi(&oSRS, pszRefSystem, pszRefUnit, papszRefFile); + oSRS.exportToWkt(&pszProjection); + + CSLDestroy(papszRefFile); + } + + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr IdrisiDataset::SetProjection(const char *pszProjString) +{ + OGRSpatialReference oSRS; + + oSRS.importFromWkt((char **) &pszProjString); + + if (oSRS.IsProjected() && oSRS.GetAttrValue("PROJCS") != NULL) + { + // ------------------------------------------------------------------ + // Check if the input projection comes from another RST file. + // ------------------------------------------------------------------ + + const char *pszRefSystem = NULL; + const char *pszFName = NULL; + + if (oSRS.GetAuthorityName("PROJCS") != NULL + && EQUAL(oSRS.GetAuthorityName("PROJCS"), "IDRISI")) + { + pszRefSystem = oSRS.GetAuthorityCode("PROJCS"); + pszFName = CPLSPrintf("%s/%s.ref", CPLGetDirname(pszFilename), pszRefSystem); + } + + if (FileExists(pszFName) == FALSE) + { + pszFName = NULL; + const char *pszIdrisiDir = CPLGetConfigOption("IDRISIDIR", NULL); + if ((pszIdrisiDir) != NULL) + { + pszFName = CPLSPrintf("%s/georef/%s.ref", pszIdrisiDir, pszRefSystem); + if (FileExists(pszFName) == FALSE) + pszFName = NULL; + } + } + + if (pszFName != NULL) + { + char *pszRefUnit = CPLStrdup(oSRS.GetAttrValue("UNIT", 0)); + if (EQUALN(pszRefUnit, "metre", 5)) + { + (pszRefUnit)[3] = 'e'; + (pszRefUnit)[4] = 'r'; + } + CSLSetNameValue(papszRDC, rdcREF_SYSTEM, CPLSPrintf("%s", pszRefSystem)); + CSLSetNameValue(papszRDC, rdcREF_UNITS, CPLSPrintf("%s", pszRefUnit)); + CPLFree(pszRefUnit); + return CE_None; + } + } + + char *pszRefSystem = NULL; + char *pszRefUnit = NULL; + char **papszRefFile = NULL; + + OSRExportToIdrisi(&oSRS, &pszRefSystem, &pszRefUnit, &papszRefFile); + + if (papszRefFile != NULL) + { + // ------------------------------------------------------------------ + // Save the suggested .ref file in to the documentation sections + // ------------------------------------------------------------------ + + int nLine = -1; + for (int i = 0; i < CSLCount(papszRDC) && nLine == -1; i++) + if (EQUALN(papszRDC[i], rdcCOMMENTS, 12)) + nLine = i; + for (int i = 0; i < CSLCount(papszRefFile); i++) + papszRDC = CSLInsertString(papszRDC, nLine++, + CPLSPrintf("%-.12s: %s", rdcCOMMENTS, papszRefFile[i])); + } + + CSLSetNameValue(papszRDC, rdcREF_SYSTEM, CPLSPrintf("%s", pszRefSystem)); + CSLSetNameValue(papszRDC, rdcREF_UNITS, CPLSPrintf("%s", pszRefUnit)); + + CSLDestroy(papszRefFile); + CPLFree(pszRefSystem); + CPLFree(pszRefUnit); + + return CE_None; +} + +// ------------------------------------------------------------------------ // +// Implementation of IdrisiRasterBand // +// ------------------------------------------------------------------------ // + +/************************************************************************/ +/* IdrisiRasterBand() */ +/************************************************************************/ + +IdrisiRasterBand::IdrisiRasterBand(IdrisiDataset *poDS, + int nBand, + GDALDataType eDataType) +{ + this->poDS = poDS; + this->nBand = nBand; + this->eDataType = eDataType; + + // -------------------------------------------------------------------- + // Set Dimension + // -------------------------------------------------------------------- + + nBlockYSize = 1; + nBlockXSize = poDS->GetRasterXSize(); + + // -------------------------------------------------------------------- + // Get ready for reading and writing + // -------------------------------------------------------------------- + + nRecordSize = poDS->GetRasterXSize() * GDALGetDataTypeSize(eDataType) / 8 * poDS->nBands; + pabyScanLine = (GByte *) CPLMalloc(nRecordSize); +} + +/************************************************************************/ +/* ~IdrisiRasterBand() */ +/************************************************************************/ + +IdrisiRasterBand::~IdrisiRasterBand() +{ + CPLFree(pabyScanLine); +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::IReadBlock(int nBlockXOff, + int nBlockYOff, + void *pImage) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + if (VSIFSeekL(poGDS->fp, nRecordSize * nBlockYOff, SEEK_SET) < 0) + { + CPLError(CE_Failure, CPLE_FileIO, + "Can't seek (%s) block with X offset %d and Y offset %d.\n%s", + poGDS->pszFilename, nBlockXOff, nBlockYOff, VSIStrerror(errno)); + return CE_Failure; + } + + if( (int) VSIFReadL(pabyScanLine, 1, nRecordSize, poGDS->fp) < nRecordSize) + { + CPLError(CE_Failure, CPLE_FileIO, + "Can't read (%s) block with X offset %d and Y offset %d.\n%s", + poGDS->pszFilename, nBlockXOff, nBlockYOff, VSIStrerror(errno)); + return CE_Failure; + } + + if (poGDS->nBands == 3) + { + int i, j; + for (i = 0, j = (3 - nBand); i < nBlockXSize; i++, j += 3) + { + ((uint8 *) pImage)[i] = pabyScanLine[j]; + } + } + else + { + memcpy(pImage, pabyScanLine, nRecordSize); + } + +#ifdef CPL_MSB + if( eDataType == GDT_Float32 ) + GDALSwapWords( pImage, 4, nBlockXSize * nBlockYSize, 4 ); +#endif + + return CE_None; +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::IWriteBlock(int nBlockXOff, + int nBlockYOff, + void *pImage) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + +#ifdef CPL_MSB + // Swap in input buffer if needed. + if( eDataType == GDT_Float32 ) + GDALSwapWords( pImage, 4, nBlockXSize * nBlockYSize, 4 ); +#endif + + if (poGDS->nBands == 1) + { + memcpy(pabyScanLine, pImage, nRecordSize); + } + else + { + if (nBand > 1) + { + VSIFSeekL(poGDS->fp, nRecordSize * nBlockYOff, SEEK_SET); + VSIFReadL(pabyScanLine, 1, nRecordSize, poGDS->fp); + } + int i, j; + for (i = 0, j = (3 - nBand); i < nBlockXSize; i++, j += 3) + { + pabyScanLine[j] = ((uint8 *) pImage)[i]; + } + } + +#ifdef CPL_MSB + // Swap input buffer back to original form. + if( eDataType == GDT_Float32 ) + GDALSwapWords( pImage, 4, nBlockXSize * nBlockYSize, 4 ); +#endif + + VSIFSeekL(poGDS->fp, nRecordSize * nBlockYOff, SEEK_SET); + + if( (int) VSIFWriteL(pabyScanLine, 1, nRecordSize, poGDS->fp) < nRecordSize) + { + CPLError(CE_Failure, CPLE_FileIO, + "Can't write (%s) block with X offset %d and Y offset %d.\n%s", + poGDS->pszFilename, nBlockXOff, nBlockYOff, VSIStrerror(errno)); + return CE_Failure; + } + + return CE_None; +} + +/************************************************************************/ +/* GetMinimum() */ +/************************************************************************/ + +double IdrisiRasterBand::GetMinimum(int *pbSuccess) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + double adfMinValue[3]; + sscanf(CSLFetchNameValue(poGDS->papszRDC, rdcMIN_VALUE), "%lf %lf %lf", + &adfMinValue[0], &adfMinValue[1], &adfMinValue[2]); + + if (pbSuccess) + *pbSuccess = TRUE; + + return adfMinValue[this->nBand - 1]; +} + +/************************************************************************/ +/* GetMaximum() */ +/************************************************************************/ + +double IdrisiRasterBand::GetMaximum(int *pbSuccess) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + double adfMaxValue[3]; + sscanf(CSLFetchNameValue(poGDS->papszRDC, rdcMAX_VALUE), "%lf %lf %lf", + &adfMaxValue[0], &adfMaxValue[1], &adfMaxValue[2]); + + if (pbSuccess) + *pbSuccess = TRUE; + + return adfMaxValue[this->nBand - 1]; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double IdrisiRasterBand::GetNoDataValue(int *pbSuccess) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + double dfNoData; + const char *pszFlagDefn; + + if (CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN) != NULL) + pszFlagDefn = CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN); + else if (CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN2) != NULL) + pszFlagDefn = CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_DEFN2); + + // -------------------------------------------------------------------------- + // If Flag_Def is not "none", Flag_Value means "background" or "missing data" + // -------------------------------------------------------------------------- + + if (! EQUAL(pszFlagDefn, "none")) + { + dfNoData = atof_nz(CSLFetchNameValue(poGDS->papszRDC, rdcFLAG_VALUE)); + *pbSuccess = TRUE; + } + else + { + dfNoData = -9999.0; /* this value should be ignored */ + *pbSuccess = FALSE; + } + + return dfNoData; +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::SetNoDataValue(double dfNoDataValue) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcFLAG_VALUE, CPLSPrintf("%.8g", dfNoDataValue)); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcFLAG_DEFN, "missing data"); + + return CE_None; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp IdrisiRasterBand::GetColorInterpretation() +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + if (poGDS->nBands == 3) + { + switch (nBand) + { + case 1: return GCI_BlueBand; + case 2: return GCI_GreenBand; + case 3: return GCI_RedBand; + } + } + else if (poGDS->poColorTable->GetColorEntryCount() > 0) + { + return GCI_PaletteIndex; + } + return GCI_GrayIndex; +} + +/************************************************************************/ +/* GetCategoryNames() */ +/************************************************************************/ + +char **IdrisiRasterBand::GetCategoryNames() +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + return poGDS->papszCategories; +} + +/************************************************************************/ +/* SetCategoryNames() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::SetCategoryNames(char **papszCategoryNames) +{ + int nCatCount = CSLCount(papszCategoryNames); + + if (nCatCount == 0) + return CE_None; + + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + CSLDestroy(poGDS->papszCategories); + poGDS->papszCategories = CSLDuplicate(papszCategoryNames); + + // ------------------------------------------------------ + // Search for the "Legend cats : N" line + // ------------------------------------------------------ + + int nLine = -1; + for (int i = 0; (i < CSLCount(poGDS->papszRDC)) && (nLine == -1); i++) + if (EQUALN(poGDS->papszRDC[i], rdcLEGEND_CATS, 12)) + nLine = i; + + if (nLine < 0) + return CE_None; + + int nCount = atoi_nz(CSLFetchNameValue(poGDS->papszRDC, rdcLEGEND_CATS)); + + // ------------------------------------------------------ + // Delte old instance of the categoty names + // ------------------------------------------------------ + + if (nCount > 0) + poGDS->papszRDC = CSLRemoveStrings(poGDS->papszRDC, nLine + 1, nCount, NULL); + + nCount = 0; + + for (int i = 0; i < nCatCount; i++) + { + if ((strlen(papszCategoryNames[i]) > 0)) + { + poGDS->papszRDC = CSLInsertString(poGDS->papszRDC, (nLine + nCount + 1), + CPLSPrintf("%s:%s", CPLSPrintf(rdcCODE_N, i), papszCategoryNames[i])); + nCount++; + } + } + + CSLSetNameValue(poGDS->papszRDC, rdcLEGEND_CATS, CPLSPrintf("%d", nCount)); + + return CE_None; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *IdrisiRasterBand::GetColorTable() +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + if (poGDS->poColorTable->GetColorEntryCount() == 0) + { + return NULL; + } + else + { + return poGDS->poColorTable; + } +} + +/************************************************************************/ +/* SetColorTable() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::SetColorTable(GDALColorTable *poColorTable) +{ + if (poColorTable == NULL) + { + return CE_None; + } + + if (poColorTable->GetColorEntryCount() == 0) + { + return CE_None; + } + + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + const char *pszSMPFilename; + pszSMPFilename = CPLResetExtension(poGDS->pszFilename, extSMP); + FILE *fpSMP; + + if ((fpSMP = VSIFOpenL(pszSMPFilename, "w")) != NULL ) + { + VSIFWriteL("[Idrisi]", 8, 1, fpSMP); + uint8 nPlatform = 1; VSIFWriteL(&nPlatform, 1, 1, fpSMP); + uint8 nVersion = 11; VSIFWriteL(&nVersion, 1, 1, fpSMP); + uint8 nDepth = 8; VSIFWriteL(&nDepth, 1, 1, fpSMP); + uint8 nHeadSz = 18; VSIFWriteL(&nHeadSz, 1, 1, fpSMP); + uint16 nCount = 255; VSIFWriteL(&nCount, 2, 1, fpSMP); + uint16 nMix = 0; VSIFWriteL(&nMix, 2, 1, fpSMP); + uint16 nMax = 255; VSIFWriteL(&nMax, 2, 1, fpSMP); + + GDALColorEntry oEntry; + uint8 aucRGB[3]; + + for (int i = 0; i < poColorTable->GetColorEntryCount(); i++) + { + poColorTable->GetColorEntryAsRGB( i, &oEntry ); + aucRGB[0] = (short) oEntry.c1; + aucRGB[1] = (short) oEntry.c2; + aucRGB[2] = (short) oEntry.c3; + VSIFWriteL(&aucRGB, 3, 1, fpSMP); + } + /* smp files always have 256 occurences */ + for (int i = poColorTable->GetColorEntryCount(); i <= 255; i++) + { + poColorTable->GetColorEntryAsRGB( i, &oEntry ); + aucRGB[0]= (short) 0; + aucRGB[1]= (short) 0; + aucRGB[2]= (short) 0; + VSIFWriteL(&aucRGB, 3, 1, fpSMP); + } + VSIFCloseL(fpSMP); + } + + return CE_None; +} + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ + +const char *IdrisiRasterBand::GetUnitType() +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + return poGDS->pszUnitType; +} + +/************************************************************************/ +/* SetUnitType() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::SetUnitType(const char *pszUnitType) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + if (strlen(pszUnitType) == 0) + { + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcVALUE_UNITS, "unspecified"); + } + else + { + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcVALUE_UNITS, pszUnitType); + } + + return CE_None; +} + +/************************************************************************/ +/* SetStatistics() */ +/************************************************************************/ + +CPLErr IdrisiRasterBand::SetStatistics(double dfMin, double dfMax, double dfMean, double dfStdDev) +{ + IdrisiDataset *poGDS = (IdrisiDataset *) poDS; + + double adfMin[3] = {0.0, 0.0, 0.0}; + double adfMax[3] = {0.0, 0.0, 0.0}; + + sscanf(CSLFetchNameValue(poGDS->papszRDC, rdcMIN_VALUE), "%lf %lf %lf", &adfMin[0], &adfMin[1], &adfMin[2]); + sscanf(CSLFetchNameValue(poGDS->papszRDC, rdcMAX_VALUE), "%lf %lf %lf", &adfMax[0], &adfMax[1], &adfMax[2]); + + adfMin[nBand - 1] = dfMin; + adfMax[nBand - 1] = dfMax; + + if (poGDS->nBands == 3) + { + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcMIN_VALUE, CPLSPrintf("%.8g %.8g %.8g", adfMin[0], adfMin[1], adfMin[2])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcMAX_VALUE, CPLSPrintf("%.8g %.8g %.8g", adfMax[0], adfMax[1], adfMax[2])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcDISPLAY_MIN, CPLSPrintf("%.8g %.8g %.8g", adfMin[0], adfMin[1], adfMin[2])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcDISPLAY_MAX, CPLSPrintf("%.8g %.8g %.8g", adfMax[0], adfMax[1], adfMax[2])); + } + else + { + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcMIN_VALUE, CPLSPrintf("%.8g", adfMin[0])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcMAX_VALUE, CPLSPrintf("%.8g", adfMax[0])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcDISPLAY_MIN, CPLSPrintf("%.8g", adfMin[0])); + poGDS->papszRDC = + CSLSetNameValue(poGDS->papszRDC, rdcDISPLAY_MAX, CPLSPrintf("%.8g", adfMax[0])); + } + + return GDALRasterBand::SetStatistics(dfMin, dfMax, dfMean, dfStdDev); +} + +/************************************************************************/ +/* FileExists() */ +/************************************************************************/ + +bool FileExists(const char *pszFilename) +{ + FILE *fp; + + bool exist = ((fp = VSIFOpenL(pszFilename, "rb")) != NULL); + + if (exist) + { + VSIFCloseL(fp); + } + + return exist; +} + +/************************************************************************/ +/* OSRImportFromIdrisi() */ +/************************************************************************/ + +/** +* \brief Import Idrisi Geo Reference +* +* This functions tries to interpret the "ref. system" information and +* process the well known codifications, like UTM-30N and SPC83MA1, +* otherwise it tries to process the RefFile file content. +* +* User defined or unsupported codifications points to a ".ref" file +* generally in the software installation folder "/Georef" or in the +* same folder as the ".rst" file. +* +* @param poSRS the Spatial Reference Object. +* @param pszRefSystem the Idrisi Referense system name +* @param pszRefUnits the Reference system unit +* @param papszRefFile the StringList with the content of a reference file +*/ + +OGRErr CPL_DLL OSRImportFromIdrisi(OGRSpatialReferenceH hSRS, + const char *pszRefSystem, + const char *pszRefUnits, + char **papszRefFile) +{ + OGRSpatialReference *poSRS = ((OGRSpatialReference *) hSRS); + + char pszRefCode[81]; + int i; + + // --------------------------------------------------------- + // Lowercase the reference in order make the sscanf to works + // --------------------------------------------------------- + + for (i = 0; pszRefSystem[i] != '\0' && i < 80; i++) + pszRefCode[i] = tolower(pszRefSystem[i]); + + pszRefCode[i] = '\0'; + + // --------------------------------------------------------- + // Check the well known codified reference names + // --------------------------------------------------------- + + if (EQUAL(pszRefSystem, rstPLANE)) + { + return OGRERR_NONE; + } + + if (EQUAL(pszRefSystem, rstLATLONG)) + { + poSRS->SetWellKnownGeogCS("WGS84"); + return OGRERR_NONE; + } + + if (EQUALN(pszRefSystem, rstUTM, 3)) + { + int nZone; + char cNorth; + + sscanf(pszRefCode, rstUTM, &nZone, &cNorth); + + poSRS->SetWellKnownGeogCS("WGS84"); + poSRS->SetUTM(nZone, (cNorth == 'n')); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + return OGRERR_NONE; + } + + if (EQUALN(pszRefSystem, rstSPC, 3)) + { + int nNAD; + int nZone; + char szState[3]; + + sscanf(pszRefCode, rstSPC, &nNAD, szState, &nZone); + + int nSPCCode = -1; + for (unsigned int i = 0; + (i < US_STATE_COUNT) && (nSPCCode == -1); + i++) + { + if (EQUAL(szState, aoUSStateTable[i].pszName)) + nSPCCode = aoUSStateTable[i].nCode; + } + if (nSPCCode == -1) + poSRS->SetWellKnownGeogCS(CPLSPrintf("NAD%d", nNAD)); + else + { + if (nZone == 1) + nZone = nSPCCode; + else + nZone = nSPCCode + nZone - 1; + poSRS->SetStatePlane(nZone, (nNAD == 83)); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + return OGRERR_NONE; + } + + if (papszRefFile == NULL) + { + // ------------------------------------------ + // Can't identify just by the reference name + // Assumming a default WGS84 projection (deg) + // ------------------------------------------ + + if (EQUALN(pszRefUnits, rstDEGREE, 3)) + poSRS->SetWellKnownGeogCS("WGS84"); + + return OGRERR_NONE; + } + + // --------------------------------------------------------- + // Read the ".ref" content + // --------------------------------------------------------- + + const char *pszProj; + const char *pszRefSys; + const char *pszDatum; + const char *pszEllipsoid; + double dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing, + dfSemiMajor, dfSemiMinor; + double dfStdP1, dfStdP2; + + pszRefSys = CSLFetchNameValue(papszRefFile, refREF_SYSTEM); + pszProj = CSLFetchNameValue(papszRefFile, refPROJECTION); + pszDatum = CSLFetchNameValue(papszRefFile, refDATUM); + pszEllipsoid = CSLFetchNameValue(papszRefFile, refELLIPSOID); + dfCenterLat = atof_nz(CSLFetchNameValue(papszRefFile, refORIGIN_LAT)); + dfCenterLong = atof_nz(CSLFetchNameValue(papszRefFile, refORIGIN_LONG)); + dfSemiMajor = atof_nz(CSLFetchNameValue(papszRefFile, refMAJOR_SAX)); + dfSemiMinor = atof_nz(CSLFetchNameValue(papszRefFile, refMINOR_SAX)); + dfFalseEasting = atof_nz(CSLFetchNameValue(papszRefFile, refORIGIN_X)); + dfFalseNorthing = atof_nz(CSLFetchNameValue(papszRefFile, refORIGIN_Y)); + dfStdP1 = atof_nz(CSLFetchNameValue(papszRefFile, refSTANDL_1)); + dfStdP2 = atof_nz(CSLFetchNameValue(papszRefFile, refSTANDL_2)); + + if (EQUAL(CSLFetchNameValue(papszRefFile, refSCALE_FAC), "na")) + dfScale = 1.0; + else + dfScale = atof_nz(CSLFetchNameValue(papszRefFile, refSCALE_FAC)); + + if (EQUAL(pszProj,"Transverse Mercator")) + { + poSRS->SetTM(dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "Lambert Conformal Conic")) + { + poSRS->SetLCC(dfStdP1, dfStdP2, dfCenterLat, dfCenterLong, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "Lambert North Polar Azimuthal Equal Area")) + { + poSRS->SetLAEA(dfCenterLat, dfCenterLong, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "Lambert South Polar Azimuthal Equal Area")) + { + poSRS->SetLAEA(dfCenterLat, dfCenterLong, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "North Polar Stereographic")) + { + poSRS->SetPS(dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "South Polar Stereographic")) + { + poSRS->SetPS(dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing); + poSRS->SetProjCS(pszProj); + } + else if (EQUAL(pszProj, "Transverse Stereographic")) + { + poSRS->SetStereographic(dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "Oblique Stereographic")) + { + poSRS->SetOS(dfCenterLat, dfCenterLong, dfScale, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "SetSinusoidal")) + { + poSRS->SetSinusoidal(dfCenterLong, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else if (EQUAL(pszProj, "Alber''s Equal Area Conic")) + { + poSRS->SetACEA(dfStdP1, dfStdP2, dfCenterLat, dfCenterLong, dfFalseEasting, dfFalseNorthing); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + + //------------------------------------------------------------ + // Try to match Datum using Approximated String option + //------------------------------------------------------------ + + int nEPSG = atoi_nz(CSVGetField(CSVFilename("gcs.csv"), + "COORD_REF_SYS_NAME", + pszDatum, + CC_ApproxString, + "COORD_REF_SYS_CODE")); + + if (nEPSG != 0) + { + OGRSpatialReference oGCS; + oGCS.importFromEPSG(nEPSG); + poSRS->CopyGeogCSFrom(&oGCS); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + else + { + //------------------------------------------------------------ + // No match + //------------------------------------------------------------ + + poSRS->SetGeogCS( + CPLSPrintf( + "Unknown datum based upon the ellipsoid %s", pszEllipsoid), + CPLSPrintf( + "Not specified (based on the spheroid %s)", pszDatum), + pszEllipsoid, + dfSemiMajor, + -1.0 / (dfSemiMinor / dfSemiMajor - 1.0)); + OSRSetAuthorityLabel(poSRS,"PROJCS", "IDRISI", pszRefCode); + } + + return OGRERR_NONE; +} + +/************************************************************************/ +/* OSRExportToIdrisi() */ +/************************************************************************/ + +/** +* \brief Export Idrisi Geo Reference +* +* Idrisi store in the RDC documentation file, field "ref. system", +* the name of the reference file (.ref) that contains the geo reference +* paramters. Those file are usually located at the software installation +* folders or in the same folder as the rst file. +* +* @param poSRS the Spatial Reference Object. +* @param pszRefSystem the Idrisi Referense system name +* @param pszRefUnits the Reference system unit +* @param papszRefFile the StringList with the content of a reference file +*/ + +OGRErr CPL_DLL OSRExportToIdrisi(OGRSpatialReferenceH hSRS, + char **pszRefSystem, + char **pszRefUnit, + char ***papszRefFile) +{ + OGRSpatialReference *poSRS = ((OGRSpatialReference *) hSRS); + + const char *pszProjection = poSRS->GetAttrValue("PROJECTION"); + + CSLDestroy(*papszRefFile); + + if (poSRS->IsLocal()) + { + *pszRefSystem = CPLStrdup(rstPLANE); + *pszRefUnit = CPLStrdup(rstMETER); + + return OGRERR_NONE; + } + + if (pszProjection == NULL) + { +#ifdef DEBUG + CPLDebug("RST", "Empty projection definition, considered as LatLong" ); +#endif + *pszRefSystem = CPLStrdup(rstLATLONG); + *pszRefUnit = CPLStrdup(poSRS->GetAttrValue("UNIT", 0)); + + return OGRERR_NONE; + } + + // ----------------------------------------------------- + // Check for UTM + // ----------------------------------------------------- + + if (EQUAL(pszProjection, SRS_PT_TRANSVERSE_MERCATOR)) + { + int nZone = poSRS->GetUTMZone(); + + if ((nZone != 0) && (EQUAL(poSRS->GetAttrValue( "DATUM" ), SRS_DN_WGS84))) + { + double dfNorth = poSRS->GetNormProjParm(SRS_PP_FALSE_NORTHING); + *pszRefSystem = CPLStrdup(CPLSPrintf(rstUTM, nZone, (dfNorth == 0.0 ? 'n' : 's'))); + *pszRefUnit = CPLStrdup(rstMETER); + + return OGRERR_NONE; + } + } + + // ----------------------------------------------------- + // Check for State Plane + // ----------------------------------------------------- + + if ((EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP)) || + (EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP)) || + (EQUAL(pszProjection, SRS_PT_TRANSVERSE_MERCATOR))) + { + // ----------------------------------------------------------------------------- + // This technique uses the reverse process of SetStatePlane (ogr_fromEPSG.cpp): + // Get the ID from [PROJCS[...AUTHORITY["EPSG","26986"]] => 26986 + // Get the PSCode from satateplane.cvs => "2001,Massachusetts,Mainland,,,26986" + // ----------------------------------------------------------------------------- + + char *pszID; + char *pszPCSCode; + + pszID = CPLStrdup(poSRS->GetAuthorityCode("PROJCS")); + if (strlen(pszID) > 0) + { + + pszPCSCode = CPLStrdup(CSVGetField(CSVFilename("stateplane.csv"), + "EPSG_PCS_CODE", pszID, CC_Integer, "ID")); + if (strlen(pszPCSCode) > 0) + { + int nNADYear = 83; + char *pszState = NULL; + int nZone = pszPCSCode[strlen(pszPCSCode) - 1] - '0'; + int nPCSCode = atoi_nz(pszPCSCode); + if (nZone == 0) + nZone = 1; + if (nPCSCode > 10000) + { + nNADYear = 27; + nPCSCode -= 10000; + } + for (unsigned int i = 0; (i < US_STATE_COUNT) && (pszState == NULL); i++) + { + if (nPCSCode == aoUSStateTable[i].nCode) + pszState = aoUSStateTable[i].pszName; + } + CPLFree(*pszRefSystem); + CPLFree(*pszRefUnit); + *pszRefSystem = CPLStrdup(CPLSPrintf(rstSPC, nNADYear, pszState, nZone)); + *pszRefUnit = CPLStrdup(poSRS->GetAttrValue("UNIT", 0)); + if (EQUALN(*pszRefUnit, "metre", 5)) + { + (*pszRefUnit)[3] = 'e'; + (*pszRefUnit)[4] = 'r'; + } + CPLFree(pszPCSCode); + CPLFree(pszID); + return OGRERR_NONE; + } + CPLFree(pszPCSCode); + } + CPLFree(pszID); + } + + // --------------------------------------------------------- + // Generate the ".ref" content + // --------------------------------------------------------- + + double padfCoef[3]; + poSRS->GetTOWGS84(padfCoef, 3); + + if (poSRS->GetAttrValue("PROJCS", 0) == NULL) + *papszRefFile = CSLAddNameValue(*papszRefFile, refPROJECTION, "none"); + else + *papszRefFile = CSLAddNameValue(*papszRefFile, refPROJECTION, + poSRS->GetAttrValue("PROJCS", 0)); + + *papszRefFile = CSLAddNameValue(*papszRefFile, refREF_SYSTEM, + poSRS->GetAttrValue("GEOGCS", 0)); + *papszRefFile = CSLAddNameValue(*papszRefFile, refDATUM, + poSRS->GetAttrValue("DATUM", 0)); + *papszRefFile = CSLAddNameValue(*papszRefFile, refDELTA_WGS84, + CPLSPrintf("%.2g %.2g %.2g", padfCoef[0], padfCoef[1], padfCoef[2])); + *papszRefFile = CSLAddNameValue(*papszRefFile, refELLIPSOID, + poSRS->GetAttrValue("SPHEROID", 0)); + *papszRefFile = CSLAddNameValue(*papszRefFile, refMAJOR_SAX, + CPLSPrintf("%.8g", poSRS->GetSemiMajor(NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refMINOR_SAX, + CPLSPrintf("%.8g", poSRS->GetSemiMinor(NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refORIGIN_LAT, + CPLSPrintf("%.8g", poSRS->GetProjParm(SRS_PP_CENTRAL_MERIDIAN, 0.0, NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refORIGIN_LONG, + CPLSPrintf("%.8g", poSRS->GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN, 0.0, NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refORIGIN_X, + CPLSPrintf("%.8g", poSRS->GetProjParm(SRS_PP_FALSE_EASTING, 0.0, NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refORIGIN_Y, + CPLSPrintf("%.8g", poSRS->GetProjParm(SRS_PP_FALSE_NORTHING, 0.0, NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refSCALE_FAC, + CPLSPrintf("%.8g", poSRS->GetProjParm(SRS_PP_SCALE_FACTOR, 0.0, NULL))); + *papszRefFile = CSLAddNameValue(*papszRefFile, refUNITS, + poSRS->GetAttrValue("UNIT", 0)); + + double dfStdP1 = poSRS->GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1, 0.0, NULL); + double dfStdP2 = poSRS->GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2, 0.0, NULL); + + if ((dfStdP1 == 0.0) && (dfStdP2 == 0.0)) + *papszRefFile = CSLAddNameValue(*papszRefFile, refPARAMETERS, "0"); + else + { + *papszRefFile = CSLAddNameValue(*papszRefFile, refPARAMETERS, "2"); + *papszRefFile = CSLAddNameValue(*papszRefFile, refSTANDL_1, CPLSPrintf("%.8g", dfStdP1)); + *papszRefFile = CSLAddNameValue(*papszRefFile, refSTANDL_2, CPLSPrintf("%.8g", dfStdP1)); + } + CSLSetNameValueSeparator(*papszRefFile, ": "); + + // ------------------------------------------------------------------ + // Assumes LATLONG only when UNIT is degree, and all else are Unknown + // ------------------------------------------------------------------ + + const char* szUnit = poSRS->GetAttrValue("UNIT", 0); + + if (szUnit && EQUAL(szUnit, rstDEGREE)) + { + *pszRefSystem = CPLStrdup(rstLATLONG); + *pszRefUnit = CPLStrdup(szUnit); + } + else + { + *pszRefSystem = CPLStrdup(rstPLANE); + *pszRefUnit = CPLStrdup(rstMETER); + } + + return OGRERR_NONE; +} + +/************************************************************************/ +/* OSRSetAuthorityLabel() */ +/************************************************************************/ + +/** + * Set the authority string label for a node. + * + * @param pszTargetKey the partial or complete path to the node to + * set an authority on. ie. "PROJCS", "GEOGCS" or "GEOGCS|UNIT". + * + * @param pszAuthority authority name, such as "IDRISI". + * @param pszLabel string for value with this authority, such as "utm-30n". + * + * @return OGRERR_NONE on success. + */ + +OGRErr OSRSetAuthorityLabel(OGRSpatialReferenceH hSRS, + const char *pszTargetKey, + const char *pszAuthority, + const char *pszLabel) +{ + OGRSpatialReference *poSRS = ((OGRSpatialReference *) hSRS); + +/* -------------------------------------------------------------------- */ +/* Find the node below which the authority should be put. */ +/* -------------------------------------------------------------------- */ + OGR_SRSNode *poNode = poSRS->GetAttrNode( pszTargetKey ); + + if( poNode == NULL ) + return OGRERR_FAILURE; + +/* -------------------------------------------------------------------- */ +/* If there is an existing AUTHORITY child blow it away before */ +/* trying to set a new one. */ +/* -------------------------------------------------------------------- */ + int iOldChild = poNode->FindChild( "AUTHORITY" ); + if( iOldChild != -1 ) + poNode->DestroyChild( iOldChild ); + +/* -------------------------------------------------------------------- */ +/* Create a new authority label. */ +/* -------------------------------------------------------------------- */ + OGR_SRSNode *poAuthNode; + + poAuthNode = new OGR_SRSNode( "AUTHORITY" ); + poAuthNode->AddChild( new OGR_SRSNode( pszAuthority ) ); + poAuthNode->AddChild( new OGR_SRSNode( pszLabel ) ); + + poNode->AddChild( poAuthNode ); + + return OGRERR_NONE; +} + +/************************************************************************/ +/* GDALRegister_IDRISI() */ +/************************************************************************/ + +void GDALRegister_IDRISI() +{ + GDALDriver *poDriver; + + if (GDALGetDriverByName("RST") == NULL) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription("RST"); + poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, rstVERSION); + poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "frmt_Idrisi.html"); + poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, extRST); + poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, "Byte Int16 Float32"); + poDriver->pfnOpen = IdrisiDataset::Open; + poDriver->pfnCreate = IdrisiDataset::Create; + poDriver->pfnCreateCopy = IdrisiDataset::CreateCopy; + + GetGDALDriverManager()->RegisterDriver(poDriver); + } +} diff --git a/Utilities/GDAL/frmts/idrisi/frmt_Idrisi.html b/Utilities/GDAL/frmts/idrisi/frmt_Idrisi.html new file mode 100644 index 0000000000..36c683cd13 --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/frmt_Idrisi.html @@ -0,0 +1,57 @@ +<html> + <head> + <title>RST --- Idrisi Raster Format</title> + </head> + <body bgcolor="#ffffff"> + <h1>RST --- Idrisi Raster Format</h1> + <P class="MsoNormal">This format is basically a raw one. There is just one band per + files, except in the RGB24 data type where the Red, Green and Blue bands are + store interleafed by pixels in the order Blue, Green and Red. The others data + type are unsigned 8 bits integer with values from 0 to 255 or signed 16 bits + integer with values from -32.768 to 32.767 or 32 bits single precision floating + point.32 bits. The description of the file is stored in a companying text file, + extension RDC. + </P> + <P class="MsoNormal">The RDC image description file doesn�t include color table, or + detailed geographic referencing information. The color table if present can be + obtained by another companying file using the same base name as the RST file + and SMP as extension. + </P> + <P class="MsoNormal">For geographical referencing identification, the RDC file + contains information that points to a file that holds the geographic reference + details. Those files uses extension REF and + <SPAN style="mso-spacerun: yes"> </SPAN>resides in the same folder as the + RST image or more likely in the Idrisi installation folders.</P> + <P class="MsoNormal">Therefore the presence or absence of the Idrisi software in + the running operation system will determine the way that this driver will work. + By setting the environment variable IDRISIDIR pointing to the Idrisi main + installation folder will enable GDAL to find more detailed information about + geographical reference and projection in the REF files.</P> + <P class="MsoNormal">Note that the RST driver recognizes the name convention used + in Idrisi for UTM and State Plane geographic reference so it doesn�t need to + access the REF files. That is the case for RDC file that specify �utm-30n� or + �spc87ma1� in the �ref. system� field. Note that exporting to RST in any other + geographical reference system will generate a suggested REF content in the + comment section of the RDC file. + </P> + <P></P> + <ul> + <li> + �.rst� the raw image file + <li> + �.rdc� the description file + <li> + �.smp� the color table file + <li> + �.ref� the geographical reference file</li> + </ul> + <h2>See Also:</h2> + <ul type="disc"> + <li> + Implemented as <tt>gdal/frmts/idrisi/idrisiraster.cpp</tt>. + <li> + <a href="http://www.idrisi.com">www.idrisi.com</a> + </li> + </ul> + </body> +</html> diff --git a/Utilities/GDAL/frmts/idrisi/makefile.vc b/Utilities/GDAL/frmts/idrisi/makefile.vc new file mode 100644 index 0000000000..ad391134a0 --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/makefile.vc @@ -0,0 +1,15 @@ +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +OBJ = idrisiDataset.obj + +EXTRAFLAGS = -D_USE_MATH_DEFINES + +default: $(OBJ) + copy *.obj ..\o + cd .. + +clean: + -del *.obj + cd .. diff --git a/Utilities/GDAL/frmts/idrisi/rdc.txt b/Utilities/GDAL/frmts/idrisi/rdc.txt new file mode 100644 index 0000000000..a19c562a90 --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/rdc.txt @@ -0,0 +1,126 @@ +Image Documentation File (.rdc) -- File Structure + +Use + +Image Documentation files contain important information about their corresponding Image data files (i.e., its metadata, or header information). Whenever an IDRISI module accesses an Image file, it also accesses the accompanying Image Documentation file. Metadata may be used to examine Image Documentation files. + +File Contents + +Following are the fields that are stored in Image Documentation files. They may be broken down into four major groups: + +Information about the image as a whole: + +file format: The format and version of the file format. + +file title: A descriptive name of the file. It is this text that appears with the title option enabled on display. + +data type: The type of numbers stored in the file. Allowable entries are byte, integer, real, RGB8 and RGB24. (See the description for Image files.) + +file type: The format in which the Image file is stored. Allowable entries are ASCII, Binary and Packed Binary (See Image files.) + +columns: The number of columns in the image. This is extremely important as it tells IDRISI modules how to construct the rectangular image from the stored values. (See Image files.) + +rows: The number of rows in the image. + + +Information about the georeferencing system of the file: + +ref. system: The name of the geographic referencing system used with the file. This may be Plane, Lat/Long, or a specific referencing system defined by a Reference System Parameter file. + +ref. units: The unit of measure used in the specified reference system. Allowable entries are m, ft, mi, km, deg and radians. + +unit dist.: The scaling factor between the given coordinates and actual measurements on the ground. This will almost always be 1. The unit distance answers the question, "If I move one unit in the reference system described here, how far have I moved on the ground, measuring in reference units?" + +min X: The minimum X coordinate (left edge) of the image. + +max X: The maximum X coordinate (right edge) of the image. + +min Y: The minimum Y coordinate (bottom edge) of the image. + +max Y: The maximum Y coordinate (top edge) of the image. + +pos'n error: A measure of the accuracy of the positions in the image. This field can be used to record the RMS (Root Mean Square) error of locational positions in the reference system. At present, this field is not analytical, but rather is for informational purposes only. (See RESAMPLE Note 5.) + +resolution: The inherent resolution of the image. In most cases, this should correspond to the result of dividing the range of reference coordinates in X by the number of columns in the image. However, there are some rare instances where it might differ from this result. An example is the case of LANDSAT Band 6 (Thermal) imagery. The resolution of those data is actually 120 meters, and would be recorded as such in this field. However, the data is distributed in an apparent 30 meter format to make them physically match the dimensions of the other bands of the scene. The resolution field is a way of correctly indicating the underlying resolution of these data. + +Information about the values stored in the file: + +min value: The minimum value in the image. If the file is of RGB24 type minimum values for the red, green and blue bands of the composite are listed in that order. + +max value: The maximum value in the image. If the file is of RGB24 type maximum values for the red, green and blue bands of the composite are listed in that order. + +display min: The value in the image to display with the first palette color and legend box. + +display max: The value in the image to display with the last palette color and legend box. + +value units: The unit of measure of the values in the image. It is suggested that the term classes be used for all qualitative data sets, and that whenever standard linear units are appropriate, that the same abbreviations that are used for reference units should also be used (m, ft, mi, km, deg, rad). + +value error: This field is very important and should be filled out whenever possible. It records the error in the data values that appear in image cells. For qualitative data, this should be recorded as a proportional error. For quantitative data, the value here should be an RMS error figure. For example, for a DEM, an RMS error of 3 would indicate 68% of all values will be within � 3 meters of the stated elevation, that approximately 95% will be within � 6 meters, and so on. This field is analytical for some modules (e.g., PCLASS) and it is intended that it will become more so in the future. + +flag value: Any value in the image that is not a data value, but rather has a special meaning. If there is no flag value, this entry should remain blank. + +flag def'n: Definition of the above flag value. The most common data flags are those used to indicate background cells and missing data cells. This field is analytical for some modules (e.g., SURFACE, Geostatistics) and will become more so in the future. The key words background and missing data are specifically recognized by some modules. Other terms are only informational in this version. If there is no flag value, this entry should remain blank. + +legend cats: The number of legend categories present. Legend entries are optional. If there is no legend, 0 should be entered in this field. If legend categories do exist, there will be as many lines following as there are legend categories. If no legend categories exist, these lines are not necessary. (See the example below.) + +Other information about the file: + +The following four entries are optional, and any number of each may be entered at the end of the file Metadata can be used to enter this information or they can be entered manually so long as each has the correct term in the 14 character descriptive field to the left. These are all text fields and are included to facilitate complete documentation of the Image file. At present, these last fields are for information only and are not read by IDRISI modules (although some modules will write them). + +comment: Any additional information about the data may be recorded here. +lineage: Description of the history by which the values were recorded/derived. +completeness: The degree to which the values describe the subject matter indicated. +consistency: The logical consistency of the file. + +Note that the lineage, consistency and completeness fields are intended to meet the recommendations of the U.S. National Committee for Digital Cartographic Data Standards (NCDCDS). Along with the pos'n error and value error fields, they provide a means of adhering to the proposed standards for reporting digital cartographic data quality. For further information about the NCDCDS standard, refer to the January 1988 issue of The American Cartographer, 15(1). + +Creation + +Documentation files may be created using the module METADATA. They are created automatically by any IDRISI module that produces an Image file. + +Structure + +Image Documentation files are stored in ASCII format. The first 14 characters of each line describe the contents of the line, while the remaining characters contain the actual information. + +Example + +For example, the documentation file for a soils image might look like this: + +file format : IDRISI Raster A.1 + +file title : Major Soils Groups +data type : byte +file type : binary +columns : 512 +rows : 480 +ref. system : plane +ref. units : m +unit dist. : 1 +min. X : 0 +max. X : 15360 +min. Y : 0 +max. Y : 14400 +pos'n error : unknown +resolution : 30 +min. value : 0 +max. value : 3 +display min : 0 +display max : 3 +value units : classes +value error : 0.15 +flag value : 0 +flag def'n : background +legend cats : 3 +code 1 : Podzol Soils + +code 2 : Brown Podzolic Soils +code 3 : Gray-Brown Podzolic Soils +lineage : Soil polygons derived from 1:5000 scale color air photography +lineage : and ground truth, with the final compilation being adjusted to +lineage : the map base by hand. +comment : Value error determined by statistical accuracy assessment +comment : based on a stratified random sample of 37 points. + +Note + +In versions of IDRISI prior to idrisi32, these files had a .DOC extension. The format has also changed. To convert images from earlier versions to idrisi32, or to convert an idrisi32 image to an earlier version, use IDRISI Conversion Tools from the File menu. \ No newline at end of file diff --git a/Utilities/GDAL/frmts/idrisi/rst.txt b/Utilities/GDAL/frmts/idrisi/rst.txt new file mode 100644 index 0000000000..145ee632cf --- /dev/null +++ b/Utilities/GDAL/frmts/idrisi/rst.txt @@ -0,0 +1,76 @@ +Image File (.rst) -- File Structure + +Use + +Image files are the data files most commonly used in IDRISI. They store the raster data layers used in analyses. + +File Contents + +Image files contain the attribute value of each pixel in the image. + +Creation + +Image files are created by most IDRISI modules. A variety of non-IDRISI format raster data may also be converted to Image files using the File/Import modules. + +Structure and Examples + +While the logical structure of an Image file is a grid, the actual structure, as it is stored, is a single long column of numbers. For instance, an image consisting of 3 rows by 5 columns is stored as a single column of 15 numbers. It is the Image Documentation file that allows IDRISI modules to construct the grid from this list. An image that looks like this: + +10 15 9 10 1 +1 14 10 11 13 +14 13 11 10 12 + +has an image file that looks like this: + +10 +15 +9 +10 +1 +1 +14 +10 +11 +13 +14 +13 +11 +10 +12 + +The numbers in an image file may be integer, byte or real. This is termed the data type. + +1. Integers are whole numbers within the range - 32768 to + 32767. +2. Byte values are positive integer numbers ranging from 0 to 255. +3. Real numbers have a fractional part, or are whole numbers outside the integer range. + +The real data types can store values within a range of � 1 x 10 to the power of 38 with a precision of 7 significant figures. IDRISI supports the standard IEEE 4-byte real number format. +Two other data types are supported by Idrisi32. These are RGB8 and RGB24. Both of these are produced by the COMPOSITE module. An RGB8 file has byte data values, but these values have special meaning. The RGB24 data type indicates a band-interleaved-by-pixel format that is displayed in true color. For more information on both RGB8 and RGB24 files, see COMPOSITE. + +Image files may be stored in ASCII, binary or packed binary file types. The module CONVERT may be used to change data or file type. However, most routines in IDRISI expect the binary format only. + +The packed binary format is a special data compression format for binary integer or byte data. The compression technique used is run-length encoding. The number of occurrences of a value is given, followed by that value, and so on. The run proceeds from left to right and may carry over from the last cell of one row to the first cell of the next row. Primarily, the packed binary format will only save space when there are several cells with identical values next to one another. If there are not sufficient repeating values, the packed binary file may actually be larger than the same file stored as regular binary. + +The following image would require 15 bytes if stored as a byte binary file. + +10 10 10 10 10 +10 9 9 10 11 +11 9 9 9 9 + +Converting the file to packed binary would yield the following file, which would require only 10 bytes of disk space: + +6 +10 +2 +9 +1 +10 +2 +11 +4 +9 + +Note + +In versions of IDRISI prior to idrisi32, these files had an .img extension. The image file structure is identical to that of earlier versions. + diff --git a/Utilities/GDAL/frmts/jp2kak/GNUmakefile b/Utilities/GDAL/frmts/jp2kak/GNUmakefile new file mode 100644 index 0000000000..2f91148a83 --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/GNUmakefile @@ -0,0 +1,28 @@ + +include ../../GDALmake.opt + +OBJ = jp2kakdataset.o + +KAKINC = -I$(KAKDIR)/coresys/common -I$(KAKDIR)/apps/compressed_io \ + -I$(KAKDIR)/apps/jp2 -I$(KAKDIR)/apps/image -I$(KAKDIR)/apps/args + +APPOBJ = $(KAKDIR)/apps/make/args.o $(KAKDIR)/apps/make/image_in.o \ + $(KAKDIR)/apps/make/image_out.o $(KAKDIR)/apps/make/jp2.o \ + $(KAKDIR)/apps/make/mj2.o $(KAKDIR)/apps/make/palette.o \ + $(KAKDIR)/apps/make/roi_sources.o +INSTOBJ = $(foreach d,$(APPOBJ),../o/$(notdir $(d))) + +#CXXFLAGS := $(CXXFLAGS) -DFILEIO_DEBUG + +CPPFLAGS := $(GDAL_INCLUDE) $(KAKINC) -I. $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + rm -f $(INSTOBJ) + +install-obj: $(O_OBJ) + cp $(APPOBJ) ../o + +$(OBJ) $(O_OBJ): jp2kak_roi.h subfile_source.h dbg_file_source.h diff --git a/Utilities/GDAL/frmts/jp2kak/dbg_file_source.h b/Utilities/GDAL/frmts/jp2kak/dbg_file_source.h new file mode 100644 index 0000000000..0bad2b7c14 --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/dbg_file_source.h @@ -0,0 +1,106 @@ +#include "kdu_file_io.h" +#include "cpl_error.h" + +/*****************************************************************************/ +/* dbg_simple_file_source */ +/*****************************************************************************/ + +class dbg_simple_file_source : public kdu_compressed_source { + /* [BIND: reference] */ + public: // Member functions + dbg_simple_file_source() { file = NULL; } + dbg_simple_file_source(const char *fname, bool allow_seeks=true) + { file = NULL; open(fname,allow_seeks); } + /* [SYNOPSIS] Convenience constructor, which also calls `open'. */ + ~dbg_simple_file_source() { close(); } + /* [SYNOPSIS] Automatically calls `close'. */ + bool exists() { return (file != NULL); } + /* [SYNOPSIS] + Returns true if there is an open file associated with the object. + */ + bool operator!() { return (file == NULL); } + /* [SYNOPSIS] + Opposite of `exists', returning false if there is an open file + associated with the object. + */ + void open(const char *fname, bool allow_seeks=true) + { + /* [SYNOPSIS] + Closes any currently open file and attempts to open a new one, + generating an appropriate error (through `kdu_error') if the + indicated file cannot be opened. + [ARG: fname] + Relative path name of file to be opened. + [ARG: allow_seeks] + If false, seeking within the code-stream will not be permitted. + Disabling seeking has no effect unless the code-stream contains + TLM and/or PLT marker segments, in which case the ability + to seek within the file can save a lot of memory when working + with large images, but this may come at the expense of some loss + in speed if we know ahead of time that we want to decompress + the entire image. + */ + close(); + file = fopen(fname,"rb"); + if (file == NULL) + { kdu_error e; + e << "Unable to open compressed data file, \"" << fname << "\"!"; } + capabilities = KDU_SOURCE_CAP_SEQUENTIAL; + if (allow_seeks) + capabilities |= KDU_SOURCE_CAP_SEEKABLE; + seek_origin = 0; + } + int get_capabilities() { return capabilities; } + /* [SYNOPSIS] + The returned capabilities word always includes the flag, + `KDU_SOURCE_CAP_SEQUENTIAL', but may also include + `KDU_SOURCE_CAP_SEEKABLE', depending on the `allow_seeks' argument + passed to `open'. See `kdu_compressed_source::get_capabilities' + for an explanation of capabilities. + */ + bool seek(kdu_long offset) + { /* [SYNOPSIS] See `kdu_compressed_source::seek' for an explanation. */ + assert(file != NULL); + if (!(capabilities & KDU_SOURCE_CAP_SEEKABLE)) + return false; + kdu_fseek(file,seek_origin+offset); + CPLDebug( "KDU", "seek(%ld)", (long) offset ); + return true; + } + bool set_seek_origin(kdu_long position) + { /* [SYNOPSIS] + See `kdu_compressed_source::set_seek_origin' for an explanation. */ + if (!(capabilities & KDU_SOURCE_CAP_SEEKABLE)) + return false; + seek_origin = position; + return true; + } + kdu_long get_pos(bool absolute) + { /* [SYNOPSIS] + See `kdu_compressed_source::get_pos' for an explanation. */ + if (file == NULL) return -1; + kdu_long result = kdu_ftell(file); + if (!absolute) result -= seek_origin; + return result; + } + int read(kdu_byte *buf, int num_bytes) + { /* [SYNOPSIS] See `kdu_compressed_source::read' for an explanation. */ + assert(file != NULL); + CPLDebug( "KDU", "read(%ld)", (long) num_bytes ); + num_bytes = fread(buf,1,(size_t) num_bytes,file); + return num_bytes; + } + void close() + { /* [SYNOPSIS] + It is safe to call this function, even if no file has been opened. + */ + if (file != NULL) + fclose(file); + file = NULL; + } + private: // Data + int capabilities; + kdu_long seek_origin; + FILE *file; + }; + diff --git a/Utilities/GDAL/frmts/jp2kak/frmt_jp2kak.html b/Utilities/GDAL/frmts/jp2kak/frmt_jp2kak.html new file mode 100644 index 0000000000..6111a9755d --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/frmt_jp2kak.html @@ -0,0 +1,107 @@ +<html> +<head> +<title>JP2KAK -- JPEG-2000 (based on Kakadu)</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>JP2KAK -- JPEG-2000 (based on Kakadu)</h1> + +Most forms of JPEG2000 JP2 and JPC compressed images (ISO/IEC 15444-1) can be +read with GDAL using a driver based on the Kakadu library. As well, new images +can be written. Existing images cannot be updated in place.<p> + +The JPEG2000 file format supports lossy and lossless compression of +8bit and 16bit images with 1 or more bands (components). Via the +<a href="http://www.mappingscience.com/msi.html">GeoJP2 (tm)</a> mechanism, +GeoTIFF style coordinate system and georeferencing information can be embedded +within the JP2 file. JPEG2000 files use a substantially different format and +compression mechanism than the traditional JPEG compression and JPEG JFIF +format. They are distinct compression mechanisms produced by the same +group. JPEG2000 is based on wavelet compression.<p> + +The JPEG2000 driver documented on this page (the JP2KAK driver) is implemented +on top of the commercial <a href="http://www.kakadusoftware.com/">Kakadu</a> +library. This is a high quality and high performance JPEG2000 library in wide +used in the geospatial and general imaging community. However, it is not free, +and so normally builds of GDAL from source will not include support for this +driver unless the builder purchases a license for the library and configures +accordingly. GDAL includes <a href="frmt_jpeg2000.html">another JPEG2000 driver</a> +based on the free JasPer library.<p> + +When reading images this driver will represent the bands as being +Byte (8bit unsigned), 16 bit signed or 16 bit unsigned. Georeferencing +and coordinate system information will be available if the file is a +GeoJP2 (tm) file. Files color encoded in YCbCr color space will be +automatically translated to RGB. Paletted images are also supported.<P> + +<h2>Creation Issues</h2> + +JPEG2000 files can only be created using the CreateCopy mechanism to +copy from an existing dataset.<p> + +JPEG2000 overviews are maintained as part of the mathematical description of +the image. Overviews cannot be built as a separate process, but on read the +image will generally be represented as having overview levels at various +power of two factors.<p> + +Creation Options:<p> + +<ul> + +<li> <b>QUALITY=n</b>: Set the compressed size ratio as a percentage +of the size of the uncompressed image. The default is 20 indicating that +the resulting image should be 20% of the size of the uncompressed image. +A value of 100 will result in use of the lossless compression algorithm . +Actual final image size may not exactly match that requested depending on +various factors.<P> + +<li> <b>BLOCKXSIZE=n</b>: Set the tile width to use. Defaults to 20000. +<p> + +<li> <b>BLOCKYSIZE=n</b>: Set the tile height to use. Defaults to image height. +<p> + +<li> <b>LAYERS=n</b>: Control the number of layers produced. These are +sort of like resolution layers, but not exactly. The default value is +12 and this works well in most situations.<p> + +<li> <b>ROI=xoff,yoff,xsize,ysize</b>: Selects a region to be a region of +interest to process with higher data quality. The various "R" flags below may +be used to control the amount better. For example the settings +"ROI=0,0,100,100", "Rweight=7" would encode the top left 100x100 area of +the image with considerable higher quality compared to the rest of the image. +<p> + +</ul> + +The following creation options are tightly tied to the Kakadu library, and +are considered to be for advanced use only. Consult Kakadu documentation +to better understand their meaning.<p> + +<ul> +<li> <b>Corder</b>: Defaults to "PRCL". +<li> <b>Cprecincts</b>: Defaults to "{512,512},{256,512},{128,512},{64,512},{32,512},{16,512},{8,512},{4,512},{2,512}". +<li> <b>ORGgen_plt</b>: Defaults to "yes". +<li> <b>Cmodes</b>: Kakadu library default used. +<li> <b>Clevels</b>: Kakadu library default used. +<li> <b>Rshift</b>: Kakadu library default used. +<li> <b>Rlevels</b>: Kakadu library default used. +<li> <b>Rweight</b>: Kakadu library default used. +</ul> + +See Also:<p> + +<ul> + +<li> Implemented as <tt>gdal/frmts/jp2kak/jp2kakdataset.cpp</tt>.<p> + +<li> <a href="http://www.remotesensing.org/jpeg2000/">JPEG2000 for Geospatial +Applications</a> page, includes GeoJP2(tm) discussion.<p> + +<li> Alternate <a href="frmt_jpeg2000.html">JPEG200 driver</a>.<p> + +</ul> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/jp2kak/jp2kak_roi.h b/Utilities/GDAL/frmts/jp2kak/jp2kak_roi.h new file mode 100644 index 0000000000..aa27152bca --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/jp2kak_roi.h @@ -0,0 +1,76 @@ +/****************************************************************************** + * $Id$ + * + * Project: JPEG-2000 + * Purpose: Classes related to ROI (region of interest) handling, derived + * very directly from Kakadu roi_sources.h. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: jp2kak_roi.h,v $ + * Revision 1.2 2006/04/07 05:37:11 fwarmerdam + * remove redundant comments + * + * Revision 1.1 2003/04/17 16:47:27 warmerda + * New + * + */ + + +/*****************************************************************************/ +/* kd_roi_rect_node */ +/*****************************************************************************/ + +class kd_roi_rect_node : public kdu_roi_node { + public: // Member functions + kd_roi_rect_node(kdu_dims tile_region, kdu_dims roi_region) + { tile_dims = tile_region; + roi_dims = roi_region & tile_region; } + void release() + { delete this; } + void pull(kdu_byte buf[], int width); + private: // Data + kdu_dims tile_dims; // Vert coord advances as lines are pulled + kdu_dims roi_dims; // Vert coord advances when intersecting line pulled + }; + +/*****************************************************************************/ +/* kdu_roi_rect */ +/*****************************************************************************/ + +class kdu_roi_rect : public kdu_roi_image { + public: // Member functions + kdu_roi_rect(kdu_codestream codestream, kdu_dims region); + ~kdu_roi_rect() + { if (comp_regions != NULL) delete[] comp_regions; } + kdu_roi_node *acquire_node(int comp_idx, kdu_dims tile_region) + { + assert((comp_idx >= 0) && (comp_idx < num_components)); + return new kd_roi_rect_node(tile_region,comp_regions[comp_idx]); + } + private: // Data + int num_components; + kdu_dims *comp_regions; + }; + diff --git a/Utilities/GDAL/frmts/jp2kak/jp2kakdataset.cpp b/Utilities/GDAL/frmts/jp2kak/jp2kakdataset.cpp new file mode 100644 index 0000000000..75fa2f51a4 --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/jp2kakdataset.cpp @@ -0,0 +1,2369 @@ +/****************************************************************************** + * $Id: jp2kakdataset.cpp,v 1.39 2006/04/28 04:21:14 fwarmerdam Exp $ + * + * Project: JPEG-2000 + * Purpose: Implementation of the ISO/IEC 15444-1 standard based on Kakadu. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: jp2kakdataset.cpp,v $ + * Revision 1.39 2006/04/28 04:21:14 fwarmerdam + * cleanup GCPs + * + * Revision 1.38 2006/04/07 14:42:49 fwarmerdam + * Overide builtin georeferencing with PAM info. + * + * Revision 1.37 2006/04/07 05:36:26 fwarmerdam + * use new ReadAndParse() method + * + * Revision 1.36 2006/03/22 20:05:26 fwarmerdam + * changed default tilesize rules, now tilexsize is at most 20K + * + * Revision 1.35 2006/03/22 19:50:38 fwarmerdam + * Trim history. + * + * Revision 1.34 2006/03/22 19:50:00 fwarmerdam + * Preliminary support for output with tiling. + * + * Revision 1.33 2006/03/16 17:11:39 fwarmerdam + * Catch exceptions in allocator.finalize() to catch common out of memory + * condition. + * + * Revision 1.32 2006/03/08 15:35:18 fwarmerdam + * Fixed problem with bIsJPX test. + * + * Revision 1.31 2006/02/28 18:04:50 fwarmerdam + * Make sure tiles get closed in case of an exception. + * + * Revision 1.30 2006/02/19 22:37:52 fwarmerdam + * avoid warning with kakadu 4 + * + * Revision 1.29 2005/07/05 22:09:50 fwarmerdam + * use GDALJP2Metadata for geoinfo, better pam support + * + * Revision 1.28 2005/05/05 15:54:48 fwarmerdam + * PAM Enabled + * + * Revision 1.27 2004/10/07 20:18:27 fwarmerdam + * added support for greyscale+alpha + * + * Revision 1.26 2004/10/07 16:48:32 fwarmerdam + * added simple CopyCreate RGBA output support + * + * Revision 1.25 2004/09/08 15:36:12 warmerda + * fixed up initialization issues + * + * Revision 1.24 2004/07/29 16:38:28 warmerda + * fixed up error trapping when opening subfile + * + * Revision 1.23 2004/07/28 14:39:48 warmerda + * added jp2 subfile support + * + * Revision 1.22 2004/07/23 19:13:41 warmerda + * Added J2K_SUBFILE support + * + * Revision 1.21 2004/04/02 17:26:46 warmerda + * Added creation options. + * + * Revision 1.20 2004/01/15 21:21:04 warmerda + * added lossless compression of 16bit values + * + * Revision 1.19 2004/01/12 19:50:09 warmerda + * Disable jpip support on 4.1 till I get around to fixing it up. + */ + +#include "gdal_pam.h" +#include "gdaljp2metadata.h" +#include "cpl_string.h" +#include "cpl_multiproc.h" +#include "jp2_local.h" + +// Kakadu core includes +#include "kdu_elementary.h" +#include "kdu_messaging.h" +#include "kdu_params.h" +#include "kdu_compressed.h" +#include "kdu_sample_processing.h" + +#ifdef FILEIO_DEBUG +#include "dbg_file_source.h" +#endif +#include "subfile_source.h" + +// Application level includes +#include "kdu_file_io.h" +#include "jp2.h" + +// ROI related. +#include "kdu_roi_processing.h" +#include "kdu_image.h" +#include "jp2kak_roi.h" + +#ifdef J2_INPUT_MAX_BUFFER_BYTES +# define KAKADU4 + +# ifdef JP2_COMPRESSION_TYPE_NONE +# define KAKADU41 +# endif +#endif + +#if defined(KAKADU4) && defined(WIN32) && !defined(KAKADU41) +# define USE_JPIP +#endif + +#ifdef USE_JPIP +# include "kdu_client.h" +#else +# define kdu_client void +#endif + +CPL_CVSID("$Id: jp2kakdataset.cpp,v 1.39 2006/04/28 04:21:14 fwarmerdam Exp $"); + +CPL_C_START +CPLErr CPL_DLL GTIFMemBufFromWkt( const char *pszWKT, + const double *padfGeoTransform, + int nGCPCount, const GDAL_GCP *pasGCPList, + int *pnSize, unsigned char **ppabyBuffer ); +CPLErr CPL_DLL GTIFWktFromMemBuf( int nSize, unsigned char *pabyBuffer, + char **ppszWKT, double *padfGeoTransform, + int *pnGCPCount, GDAL_GCP **ppasGCPList ); +CPL_C_END + +static int kakadu_initialized = FALSE; + +static void +transfer_bytes(kdu_byte *dest, kdu_line_buf &src, int gap, int precision, + GDALDataType eOutType ); + +static const unsigned int jp2_uuid_box_type = 0x75756964; + +static unsigned char msi_uuid2[16] = +{0xb1,0x4b,0xf8,0xbd,0x08,0x3d,0x4b,0x43, + 0xa5,0xae,0x8c,0xd7,0xd5,0xa6,0xce,0x03}; + +static unsigned char jp2_header[] = +{0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a}; + +static unsigned char jpc_header[] = +{0xff,0x4f}; + + +/************************************************************************/ +/* ==================================================================== */ +/* JP2KAKDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class JP2KAKDataset : public GDALPamDataset +{ + kdu_codestream oCodeStream; + kdu_compressed_source *poInput; + kdu_compressed_source *poRawInput; +#ifdef KAKADU4 + jp2_family_src *family; +#endif + kdu_client *jpip_client; + kdu_dims dims; + + char *pszProjection; + double adfGeoTransform[6]; + int bGeoTransformValid; + + int nGCPCount; + GDAL_GCP *pasGCPList; + + void PamOverride(); + + public: + JP2KAKDataset(); + ~JP2KAKDataset(); + + virtual CPLErr GetGeoTransform( double * ); + virtual const char *GetProjectionRef(void); + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + static void KakaduInitialize(); + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* JP2KAKRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class JP2KAKRasterBand : public GDALPamRasterBand +{ + friend class JP2KAKDataset; + + int nDiscardLevels; + + kdu_dims band_dims; + + int nOverviewCount; + JP2KAKRasterBand **papoOverviewBand; + + kdu_client *jpip_client; + + kdu_codestream oCodeStream; + + GDALColorTable oCT; + + int bYCbCrReported; + + GDALColorInterp eInterp; + + public: + + JP2KAKRasterBand( int, int, kdu_codestream, int, kdu_client *, + jp2_channels ); + ~JP2KAKRasterBand(); + + virtual CPLErr IReadBlock( int, int, void * ); + + virtual int GetOverviewCount(); + virtual GDALRasterBand *GetOverview( int ); + + virtual GDALColorInterp GetColorInterpretation(); + virtual GDALColorTable *GetColorTable(); + + // internal + + void ApplyPalette( jp2_palette oJP2Palette ); + void ProcessYCbCrTile(kdu_tile tile, GByte *pabyBuffer, + int nTileXOff, int nTileYOff ); + void ProcessTile(kdu_tile tile, GByte *pabyBuffer, + int nTileXOff, int nTileYOff ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* Set up messaging services */ +/* ==================================================================== */ +/************************************************************************/ + +class kdu_cpl_error_message : public kdu_message +{ +public: // Member classes + kdu_cpl_error_message( CPLErr eErrClass ) + { + m_eErrClass = eErrClass; + m_pszError = NULL; + } + + void put_text(const char *string) + { + if( m_pszError == NULL ) + m_pszError = CPLStrdup( string ); + else + { + m_pszError = (char *) + CPLRealloc(m_pszError, strlen(m_pszError) + strlen(string)+1 ); + strcat( m_pszError, string ); + } + } + + class JP2KAKException + { + }; + + void flush(bool end_of_message=false) + { + if( m_pszError == NULL ) + return; + if( m_pszError[strlen(m_pszError)-1] == '\n' ) + m_pszError[strlen(m_pszError)-1] = '\0'; + + CPLError( m_eErrClass, CPLE_AppDefined, "%s", m_pszError ); + CPLFree( m_pszError ); + m_pszError = NULL; + + if( end_of_message && m_eErrClass == CE_Failure ) + { + throw new JP2KAKException(); + } + } + +private: + CPLErr m_eErrClass; + char *m_pszError; +}; + +/************************************************************************/ +/* ==================================================================== */ +/* JP2KAKRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* JP2KAKRasterBand() */ +/************************************************************************/ + +JP2KAKRasterBand::JP2KAKRasterBand( int nBand, int nDiscardLevels, + kdu_codestream oCodeStream, + int nResCount, kdu_client *jpip_client, + jp2_channels oJP2Channels ) + +{ + this->nBand = nBand; + bYCbCrReported = FALSE; + + if( oCodeStream.get_bit_depth(nBand-1) == 16 + && oCodeStream.get_signed(nBand-1) ) + this->eDataType = GDT_Int16; + else if( oCodeStream.get_bit_depth(nBand-1) == 16 + && !oCodeStream.get_signed(nBand-1) ) + this->eDataType = GDT_UInt16; + else if( oCodeStream.get_bit_depth(nBand-1) == 32 ) + this->eDataType = GDT_Float32; + else + this->eDataType = GDT_Byte; + + this->nDiscardLevels = nDiscardLevels; + this->oCodeStream = oCodeStream; + + this->jpip_client = jpip_client; + + oCodeStream.apply_input_restrictions( 0, 0, nDiscardLevels, 0, NULL ); + oCodeStream.get_dims( 0, band_dims ); + + this->nRasterXSize = band_dims.size.x; + this->nRasterYSize = band_dims.size.y; + +/* -------------------------------------------------------------------- */ +/* Use a 512x128 "virtual" block size unless the file is small. */ +/* -------------------------------------------------------------------- */ + if( nRasterXSize >= 1024 ) + nBlockXSize = 512; + else + nBlockXSize = nRasterXSize; + + if( nRasterYSize >= 256 ) + nBlockYSize = 128; + else + nBlockYSize = nRasterYSize; + +/* -------------------------------------------------------------------- */ +/* Figure out the color interpretation for this band. */ +/* -------------------------------------------------------------------- */ + + eInterp = GCI_Undefined; + + if( oJP2Channels.exists() ) + { + int nRedIndex=-1, nGreenIndex=-1, nBlueIndex=-1, nLutIndex; +#ifdef KAKADU41 + int nCSI; +#endif + + if( oJP2Channels.get_num_colours() == 3 ) + { +#ifdef KAKADU41 + oJP2Channels.get_colour_mapping( 0, nRedIndex, nLutIndex, nCSI ); + oJP2Channels.get_colour_mapping( 1, nGreenIndex, nLutIndex, nCSI ); + oJP2Channels.get_colour_mapping( 2, nBlueIndex, nLutIndex, nCSI ); +#else + oJP2Channels.get_colour_mapping( 0, nRedIndex, nLutIndex ); + oJP2Channels.get_colour_mapping( 1, nGreenIndex, nLutIndex ); + oJP2Channels.get_colour_mapping( 2, nBlueIndex, nLutIndex ); +#endif + } + else + { +#ifdef KAKADU41 + oJP2Channels.get_colour_mapping( 0, nRedIndex, nLutIndex, nCSI ); +#else + oJP2Channels.get_colour_mapping( 0, nRedIndex, nLutIndex ); +#endif + if( nBand == 1 ) + eInterp = GCI_GrayIndex; + } + + if( eInterp != GCI_Undefined ) + /* nothing to do */; + + // If we have LUT info, it is a palette image. + else if( nLutIndex != -1 ) + eInterp = GCI_PaletteIndex; + + // Establish color band this is. + else if( nRedIndex == nBand-1 ) + eInterp = GCI_RedBand; + else if( nGreenIndex == nBand-1 ) + eInterp = GCI_GreenBand; + else if( nBlueIndex == nBand-1 ) + eInterp = GCI_BlueBand; + else + eInterp = GCI_Undefined; + + // Could this band be an alpha band? + if( eInterp == GCI_Undefined ) + { + int color_idx, opacity_idx, lut_idx; + + for( color_idx = 0; + color_idx < oJP2Channels.get_num_colours(); color_idx++ ) + { +#ifdef KAKADU41 + if( oJP2Channels.get_opacity_mapping( color_idx, opacity_idx, + lut_idx, nCSI ) ) + { + if( opacity_idx == nBand - 1 ) + eInterp = GCI_AlphaBand; + } + if( oJP2Channels.get_premult_mapping( color_idx, opacity_idx, + lut_idx, nCSI ) ) + { + if( opacity_idx == nBand - 1 ) + eInterp = GCI_AlphaBand; + } +#else + if( oJP2Channels.get_opacity_mapping( color_idx, opacity_idx, + lut_idx ) ) + { + if( opacity_idx == nBand - 1 ) + eInterp = GCI_AlphaBand; + } + if( oJP2Channels.get_premult_mapping( color_idx, opacity_idx, + lut_idx ) ) + { + if( opacity_idx == nBand - 1 ) + eInterp = GCI_AlphaBand; + } +#endif + } + } + } + else if( nBand == 1 ) + eInterp = GCI_RedBand; + else if( nBand == 2 ) + eInterp = GCI_GreenBand; + else if( nBand == 3 ) + eInterp = GCI_BlueBand; + else + eInterp = GCI_GrayIndex; + +/* -------------------------------------------------------------------- */ +/* Do we have any overviews? Only check if we are the full res */ +/* image. */ +/* -------------------------------------------------------------------- */ + nOverviewCount = 0; + papoOverviewBand = 0; + + if( nDiscardLevels == 0 ) + { + int nXSize = nRasterXSize, nYSize = nRasterYSize; + + for( int nDiscard = 1; nDiscard < nResCount; nDiscard++ ) + { + kdu_dims dims; + + nXSize = (nXSize+1) / 2; + nYSize = (nYSize+1) / 2; + + if( (nXSize+nYSize) < 128 || nXSize < 4 || nYSize < 4 ) + continue; /* skip super reduced resolution layers */ + + oCodeStream.apply_input_restrictions( 0, 0, nDiscard, 0, NULL ); + oCodeStream.get_dims( 0, dims ); + + if( (dims.size.x == nXSize || dims.size.x == nXSize-1) + && (dims.size.y == nYSize || dims.size.y == nYSize-1) ) + { + nOverviewCount++; + papoOverviewBand = (JP2KAKRasterBand **) + CPLRealloc( papoOverviewBand, + sizeof(void*) * nOverviewCount ); + papoOverviewBand[nOverviewCount-1] = + new JP2KAKRasterBand( nBand, nDiscard, oCodeStream, 0, + jpip_client, oJP2Channels ); + } + else + { + CPLDebug( "GDAL", "Discard %dx%d JPEG2000 overview layer,\n" + "expected %dx%d.", + dims.size.x, dims.size.y, nXSize, nYSize ); + } + } + } +} + +/************************************************************************/ +/* ~JP2KAKRasterBand() */ +/************************************************************************/ + +JP2KAKRasterBand::~JP2KAKRasterBand() + +{ + for( int i = 0; i < nOverviewCount; i++ ) + delete papoOverviewBand[i]; + + CPLFree( papoOverviewBand ); +} + +/************************************************************************/ +/* GetOverviewCount() */ +/************************************************************************/ + +int JP2KAKRasterBand::GetOverviewCount() + +{ + return nOverviewCount; +} + +/************************************************************************/ +/* GetOverview() */ +/************************************************************************/ + +GDALRasterBand *JP2KAKRasterBand::GetOverview( int iOverviewIndex ) + +{ + if( iOverviewIndex < 0 || iOverviewIndex >= nOverviewCount ) + return NULL; + else + return papoOverviewBand[iOverviewIndex]; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr JP2KAKRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) +{ + try + { +/* -------------------------------------------------------------------- */ +/* Setup a ROI matching the block requested. */ +/* -------------------------------------------------------------------- */ + kdu_dims dims = band_dims; + + dims.pos.x = dims.pos.x + nBlockXOff * nBlockXSize; + dims.pos.y = dims.pos.y + nBlockYOff * nBlockYSize; + dims.size.x = nBlockXSize; + dims.size.y = nBlockYSize; + + kdu_dims dims_roi; + + oCodeStream.apply_input_restrictions( 0, 0, nDiscardLevels, 0, NULL ); + oCodeStream.map_region( 0, dims, dims_roi ); + oCodeStream.apply_input_restrictions( 0, 0, nDiscardLevels, 0, + &dims_roi ); + +/* -------------------------------------------------------------------- */ +/* Handle JPIP Protocol request if we are using it. */ +/* -------------------------------------------------------------------- */ +#ifdef USE_JPIP + if( jpip_client != NULL ) + { + kdu_window window; + + window.region = dims_roi; + window.resolution.x = nRasterXSize; + window.resolution.y = nRasterYSize; + window.set_num_components(1); + window.components[0] = nBand - 1; + window.max_layers = 0; + + jpip_client->post_window( &window ); + + while( !jpip_client->is_idle() ) + CPLSleep( 0.25 ); + + if( !jpip_client->is_alive() ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "JPIP failure some time after post_window()." ); + return CE_Failure; + } + } +#endif + +/* -------------------------------------------------------------------- */ +/* Now we are ready to walk through the tiles processing them */ +/* one-by-one. */ +/* -------------------------------------------------------------------- */ + kdu_dims tile_indices; + kdu_coords tpos; + int nWordSize = GDALGetDataTypeSize( eDataType ) / 8; + + oCodeStream.get_valid_tiles(tile_indices); + + for (tpos.y=0; tpos.y < tile_indices.size.y; tpos.y++) + { + for (tpos.x=0; tpos.x < tile_indices.size.x; tpos.x++) + { + kdu_tile tile = oCodeStream.open_tile(tpos+tile_indices.pos); + + kdu_resolution res = + tile.access_component(0).access_resolution(); + kdu_dims tile_dims; res.get_dims(tile_dims); + kdu_coords offset = tile_dims.pos - dims.pos; + + GByte *pabyDest; + + pabyDest = ((GByte *)pImage) + + (offset.x + offset.y*nBlockXSize) * nWordSize; + + try + { + + if( tile.get_ycc() && nBand < 4 ) + ProcessYCbCrTile( tile, pabyDest, offset.x, offset.y ); + else + ProcessTile( tile, pabyDest, offset.x, offset.y ); + tile.close(); + } + catch( ... ) + { + tile.close(); + return CE_Failure; + } + + } + } + + return CE_None; + } +/* -------------------------------------------------------------------- */ +/* Catch interal Kakadu errors. */ +/* -------------------------------------------------------------------- */ + catch( ... ) + { + return CE_Failure; + } +} + +/************************************************************************/ +/* ProcessTile() */ +/* */ +/* Process data from one component of one tile into working */ +/* buffer. */ +/************************************************************************/ + +void JP2KAKRasterBand::ProcessTile( kdu_tile tile, GByte *pabyDest, + int /*nTileXOff*/, int /*nTileYOff*/ ) + +{ + // Open tile-components and create processing engines and resources + kdu_dims dims; + kdu_sample_allocator allocator; + kdu_tile_comp comp = tile.access_component(nBand-1); + kdu_line_buf line; + kdu_pull_ifc engine; + bool reversible = comp.get_reversible(); + int bit_depth = comp.get_bit_depth(); + kdu_resolution res = comp.access_resolution(); + int nWordSize = GDALGetDataTypeSize( eDataType ) / 8; + + res.get_dims(dims); + + bool use_shorts = (comp.get_bit_depth(true) <= 16); + + line.pre_create(&allocator,dims.size.x,reversible,use_shorts); + + if (res.which() == 0) // No DWT levels used + engine = + kdu_decoder(res.access_subband(LL_BAND),&allocator,use_shorts); + else + engine = kdu_synthesis(res,&allocator,use_shorts); + + allocator.finalize(); // Actually creates buffering resources + + line.create(); // Grabs resources from the allocator. + + // Now walk through the lines of the buffer, recovering them from the + // relevant tile-component processing engines. + + for( int y = 0; y < dims.size.y; y++ ) + { + engine.pull(line,true); + transfer_bytes(pabyDest + y * nBlockXSize * nWordSize, + line, nWordSize, bit_depth, eDataType ); + } + + engine.destroy(); +} + +/************************************************************************/ +/* ProcessYCbCrTile() */ +/* */ +/* Process data from the Y, Cb and Cr components of a tile into */ +/* RGB and then copy the desired red, green or blue portion out */ +/* into the working buffer. */ +/************************************************************************/ + +void JP2KAKRasterBand::ProcessYCbCrTile( kdu_tile tile, GByte *pabyDest, + int /*nTileXOff*/, int /*nTileYOff*/ ) + +{ + // Open tile-components and create processing engines and resources + kdu_dims dims; + kdu_sample_allocator allocator; + kdu_tile_comp comp[3] = {tile.access_component(0), + tile.access_component(1), + tile.access_component(2)}; + kdu_line_buf line[3]; + kdu_pull_ifc engine[3]; + bool reversible = comp[0].get_reversible(); + int bit_depth = comp[0].get_bit_depth(); + kdu_resolution res = comp[0].access_resolution(); + int nWordSize = GDALGetDataTypeSize( eDataType ) / 8; + int iComp; + + if( !bYCbCrReported && nBand == 1 ) + { + bYCbCrReported = TRUE; + CPLDebug( "JP2KAK", "Using ProcessYCbCrTile() for this dataset." ); + } + + res.get_dims(dims); + + bool use_shorts = (comp[0].get_bit_depth(true) <= 16); + + for( iComp = 0; iComp < 3; iComp++ ) + { + line[iComp].pre_create(&allocator,dims.size.x,reversible,use_shorts); + + if (res.which() == 0) // No DWT levels used + engine[iComp] = + kdu_decoder(comp[iComp].access_resolution().access_subband(LL_BAND), + &allocator,use_shorts); + else + engine[iComp] = + kdu_synthesis(comp[iComp].access_resolution(),&allocator,use_shorts); + } + + allocator.finalize(); // Actually creates buffering resources + + for( iComp = 0; iComp < 3; iComp++ ) + line[iComp].create(); // Grabs resources from the allocator. + + // Now walk through the lines of the buffer, recovering them from the + // relevant tile-component processing engines. + + for( int y = 0; y < dims.size.y; y++ ) + { + engine[0].pull(line[0],true); + engine[1].pull(line[1],true); + engine[2].pull(line[2],true); + + kdu_convert_ycc_to_rgb(line[0], line[1], line[2]); + + transfer_bytes(pabyDest + y * nBlockXSize * nWordSize, + line[nBand-1], nWordSize, bit_depth, eDataType ); + } + + engine[0].destroy(); + engine[1].destroy(); + engine[2].destroy(); +} + +/************************************************************************/ +/* ApplyPalette() */ +/************************************************************************/ + +void JP2KAKRasterBand::ApplyPalette( jp2_palette oJP2Palette ) + +{ +/* -------------------------------------------------------------------- */ +/* Do we have a reasonable LUT configuration? RGB or RGBA? */ +/* -------------------------------------------------------------------- */ + if( !oJP2Palette.exists() ) + return; + + if( oJP2Palette.get_num_luts() == 0 || oJP2Palette.get_num_entries() == 0 ) + return; + + if( oJP2Palette.get_num_luts() < 3 ) + { + CPLDebug( "JP2KAK", "JP2KAKRasterBand::ApplyPalette()\n" + "Odd get_num_luts() value (%d)", + oJP2Palette.get_num_luts() ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Fetch the lut entries. Note that they are normalized in the */ +/* -0.5 to 0.5 range. */ +/* -------------------------------------------------------------------- */ + float *pafLUT; + int iColor, nCount = oJP2Palette.get_num_entries(); + + pafLUT = (float *) CPLCalloc(sizeof(float)*4, nCount); + + oJP2Palette.get_lut(0, pafLUT + 0); + oJP2Palette.get_lut(1, pafLUT + nCount); + oJP2Palette.get_lut(2, pafLUT + nCount*2); + + if( oJP2Palette.get_num_luts() == 4 ) + { + oJP2Palette.get_lut( 2, pafLUT + nCount*3 ); + } + else + { + for( iColor = 0; iColor < nCount; iColor++ ) + { + pafLUT[nCount*3 + iColor] = 0.5; + } + } + +/* -------------------------------------------------------------------- */ +/* Apply to GDAL colortable. */ +/* -------------------------------------------------------------------- */ + for( iColor=0; iColor < nCount; iColor++ ) + { + GDALColorEntry sEntry; + + sEntry.c1 = (short) MAX(0,MIN(255,pafLUT[iColor + nCount*0]*256+128)); + sEntry.c2 = (short) MAX(0,MIN(255,pafLUT[iColor + nCount*1]*256+128)); + sEntry.c3 = (short) MAX(0,MIN(255,pafLUT[iColor + nCount*2]*256+128)); + sEntry.c4 = (short) MAX(0,MIN(255,pafLUT[iColor + nCount*3]*256+128)); + + oCT.SetColorEntry( iColor, &sEntry ); + } + + CPLFree( pafLUT ); + + eInterp = GCI_PaletteIndex; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp JP2KAKRasterBand::GetColorInterpretation() + +{ + return eInterp; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *JP2KAKRasterBand::GetColorTable() + +{ + if( oCT.GetColorEntryCount() > 0 ) + return &oCT; + else + return NULL; +} + +/************************************************************************/ +/* ==================================================================== */ +/* JP2KAKDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* JP2KAKDataset() */ +/************************************************************************/ + +JP2KAKDataset::JP2KAKDataset() + +{ + poInput = NULL; + poRawInput = NULL; + pszProjection = NULL; + nGCPCount = 0; + pasGCPList = NULL; +#ifdef KAKADU4 + family = NULL; +#endif + + bGeoTransformValid = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~JP2KAKDataset() */ +/************************************************************************/ + +JP2KAKDataset::~JP2KAKDataset() + +{ + FlushCache(); + + CPLFree( pszProjection ); + + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + + if( poInput != NULL ) + { + oCodeStream.destroy(); + poInput->close(); + delete poInput; +#ifdef KAKADU4 + if( family ) + { + family->close(); + delete family; + } +#endif + if( poRawInput != NULL ) + delete poRawInput; +#ifdef USE_JPIP + if( jpip_client != NULL ) + { + jpip_client->close(); + delete jpip_client; + } +#endif + } +} + + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *JP2KAKDataset::GetProjectionRef() + +{ + if( pszProjection && *pszProjection ) + return( pszProjection ); + else + return GDALPamDataset::GetProjectionRef(); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr JP2KAKDataset::GetGeoTransform( double * padfTransform ) + +{ + if( bGeoTransformValid ) + { + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + + return CE_None; + } + else + return GDALPamDataset::GetGeoTransform( padfTransform ); +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int JP2KAKDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *JP2KAKDataset::GetGCPProjection() + +{ + if( nGCPCount > 0 ) + return pszProjection; + else + return ""; +} + +/************************************************************************/ +/* GetGCP() */ +/************************************************************************/ + +const GDAL_GCP *JP2KAKDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* KakaduInitialize() */ +/************************************************************************/ + +void JP2KAKDataset::KakaduInitialize() + +{ +/* -------------------------------------------------------------------- */ +/* Initialize Kakadu warning/error reporting subsystem. */ +/* -------------------------------------------------------------------- */ + if( !kakadu_initialized ) + { + kakadu_initialized = TRUE; + + kdu_cpl_error_message oErrHandler( CE_Failure ); + kdu_cpl_error_message oWarningHandler( CE_Warning ); + + kdu_customize_warnings(new kdu_cpl_error_message( CE_Warning ) ); + kdu_customize_errors(new kdu_cpl_error_message( CE_Failure ) ); + } +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *JP2KAKDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + subfile_source *poRawInput = NULL; + const char *pszExtension = NULL; + int bIsJPIP = FALSE; + int bIsSubfile = FALSE; + GByte *pabyHeader = NULL; + +/* -------------------------------------------------------------------- */ +/* Check header */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp == NULL ) + { + pszExtension = CPLGetExtension( poOpenInfo->pszFilename ); + if( (EQUALN(poOpenInfo->pszFilename,"http://",7) + || EQUALN(poOpenInfo->pszFilename,"https://",8) + || EQUALN(poOpenInfo->pszFilename,"jpip://",7)) + && EQUAL(pszExtension,"jp2") ) + { + bIsJPIP = TRUE; + } + else if( EQUALN(poOpenInfo->pszFilename,"J2K_SUBFILE:",12) ) + { + static GByte abySubfileHeader[16]; + + KakaduInitialize(); + try + { + poRawInput = new subfile_source( poOpenInfo->pszFilename ); + poRawInput->seek( 0 ); + + poRawInput->read( abySubfileHeader, 16 ); + poRawInput->seek( 0 ); + } + catch( ... ) + { + return NULL; + } + + pabyHeader = abySubfileHeader; + + bIsSubfile = TRUE; + } + else + return NULL; + } + else + { + if( poOpenInfo->nHeaderBytes < 16 ) + return NULL; + + pabyHeader = poOpenInfo->pabyHeader; + } + +/* -------------------------------------------------------------------- */ +/* Any extension is supported for JP2 files. Only selected */ +/* extensions are supported for JPC files since the standard */ +/* prefix is so short (two bytes). */ +/* -------------------------------------------------------------------- */ + if( !bIsJPIP ) + { + if( memcmp(pabyHeader,jp2_header,sizeof(jp2_header)) == 0 ) + pszExtension = "jp2"; + else if( memcmp( pabyHeader, jpc_header, sizeof(jpc_header) ) == 0 ) + { + pszExtension = CPLGetExtension( poOpenInfo->pszFilename ); + if( !EQUAL(pszExtension,"jpc") && !EQUAL(pszExtension,"j2k") + && !EQUAL(pszExtension,"jp2") && !EQUAL(pszExtension,"jpx") + && !EQUAL(pszExtension,"j2c") ) + pszExtension = "jpc"; + } + else + return NULL; + } + + KakaduInitialize(); + +/* -------------------------------------------------------------------- */ +/* Try to open the file in a manner depending on the extension. */ +/* -------------------------------------------------------------------- */ + kdu_compressed_source *poInput = NULL; + kdu_client *jpip_client = NULL; + jp2_palette oJP2Palette; + jp2_channels oJP2Channels; + +#ifdef KAKADU4 + jp2_family_src *family = NULL; +#endif + + try + { + if( bIsJPIP ) + { +#ifdef USE_JPIP + jp2_source *jp2_src; + char *pszWrk = CPLStrdup(strstr(poOpenInfo->pszFilename,"://")+3); + char *pszRequest = strstr(pszWrk,"/"); + + if( pszRequest == NULL ) + { + CPLDebug( "JP2KAK", + "Failed to parse JPIP server and request." ); + CPLFree( pszWrk ); + return NULL; + } + + *(pszRequest++) = '\0'; + + CPLDebug( "JP2KAK", "server=%s, request=%s", + pszWrk, pszRequest ); + + CPLSleep( 15.0 ); + jpip_client = new kdu_client; + jpip_client->connect( pszWrk, NULL, pszRequest, "http-tcp", + "" ); + + CPLDebug( "JP2KAK", "After connect()" ); + + bool bin0_complete = false; + + while( jpip_client->get_databin_length(KDU_META_DATABIN,0,0, + &bin0_complete) <= 0 + || !bin0_complete ) + CPLSleep( 0.25 ); + + family = new jp2_family_src; + family->open( jpip_client ); + + jp2_src = new jp2_source; + jp2_src->open( family ); + jp2_src->read_header(); + + while( !jpip_client->is_idle() ) + CPLSleep( 0.25 ); + + if( jpip_client->is_alive() ) + CPLDebug( "JP2KAK", "connect() seems to be complete." ); + else + { + CPLDebug( "JP2KAK", "connect() seems to have failed." ); + return NULL; + } + + oJP2Channels = jp2_src->access_channels(); + + poInput = jp2_src; +#else + CPLError( CE_Failure, CPLE_OpenFailed, + "JPIP Protocol not supported by GDAL with Kakadu 3.4 or on Unix." ); +#endif + } + else if( EQUAL(pszExtension,"jp2") || EQUAL(pszExtension,"jpx") ) + { + jp2_source *jp2_src; + +#ifdef KAKADU4 + family = new jp2_family_src; + if( poRawInput != NULL ) + family->open( poRawInput ); + else + family->open( poOpenInfo->pszFilename, true ); + jp2_src = new jp2_source; + jp2_src->open( family ); + jp2_src->read_header(); +#else + jp2_src = new jp2_source; + jp2_src->open( poOpenInfo->pszFilename, true ); +#endif + poInput = jp2_src; + + oJP2Palette = jp2_src->access_palette(); + oJP2Channels = jp2_src->access_channels(); + } + else if( poRawInput == NULL ) + { +#ifndef FILEIO_DEBUG + poInput = new kdu_simple_file_source( poOpenInfo->pszFilename ); +#else + poInput = new dbg_simple_file_source( poOpenInfo->pszFilename ); +#endif + } + else + { + poInput = poRawInput; + poRawInput = NULL; + } + } + catch( ... ) + { + CPLDebug( "JP2KAK", "Trapped Kakadu exception." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + JP2KAKDataset *poDS = NULL; + + try + { + poDS = new JP2KAKDataset(); + + poDS->poInput = poInput; + poDS->poRawInput = poRawInput; + poDS->oCodeStream.create( poInput ); + poDS->oCodeStream.set_fussy(); +// poDS->oCodeStream.set_resilient(); + poDS->oCodeStream.set_persistent(); + + poDS->jpip_client = jpip_client; + +#ifdef KAKADU4 + poDS->family = family; +#endif +/* -------------------------------------------------------------------- */ +/* Get overall image size. */ +/* -------------------------------------------------------------------- */ + poDS->oCodeStream.get_dims( 0, poDS->dims ); + + poDS->nRasterXSize = poDS->dims.size.x; + poDS->nRasterYSize = poDS->dims.size.y; + +/* -------------------------------------------------------------------- */ +/* Ensure that all the components have the same dimensions. If */ +/* not, just process the first dimension. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = poDS->oCodeStream.get_num_components(); + + if (poDS->nBands > 1 ) + { + int iDim; + + for( iDim = 1; iDim < poDS->nBands; iDim++ ) + { + kdu_dims dim_this_comp; + + poDS->oCodeStream.get_dims(iDim, dim_this_comp); + + if( dim_this_comp != poDS->dims ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Some components have mismatched dimensions, " + "ignoring all but first." ); + poDS->nBands = 1; + break; + } + } + } + +/* -------------------------------------------------------------------- */ +/* find out how many resolutions levels are available. */ +/* -------------------------------------------------------------------- */ + kdu_dims tile_indices; + poDS->oCodeStream.get_valid_tiles(tile_indices); + + kdu_tile tile = poDS->oCodeStream.open_tile(tile_indices.pos); + int nResCount = tile.access_component(0).get_num_resolutions(); + tile.close(); + + CPLDebug( "JP2KAK", "nResCount=%d", nResCount ); + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + int iBand; + + for( iBand = 1; iBand <= poDS->nBands; iBand++ ) + { + JP2KAKRasterBand *poBand = + new JP2KAKRasterBand(iBand,0,poDS->oCodeStream, nResCount, + jpip_client, oJP2Channels ); + + if( iBand == 1 && oJP2Palette.exists() ) + poBand->ApplyPalette( oJP2Palette ); + + poDS->SetBand( iBand, poBand ); + } + +/* -------------------------------------------------------------------- */ +/* Look for supporting coordinate system information. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp != NULL ) + { + GDALJP2Metadata oJP2Geo; + + if( oJP2Geo.ReadAndParse( poOpenInfo->pszFilename ) ) + { + poDS->pszProjection = CPLStrdup(oJP2Geo.pszProjection); + poDS->bGeoTransformValid = TRUE; + memcpy( poDS->adfGeoTransform, oJP2Geo.adfGeoTransform, + sizeof(double) * 6 ); + poDS->nGCPCount = oJP2Geo.nGCPCount; + poDS->pasGCPList = oJP2Geo.pasGCPList; + oJP2Geo.pasGCPList = NULL; + oJP2Geo.nGCPCount = 0; + } + } + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + +/* -------------------------------------------------------------------- */ +/* Do we have PAM information to override other geo-info? */ +/* -------------------------------------------------------------------- */ + poDS->PamOverride(); + + return( poDS ); + } + +/* -------------------------------------------------------------------- */ +/* Catch all fatal kakadu errors and cleanup a bit. */ +/* -------------------------------------------------------------------- */ + catch( ... ) + { + CPLDebug( "JP2KAK", "JP2KAKDataset::Open() - caught exception." ); + if( poDS != NULL ) + delete poDS; + + return NULL; + } +} + +/************************************************************************/ +/* PamOverride() */ +/* */ +/* Override geolocation information from PAM if there is PAM */ +/* geolocation information. */ +/************************************************************************/ + +void JP2KAKDataset::PamOverride() + +{ + if( strlen(GDALPamDataset::GetProjectionRef()) > 0 ) + { + CPLFree( pszProjection ); + pszProjection = CPLStrdup(GDALPamDataset::GetProjectionRef()); + } + + double adfPamGT[6]; + if( GDALPamDataset::GetGeoTransform( adfPamGT ) == CE_None ) + { + memcpy( adfGeoTransform, adfPamGT, sizeof(double) * 6 ); + bGeoTransformValid = TRUE; + } + + if( GDALPamDataset::GetGCPCount() > 0 ) + { + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + + nGCPCount = GDALPamDataset::GetGCPCount(); + pasGCPList = GDALDuplicateGCPs( nGCPCount, GDALPamDataset::GetGCPs() ); + CPLFree( pszProjection ); + pszProjection = CPLStrdup(GDALPamDataset::GetGCPProjection()); + } +} + +/************************************************************************/ +/* transfer_bytes() */ +/* */ +/* Support function for JP2KAKRasterBand::ProcessTile(). */ +/************************************************************************/ + +static void +transfer_bytes(kdu_byte *dest, kdu_line_buf &src, int gap, int precision, + GDALDataType eOutType ) + + /* Transfers source samples from the supplied line buffer into the output + byte buffer, spacing successive output samples apart by `gap' bytes + (to allow for interleaving of colour components). The function performs + all necessary level shifting, type conversion, rounding and truncation. */ +{ + int width = src.get_width(); + if (src.get_buf32() != NULL) + { // Decompressed samples have a 32-bit representation (integer or float) + assert(precision >= 8); // Else would have used 16 bit representation + kdu_sample32 *sp = src.get_buf32(); + if (!src.is_absolute() && eOutType != GDT_Byte ) + { // Transferring normalized floating point data. + float scale16 = (float)(1<<16); + int val; + + for (; width > 0; width--, sp++, dest+=gap) + { + if( eOutType == GDT_Int16 ) + { + val = (int) (sp->fval*scale16); + *((GInt16 *) dest) = (GInt16) MAX(MIN(val,32767),-32768); + } + else if( eOutType == GDT_UInt16 ) + { + val = (int) (sp->fval*scale16) + 32768; + *((GUInt16 *) dest) = (GUInt16) MAX(MIN(val,65535),0); + } + else if( eOutType == GDT_Float32 ) + *((float *) dest) = sp->fval; + } + } + else if (!src.is_absolute()) + { // Transferring normalized floating point data. + float scale16 = (float)(1<<16); + kdu_int32 val; + + for (; width > 0; width--, sp++, dest+=gap) + { + val = (kdu_int32)(sp->fval*scale16); + val = (val+128)>>8; // May be faster than true rounding + val += 128; + if (val & ((-1)<<8)) + val = (val<0)?0:255; + *dest = (kdu_byte) val; + } + } + else if( eOutType == GDT_Int16 || eOutType == GDT_UInt16 ) + { // Transferring 32-bit absolute integers. + kdu_int32 val; + + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + + if( eOutType == GDT_Int16 ) + { + *((GInt16 *) dest) = (GInt16) MAX(MIN(val,32767),-32768); + } + else + { + assert( eOutType == GDT_UInt16 ); + *((GUInt16 *) dest) = (GUInt16) MAX(MIN(val,65535),0); + } + } + } + else + { // Transferring 32-bit absolute integers. + kdu_int32 val; + kdu_int32 downshift = precision-8; + kdu_int32 offset = (1<<downshift)>>1; + + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + val = (val+offset)>>downshift; + val += 128; + + if (val & ((-1)<<8)) + val = (val<0)?0:255; + *dest = (kdu_byte) val; + } + } + } + else + { // Source data is 16 bits. + kdu_sample16 *sp = src.get_buf16(); + if (!src.is_absolute()) + { // Transferring 16-bit fixed point quantities + kdu_int16 val; + + if (precision >= 8) + { // Can essentially ignore the bit-depth. + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + val += (1<<(KDU_FIX_POINT-8))>>1; + val >>= (KDU_FIX_POINT-8); + val += 128; + if (val & ((-1)<<8)) + val = (val<0)?0:255; + *dest = (kdu_byte) val; + } + } + else + { // Need to force zeros into one or more least significant bits. + kdu_int16 downshift = (kdu_int16) (KDU_FIX_POINT-precision); + kdu_int16 upshift = (kdu_int16) (8-precision); + kdu_int16 offset = 1<<(downshift-1); + + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + val = (val+offset)>>downshift; + val <<= upshift; + val += 128; + if (val & ((-1)<<8)) + val = (val<0)?0:(256-(1<<upshift)); + *dest = (kdu_byte) val; + } + } + } + else + { // Transferring 16-bit absolute integers. + kdu_int16 val; + + if (precision >= 8) + { + kdu_int16 downshift = (kdu_int16) (precision-8); + kdu_int16 offset = (kdu_int16) ((1<<downshift)>>1); + + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + val = (val+offset)>>downshift; + val += 128; + if (val & ((-1)<<8)) + val = (val<0)?0:255; + *dest = (kdu_byte) val; + } + } + else + { + kdu_int16 upshift = (kdu_int16) (8-precision); + + for (; width > 0; width--, sp++, dest+=gap) + { + val = sp->ival; + val <<= upshift; + val += 128; + if (val & ((-1)<<8)) + val = (val<0)?0:(256-(1<<upshift)); + *dest = (kdu_byte) val; + } + } + } + } +} + +/************************************************************************/ +/* JP2KAKWriteGeoTIFFInfo() */ +/************************************************************************/ + +void JP2KAKWriteGeoTIFFInfo( jp2_target *jp2_out, GDALDataset *poSrcDS ) + +{ +/* -------------------------------------------------------------------- */ +/* Prepare the memory buffer containing the degenerate GeoTIFF */ +/* file. */ +/* -------------------------------------------------------------------- */ + const char *pszWKT; + double adfGeoTransform[6]; + int nGTBufSize = 0; + unsigned char *pabyGTBuf = NULL; + + if( GDALGetGCPCount( poSrcDS ) > 0 ) + pszWKT = poSrcDS->GetGCPProjection(); + else + pszWKT = poSrcDS->GetProjectionRef(); + + poSrcDS->GetGeoTransform(adfGeoTransform); + + if( GTIFMemBufFromWkt( pszWKT, adfGeoTransform, + poSrcDS->GetGCPCount(), poSrcDS->GetGCPs(), + &nGTBufSize, &pabyGTBuf ) != CE_None ) + return; + + if( nGTBufSize == 0 ) + return; + +/* -------------------------------------------------------------------- */ +/* Write to a box on the JP2 file. */ +/* -------------------------------------------------------------------- */ +#ifdef KAKADU4 + jp2_out->open_next( jp2_uuid_box_type ); + + jp2_out->write( (kdu_byte *) msi_uuid2, sizeof(msi_uuid2) ); + + jp2_out->write( (kdu_byte *) pabyGTBuf, nGTBufSize ); + + jp2_out->close(); +#else + jp2_output_box &uuid_box = jp2_out->open_box( jp2_uuid_box_type ); + + uuid_box.write( (kdu_byte *) msi_uuid2, sizeof(msi_uuid2) ); + + uuid_box.write( (kdu_byte *) pabyGTBuf, nGTBufSize ); + + uuid_box.close(); +#endif + + CPLFree( pabyGTBuf ); +} + +/************************************************************************/ +/* JP2KAKCreateCopy_WriteTile() */ +/************************************************************************/ + +static int +JP2KAKCreateCopy_WriteTile( GDALDataset *poSrcDS, kdu_tile &oTile, + kdu_roi_image *poROIImage, + int nXOff, int nYOff, int nXSize, int nYSize, + int bReversible, GDALDataType eType, + kdu_codestream &oCodeStream, int bFlushEnabled, + kdu_long *layer_bytes, int layer_count, + GDALProgressFunc pfnProgress, void * pProgressData) + +{ +/* -------------------------------------------------------------------- */ +/* Create one big tile, and a compressing engine, and line */ +/* buffer for each component. */ +/* -------------------------------------------------------------------- */ + int c, num_components = oTile.get_num_components(); + kdu_push_ifc *engines = new kdu_push_ifc[num_components]; + kdu_line_buf *lines = new kdu_line_buf[num_components]; + kdu_sample_allocator allocator; + for (c=0; c < num_components; c++) + { + kdu_resolution res = oTile.access_component(c).access_resolution(); + kdu_roi_node *roi_node = NULL; + + if( poROIImage != NULL ) + { + kdu_dims dims; + + res.get_dims(dims); + roi_node = poROIImage->acquire_node(c,dims); + } + + lines[c].pre_create(&allocator,nXSize,bReversible,bReversible); + engines[c] = kdu_analysis(res,&allocator,bReversible,1.0F,roi_node); + } + + try + { + allocator.finalize(); + + for (c=0; c < num_components; c++) + lines[c].create(); + } + catch( ... ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "allocate.finalize() failed, likely out of memory for compression information." ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Write whole image. Write 1024 lines of each component, then */ +/* go back to the first, and do again. This gives the rate */ +/* computing machine all components to make good estimates. */ +/* -------------------------------------------------------------------- */ + int iLine, iLinesWritten = 0; +#define CHUNK_SIZE 1024 + + GByte *pabyBuffer = (GByte *) + CPLMalloc(nXSize * (GDALGetDataTypeSize(eType)/8) ); + + CPLAssert( !oTile.get_ycc() ); + + for( iLine = 0; iLine < nYSize; iLine += CHUNK_SIZE ) + { + for (c=0; c < num_components; c++) + { + GDALRasterBand *poBand = poSrcDS->GetRasterBand( c+1 ); + int iSubline = 0; + + for( iSubline = iLine; + iSubline < iLine+CHUNK_SIZE && iSubline < nYSize; + iSubline++ ) + { + if( poBand->RasterIO( GF_Read, + nXOff, nYOff+iSubline, nXSize, 1, + (void *) pabyBuffer, nXSize, 1, eType, + 0, 0 ) == CE_Failure ) + return FALSE; + + if( bReversible && eType == GDT_Byte ) + { + kdu_sample16 *dest = lines[c].get_buf16(); + kdu_byte *sp = pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->ival = ((kdu_int16)(*sp)) - 128; + } + else if( bReversible && eType == GDT_Int16 ) + { + kdu_sample16 *dest = lines[c].get_buf16(); + GInt16 *sp = (GInt16 *) pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->ival = *sp; + } + else if( bReversible && eType == GDT_UInt16 ) + { + kdu_sample16 *dest = lines[c].get_buf16(); + GUInt16 *sp = (GUInt16 *) pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->ival = *sp - 32767; + } + else if( eType == GDT_Byte ) + { + kdu_sample32 *dest = lines[c].get_buf32(); + kdu_byte *sp = pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->fval = (float) + ((((kdu_int16)(*sp))-128.0) * 0.00390625); + } + else if( eType == GDT_Int16 ) + { + kdu_sample32 *dest = lines[c].get_buf32(); + GInt16 *sp = (GInt16 *) pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->fval = (float) + (((kdu_int16)(*sp)) * 0.0000152588); + } + else if( eType == GDT_UInt16 ) + { + kdu_sample32 *dest = lines[c].get_buf32(); + GUInt16 *sp = (GUInt16 *) pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->fval = (float) + (((int)(*sp) - 32768) * 0.0000152588); + } + else if( eType == GDT_Float32 ) + { + kdu_sample32 *dest = lines[c].get_buf32(); + float *sp = (float *) pabyBuffer; + + for (int n=nXSize; n > 0; n--, dest++, sp++) + dest->fval = *sp; /* scale it? */ + } + + engines[c].push(lines[c],true); + + iLinesWritten++; + + if( !pfnProgress( iLinesWritten + / (double) (num_components * nYSize), + NULL, pProgressData ) ) + { + return FALSE; + } + } + } + + if( oCodeStream.ready_for_flush() && bFlushEnabled ) + { + CPLDebug( "JP2KAK", + "Calling oCodeStream.flush() at line %d", + MIN(nYSize,iLine+CHUNK_SIZE) ); + + oCodeStream.flush( layer_bytes, layer_count ); + } + else if( bFlushEnabled ) + CPLDebug( "JP2KAK", + "read_for_flush() is false at line %d.", + iLine ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup resources. */ +/* -------------------------------------------------------------------- */ + for( c = 0; c < num_components; c++ ) + engines[c].destroy(); + + delete[] engines; + delete[] lines; + + CPLFree( pabyBuffer ); + + if( poROIImage != NULL ) + delete poROIImage; + + return TRUE; +} + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +static GDALDataset * +JP2KAKCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + int nXSize = poSrcDS->GetRasterXSize(); + int nYSize = poSrcDS->GetRasterYSize(); + int nTileXSize = nXSize; + int nTileYSize = nYSize; + bool bReversible = false; + int bFlushEnabled = CSLFetchBoolean( papszOptions, "FLUSH", TRUE ); + +/* -------------------------------------------------------------------- */ +/* Initialize Kakadu warning/error reporting subsystem. */ +/* -------------------------------------------------------------------- */ + if( !kakadu_initialized ) + { + kakadu_initialized = TRUE; + + kdu_cpl_error_message oErrHandler( CE_Failure ); + kdu_cpl_error_message oWarningHandler( CE_Warning ); + + kdu_customize_warnings(new kdu_cpl_error_message( CE_Warning ) ); + kdu_customize_errors(new kdu_cpl_error_message( CE_Failure ) ); + } + +/* -------------------------------------------------------------------- */ +/* What data type should we use? We assume all datatypes match */ +/* the first band. */ +/* -------------------------------------------------------------------- */ + GDALDataType eType; + GDALRasterBand *poPrototypeBand = poSrcDS->GetRasterBand(1); + + eType = poPrototypeBand->GetRasterDataType(); + if( eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_UInt16 + && eType != GDT_Float32 ) + { + if( bStrict ) + { + CPLError(CE_Failure, CPLE_AppDefined, + "JP2KAK (JPEG2000) driver does not support data type %s.", + GDALGetDataTypeName( eType ) ); + return NULL; + } + + CPLError(CE_Warning, CPLE_AppDefined, + "JP2KAK (JPEG2000) driver does not support data type %s, forcing to Float32.", + GDALGetDataTypeName( eType ) ); + + eType = GDT_Float32; + } + +/* -------------------------------------------------------------------- */ +/* Do we want to write a pseudo-colored image? */ +/* -------------------------------------------------------------------- */ + int bHaveCT = poPrototypeBand->GetColorTable() != NULL + && poSrcDS->GetRasterCount() == 1; + +/* -------------------------------------------------------------------- */ +/* How many layers? */ +/* -------------------------------------------------------------------- */ + int layer_count = 12; + + if( CSLFetchNameValue(papszOptions,"LAYERS") != NULL ) + layer_count = atoi(CSLFetchNameValue(papszOptions,"LAYERS")); + else if( CSLFetchNameValue(papszOptions,"Clayers") != NULL ) + layer_count = atoi(CSLFetchNameValue(papszOptions,"Clayers")); + +/* -------------------------------------------------------------------- */ +/* Establish how many bytes of data we want for each layer. */ +/* We take the quality as a percentage, so if QUALITY of 50 is */ +/* selected, we will set the base layer to 50% the default size. */ +/* We let the other layers be computed internally. */ +/* -------------------------------------------------------------------- */ + kdu_long *layer_bytes; + double dfQuality = 20.0; + + layer_bytes = (kdu_long *) CPLCalloc(sizeof(kdu_long),layer_count); + + if( CSLFetchNameValue(papszOptions,"QUALITY") != NULL ) + { + dfQuality = atof(CSLFetchNameValue(papszOptions,"QUALITY")); + } + + if( dfQuality < 1.0 || dfQuality > 100.0 ) + { + CPLError( CE_Failure, CPLE_IllegalArg, + "QUALITY=%s is not a legal value in the range 1-100.", + CSLFetchNameValue(papszOptions,"QUALITY") ); + return NULL; + } + + if( dfQuality < 99.5 ) + { + double dfLayerBytes = + (nXSize * ((double) nYSize) * dfQuality / 100.0); + + dfLayerBytes *= (GDALGetDataTypeSize(eType) / 8); + dfLayerBytes *= GDALGetRasterCount(poSrcDS); + + if( dfLayerBytes > 2000000000.0 && sizeof(kdu_long) == 4 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Trimmming maximum size of file 2GB from %.1fGB\n" + "to avoid overflow of kdu_long layer size.", + dfLayerBytes / 1000000000.0 ); + dfLayerBytes = 2000000000.0; + } + + layer_bytes[layer_count-1] = (kdu_long) dfLayerBytes; + + CPLDebug( "JP2KAK", "layer_bytes[] = %g\n", + (double) layer_bytes[layer_count-1] ); + } + else + bReversible = true; + +/* -------------------------------------------------------------------- */ +/* Do we want to use more than one tile? */ +/* -------------------------------------------------------------------- */ + if( nTileXSize > 25000 ) + { + // Don't generate tiles that are terrible wide by default, as + // they consume alot of memory for the compression engine. + nTileXSize = 20000; + } + + if( CSLFetchNameValue( papszOptions, "BLOCKXSIZE" ) != NULL ) + nTileXSize = MIN(nXSize, + atoi(CSLFetchNameValue( papszOptions, "BLOCKXSIZE"))); + + if( CSLFetchNameValue( papszOptions, "BLOCKYSIZE" ) != NULL ) + nTileYSize = MIN(nYSize, + atoi(CSLFetchNameValue( papszOptions, "BLOCKYSIZE"))); + +/* -------------------------------------------------------------------- */ +/* Establish the general image parameters. */ +/* -------------------------------------------------------------------- */ + siz_params oSizeParams; + + oSizeParams.set( Scomponents, 0, 0, poSrcDS->GetRasterCount() ); + oSizeParams.set( Sdims, 0, 0, nYSize ); + oSizeParams.set( Sdims, 0, 1, nXSize ); + oSizeParams.set( Sprecision, 0, 0, GDALGetDataTypeSize(eType) ); + if( eType == GDT_UInt16 || eType == GDT_Byte ) + oSizeParams.set( Ssigned, 0, 0, false ); + else + oSizeParams.set( Ssigned, 0, 0, true ); + + if( nTileXSize != nXSize || nTileYSize != nYSize ) + { + oSizeParams.set( Stiles, 0, 0, nTileYSize ); + oSizeParams.set( Stiles, 0, 1, nTileXSize ); + + CPLDebug( "JP2KAK", "Stiles=%d,%d", nTileYSize, nTileXSize ); + } + + kdu_params *poSizeRef = &oSizeParams; poSizeRef->finalize(); + +/* -------------------------------------------------------------------- */ +/* Open output file, and setup codestream. */ +/* -------------------------------------------------------------------- */ +#ifdef KAKADU4 + jp2_family_tgt family; +#endif +#ifdef KAKADU42 + jpx_family_tgt jpx_family; + jpx_target jpx_out; + int bIsJPX = !EQUAL(CPLGetExtension(pszFilename),"jpf"); +#else + int bIsJPX = FALSE; +#endif + + kdu_compressed_target *poOutputFile = NULL; + jp2_target jp2_out; + kdu_simple_file_target jpc_out; + int bIsJP2 = !EQUAL(CPLGetExtension(pszFilename),"jpc") + && !bIsJPX; + kdu_codestream oCodeStream; + + if( !pfnProgress( 0.0, NULL, pProgressData ) ) + return NULL; + + try + { + if( bIsJP2 ) + { +#ifdef KAKADU4 + family.open( pszFilename ); + + jp2_out.open( &family ); +#else + jp2_out.open( pszFilename ); +#endif + poOutputFile = &jp2_out; + } +#ifdef KAKADU42 + else if( bIsJPX ) + { + jpx_family.open( pszFilename ); + + jpx_out.open( &jpx_family ); + jpx_out.add_codestream(); + } +#endif + else + { + jpc_out.open( pszFilename ); + poOutputFile = &jpc_out; + } + + oCodeStream.create(&oSizeParams, poOutputFile ); + } + catch( ... ) + { + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Do we have a high res region of interest? */ +/* -------------------------------------------------------------------- */ + kdu_roi_image *poROIImage = NULL; + char **papszROIDefs = CSLFetchNameValueMultiple( papszOptions, "ROI" ); + int iROI; + + for( iROI = 0; papszROIDefs != NULL && papszROIDefs[iROI] != NULL; iROI++ ) + { + kdu_dims region; + char **papszTokens = CSLTokenizeStringComplex( papszROIDefs[iROI], ",", + FALSE, FALSE ); + + if( CSLCount(papszTokens) != 4 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Skipping corrupt ROI def = \n%s", + papszROIDefs[iROI] ); + continue; + } + + region.pos.x = atoi(papszTokens[0]); + region.pos.y = atoi(papszTokens[1]); + region.size.x = atoi(papszTokens[2]); + region.size.y = atoi(papszTokens[3]); + + CSLDestroy( papszTokens ); + + poROIImage = new kdu_roi_rect(oCodeStream,region); + } + +/* -------------------------------------------------------------------- */ +/* Set some particular parameters. */ +/* -------------------------------------------------------------------- */ + oCodeStream.access_siz()->parse_string( + CPLSPrintf("Clayers=%d",layer_count)); + oCodeStream.access_siz()->parse_string("Cycc=no"); + if( eType == GDT_Int16 || eType == GDT_UInt16 ) + oCodeStream.access_siz()->parse_string("Qstep=0.0000152588"); + + if( bReversible ) + oCodeStream.access_siz()->parse_string("Creversible=yes"); + else + oCodeStream.access_siz()->parse_string("Creversible=no"); + +/* -------------------------------------------------------------------- */ +/* Set some user-overridable parameters. */ +/* -------------------------------------------------------------------- */ + int iParm; + char *apszParms[] = { "Corder", "PCRL", + "Cprecincts", "{512,512},{256,512},{128,512},{64,512},{32,512},{16,512},{8,512},{4,512},{2,512}", + "ORGgen_plt", "yes", + "Cmodes", NULL, + "Clevels", NULL, + "Rshift", NULL, + "Rlevels", NULL, + "Rweight", NULL, + NULL, NULL }; + + for( iParm = 0; apszParms[iParm] != NULL; iParm += 2 ) + { + const char *pszValue = + CSLFetchNameValue( papszOptions, apszParms[iParm] ); + + if( pszValue == NULL ) + pszValue = apszParms[iParm+1]; + + if( pszValue != NULL ) + { + const char *pszOpt = + CPLSPrintf( "%s=%s", apszParms[iParm], pszValue ); + oCodeStream.access_siz()->parse_string( pszOpt ); + + CPLDebug( "JP2KAK", "parse_string(%s)", pszOpt ); + } + } + + oCodeStream.access_siz()->finalize_all(); + +/* -------------------------------------------------------------------- */ +/* Some JP2 specific parameters. */ +/* -------------------------------------------------------------------- */ + if( bIsJP2 ) + { + // Set dimensional information (all redundant with the SIZ marker segment) + jp2_dimensions dims = jp2_out.access_dimensions(); + dims.init(&oSizeParams); + + // Set colour space information (mandatory) + jp2_colour colour = jp2_out.access_colour(); + + if( bHaveCT || poSrcDS->GetRasterCount() == 3 ) + colour.init( JP2_sRGB_SPACE ); + else if( poSrcDS->GetRasterCount() >= 4 + && poSrcDS->GetRasterBand(4)->GetColorInterpretation() + == GCI_AlphaBand ) + { + colour.init( JP2_sRGB_SPACE ); + jp2_out.access_channels().init( 3 ); + jp2_out.access_channels().set_colour_mapping(0,0); + jp2_out.access_channels().set_colour_mapping(1,1); + jp2_out.access_channels().set_colour_mapping(2,2); + jp2_out.access_channels().set_opacity_mapping(0,3); + jp2_out.access_channels().set_opacity_mapping(1,3); + jp2_out.access_channels().set_opacity_mapping(2,3); + } + else if( poSrcDS->GetRasterCount() >= 2 + && poSrcDS->GetRasterBand(2)->GetColorInterpretation() + == GCI_AlphaBand ) + { + colour.init( JP2_sLUM_SPACE ); + jp2_out.access_channels().init( 1 ); + jp2_out.access_channels().set_colour_mapping(0,0); + jp2_out.access_channels().set_opacity_mapping(0,1); + } + else + colour.init( JP2_sLUM_SPACE ); + } + +/* -------------------------------------------------------------------- */ +/* Write JP2 pseudocolor table if available. */ +/* -------------------------------------------------------------------- */ + if( bIsJP2 && bHaveCT ) + { + jp2_palette oJP2Palette; + GDALColorTable *poCT = poPrototypeBand->GetColorTable(); + int iColor, nCount = poCT->GetColorEntryCount(); + kdu_int32 *panLUT = (kdu_int32 *) + CPLMalloc(sizeof(kdu_int32) * nCount * 3); + + oJP2Palette = jp2_out.access_palette(); + oJP2Palette.init( 3, nCount ); + + for( iColor = 0; iColor < nCount; iColor++ ) + { + GDALColorEntry sEntry; + + poCT->GetColorEntryAsRGB( iColor, &sEntry ); + panLUT[iColor + nCount * 0] = sEntry.c1; + panLUT[iColor + nCount * 1] = sEntry.c2; + panLUT[iColor + nCount * 2] = sEntry.c3; + } + + oJP2Palette.set_lut( 0, panLUT + nCount * 0, 8, false ); + oJP2Palette.set_lut( 1, panLUT + nCount * 1, 8, false ); + oJP2Palette.set_lut( 2, panLUT + nCount * 2, 8, false ); + + CPLFree( panLUT ); + + jp2_channels oJP2Channels = jp2_out.access_channels(); + + oJP2Channels.init( 3 ); + oJP2Channels.set_colour_mapping( 0, 0, 0 ); + oJP2Channels.set_colour_mapping( 1, 0, 1 ); + oJP2Channels.set_colour_mapping( 2, 0, 2 ); + } + +#ifdef KAKADU4 + if( bIsJP2 ) + { + jp2_out.write_header(); + } +#endif + +/* -------------------------------------------------------------------- */ +/* Set the GeoTIFF box if georeferencing is available, and this */ +/* is a JP2 file. */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + if( bIsJP2 + && ((poSrcDS->GetGeoTransform(adfGeoTransform) == CE_None + && (adfGeoTransform[0] != 0.0 + || adfGeoTransform[1] != 1.0 + || adfGeoTransform[2] != 0.0 + || adfGeoTransform[3] != 0.0 + || adfGeoTransform[4] != 0.0 + || ABS(adfGeoTransform[5]) != 1.0)) + || poSrcDS->GetGCPCount() > 0) ) + { + JP2KAKWriteGeoTIFFInfo( &jp2_out, poSrcDS ); + } + +/* -------------------------------------------------------------------- */ +/* Open codestream box. */ +/* -------------------------------------------------------------------- */ +#ifdef KAKADU4 + if( bIsJP2 ) + jp2_out.open_codestream(); +#endif + +/* -------------------------------------------------------------------- */ +/* Create one big tile, and a compressing engine, and line */ +/* buffer for each component. */ +/* -------------------------------------------------------------------- */ + int iTileXOff, iTileYOff; + double dfPixelsDone = 0.0; + double dfPixelsTotal = nXSize * (double) nYSize; + + for( iTileYOff = 0; iTileYOff < nYSize; iTileYOff += nTileYSize ) + { + for( iTileXOff = 0; iTileXOff < nXSize; iTileXOff += nTileXSize ) + { + kdu_tile oTile = oCodeStream.open_tile( + kdu_coords(iTileXOff/nTileXSize,iTileYOff/nTileYSize)); + int nThisTileXSize, nThisTileYSize; + + // --------------------------------------------------------------- + // Is this a partial tile on the right or bottom? + if( iTileXOff + nTileXSize < nXSize ) + nThisTileXSize = nTileXSize; + else + nThisTileXSize = nXSize - iTileXOff; + + if( iTileYOff + nTileYSize < nYSize ) + nThisTileYSize = nTileYSize; + else + nThisTileYSize = nYSize - iTileYOff; + + // --------------------------------------------------------------- + // Setup scaled progress monitor + + void *pScaledProgressData; + double dfPixelsDoneAfter = + dfPixelsDone + (nThisTileXSize * (double) nThisTileYSize); + + pScaledProgressData = + GDALCreateScaledProgress( dfPixelsDone / dfPixelsTotal, + dfPixelsDoneAfter / dfPixelsTotal, + pfnProgress, pProgressData ); + if( !JP2KAKCreateCopy_WriteTile( poSrcDS, oTile, poROIImage, + iTileXOff, iTileYOff, + nThisTileXSize, nThisTileYSize, + bReversible, eType, + oCodeStream, bFlushEnabled, + layer_bytes, layer_count, + GDALScaledProgress, + pScaledProgressData ) ) + { + GDALDestroyScaledProgress( pScaledProgressData ); + + oCodeStream.destroy(); + poOutputFile->close(); + VSIUnlink( pszFilename ); + return NULL; + } + + GDALDestroyScaledProgress( pScaledProgressData ); + dfPixelsDone = dfPixelsDoneAfter; + + oTile.close(); + } + } + +/* -------------------------------------------------------------------- */ +/* Finish flushing out results. */ +/* -------------------------------------------------------------------- */ + oCodeStream.flush(layer_bytes, layer_count); + oCodeStream.destroy(); + + CPLFree( layer_bytes ); + + if( bIsJP2 ) + { + jp2_out.close(); +#ifdef KAKADU4 + family.close(); +#endif + } + else + { + poOutputFile->close(); + } + + if( !pfnProgress( 1.0, NULL, pProgressData ) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Re-open dataset, and copy any auxilary pam information. */ +/* -------------------------------------------------------------------- */ + GDALPamDataset *poDS = (GDALPamDataset *) + GDALOpen( pszFilename, GA_ReadOnly ); + + if( poDS ) + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + +/************************************************************************/ +/* GDALRegister_JP2KAK() */ +/************************************************************************/ + +void GDALRegister_JP2KAK() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "JP2KAK" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "JP2KAK" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "JPEG-2000 (based on Kakadu)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_jpeg2000.html" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16" ); + poDriver->SetMetadataItem( GDAL_DMD_MIMETYPE, "image/jp2" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "jp2" ); + + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='QUALITY' type='integer' description='1-100, 100 is lossless'/>" +" <Option name='BLOCKXSIZE' type='int' description='Tile Width'/>" +" <Option name='BLOCKYSIZE' type='int' description='Tile Height'/>" +" <Option name='LAYERS' type='integer'/>" +" <Option name='ROI' type='string'/>" +" <Option name='Corder' type='string'/>" +" <Option name='Cprecincts' type='string'/>" +" <Option name='ORGgen_plt' type='string'/>" +" <Option name='Cmodes' type='string'/>" +" <Option name='Clevels' type='string'/>" +" <Option name='Rshift' type='string'/>" +" <Option name='Rlevels' type='string'/>" +" <Option name='Rweight' type='string'/>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = JP2KAKDataset::Open; + poDriver->pfnCreateCopy = JP2KAKCreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/jp2kak/makefile.vc b/Utilities/GDAL/frmts/jp2kak/makefile.vc new file mode 100644 index 0000000000..fb77302c61 --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/makefile.vc @@ -0,0 +1,17 @@ + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +OBJ = jp2kakdataset.obj +EXTRAFLAGS = -I$(KAKDIR) /DKDU_PENTIUM_MSVC /GX + +default: $(OBJ) kakinstall + copy *.obj ..\o + +kakinstall: + copy $(KAKDIR)\*.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/jp2kak/subfile_source.h b/Utilities/GDAL/frmts/jp2kak/subfile_source.h new file mode 100644 index 0000000000..a0e5bec378 --- /dev/null +++ b/Utilities/GDAL/frmts/jp2kak/subfile_source.h @@ -0,0 +1,166 @@ +/****************************************************************************** + * $Id$ + * + * Project: JPEG-2000 + * Purpose: Implements read-only virtual io on a subregion of a file. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: subfile_source.h,v $ + * Revision 1.2 2004/07/29 16:37:56 warmerda + * fixed parsing of subfile definition to handle spaces properly + * + * Revision 1.1 2004/07/23 19:14:00 warmerda + * New + * + */ + +#include "kdu_file_io.h" +#include "cpl_error.h" + +/************************************************************************/ +/* subfile_source */ +/************************************************************************/ + +class subfile_source : public kdu_compressed_source { + + public: + subfile_source() { file = NULL; } + subfile_source(const char *fname, bool allow_seeks=true) + { file = NULL; open(fname,allow_seeks); } + + + ~subfile_source() { close(); } + + + bool exists() { return (file != NULL); } + + bool operator!() { return (file == NULL); } + + void open(const char *fname, bool allow_seeks=true) + { + const char *real_filename; + close(); + + if( sscanf( fname, "J2K_SUBFILE:%d,%d", + &subfile_offset, &subfile_size ) != 2 ) + { + kdu_error e; + + e << "Corrupt subfile definition:" << fname; + return; + } + + real_filename = strstr(fname,","); + if( real_filename != NULL ) + real_filename = strstr(real_filename+1,","); + if( real_filename != NULL ) + real_filename = real_filename++; + else + { + kdu_error e; + + e << "Could not find filename in subfile definition." << fname; + return; + } + + file = VSIFOpenL( real_filename, "rb" ); + if( file == NULL ) + { + kdu_error e; + e << "Unable to open compressed data file, \"" << + real_filename << "\"!"; + return; + } + + capabilities = KDU_SOURCE_CAP_SEQUENTIAL; + if (allow_seeks) + capabilities |= KDU_SOURCE_CAP_SEEKABLE; + + seek_origin = subfile_offset; + seek( 0 ); + } + + int get_capabilities() { return capabilities; } + + bool seek(kdu_long offset) + { + assert(file != NULL); + if( file == NULL ) + return false; + + if (!(capabilities & KDU_SOURCE_CAP_SEEKABLE)) + return false; + + if( VSIFSeekL( file, seek_origin+offset, SEEK_SET ) == 0 ) + return true; + else + return false; + } + + bool set_seek_origin(kdu_long position) + { + if (!(capabilities & KDU_SOURCE_CAP_SEEKABLE)) + return false; + seek_origin = position + subfile_offset; + return true; + } + + kdu_long get_pos(bool absolute) + { + if (file == NULL) return -1; + kdu_long result = VSIFTell( file ); + if (!absolute) + result -= seek_origin; + else + result -= subfile_offset; + return result; + } + + int read(kdu_byte *buf, int num_bytes) + { + assert(file != NULL); + + num_bytes = VSIFReadL(buf,1,(size_t) num_bytes,file); + return num_bytes; + } + + bool close() + { + if (file != NULL) + VSIFCloseL( file ); + file = NULL; + return true; + } + + private: // Data + int capabilities; + kdu_long seek_origin; + + int subfile_offset; + int subfile_size; + + FILE *file; + }; + diff --git a/Utilities/GDAL/frmts/leveller/GNUmakefile b/Utilities/GDAL/frmts/leveller/GNUmakefile new file mode 100644 index 0000000000..b6a9e22e00 --- /dev/null +++ b/Utilities/GDAL/frmts/leveller/GNUmakefile @@ -0,0 +1,13 @@ + +include ../../GDALmake.opt + +OBJ = levellerdataset.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + +install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/leveller/frmt_leveller.html b/Utilities/GDAL/frmts/leveller/frmt_leveller.html new file mode 100644 index 0000000000..296874f973 --- /dev/null +++ b/Utilities/GDAL/frmts/leveller/frmt_leveller.html @@ -0,0 +1,33 @@ +<html> +<head> + <title>Leveller --- Daylon Leveller heightfield</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>Leveller --- Daylon Leveller Heightfield</h1> + +This driver implements read-only access to Leveller heightfields. +Leveller heightfields store 32-bit elevation values with +optional simple geospatial measures (but not positioning). +Format versions 4 through 6 are supported, which do not +have full georeferencing. The file extension for Leveller heightfields is "TER" (which +is the same as Terragen, but the driver only recognizes Leveller files).<p> + +Although format versions 4 and 5 use 16.16 fixed-point storage, +the driver autoconverts them to floating-point so that GDAL +always sees pixels of type Float32.<p> + +<h2>See Also:</h2> + +<ul> +<li> Implemented as <tt>gdal/frmts/leveller/levellerdataset.cpp</tt>.<p> + +<li> <a href="http://www.daylongraphics.com/products/leveller/dev/index.htm"> +Leveller SDK</a>, which documents the Leveller format.<p> + +</ul> + +</body> +</html> + diff --git a/Utilities/GDAL/frmts/leveller/levellerdataset.cpp b/Utilities/GDAL/frmts/leveller/levellerdataset.cpp new file mode 100644 index 0000000000..4953957efd --- /dev/null +++ b/Utilities/GDAL/frmts/leveller/levellerdataset.cpp @@ -0,0 +1,705 @@ +/****************************************************************************** + * levellerdataset.cpp,v 1.0 + * + * Project: Leveller TER Driver + * Purpose: Reader for Leveller TER documents + * Author: Ray Gardener, Daylon Graphics Ltd. + * + * Portions of this module derived from GDAL drivers by + * Frank Warmerdam, see http://www.gdal.org + * + ****************************************************************************** + * Copyright (c) 2005 Daylon Graphics Ltd. + * + * 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: levellerdataset.cpp,v $ + * Revision 1.4 2006/02/02 22:30:49 fwarmerdam + * byte swapping fix for mac + * + * Revision 1.3 2005/10/21 00:03:41 fwarmerdam + * added coordinate system support from Ray + * + * Revision 1.2 2005/10/20 20:18:14 fwarmerdam + * Applied some patches from Ray. + * + * Revision 1.1 2005/10/20 13:44:29 fwarmerdam + * New + * + */ + + +#include "gdal_pam.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: levellerdataset.cpp,v 1.4 2006/02/02 22:30:49 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_Leveller(void); +CPL_C_END + + +#define str_equal(_s1, _s2) (0 == strcmp((_s1),(_s2))) +#define array_size(_a) (sizeof(_a) / sizeof(_a[0])) + +/*GDALDataset *LevellerCreateCopy( const char *, GDALDataset *, int, char **, + GDALProgressFunc pfnProgress, + void * pProgressData ); + +*/ + +/************************************************************************/ +/* ==================================================================== */ +/* LevellerDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class LevellerRasterBand; + +class LevellerDataset : public GDALPamDataset +{ + friend class LevellerRasterBand; + + int m_version; + + char* m_pszProjection; + + char m_szWorldscaleUnits[32]; + double m_dWorldscale; + double m_dElevScale; + double m_dElevBase; + double m_adfTransform[6]; + + FILE* m_fp; + vsi_l_offset m_nDataOffset; + + int LoadFromFile(FILE*); + + + int locate_data(vsi_l_offset&, size_t&, FILE*, const char*); + int get(int&, FILE*, const char*); + int get(double&, FILE*, const char*); + int get(char*, size_t, FILE*, const char*); + + double convert_measure(double, const char* pszUnitsFrom); + +public: + LevellerDataset(); + ~LevellerDataset(); + + static GDALDataset* Open( GDALOpenInfo* ); + static GDALDataset* Create( const char* pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char** papszOptions ); + + virtual CPLErr GetGeoTransform( double* ); + virtual const char* GetProjectionRef(void); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* LevellerRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class LevellerRasterBand : public GDALPamRasterBand +{ + friend class LevellerDataset; + +public: + + LevellerRasterBand(LevellerDataset*); + + // Geomeasure support. + virtual const char* GetUnitType(); + virtual double GetScale(int* pbSuccess = NULL); + virtual double GetOffset(int* pbSuccess = NULL); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + + +/************************************************************************/ +/* LevellerRasterBand() */ +/************************************************************************/ + +LevellerRasterBand::LevellerRasterBand( LevellerDataset *poDS ) +{ + this->poDS = poDS; + this->nBand = 1; + + eDataType = GDT_Float32; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1;//poDS->GetRasterYSize(); +} + + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr LevellerRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void* pImage ) + +{ + CPLAssert( sizeof(float) == sizeof(GInt32) ); + CPLAssert( nBlockXOff == 0 ); + CPLAssert( pImage != NULL ); + + LevellerDataset *poGDS = (LevellerDataset *) poDS; + +/* -------------------------------------------------------------------- */ +/* Seek to scanline. */ +/* -------------------------------------------------------------------- */ + const size_t rowbytes = nBlockXSize * sizeof(float); + + if(0 != VSIFSeekL( + poGDS->m_fp, + poGDS->m_nDataOffset + nBlockYOff * rowbytes, + SEEK_SET)) + { + CPLError( CE_Failure, CPLE_FileIO, + ".bt Seek failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + + +/* -------------------------------------------------------------------- */ +/* Read the scanline into the image buffer. */ +/* -------------------------------------------------------------------- */ + + if( VSIFReadL( pImage, rowbytes, 1, poGDS->m_fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Leveller read failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Swap on MSB platforms. */ +/* -------------------------------------------------------------------- */ +#ifdef CPL_MSB + GDALSwapWords( pImage, 4, nRasterXSize, 4 ); +#endif + +/* -------------------------------------------------------------------- */ +/* Convert from legacy-format fixed-point if necessary. */ +/* -------------------------------------------------------------------- */ + float* pf = (float*)pImage; + + if(poGDS->m_version < 6) + { + GInt32* pi = (int*)pImage; + for(int i = 0; i < nBlockXSize; i++) + pf[i] = (float)pi[i] / 65536; + } + + +/* -------------------------------------------------------------------- */ +/* Convert raw elevations to realworld elevs. */ +/* -------------------------------------------------------------------- */ + for(int i = 0; i < nBlockXSize; i++) + pf[i] *= poGDS->m_dWorldscale; //this->GetScale(); + + return CE_None; +} + + + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ +const char *LevellerRasterBand::GetUnitType() +{ + // Return elevation units. + // For Leveller documents, it's the same as the ground units. + LevellerDataset *poGDS = (LevellerDataset *) poDS; + + return poGDS->m_szWorldscaleUnits; +} + + +/************************************************************************/ +/* GetScale() */ +/************************************************************************/ + +double LevellerRasterBand::GetScale(int* pbSuccess) +{ + LevellerDataset *poGDS = (LevellerDataset *) poDS; + if(pbSuccess != NULL) + *pbSuccess = TRUE; + return poGDS->m_dElevScale; +} + +/************************************************************************/ +/* GetOffset() */ +/************************************************************************/ + +double LevellerRasterBand::GetOffset(int* pbSuccess) +{ + LevellerDataset *poGDS = (LevellerDataset *) poDS; + if(pbSuccess != NULL) + *pbSuccess = TRUE; + return poGDS->m_dElevBase; +} + + +/************************************************************************/ +/* ==================================================================== */ +/* LevellerDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* LevellerDataset() */ +/************************************************************************/ + +LevellerDataset::LevellerDataset() + +{ + m_fp = NULL; + m_pszProjection = NULL; +} + +/************************************************************************/ +/* ~LevellerDataset() */ +/************************************************************************/ + +LevellerDataset::~LevellerDataset() + +{ + FlushCache(); + + CPLFree(m_pszProjection); + + if( m_fp != NULL ) + VSIFCloseL( m_fp ); +} + +/************************************************************************/ +/* LoadFromFile() */ +/* */ +/* If the data from DEM is in meters, then values are stored as */ +/* shorts. If DEM data is in feet, then height data will be */ +/* stored in float, to preserve the precision of the original */ +/* data. returns true if the file was successfully opened and */ +/* read. */ +/************************************************************************/ + +int LevellerDataset::locate_data(vsi_l_offset& offset, size_t& len, FILE* fp, const char* pszTag) +{ + // Locate the file offset of the desired tag's data. + // If it is not available, return false. + // If the tag is found, leave the filemark at the + // start of its data. + + if(0 != VSIFSeekL(fp, 5, SEEK_SET)) + return 0; + + const int kMaxDescLen = 64; + for(;;) + { + unsigned char c; + if(1 != VSIFReadL(&c, sizeof(c), 1, fp)) + return 0; + const int descriptorLen = c; + if(descriptorLen == 0 || descriptorLen > kMaxDescLen) + return 0; + + char descriptor[kMaxDescLen+1]; + if(1 != VSIFReadL(descriptor, descriptorLen, 1, fp)) + return 0; + + GInt32 datalen; + if(1 != VSIFReadL(&datalen, sizeof(datalen), 1, fp)) + return 0; + + datalen = CPL_LSBWORD32(datalen); + descriptor[descriptorLen] = 0; + if(str_equal(descriptor, pszTag)) + { + len = (size_t)datalen; + offset = VSIFTellL(fp); + return 1; + } + else + { + // Seek to next tag. + if(0 != VSIFSeekL(fp, (vsi_l_offset)datalen, SEEK_CUR)) + return 0; + } + } + return 0; +} + +/************************************************************************/ +/* get() */ +/************************************************************************/ + +int LevellerDataset::get(int& n, FILE* fp, const char* psz) +{ + vsi_l_offset offset; + size_t len; + + if(this->locate_data(offset, len, fp, psz)) + { + GInt32 value; + if(1 == VSIFReadL(&value, sizeof(value), 1, fp)) + { + CPL_LSBPTR32(&value); + n = (int)value; + return 1; + } + } + return 0; +} + +/************************************************************************/ +/* get() */ +/************************************************************************/ + +int LevellerDataset::get(double& d, FILE* fp, const char* pszTag) +{ + vsi_l_offset offset; + size_t len; + + if(this->locate_data(offset, len, fp, pszTag)) + { + if(1 == VSIFReadL(&d, sizeof(d), 1, fp)) + { + CPL_LSBPTR64(&d); + return 1; + } + } + return 0; +} + + +/************************************************************************/ +/* get() */ +/************************************************************************/ +int LevellerDataset::get(char* pszValue, size_t maxchars, FILE* fp, const char* pszTag) +{ + char szTag[65]; + + // We can assume 8-bit encoding, so just go straight + // to the *_d tag. + sprintf(szTag, "%sd", pszTag); + + vsi_l_offset offset; + size_t len; + + if(this->locate_data(offset, len, fp, szTag)) + { + if(len > maxchars) + return 0; + + if(1 == VSIFReadL(pszValue, len, 1, fp)) + { + pszValue[len] = 0; // terminate C-string + return 1; + } + } + + return 0; +} + + +/************************************************************************/ +/* convert_measure() */ +/************************************************************************/ + +double LevellerDataset::convert_measure +( + double d, + const char* pszSpace +) +{ + // Convert a measure to meters. + + const char* szLabels[] = + { + "fm", "pm", "A", "nm", "u", "um", + "mm", "cm", "in", "dft", "dm", "sp", "ft", "sft", + "yd", "m", "r", "dam", "dkm", "f", "km", "mi", "nmi", + "ls", "lm", "AU", "lhr", "ld", "ly", "pc", "kly" + }; + + const double dLYtoM = 9.4608953536e+15; + + const double dScales[] = + { + 1.0e-15, // fm (femtometer) + 1.0e-12, // pm (picometer) + 1.0e-10, // A (angstrom) + 1.0e-9, // nm (nanometer) + 1.0e-6, // u (micron) + 1.0e-6, // um (micrometer) + 1.0e-3, // mm (millimeter) + 1.0e-2, // cm (centimeter) + 0.0254, // in (inch) + 0.03048, // dft (decifoot) + 1.0e-1, // dm (decimeter) + 0.2286, // sp (span) + 0.3048, // ft (foot) + 1200.0 / 3937.0, // sft (survey foot) + 0.9144, // yd (yard) + 1.0, // m (meter) + 5.029, // r (rod) + 10.0, // dam (decameter) + 10.0, // dkm (decameter) + 201.168, // f (furlong) + 1.0e+3, // km + 1609.344,// mi (mile) //1611.7874086021505376344086021505, + 1853.0, // nmi (nautical mile) + dLYtoM / 3.16E+07, // ls (light second) + // 299,367,088.60759493670886075949367 meters. + // 299,791,819.008 if we use 186,282 miles per ls. + dLYtoM / 5.26E+05, // lm (light minute) + 1.50e+11, // AU (astronomical units) + dLYtoM / 5.26E+05 * 60 , // lhr (light hour) + dLYtoM / 5.26E+05 * 60 * 24 , // ld (light day) + dLYtoM, // ly (light year) + dLYtoM * 3.26, // 3.08e+16, // pc (parsec) + dLYtoM * 1000, // kly (kilo light year) + }; + + CPLAssert(array_size(dScales) == array_size(szLabels)); + + for(size_t i = 0; i < array_size(dScales); i++) + { + if(str_equal(pszSpace, szLabels[i])) + return d * dScales[i]; + } + CPLAssert(0); + return d; +} + +/************************************************************************/ +/* LoadFromFile() */ +/************************************************************************/ + +int LevellerDataset::LoadFromFile(FILE* file) +{ + // get hf dimensions + if(!this->get(nRasterXSize, file, "hf_w")) + return 0; + + if(!this->get(nRasterYSize, file, "hf_b")) + return 0; + + // record start of pixel data + size_t datalen; + if(!this->locate_data(m_nDataOffset, datalen, file, "hf_data")) + return 0; + + // sanity check: do we have enough pixels? + if(datalen != nRasterXSize * nRasterYSize * sizeof(float)) + return 0; + + // Read any world scaling. + m_dWorldscale = 1.0; + strcpy(m_szWorldscaleUnits, "m"); + + m_dElevBase = 0.0; + + m_adfTransform[0] = 0.0; + m_adfTransform[1] = 1.0; + m_adfTransform[2] = 0.0; + m_adfTransform[3] = 0.0; + m_adfTransform[4] = 0.0; + m_adfTransform[5] = 1.0; + + if(this->get(m_dWorldscale, file, "hf_worldspacing")) + { + //m_bHasWorldscale = true; + if(this->get(m_szWorldscaleUnits, sizeof(m_szWorldscaleUnits)-1, file, "hf_worldspacinglabel")) + { + // Drop long name, if present. + char* p = strchr(m_szWorldscaleUnits, ' '); + if(p != NULL) + *p = 0; + } + + // If the units are something besides m/ft/sft, + // then convert them to meters. + + if(!str_equal("m", m_szWorldscaleUnits) + && !str_equal("ft", m_szWorldscaleUnits) + && !str_equal("sft", m_szWorldscaleUnits)) + { + m_dWorldscale = this->convert_measure(m_dWorldscale, m_szWorldscaleUnits); + strcpy(m_szWorldscaleUnits, "m"); + } + + // Our extents are such that the origin is at the + // center of the heightfield. + m_adfTransform[0] = -0.5 * m_dWorldscale * nRasterXSize; + m_adfTransform[3] = -0.5 * m_dWorldscale * nRasterYSize; + m_adfTransform[1] = m_dWorldscale; + m_adfTransform[5] = m_dWorldscale; + } + m_dElevScale = 1.0;//m_dWorldscale; + + +/* -------------------------------------------------------------------- */ +/* Set projection. */ +/* -------------------------------------------------------------------- */ + // Leveller files as of Oct 2005 are not currently georeferenced, + // but we can't indicate ground units without a spatialref, + // so make a default geocs (local). + OGRSpatialReference sr; + + sr.SetLocalCS("Leveller world space"); + if(OGRERR_NONE != sr.SetLinearUnits(m_szWorldscaleUnits, + this->convert_measure(1.0, m_szWorldscaleUnits))) + return 0; + + if(OGRERR_NONE != sr.exportToWkt(&m_pszProjection)) + return 0; + + + return TRUE; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char* LevellerDataset::GetProjectionRef(void) +{ + if(m_pszProjection == NULL ) + return ""; + else + return m_pszProjection; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr LevellerDataset::GetGeoTransform(double* padfTransform) + +{ + // Return identity transform, since Leveller heightfields + // do not currently have geodata. + + memcpy(padfTransform, m_adfTransform, sizeof(m_adfTransform)); + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *LevellerDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + // The file should have at least 5 header bytes + // and hf_w, hf_b, and hf_data tags. + if( poOpenInfo->nHeaderBytes < 5+13+13+16 ) + return NULL; + + if( !EQUALN((const char *) poOpenInfo->pabyHeader, "trrn",4) ) + return NULL; + + const int version = poOpenInfo->pabyHeader[4]; + if(version < 4 || version > 6) + return NULL; + + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + LevellerDataset *poDS; + + poDS = new LevellerDataset(); + + poDS->m_version = version; + + // Reopen for large file access. + if( poOpenInfo->eAccess == GA_Update ) + poDS->m_fp = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); + else + poDS->m_fp = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + + if( poDS->m_fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to re-open %s within Leveller driver.\n", + poOpenInfo->pszFilename ); + return NULL; + } + poDS->eAccess = poOpenInfo->eAccess; + + +/* -------------------------------------------------------------------- */ +/* Read the file. */ +/* -------------------------------------------------------------------- */ + if( !poDS->LoadFromFile( poDS->m_fp ) ) + { + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->SetBand( 1, new LevellerRasterBand( poDS )); + + poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_Leveller() */ +/************************************************************************/ + +void GDALRegister_Leveller() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "Leveller" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "Leveller" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, + "ter" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Leveller heightfield" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_leveller.html" ); + + poDriver->pfnOpen = LevellerDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/leveller/makefile.vc b/Utilities/GDAL/frmts/leveller/makefile.vc new file mode 100644 index 0000000000..8c8085d1c3 --- /dev/null +++ b/Utilities/GDAL/frmts/leveller/makefile.vc @@ -0,0 +1,13 @@ + +OBJ = levellerdataset.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/makefile.vc b/Utilities/GDAL/frmts/makefile.vc new file mode 100644 index 0000000000..86af001669 --- /dev/null +++ b/Utilities/GDAL/frmts/makefile.vc @@ -0,0 +1,95 @@ + +GDAL_ROOT = .. + +EXTRAFLAGS = -DFRMT_ceos -DFRMT_aigrid -DFRMT_elas -DFRMT_hfa -DFRMT_gtiff\ + -DFRMT_sdts -DFRMT_raw -DFRMT_gxf -DFRMT_ceos2 -DFRMT_png \ + -DFRMT_dted -DFRMT_mem -DFRMT_jdem -DFRMT_gif \ + -DFRMT_envisat -DFRMT_aaigrid -DFRMT_usgsdem -DFRMT_l1b \ + -DFRMT_fit -DFRMT_vrt -DFRMT_xpm -DFRMT_bmp -DFRMT_rmf \ + -DFRMT_nitf -DFRMT_pcidsk -DFRMT_airsar -DFRMT_rs2 \ + -DFRMT_ilwis -DFRMT_msgn -DFRMT_rik -DFRMT_pcraster \ + -DFRMT_leveller -DFRMT_sgi -DFRMT_idrisi + +MOREEXTRA = + +DIRLIST = $(EXTRAFLAGS:-DFRMT_=) + +!INCLUDE $(GDAL_ROOT)/nmake.opt + +!IFDEF JPEG_SUPPORTED +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_jpeg +!ENDIF + +!IFDEF BSB_SUPPORTED +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_bsb +!ENDIF + +!IFDEF OGDIDIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_ogdi +!ELSE +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_zlib +!ENDIF + +!IFDEF JASPER_DIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_jpeg2000 +!ENDIF + +!IFDEF KAKDIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_jp2kak +!ENDIF + +!IFDEF ECWDIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_ecw +!ENDIF + +!IFDEF HDF4_DIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_hdf4 +!ENDIF + +!IFDEF HDF5_DIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_hdf5 +!ENDIF + +!IFDEF MRSID_DIR +!IFNDEF MRSID_PLUGIN +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_mrsid +!ENDIF +!ENDIF + +!IFDEF FITS_DIR +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_fits +!ENDIF + +!IFDEF NETCDF_SETTING +EXTRAFLAGS = $(EXTRAFLAGS) -DFRMT_netcdf +!ENDIF + +default: o\gdalallregister.obj subdirs + +list: + echo $(DIRLIST) + +subdirs: + for %d in ( $(DIRLIST) ) do \ + cd %d \ + && nmake /NOLOGO /f makefile.vc \ + && cd .. + +o\gdalallregister.obj: gdalallregister.cpp ..\nmake.opt + $(CC) $(CFLAGS) $(MOREEXTRA) /c gdalallregister.cpp + copy gdalallregister.obj o + +clean: + -del o\*.obj *.obj + for %d in ( $(DIRLIST) ) do \ + cd %d \ + && nmake /NOLOGO /f makefile.vc clean \ + && cd .. + cd iso8211 + nmake /NOLOGO /f makefile.vc clean + + +html-install: + copy *.html $(HTMLDIR) + -for %d in ( $(DIRLIST) ) do \ + copy %d\frmt_*.html $(HTMLDIR) diff --git a/Utilities/GDAL/frmts/netcdf/GNUmakefile b/Utilities/GDAL/frmts/netcdf/GNUmakefile new file mode 100644 index 0000000000..dfdf0b4636 --- /dev/null +++ b/Utilities/GDAL/frmts/netcdf/GNUmakefile @@ -0,0 +1,13 @@ + +include ../../GDALmake.opt + +OBJ = netcdfdataset.o gmtdataset.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) $(XTRA_OPT) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + +install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/netcdf/gmtdataset.cpp b/Utilities/GDAL/frmts/netcdf/gmtdataset.cpp new file mode 100644 index 0000000000..a1701247dc --- /dev/null +++ b/Utilities/GDAL/frmts/netcdf/gmtdataset.cpp @@ -0,0 +1,599 @@ +/****************************************************************************** + * $Id: gmtdataset.cpp,v 1.3 2005/11/18 22:31:01 fwarmerdam Exp $ + * + * Project: netCDF read/write Driver + * Purpose: GDAL bindings over netCDF library for GMT Grids. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, 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: gmtdataset.cpp,v $ + * Revision 1.3 2005/11/18 22:31:01 fwarmerdam + * Fixed problem with add_offset=0 "pixel-is-point" datasets (bug 796). + * Added support for attaching scale and offset to band. + * + * Revision 1.2 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.1 2004/10/16 14:56:34 fwarmerdam + * split off GMT version as gmtdataset.cpp + * + */ + +#include "gdal_pam.h" +#include "gdal_frmts.h" +#include "netcdf.h" + +CPL_CVSID("$Id: gmtdataset.cpp,v 1.3 2005/11/18 22:31:01 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* GMTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class GMTRasterBand; + +class GMTDataset : public GDALPamDataset +{ + int z_id; + double adfGeoTransform[6]; + + public: + int cdfid; + + ~GMTDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + + CPLErr GetGeoTransform( double * padfTransform ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* GMTRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class GMTRasterBand : public GDALPamRasterBand +{ + nc_type nc_datatype; + int nZId; + + public: + + GMTRasterBand( GMTDataset *poDS, int nZId, int nBand ); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + + +/************************************************************************/ +/* GMTRasterBand() */ +/************************************************************************/ + +GMTRasterBand::GMTRasterBand( GMTDataset *poDS, int nZId, int nBand ) + +{ + this->poDS = poDS; + this->nBand = nBand; + this->nZId = nZId; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; + +/* -------------------------------------------------------------------- */ +/* Get the type of the "z" variable, our target raster array. */ +/* -------------------------------------------------------------------- */ + if( nc_inq_var( poDS->cdfid, nZId, NULL, &nc_datatype, NULL, NULL, + NULL ) != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Error in nc_var_inq() on 'z'." ); + return; + } + + if( nc_datatype == NC_BYTE ) + eDataType = GDT_Byte; + else if( nc_datatype == NC_SHORT ) + eDataType = GDT_Int16; + else if( nc_datatype == NC_INT ) + eDataType = GDT_Int32; + else if( nc_datatype == NC_FLOAT ) + eDataType = GDT_Float32; + else if( nc_datatype == NC_DOUBLE ) + eDataType = GDT_Float64; + else + { + if( nBand == 1 ) + CPLError( CE_Warning, CPLE_AppDefined, + "Unsupported GMT datatype (%d), treat as Float32.", + (int) nc_datatype ); + eDataType = GDT_Float32; + } +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr GMTRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + size_t start[2], edge[2]; + int nErr; + int cdfid = ((GMTDataset *) poDS)->cdfid; + + start[0] = nBlockYOff * nBlockXSize; + edge[0] = nBlockXSize; + + if( eDataType == GDT_Byte ) + nErr = nc_get_vara_uchar( cdfid, nZId, start, edge, + (unsigned char *) pImage ); + else if( eDataType == GDT_Int16 ) + nErr = nc_get_vara_short( cdfid, nZId, start, edge, + (short int *) pImage ); + else if( eDataType == GDT_Int32 ) + { + if( sizeof(long) == 4 ) + nErr = nc_get_vara_long( cdfid, nZId, start, edge, + (long *) pImage ); + else + nErr = nc_get_vara_int( cdfid, nZId, start, edge, + (int *) pImage ); + } + else if( eDataType == GDT_Float32 ) + nErr = nc_get_vara_float( cdfid, nZId, start, edge, + (float *) pImage ); + else if( eDataType == GDT_Float64 ) + nErr = nc_get_vara_double( cdfid, nZId, start, edge, + (double *) pImage ); + + if( nErr != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "GMT scanline fetch failed: %s", + nc_strerror( nErr ) ); + return CE_Failure; + } + else + return CE_None; +} + +/************************************************************************/ +/* ==================================================================== */ +/* GMTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* ~GMTDataset() */ +/************************************************************************/ + +GMTDataset::~GMTDataset() + +{ + FlushCache(); + nc_close (cdfid); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr GMTDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *GMTDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Does this file have the GMT magic number? */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 50 ) + return NULL; + + if( poOpenInfo->pabyHeader[0] != 'C' + || poOpenInfo->pabyHeader[1] != 'D' + || poOpenInfo->pabyHeader[2] != 'F' + || poOpenInfo->pabyHeader[3] != 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + int cdfid, nm_id, dim_count, z_id; + + if( nc_open( poOpenInfo->pszFilename, NC_NOWRITE, &cdfid ) != NC_NOERR ) + return NULL; + + if( nc_inq_varid( cdfid, "dimension", &nm_id ) != NC_NOERR + || nc_inq_varid( cdfid, "z", &z_id ) != NC_NOERR ) + { +#ifdef notdef + CPLError( CE_Warning, CPLE_AppDefined, + "%s is a GMT file, but not in GMT configuration.", + poOpenInfo->pszFilename ); +#endif + nc_close( cdfid ); + return NULL; + } + + if( nc_inq_ndims( cdfid, &dim_count ) != NC_NOERR || dim_count < 2 ) + { + nc_close( cdfid ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + GMTDataset *poDS; + + poDS = new GMTDataset(); + + poDS->cdfid = cdfid; + poDS->z_id = z_id; + +/* -------------------------------------------------------------------- */ +/* Get dimensions. If we can't find this, then this is a */ +/* GMT file, but not a normal grid product. */ +/* -------------------------------------------------------------------- */ + size_t start[2], edge[2]; + int nm[2]; + + start[0] = 0; + edge[0] = 2; + + nc_get_vara_int(cdfid, nm_id, start, edge, nm); + + poDS->nRasterXSize = nm[0]; + poDS->nRasterYSize = nm[1]; + +/* -------------------------------------------------------------------- */ +/* Fetch "z" attributes scale_factor, add_offset, and */ +/* node_offset. */ +/* -------------------------------------------------------------------- */ + double scale_factor=1.0, add_offset=0.0; + int node_offset = 1; + + nc_get_att_double( cdfid, z_id, "scale_factor", &scale_factor ); + nc_get_att_double( cdfid, z_id, "add_offset", &add_offset ); + nc_get_att_int( cdfid, z_id, "node_offset", &node_offset ); + +/* -------------------------------------------------------------------- */ +/* Get x/y range information. */ +/* -------------------------------------------------------------------- */ + int x_range_id, y_range_id; + + if( nc_inq_varid (cdfid, "x_range", &x_range_id) == NC_NOERR + && nc_inq_varid (cdfid, "y_range", &y_range_id) == NC_NOERR ) + { + double x_range[2], y_range[2]; + + nc_get_vara_double( cdfid, x_range_id, start, edge, x_range ); + nc_get_vara_double( cdfid, y_range_id, start, edge, y_range ); + + // Pixel is area + if( node_offset == 1 ) + { + poDS->adfGeoTransform[0] = x_range[0]; + poDS->adfGeoTransform[1] = + (x_range[1] - x_range[0]) / poDS->nRasterXSize; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = y_range[1]; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = + (y_range[0] - y_range[1]) / poDS->nRasterYSize; + } + + // Pixel is point - offset by half pixel. + else /* node_offset == 0 */ + { + poDS->adfGeoTransform[1] = + (x_range[1] - x_range[0]) / (poDS->nRasterXSize-1); + poDS->adfGeoTransform[0] = + x_range[0] - poDS->adfGeoTransform[1]*0.5; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = + (y_range[0] - y_range[1]) / (poDS->nRasterYSize-1); + poDS->adfGeoTransform[3] = + y_range[1] - poDS->adfGeoTransform[5]*0.5; + } + } + else + { + poDS->adfGeoTransform[0] = 0.0; + poDS->adfGeoTransform[1] = 1.0; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = 1.0; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = 1; + poDS->SetBand( 1, new GMTRasterBand( poDS, z_id, 1 )); + + if( scale_factor != 1.0 || add_offset != 0.0 ) + { + poDS->GetRasterBand(1)->SetOffset( add_offset ); + poDS->GetRasterBand(1)->SetScale( scale_factor ); + } + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GMTCreateCopy() */ +/* */ +/* This code mostly cribbed from GMT's "gmt_cdf.c" module. */ +/************************************************************************/ + +static GDALDataset * +GMTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ +/* -------------------------------------------------------------------- */ +/* Figure out general characteristics. */ +/* -------------------------------------------------------------------- */ + nc_type nc_datatype; + GDALRasterBand *poBand = poSrcDS->GetRasterBand(1); + int nXSize, nYSize; + + if( poSrcDS->GetRasterCount() != 1 || poBand == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Currently GMT export only supports 1 band datasets." ); + return NULL; + } + + nXSize = poSrcDS->GetRasterXSize(); + nYSize = poSrcDS->GetRasterYSize(); + + if( poBand->GetRasterDataType() == GDT_Int16 ) + nc_datatype = NC_SHORT; + else if( poBand->GetRasterDataType() == GDT_Int32 ) + nc_datatype = NC_INT; + else if( poBand->GetRasterDataType() == GDT_Float32 ) + nc_datatype = NC_FLOAT; + else if( poBand->GetRasterDataType() == GDT_Float64 ) + nc_datatype = NC_DOUBLE; + else if( bStrict ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Band data type %s not supported in GMT, giving up.", + GDALGetDataTypeName( poBand->GetRasterDataType() ) ); + return NULL; + } + else if( poBand->GetRasterDataType() == GDT_Byte ) + nc_datatype = NC_SHORT; + else if( poBand->GetRasterDataType() == GDT_UInt16 ) + nc_datatype = NC_INT; + else if( poBand->GetRasterDataType() == GDT_UInt32 ) + nc_datatype = NC_INT; + else + nc_datatype = NC_FLOAT; + +/* -------------------------------------------------------------------- */ +/* Establish bounds from geotransform. */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + double dfXMax, dfYMin; + + poSrcDS->GetGeoTransform( adfGeoTransform ); + + if( adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0 ) + { + CPLError( bStrict ? CE_Failure : CE_Warning, CPLE_AppDefined, + "Geotransform has rotational coefficients not supported in GMT." ); + if( bStrict ) + return NULL; + } + + dfXMax = adfGeoTransform[0] + adfGeoTransform[1] * nXSize; + dfYMin = adfGeoTransform[3] + adfGeoTransform[5] * nYSize; + +/* -------------------------------------------------------------------- */ +/* Create base file. */ +/* -------------------------------------------------------------------- */ + int cdfid, err; + + err = nc_create (pszFilename, NC_CLOBBER,&cdfid); + if( err != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "nc_create(%s): %s", + pszFilename, nc_strerror( err ) ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Define the dimensions and so forth. */ +/* -------------------------------------------------------------------- */ + int side_dim, xysize_dim, dims[1]; + int x_range_id, y_range_id, z_range_id, inc_id, nm_id, z_id; + + nc_def_dim(cdfid, "side", 2, &side_dim); + nc_def_dim(cdfid, "xysize", (int) (nXSize * nYSize), &xysize_dim); + + dims[0] = side_dim; + nc_def_var (cdfid, "x_range", NC_DOUBLE, 1, dims, &x_range_id); + nc_def_var (cdfid, "y_range", NC_DOUBLE, 1, dims, &y_range_id); + nc_def_var (cdfid, "z_range", NC_DOUBLE, 1, dims, &z_range_id); + nc_def_var (cdfid, "spacing", NC_DOUBLE, 1, dims, &inc_id); + nc_def_var (cdfid, "dimension", NC_LONG, 1, dims, &nm_id); + + dims[0] = xysize_dim; + nc_def_var (cdfid, "z", nc_datatype, 1, dims, &z_id); + +/* -------------------------------------------------------------------- */ +/* Assign attributes. */ +/* -------------------------------------------------------------------- */ + double default_scale = 1.0; + double default_offset = 0.0; + int default_node_offset = 0; + + nc_put_att_text (cdfid, x_range_id, "units", 7, "meters"); + nc_put_att_text (cdfid, y_range_id, "units", 7, "meters"); + nc_put_att_text (cdfid, z_range_id, "units", 7, "meters"); + + nc_put_att_double (cdfid, z_id, "scale_factor", NC_DOUBLE, 1, + &default_scale ); + nc_put_att_double (cdfid, z_id, "add_offset", NC_DOUBLE, 1, + &default_offset ); + + nc_put_att_int (cdfid, z_id, "node_offset", NC_LONG, 1, + &default_node_offset ); + nc_put_att_text (cdfid, NC_GLOBAL, "title", 1, ""); + nc_put_att_text (cdfid, NC_GLOBAL, "source", 1, ""); + + /* leave define mode */ + nc_enddef (cdfid); + +/* -------------------------------------------------------------------- */ +/* Get raster min/max. */ +/* -------------------------------------------------------------------- */ + double adfMinMax[2]; + GDALComputeRasterMinMax( (GDALRasterBandH) poBand, FALSE, adfMinMax ); + +/* -------------------------------------------------------------------- */ +/* Set range variables. */ +/* -------------------------------------------------------------------- */ + size_t start[2], edge[2]; + double dummy[2]; + int nm[2]; + + start[0] = 0; + edge[0] = 2; + dummy[0] = adfGeoTransform[0]; + dummy[1] = dfXMax; + nc_put_vara_double(cdfid, x_range_id, start, edge, dummy); + + dummy[0] = dfYMin; + dummy[1] = adfGeoTransform[3]; + nc_put_vara_double(cdfid, y_range_id, start, edge, dummy); + + dummy[0] = adfGeoTransform[1]; + dummy[1] = -adfGeoTransform[5]; + nc_put_vara_double(cdfid, inc_id, start, edge, dummy); + + nm[0] = nXSize; + nm[1] = nYSize; + nc_put_vara_int(cdfid, nm_id, start, edge, nm); + + nc_put_vara_double(cdfid, z_range_id, start, edge, adfMinMax); + +/* -------------------------------------------------------------------- */ +/* Write out the image one scanline at a time. */ +/* -------------------------------------------------------------------- */ + double *padfData; + int iLine; + + padfData = (double *) CPLMalloc( sizeof(double) * nXSize ); + + edge[0] = nXSize; + for( iLine = 0; iLine < nYSize; iLine++ ) + { + start[0] = iLine * nXSize; + poBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + padfData, nXSize, 1, GDT_Float64, 0, 0 ); + err = nc_put_vara_double( cdfid, z_id, start, edge, padfData ); + if( err != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "nc_put_vara_double(%s): %s", + pszFilename, nc_strerror( err ) ); + nc_close (cdfid); + return( NULL ); + } + } + + CPLFree( padfData ); + +/* -------------------------------------------------------------------- */ +/* Close file, and reopen. */ +/* -------------------------------------------------------------------- */ + nc_close (cdfid); + +/* -------------------------------------------------------------------- */ +/* Re-open dataset, and copy any auxilary pam information. */ +/* -------------------------------------------------------------------- */ + GDALPamDataset *poDS = (GDALPamDataset *) + GDALOpen( pszFilename, GA_ReadOnly ); + + if( poDS ) + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + +/************************************************************************/ +/* GDALRegister_GMT() */ +/************************************************************************/ + +void GDALRegister_GMT() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "GMT" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "GMT" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "GMT NetCDF Grid Format" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#GMT" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "nc" ); + + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Int16 Int32 Float32 Float64" ); + + poDriver->pfnOpen = GMTDataset::Open; + poDriver->pfnCreateCopy = GMTCreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/netcdf/makefile.vc b/Utilities/GDAL/frmts/netcdf/makefile.vc new file mode 100644 index 0000000000..232c84622b --- /dev/null +++ b/Utilities/GDAL/frmts/netcdf/makefile.vc @@ -0,0 +1,14 @@ + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +OBJ = netcdfdataset.obj gmtdataset.obj +EXTRAFLAGS = /I$(NETCDF_INC_DIR) + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/netcdf/netcdfdataset.cpp b/Utilities/GDAL/frmts/netcdf/netcdfdataset.cpp new file mode 100644 index 0000000000..c0c09db04b --- /dev/null +++ b/Utilities/GDAL/frmts/netcdf/netcdfdataset.cpp @@ -0,0 +1,2413 @@ +/****************************************************************************** + * $Id: netcdfdataset.cpp,v 1.23 2006/04/28 19:28:45 dnadeau Exp $ + * + * Project: netCDF read/write Driver + * Purpose: GDAL bindings over netCDF library. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, 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: netcdfdataset.cpp,v $ + * Revision 1.23 2006/04/28 19:28:45 dnadeau + * CreateCopy added. + * Generate CF compliant netCDF files. + * Generation on the fly of geolocation arrays. + * + * Revision 1.22 2006/04/10 20:25:21 dnadeau + * generalized identification of the X and Y; + * collaping all dimension + * other than X and Y into bands when reading; + * SUBDATASET mechanism for datasets having multiple geospatial data arrays; + * identify (via metadata) geolocation data + * + * Revision 1.21 2005/10/12 20:14:30 fwarmerdam + * Use SetMetadataItem() for bands. + * + * Revision 1.20 2005/08/29 16:26:41 hobu + * move the declaration up instead of having it + * inlined so it is easy to find + * + * Revision 1.19 2005/08/29 16:16:31 hobu + * according to msvc 7.1, var on line 1099 was already + * declared on line 946. removed the declaration and it + * builds fine now + * + * Revision 1.18 2005/08/27 19:46:59 dnadeau + * add rint function for Windows + * + * Revision 1.17 2005/08/26 22:37:22 dnadeau + * add WGS84 for lat/lon data + * + * Revision 1.16 2005/08/26 22:02:09 fwarmerdam + * Changed to use # instead of : as the separator between variable name + * and attribute name in metadata, since : is reserved. + * Set WGS84 as the GEOGCS for projected coordinate systems. + * Don't set WGS84 as a GEOGCS if we don't recognise the projection. + * + * Revision 1.15 2005/08/26 21:34:53 dnadeau + * support projections (UTM and LCC) + * + * Revision 1.14 2005/08/25 23:10:44 dnadeau + * add metadata for all bands + * + * Revision 1.13 2005/08/25 22:38:44 dnadeau + * add xdim and ydim as label for x and y dimension + * + * Revision 1.12 2005/08/19 20:07:55 dnadeau + * add netcdf band metadata info + * + * Revision 1.11 2005/08/18 17:00:31 dnadeau + * fix latitude/longitude variable name identification + * + * Revision 1.9 2005/08/17 21:43:16 dnadeau + * support CF convention and lat/long proj. + * + * Revision 1.8 2005/07/29 16:21:37 fwarmerdam + * use CPLIsNan, and float.h + * + * Revision 1.7 2005/07/29 02:33:32 dnadeau + * enhance netcdf to conform to CF convention. + * Allow multidimensionnal array and read metatdata + * + * Revision 1.6 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.5 2004/10/16 14:57:31 fwarmerdam + * Substantial rewrite by Radim to sometimes handle COARDS style datasets + * but really only under some circumstances. CreateCopy() removed since + * no COARDS implementation is available. + * + * Revision 1.4 2004/10/14 14:51:31 fwarmerdam + * Fixed last fix. + * + * Revision 1.3 2004/10/14 13:59:13 fwarmerdam + * Added error for non-GMT netCDF files. + * + * Revision 1.2 2004/01/07 21:02:19 warmerda + * fix up driver metadata + * + * Revision 1.1 2004/01/07 20:05:53 warmerda + * New + * + */ + +#include "netcdfdataset.h" + +CPL_CVSID("$Id: netcdfdataset.cpp,v 1.23 2006/04/28 19:28:45 dnadeau Exp $"); + + +/************************************************************************/ +/* ==================================================================== */ +/* netCDFRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class netCDFRasterBand : public GDALPamRasterBand +{ + nc_type nc_datatype; + int nZId; + int nZDim; + int nLevel; + int nBandXPos; + int nBandYPos; + int *panBandZPos; + int *panBandZLev; + int bNoDataSet; + double dfNoDataValue; + CPLErr CreateBandMetadata( ); + + public: + + netCDFRasterBand( netCDFDataset *poDS, + int nZId, + int nZDim, + int nLevel, + int *panBandZLen, + int *panBandPos, + int nBand ); + ~netCDFRasterBand( ); + virtual double GetNoDataValue( int * ); + virtual CPLErr SetNoDataValue( double ); + virtual CPLErr IReadBlock( int, int, void * ); + + +}; + +/************************************************************************/ +/* GetMetadata() */ +/************************************************************************/ +char **netCDFDataset::GetMetadata( const char *pszDomain ) +{ + if( pszDomain != NULL && EQUALN( pszDomain, "SUBDATASETS", 11 ) ) + return papszSubDatasets; + else + return GDALDataset::GetMetadata( pszDomain ); +} + + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char * netCDFDataset::GetProjectionRef() +{ + if( bGotGeoTransform ) + return pszProjection; + else + return ""; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double netCDFRasterBand::GetNoDataValue( int * pbSuccess ) + +{ + if( pbSuccess ) + *pbSuccess = bNoDataSet; + + return dfNoDataValue; +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr netCDFRasterBand::SetNoDataValue( double dfNoData ) + +{ + bNoDataSet = TRUE; + dfNoDataValue = dfNoData; + + return CE_None; +} + +/************************************************************************/ +/* ~netCDFRasterBand() */ +/************************************************************************/ + +netCDFRasterBand::~netCDFRasterBand() +{ + if( panBandZPos ) + CPLFree( panBandZPos ); + if( panBandZLev ) + CPLFree( panBandZLev ); +} + +/************************************************************************/ +/* CreateBandMetadata() */ +/************************************************************************/ + +CPLErr netCDFRasterBand::CreateBandMetadata( ) +{ + char szVarName[NC_MAX_NAME]; + char szMetaName[NC_MAX_NAME]; + char szMetaTemp[8192]; + int nd; + int i,j; + int Sum = 1; + int Taken = 0; + int result = 0; + int status; + int nVarID = -1; + int nDims; + size_t start[1]; + size_t count[1]; + char szTemp[NC_MAX_NAME]; + const char *pszValue; + + nc_type nVarType; + netCDFDataset *poDS; + + poDS = (netCDFDataset *) this->poDS; +/* -------------------------------------------------------------------- */ +/* Compute all dimensions from Band number and save in Metadata */ +/* -------------------------------------------------------------------- */ + nc_inq_varname( poDS->cdfid, nZId, szVarName ); + nc_inq_varndims( poDS->cdfid, nZId, &nd ); +/* -------------------------------------------------------------------- */ +/* Compute multidimention band position */ +/* */ +/* BandPosition = (Total - sum(PastBandLevels) - 1)/sum(remainingLevels)*/ +/* if Data[2,3,4,x,y] */ +/* */ +/* BandPos0 = (nBand ) / (3*4) */ +/* BandPos1 = (nBand - BandPos0*(3*4) ) / (4) */ +/* BandPos2 = (nBand - BandPos0*(3*4) ) % (4) */ +/* -------------------------------------------------------------------- */ + + sprintf( szMetaName,"NETCDF_VARNAME"); + sprintf( szMetaTemp,"%s",szVarName); + SetMetadataItem( szMetaName, szMetaTemp ); + if( nd == 3 ) { + Sum *= panBandZLev[0]; + } + + for( i=0; i < nd-2 ; i++ ) { + if( i != nd - 2 -1 ) { + for( j=i+1; j < nd-2; j++ ) { + Sum *= panBandZLev[j]; + } + result = (int) ( ( nLevel-Taken ) / Sum ); + } + else { + result = (int) ( ( nLevel-Taken ) % Sum ); + } + + strcpy(szVarName, poDS->papszDimName[poDS->paDimIds[ + panBandZPos[i]]] ); + + sprintf( szMetaName,"NETCDF_DIMENSION_%s", szVarName ); + + status=nc_inq_varid(poDS->cdfid, + szVarName, + &nVarID ); + +/* -------------------------------------------------------------------- */ +/* Try to uppercase the first letter of the variable */ +/* -------------------------------------------------------------------- */ + + if( status != NC_NOERR ) { + szVarName[0]=toupper(szVarName[0]); + status=nc_inq_varid(poDS->cdfid, + szVarName, + &nVarID ); + } + + status = nc_inq_vartype( poDS->cdfid, nVarID, &nVarType ); + + nDims = 0; + status = nc_inq_varndims( poDS->cdfid, nVarID, &nDims ); + + if( nDims == 1 ) { + count[0]=1; + start[0]=result; + switch( nVarType ) { + case NC_SHORT: + short sData; + status = nc_get_vara_short( poDS->cdfid, nVarID, + start, + count, &sData ); + sprintf( szMetaTemp,"%d", sData ); + break; + case NC_INT: + int nData; + status = nc_get_vara_int( poDS->cdfid, nVarID, + start, + count, &nData ); + sprintf( szMetaTemp,"%d", nData ); + break; + case NC_FLOAT: + float fData; + status = nc_get_vara_float( poDS->cdfid, nVarID, + start, + count, &fData ); + sprintf( szMetaTemp,"%f", fData ); + break; + case NC_DOUBLE: + double dfData; + status = nc_get_vara_double( poDS->cdfid, nVarID, + start, + count, &dfData); + sprintf( szMetaTemp,"%g", dfData ); + break; + default: + break; + } + } + else + sprintf( szMetaTemp,"%d", result+1); + + SetMetadataItem( szMetaName, szMetaTemp ); + +/* -------------------------------------------------------------------- */ +/* Fetch dimension units */ +/* -------------------------------------------------------------------- */ + + strcpy( szTemp, szVarName ); + strcat( szTemp, "#units" ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue != NULL ) { + if( EQUAL( pszValue, "T") ) { + strcpy( szTemp, szVarName ); + strcat( szTemp, "#original_units" ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + strcpy( szTemp, "NETCDF_"); + strcat( szTemp, szVarName ); + strcat( szTemp, "_original_units" ); + SetMetadataItem( szTemp, pszValue ); + } + else { + strcpy( szTemp, "NETCDF_"); + strcat( szTemp, szVarName ); + strcat( szTemp, "_units" ); + SetMetadataItem( szTemp, pszValue ); + } + } + Taken += result * Sum; + } + + + + return CE_None; +} + +/************************************************************************/ +/* netCDFRasterBand() */ +/************************************************************************/ + +netCDFRasterBand::netCDFRasterBand( netCDFDataset *poDS, + int nZId, + int nZDim, + int nLevel, + int *panBandZLev, + int *panBandDimPos, + int nBand) + +{ + double dfNoData; + int bNoDataSet = FALSE; + nc_type vartype=NC_NAT; + nc_type atttype=NC_NAT; + size_t attlen; + int status; + char szNoValueName[8192]; + + + this->panBandZPos = NULL; + this->panBandZLev = NULL; + this->poDS = poDS; + this->nBand = nBand; + this->nZId = nZId; + this->nZDim = nZDim; + this->nLevel = nLevel; + this->nBandXPos = panBandDimPos[0]; + this->nBandYPos = panBandDimPos[1]; + +/* -------------------------------------------------------------------- */ +/* Take care of all other dimmensions */ +/* ------------------------------------------------------------------ */ + if( nZDim > 2 ) { + this->panBandZPos = + (int *) CPLCalloc( nZDim-2, sizeof( int ) ); + this->panBandZLev = + (int *) CPLCalloc( nZDim-2, sizeof( int ) ); + + for ( int i=0; i < nZDim - 2; i++ ){ + this->panBandZPos[i] = panBandDimPos[i+2]; + this->panBandZLev[i] = panBandZLev[i]; + } + } + CreateBandMetadata(); + bNoDataSet = FALSE; + dfNoDataValue = -9999.0; + + nBlockXSize = poDS->GetRasterXSize( ); + nBlockYSize = 1; + +/* -------------------------------------------------------------------- */ +/* Get the type of the "z" variable, our target raster array. */ +/* -------------------------------------------------------------------- */ + if( nc_inq_var( poDS->cdfid, nZId, NULL, &nc_datatype, NULL, NULL, + NULL ) != NC_NOERR ){ + CPLError( CE_Failure, CPLE_AppDefined, + "Error in nc_var_inq() on 'z'." ); + return; + } + + if( nc_datatype == NC_BYTE ) + eDataType = GDT_Byte; + else if( nc_datatype == NC_SHORT ) + eDataType = GDT_Int16; + else if( nc_datatype == NC_INT ) + eDataType = GDT_Int32; + else if( nc_datatype == NC_FLOAT ) + eDataType = GDT_Float32; + else if( nc_datatype == NC_DOUBLE ) + eDataType = GDT_Float64; + else + { + if( nBand == 1 ) + CPLError( CE_Warning, CPLE_AppDefined, + "Unsupported netCDF datatype (%d), treat as Float32.", + (int) nc_datatype ); + eDataType = GDT_Float32; + } +/* -------------------------------------------------------------------- */ +/* Find out what is No Data for this variable */ +/* -------------------------------------------------------------------- */ + + status = nc_inq_att( poDS->cdfid, nZId, + _FillValue, &atttype, &attlen); + +/* -------------------------------------------------------------------- */ +/* Look for either Missing_Value or _FillValue attributes */ +/* -------------------------------------------------------------------- */ + + if( status == NC_NOERR ) { + strcpy(szNoValueName, _FillValue ); + } + else { + status = nc_inq_att( poDS->cdfid, nZId, + "missing_value", &atttype, &attlen ); + if( status == NC_NOERR ) { + + strcpy( szNoValueName, "missing_value" ); + } + } + + nc_inq_vartype( poDS->cdfid, nZId, &vartype ); + + if( status == NC_NOERR ) { + switch( atttype ) { + case NC_CHAR: + char *fillc; + fillc = (char *) CPLCalloc( attlen+1, sizeof(char) ); + status=nc_get_att_text( poDS->cdfid, nZId, + szNoValueName, fillc ); + dfNoData = atof( fillc ); + CPLFree(fillc); + break; + case NC_SHORT: + short sNoData; + status = nc_get_att_short( poDS->cdfid, nZId, + szNoValueName, &sNoData ); + dfNoData = (double) sNoData; + break; + case NC_INT: + int nNoData; + status = nc_get_att_int( poDS->cdfid, nZId, + szNoValueName, &nNoData ); + dfNoData = (double) nNoData; + break; + case NC_FLOAT: + float fNoData; + status = nc_get_att_float( poDS->cdfid, nZId, + szNoValueName, &fNoData ); + dfNoData = (double) fNoData; + break; + case NC_DOUBLE: + status = nc_get_att_double( poDS->cdfid, nZId, + szNoValueName, &dfNoData ); + break; + default: + break; + } + status = nc_get_att_double( poDS->cdfid, nZId, + szNoValueName, &dfNoData ); + + } else { + switch( vartype ) { + case NC_BYTE: + /* don't do default fill-values for bytes, too risky */ + dfNoData = 0.0; + break; + case NC_CHAR: + dfNoData = NC_FILL_CHAR; + break; + case NC_SHORT: + dfNoData = NC_FILL_SHORT; + break; + case NC_INT: + dfNoData = NC_FILL_INT; + break; + case NC_FLOAT: + dfNoData = NC_FILL_FLOAT; + break; + case NC_DOUBLE: + dfNoData = NC_FILL_DOUBLE; + break; + default: + dfNoData = 0.0; + break; + } + bNoDataSet = TRUE; + } + SetNoDataValue( dfNoData ); + +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr netCDFRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int nErr; + int cdfid = ( ( netCDFDataset * ) poDS )->cdfid; + size_t start[ MAX_NC_DIMS ]; + size_t edge[ MAX_NC_DIMS ]; + char pszName[ MAX_STR_LEN ]; + int i,j; + int Sum,Taken; + int nd; + + *pszName='\0'; + memset( start, 0, sizeof( start ) ); + memset( edge, 0, sizeof( edge ) ); + nc_inq_varndims ( cdfid, nZId, &nd ); + +/* -------------------------------------------------------------------- */ +/* Locate X, Y and Z position in the array */ +/* -------------------------------------------------------------------- */ + + start[nBandXPos] = 0; // x dim can move arround in array + start[nBandYPos] = nBlockYOff; // y + + edge[nBandXPos] = nBlockXSize; + edge[nBandYPos] = 1; + + if( nd == 3 ) { + start[panBandZPos[0]] = nLevel; // z + edge [panBandZPos[0]] = 1; + } + +/* -------------------------------------------------------------------- */ +/* Compute multidimention band position */ +/* */ +/* BandPosition = (Total - sum(PastBandLevels) - 1)/sum(remainingLevels)*/ +/* if Data[2,3,4,x,y] */ +/* */ +/* BandPos0 = (nBand ) / (3*4) */ +/* BandPos1 = (nBand - (3*4) ) / (4) */ +/* BandPos2 = (nBand - (3*4) ) % (4) */ +/* -------------------------------------------------------------------- */ + if( nd > 3 ) { + for( i=0; i < nd-2-1 ; i++ ) { + Sum = 1; + Taken = 0; + for( j=i+1; j < nd-2; j++ ) { + Sum *= panBandZLev[j]; + } + start[panBandZPos[i]] = ( nLevel-Taken ) / Sum; + edge[panBandZPos[i]] = 1; + Taken += Sum; + } + start[panBandZPos[i]] = ( nLevel-( Taken-Sum ) ) % Sum; + edge[panBandZPos[i]] = 1; + } + + + + if( eDataType == GDT_Byte ) + nErr = nc_get_vara_uchar( cdfid, nZId, start, edge, + (unsigned char *) pImage ); + else if( eDataType == GDT_Int16 ) + nErr = nc_get_vara_short( cdfid, nZId, start, edge, + (short int *) pImage ); + else if( eDataType == GDT_Int32 ) + { + if( sizeof(long) == 4 ) + nErr = nc_get_vara_long( cdfid, nZId, start, edge, + (long *) pImage ); + else + nErr = nc_get_vara_int( cdfid, nZId, start, edge, + (int *) pImage ); + } + else if( eDataType == GDT_Float32 ){ + nErr = nc_get_vara_float( cdfid, nZId, start, edge, + (float *) pImage ); + for( i=0; i<nBlockXSize; i++ ){ + if( CPLIsNan( ( (float *) pImage )[i] ) ) + ( (float *)pImage )[i] = dfNoDataValue; + } + } + else if( eDataType == GDT_Float64 ){ + nErr = nc_get_vara_double( cdfid, nZId, start, edge, + (double *) pImage ); + for( i=0; i<nBlockXSize; i++ ){ + if( CPLIsNan( ( (double *) pImage)[i] ) ) + ( (double *)pImage )[i] = dfNoDataValue; + } + + } + + if( nErr != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "netCDF scanline fetch failed: %s", + nc_strerror( nErr ) ); + return CE_Failure; + } + else + return CE_None; +} + +/************************************************************************/ +/* ==================================================================== */ +/* netCDFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* netCDFDataset() */ +/************************************************************************/ + +netCDFDataset::netCDFDataset() + +{ + papszMetadata = NULL; + papszGeolocation = NULL; + papszSubDatasets = NULL; + bGotGeoTransform = FALSE; + pszProjection = NULL; + papszName = NULL; + pszFilename = NULL; + cdfid = 0; +} + + +/************************************************************************/ +/* ~netCDFDataset() */ +/************************************************************************/ + +netCDFDataset::~netCDFDataset() + +{ + + FlushCache(); + + if( papszMetadata != NULL ) + CSLDestroy( papszMetadata ); + + if( pszProjection != NULL ) + CPLFree( pszProjection ); + + if( papszName != NULL ) + CSLDestroy( papszName ); + + if( pszFilename != NULL ) + CPLFree( pszFilename ); + + if( papszSubDatasets ) + CSLDestroy( papszSubDatasets ); + + if( papszGeolocation ) + CSLDestroy( papszGeolocation ); + + if( cdfid ) + nc_close( cdfid ); + + +} + + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ +void netCDFDataset::SetProjection( int var ) +{ +/* -------------------------------------------------------------------- */ +/* Set Projection */ +/* -------------------------------------------------------------------- */ + + size_t start[2], edge[2]; + int status; + unsigned int i; + const char *pszValue; + int nVarProjectionID; + char szVarName[ MAX_NC_NAME ]; + char szTemp[ MAX_NC_NAME ]; + char szGridMappingName[ MAX_NC_NAME ]; + char szGridMappingValue[ MAX_NC_NAME ]; + + double dfStdP1; + double dfStdP2; + double dfCenterLat; + double dfCenterLon; + double dfScale; + double dfFalseEasting; + double dfFalseNorthing; + + OGRSpatialReference oSRS; + int nVarDimXID = -1; + int nVarDimYID = -1; + double *pdfXCoord; + double *pdfYCoord; + char szDimNameX[ MAX_NC_NAME ]; + int nSpacingBegin; + int nSpacingMiddle; + int nSpacingLast; + + const char *pszWKT; + const char *pszGeoTransform; + char **papszGeoTransform; + + + netCDFDataset * poDS; + poDS = this; + +/* -------------------------------------------------------------------- */ +/* Get x/y range information. */ +/* -------------------------------------------------------------------- */ + + poDS->adfGeoTransform[0] = 0.0; + poDS->adfGeoTransform[1] = 1.0; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = 1.0; + poDS->pszProjection = NULL; + + +/* -------------------------------------------------------------------- */ +/* Look for grid_mapping metadata */ +/* -------------------------------------------------------------------- */ + + strcpy( szGridMappingValue, "" ); + strcpy( szGridMappingName, "" ); + + nc_inq_varname( cdfid, var, szVarName ); + strcpy(szTemp,szVarName); + strcat(szTemp,"#grid_mapping"); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue ) { + strcpy(szGridMappingName,szTemp); + strcpy(szGridMappingValue,pszValue); + } + +/* -------------------------------------------------------------------- */ +/* Look for dimension: lon */ +/* -------------------------------------------------------------------- */ + + for( i = 0; (i < strlen( poDS->papszDimName[ poDS->nDimXid ] ) && + i < 3 ); i++ ) { + szDimNameX[i] = tolower( ( poDS->papszDimName[poDS->nDimXid] )[i] ); + } + szDimNameX[3] = '\0'; + +/* -------------------------------------------------------------------- */ +/* Read grid_mappinginformation and set projections */ +/* -------------------------------------------------------------------- */ + + if( !( EQUAL(szGridMappingName,"" ) ) ) { + nc_inq_varid( cdfid, szGridMappingValue, &nVarProjectionID ); + poDS->ReadAttributes( cdfid, nVarProjectionID ); + + strcpy( szTemp, szGridMappingValue ); + strcat( szTemp, "#" ); + strcat( szTemp, GRD_MAPPING_NAME ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + "grid_mapping", + pszValue); + if( pszValue != NULL ) { +/* -------------------------------------------------------------------- */ +/* Transverse Mercator */ +/* -------------------------------------------------------------------- */ + + if( EQUAL( pszValue, TM ) ) { + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, SCALE_FACTOR ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + SCALE_FACTOR, + pszValue); + if( pszValue ) + dfScale = atof( pszValue ); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, LONG_CENTRAL_MERIDIAN ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + LONG_CENTRAL_MERIDIAN, + pszValue); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue ) + dfCenterLon = atof( pszValue ); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, LAT_PROJ_ORIGIN ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + LAT_PROJ_ORIGIN, + pszValue); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue ) + dfCenterLat = atof( pszValue ); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, FALSE_EASTING ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + FALSE_EASTING, + pszValue); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue ) + dfFalseEasting = atof( pszValue ); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, FALSE_NORTHING ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + FALSE_NORTHING, + pszValue); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + if( pszValue ) + dfFalseNorthing = atof (pszValue); + + oSRS.SetTM( dfCenterLat, + dfCenterLon, + dfScale, + dfFalseEasting, + dfFalseNorthing ); + oSRS.SetWellKnownGeogCS( "WGS84" ); + } +/* -------------------------------------------------------------------- */ +/* Lambert conformal conic */ +/* -------------------------------------------------------------------- */ + else if( EQUAL( pszValue, L_C_CONIC ) ) { + + strcpy( szTemp,szGridMappingValue ); + strcat( szTemp, "#" ); + strcat( szTemp, STD_PARALLEL_1 ); + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + STD_PARALLEL_1, + pszValue); + + + if( pszValue ) { + dfStdP1 = atof( pszValue ); + } + + strcpy( szTemp,szGridMappingValue ); + strcat( szTemp, "#" ); + strcat( szTemp, STD_PARALLEL_1 ); + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + papszGeolocation = CSLSetNameValue( papszGeolocation, + STD_PARALLEL_2, + pszValue); + + if( pszValue ) { + dfStdP2 = atof( pszValue ); + } + + strcpy( szTemp,szGridMappingValue ); + strcat( szTemp, "#" ); + strcat( szTemp, LONG_CENTRAL_MERIDIAN ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + LONG_CENTRAL_MERIDIAN, + pszValue); + + if( pszValue ) + dfCenterLon = atof(pszValue); + + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, LAT_PROJ_ORIGIN ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + LAT_PROJ_ORIGIN, + pszValue); + + if( pszValue ) + dfCenterLat = atof(pszValue); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, FALSE_EASTING ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + FALSE_EASTING, + pszValue); + + if( pszValue ) + dfFalseEasting = atof(pszValue); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, FALSE_NORTHING ); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + papszGeolocation = CSLSetNameValue( papszGeolocation, + FALSE_NORTHING, + pszValue); + + if( pszValue ) + dfFalseNorthing = atof(pszValue); + + oSRS.SetLCC( dfStdP1, dfStdP2, dfCenterLat, dfCenterLon, + dfFalseEasting, dfFalseNorthing ); + oSRS.SetWellKnownGeogCS( "WGS84" ); + + } +/* -------------------------------------------------------------------- */ +/* Is this Latitude/Longitude Grid */ +/* -------------------------------------------------------------------- */ + + } else if( EQUAL( szDimNameX,"lon" ) ) { + papszGeolocation = CSLSetNameValue( papszGeolocation, + "grid_mapping", + "Latitude Longitude" ); + + strcpy( szTemp, poDS->papszDimName[nDimXid] ); + strcat( szTemp, "#" ); + strcat( szTemp, UNITS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lon_"); + strcat( szTemp, UNITS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + strcpy(szTemp, poDS->papszDimName[nDimXid]); + strcat(szTemp, "#" ); + strcat(szTemp, AXIS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lon_"); + strcat( szTemp, AXIS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + strcpy(szTemp, poDS->papszDimName[nDimXid]); + strcat(szTemp, "#" ); + strcat(szTemp, BOUNDS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lon_"); + strcat( szTemp, BOUNDS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + strcpy(szTemp, poDS->papszDimName[nDimXid]); + strcat(szTemp, "#" ); + strcat(szTemp, ORIG_AXIS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lon_"); + strcat( szTemp, ORIG_AXIS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + + strcpy( szTemp, poDS->papszDimName[nDimYid] ); + strcat( szTemp, "#" ); + strcat( szTemp, UNITS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lat_"); + strcat( szTemp, UNITS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + strcpy(szTemp, poDS->papszDimName[nDimYid]); + strcat(szTemp, "#" ); + strcat(szTemp, AXIS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lat_"); + strcat( szTemp, AXIS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + strcpy(szTemp, poDS->papszDimName[nDimYid]); + strcat(szTemp, "#" ); + strcat(szTemp, BOUNDS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lat_"); + strcat( szTemp, BOUNDS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue) +; + strcpy(szTemp, poDS->papszDimName[nDimYid]); + strcat(szTemp, "#" ); + strcat(szTemp, ORIG_AXIS ); + + pszValue = CSLFetchNameValue( poDS->papszMetadata, szTemp ); + + strcpy( szTemp, "Lat_"); + strcat( szTemp, ORIG_AXIS ); + + papszGeolocation = CSLSetNameValue( papszGeolocation, + szTemp, + pszValue); + + + + oSRS.SetWellKnownGeogCS( "WGS84" ); + } else { + // This would be too indiscrimant. But we should set + // it if we know the data is geographic. + //oSRS.SetWellKnownGeogCS( "WGS84" ); + } + } +/* -------------------------------------------------------------------- */ +/* Read projection coordinates */ +/* -------------------------------------------------------------------- */ + + nc_inq_varid( cdfid, poDS->papszDimName[nDimXid], &nVarDimXID ); + nc_inq_varid( cdfid, poDS->papszDimName[nDimYid], &nVarDimYID ); + + if( ( nVarDimXID != -1 ) && ( nVarDimYID != -1 ) ) { + pdfXCoord = (double *) CPLCalloc( xdim, sizeof(double) ); + pdfYCoord = (double *) CPLCalloc( ydim, sizeof(double) ); + + start[0] = 0; + edge[0] = xdim; + + status = nc_get_vara_double( cdfid, nVarDimXID, + start, edge, pdfXCoord); + edge[0] = ydim; + status = nc_get_vara_double( cdfid, nVarDimYID, + start, edge, pdfYCoord); + +/* -------------------------------------------------------------------- */ +/* Is pixel spacing is uniform accross the map? */ +/* -------------------------------------------------------------------- */ + nSpacingBegin = (int) poDS->rint((pdfXCoord[1]-pdfXCoord[0]) * 1000); + + nSpacingMiddle = (int) poDS->rint((pdfXCoord[xdim / 2] - + pdfXCoord[(xdim / 2) + 1]) * 1000); + + nSpacingLast = (int) poDS->rint((pdfXCoord[xdim - 2] - + pdfXCoord[xdim-1]) * 1000); + + if( ( abs( nSpacingBegin ) == abs( nSpacingLast )) && + ( abs( nSpacingBegin ) == abs( nSpacingMiddle )) && + ( abs( nSpacingMiddle ) == abs( nSpacingLast )) ) { + +/* -------------------------------------------------------------------- */ +/* Enable GeoTransform */ +/* -------------------------------------------------------------------- */ + poDS->bGotGeoTransform = TRUE; + + poDS->adfGeoTransform[0] = pdfXCoord[0]; + poDS->adfGeoTransform[3] = pdfYCoord[0]; + poDS->adfGeoTransform[2] = 0; + poDS->adfGeoTransform[4] = 0; + poDS->adfGeoTransform[1] = (( pdfXCoord[xdim-1] - pdfXCoord[0] ) / + poDS->nRasterXSize); + poDS->adfGeoTransform[5] = (( pdfYCoord[ydim-1] - pdfYCoord[0] ) / + poDS->nRasterYSize); + oSRS.exportToWkt( &(poDS->pszProjection) ); + + } + CPLFree( pdfXCoord ); + CPLFree( pdfYCoord ); + + } + + +/* -------------------------------------------------------------------- */ +/* Is this a netCDF file created by GDAL? */ +/* -------------------------------------------------------------------- */ + if( !EQUAL( szGridMappingValue, "" ) ) { + strcpy( szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "spatial_ref"); + pszWKT = CSLFetchNameValue(poDS->papszMetadata, szTemp); + + if( pszWKT != NULL ) { + + pszProjection = strdup( pszWKT ); + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "GeoTransform"); + + pszGeoTransform = CSLFetchNameValue(poDS->papszMetadata, szTemp); + +/* -------------------------------------------------------------------- */ +/* Look for GeoTransform Array */ +/* -------------------------------------------------------------------- */ + + if( pszGeoTransform != NULL ) { + papszGeoTransform = CSLTokenizeString2( pszGeoTransform, + " ", + CSLT_HONOURSTRINGS ); + poDS->bGotGeoTransform = TRUE; + + poDS->adfGeoTransform[0] = atof( papszGeoTransform[0] ); + poDS->adfGeoTransform[1] = atof( papszGeoTransform[1] ); + poDS->adfGeoTransform[2] = atof( papszGeoTransform[2] ); + poDS->adfGeoTransform[3] = atof( papszGeoTransform[3] ); + poDS->adfGeoTransform[4] = atof( papszGeoTransform[4] ); + poDS->adfGeoTransform[5] = atof( papszGeoTransform[5] ); +/* -------------------------------------------------------------------- */ +/* Look for corner array values */ +/* -------------------------------------------------------------------- */ + } else { + double dfNN, dfSN, dfEE, dfWE; + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "Northernmost_Northing"); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + + if( pszValue != NULL ) { + dfNN = atof( pszValue ); + } + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "Southernmost_Northing"); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + + if( pszValue != NULL ) { + dfSN = atof( pszValue ); + } + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "Easternmost_Easting"); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + + if( pszValue != NULL ) { + dfEE = atof( pszValue ); + } + + strcpy(szTemp,szGridMappingValue); + strcat( szTemp, "#" ); + strcat( szTemp, "Westernmost_Easting"); + pszValue = CSLFetchNameValue(poDS->papszMetadata, szTemp); + + if( pszValue != NULL ) { + dfWE = atof( pszValue ); + } + + adfGeoTransform[0] = dfWE; + adfGeoTransform[1] = (dfEE - dfWE) / poDS->GetRasterXSize(); + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = dfNN; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = (dfSN - dfNN) / poDS->GetRasterYSize(); + + bGotGeoTransform = TRUE; + } + CSLDestroy( papszGeoTransform ); + + } + } + +} +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr netCDFDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + if( bGotGeoTransform ) + return CE_None; + else + return CE_Failure; +} + +double netCDFDataset::rint( double dfX) +{ + if( dfX > 0 ) { + int nX = (int) (dfX+0.5); + if( nX % 2 ) { + double dfDiff = dfX - (double)nX; + if( dfDiff == -0.5 ) + return double( nX-1 ); + } + return double( nX ); + } else { + int nX= (int) (dfX-0.5); + if( nX % 2 ) { + double dfDiff = dfX - (double)nX; + if( dfDiff == 0.5 ) + return double(nX+1); + } + return double(nX); + } +} + +/************************************************************************/ +/* ReadAttributes() */ +/************************************************************************/ + +CPLErr netCDFDataset::ReadAttributes( int cdfid, int var) + +{ + char szAttrName[ NC_MAX_NAME ]; + char szVarName [ NC_MAX_NAME ]; + char szMetaName[ NC_MAX_NAME ]; + char szMetaTemp[ MAX_STR_LEN ]; + nc_type nAttrType; + size_t nAttrLen,m; + int nbAttr; + char szTemp[ NC_MAX_NAME ]; + + nc_inq_varnatts( cdfid, var, &nbAttr ); + if( var == NC_GLOBAL ) { + strcpy( szVarName,"NC_GLOBAL" ); + } + else { + nc_inq_varname( cdfid, var, szVarName ); + } + + for( int l=0; l < nbAttr; l++){ + + nc_inq_attname( cdfid, var, l, szAttrName); + sprintf( szMetaName, "%s#%s", szVarName, szAttrName ); + *szMetaTemp='\0'; + nc_inq_att( cdfid, var, szAttrName, &nAttrType, &nAttrLen ); + + + switch (nAttrType) { + case NC_CHAR: + char *pszTemp; + pszTemp = (char *) CPLCalloc( nAttrLen+1, sizeof( char ) ); + nc_get_att_text( cdfid, var, szAttrName,pszTemp ); + pszTemp[nAttrLen]='\0'; + strcpy(szMetaTemp,pszTemp); + CPLFree(pszTemp); + break; + case NC_SHORT: + short *psTemp; + + psTemp = (short *) CPLCalloc( nAttrLen, sizeof( short ) ); + nc_get_att_short( cdfid, var, szAttrName, psTemp ); + for(m=0; m < nAttrLen-1; m++) { + sprintf( szTemp, "%d, ",psTemp[m] ); + strcat(szMetaTemp,szTemp); + } + sprintf( szTemp, "%d",psTemp[m] ); + CPLFree(psTemp); + strcat(szMetaTemp,szTemp); + + break; + case NC_INT: + int *pnTemp; + + pnTemp = (int *) CPLCalloc( nAttrLen, sizeof( int ) ); + nc_get_att_int( cdfid, var, szAttrName, pnTemp ); + for(m=0; m < nAttrLen-1; m++) { + sprintf( szTemp, "%d",pnTemp[m] ); + strcat(szMetaTemp,szTemp); + } + sprintf( szTemp, "%d",pnTemp[m] ); + CPLFree(pnTemp); + strcat(szMetaTemp,szTemp); + break; + case NC_FLOAT: + float *pfTemp; + pfTemp = (float *) CPLCalloc( nAttrLen, sizeof( float ) ); + nc_get_att_float( cdfid, var, szAttrName, pfTemp ); + for(m=0; m < nAttrLen-1; m++) { + sprintf( szTemp, "%e",pfTemp[m] ); + strcat(szMetaTemp,szTemp); + } + sprintf( szTemp, "%e",pfTemp[m] ); + CPLFree(pfTemp); + strcat(szMetaTemp,szTemp); + + break; + case NC_DOUBLE: + double *pdfTemp; + pdfTemp = (double *) CPLCalloc(nAttrLen, sizeof(double)); + nc_get_att_double( cdfid, var, szAttrName, pdfTemp ); + for(m=0; m < nAttrLen-1; m++) { + sprintf( szTemp, "%g",pdfTemp[m] ); + strcat(szMetaTemp,szTemp); + } + sprintf( szTemp, "%g",pdfTemp[m] ); + CPLFree(pdfTemp); + strcat(szMetaTemp,szTemp); + + break; + default: + break; + } + + papszMetadata = CSLSetNameValue(papszMetadata, + szMetaName, + szMetaTemp); + + } + + + return CE_None; + +} + +/************************************************************************/ +/* netCDFDataset::CreateSubDatasetList() */ +/************************************************************************/ +void netCDFDataset::CreateSubDatasetList( ) +{ + + char szDim[ MAX_NC_NAME ]; + char szTemp[ MAX_NC_NAME ]; + char szType[ MAX_NC_NAME ]; + char szName[ MAX_NC_NAME ]; + char szVarStdName[ MAX_NC_NAME ]; + int nDims; + int nVar; + int nVarCount; + int i; + nc_type nVarType; + int *ponDimIds; + size_t nDimLen; + int nSub; + nc_type nAttype; + size_t nAttlen; + + netCDFDataset *poDS; + poDS = this; + + nSub=1; + nc_inq_nvars ( cdfid, &nVarCount ); + for ( nVar = 0; nVar < nVarCount; nVar++ ) { + + nc_inq_varndims ( cdfid, nVar, &nDims ); + if( nDims >= 2 ) { + ponDimIds = (int *) CPLCalloc( nDims, sizeof( int ) ); + nc_inq_vardimid ( cdfid, nVar, ponDimIds ); + +/* -------------------------------------------------------------------- */ +/* Create Sub dataset list */ +/* -------------------------------------------------------------------- */ + szDim[0]='\0'; + for( i = 0; i < nDims; i++ ) { + nc_inq_dimlen ( cdfid, ponDimIds[i], &nDimLen ); + sprintf(szTemp, "%d", nDimLen); + strcat(szTemp, "x" ); + strcat(szDim, szTemp); + } + + nc_inq_vartype( cdfid, nVar, &nVarType ); +/* -------------------------------------------------------------------- */ +/* Get rid of the last "x" character */ +/* -------------------------------------------------------------------- */ + szDim[strlen(szDim) - 1] = '\0'; + + switch( nVarType ) { + case NC_BYTE: + strcpy(szType, "8-bit character"); + break; + case NC_SHORT: + strcpy(szType, "8-bit integer"); + break; + case NC_INT: + strcpy(szType, "16-bit integer"); + break; + case NC_FLOAT: + strcpy(szType, "32-bit floating-point"); + break; + case NC_DOUBLE: + strcpy(szType, "64-bit floating-point"); + break; + default: + break; + } + nc_inq_varname ( cdfid, nVar, szName); + nc_inq_att( cdfid, nVar, "standard_name", &nAttype, &nAttlen); + if( nc_get_att_text ( cdfid, nVar, "standard_name", + szVarStdName ) == NC_NOERR ) { + szVarStdName[nAttlen] = '\0'; + } + else { + strcpy( szVarStdName, szName ); + } + + sprintf( szTemp, "SUBDATASET_%d_NAME", nSub) ; + + poDS->papszSubDatasets = + CSLSetNameValue( poDS->papszSubDatasets, szTemp, + CPLSPrintf( "NETCDF:\"%s\":%s", + poDS->pszFilename, + szName) ) ; + + sprintf( szTemp, "SUBDATASET_%d_DESC", nSub++ ); + + poDS->papszSubDatasets = + CSLSetNameValue( poDS->papszSubDatasets, szTemp, + CPLSPrintf( "[%s] %s (%s)", + szDim, + szVarStdName, + szType ) ); + CPLFree(ponDimIds); + } + } + +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int j; + unsigned int k; + int nd; + int cdfid, dim_count, var, var_count; + int i = 0; + size_t lev_count; + size_t nTotLevCount = 1; + int nDim = 2; + int status; + int nDimID; + char attname[NC_MAX_NAME]; + int ndims, nvars, ngatts, unlimdimid; + + +/* -------------------------------------------------------------------- */ +/* Check if filename start with NETCDF: tag */ +/* -------------------------------------------------------------------- */ + + netCDFDataset *poDS; + poDS = new netCDFDataset(); + + poDS->papszName = CSLTokenizeString2( poOpenInfo->pszFilename, + ":", CSLT_HONOURSTRINGS ); + + if( EQUAL( poDS->papszName[0], "NETCDF" ) ) { + if( ( CSLCount(poDS->papszName) == 3 ) ){ + poDS->pszFilename = strdup( poDS->papszName[1] ); + } + } + else { + poDS->pszFilename = strdup( poOpenInfo->pszFilename ); + } + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + if( nc_open( poDS->pszFilename, NC_NOWRITE, &cdfid ) != NC_NOERR ) { + delete poDS; + return NULL; + } +/* -------------------------------------------------------------------- */ +/* Is this a real netCDF file? */ +/* -------------------------------------------------------------------- */ + status = nc_inq(cdfid, &ndims, &nvars, &ngatts, &unlimdimid); + if( status != NC_NOERR ) { + CPLFree( poDS->pszFilename ); + CSLDestroy( poDS->papszName ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Does the request variable exist? */ +/* -------------------------------------------------------------------- */ + if( ( CSLCount(poDS->papszName) == 3 ) ){ + status = nc_inq_varid( cdfid, poDS->papszName[2], &var); + if( status != NC_NOERR ) { + CPLError( CE_Warning, CPLE_AppDefined, + "%s is a netCDF file, but %s is not a variable.", + poOpenInfo->pszFilename, + poDS->papszName[2] ); + + nc_close( cdfid ); + return NULL; + } + } + + if( nc_inq_ndims( cdfid, &dim_count ) != NC_NOERR || dim_count < 2 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "%s is a netCDF file, but not in GMT configuration.", + poOpenInfo->pszFilename ); + + nc_close( cdfid ); + return NULL; + } + + CPLDebug( "GDAL_netCDF", "dim_count = %d\n", dim_count ); + + if( (status = nc_get_att_text( cdfid, NC_GLOBAL, "Conventions", + attname )) != NC_NOERR ) { + CPLError( CE_Warning, CPLE_AppDefined, + "No UNIDATA NC_GLOBAL:Conventions attribute"); + /* note that 'Conventions' is always capital 'C' in CF spec*/ + } + + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + if ( nc_inq_nvars ( cdfid, &var_count) != NC_NOERR ) + return NULL; + + CPLDebug( "GDAL_netCDF", "var_count = %d\n", var_count ); + + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* Create Netcdf Subdataset if filename as NETCDF tag */ +/* -------------------------------------------------------------------- */ + poDS->cdfid = cdfid; + + poDS->ReadAttributes( cdfid, NC_GLOBAL ); + if( !EQUAL( poDS->papszName[0], "NETCDF" ) ) { + poDS->CreateSubDatasetList( ); + poDS->SetMetadata( poDS->papszMetadata ); + return( poDS ); + } + + +/* -------------------------------------------------------------------- */ +/* Open the NETCDF subdataset NETCDF:"filename":subdataset */ +/* -------------------------------------------------------------------- */ + + var=-1; + nc_inq_varid( cdfid, poDS->papszName[2], &var); + nc_inq_varndims ( cdfid, var, &nd ); + + poDS->paDimIds = (int *)CPLCalloc(nd, sizeof( int ) ); + poDS->panBandDimPos = ( int * ) CPLCalloc( nd, sizeof( int ) ); + + nc_inq_vardimid( cdfid, var, poDS->paDimIds ); + + +/* -------------------------------------------------------------------- */ +/* Check somebody tried to pass a variable with less than 2D */ +/* -------------------------------------------------------------------- */ + + if ( nd < 2 ) { + CPLFree( poDS->paDimIds ); + CPLFree( poDS->panBandDimPos ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* CF-1 Convention */ +/* dimensions to appear in the relative order T, then Z, then Y, */ +/* then X to the file. All other dimensions should, whenever */ +/* possible, be placed to the left of the spatiotemporal */ +/* dimensions. */ +/* -------------------------------------------------------------------- */ + +/* -------------------------------------------------------------------- */ +/* Get X dimensions information */ +/* -------------------------------------------------------------------- */ + poDS->nDimXid = poDS->paDimIds[nd-1]; + nc_inq_dimlen ( cdfid, poDS->nDimXid, &poDS->xdim ); + poDS->nRasterXSize = poDS->xdim; + +/* -------------------------------------------------------------------- */ +/* Get Y dimension information */ +/* -------------------------------------------------------------------- */ + poDS->nDimYid = poDS->paDimIds[nd-2]; + nc_inq_dimlen ( cdfid, poDS->nDimYid, &poDS->ydim ); + poDS->nRasterYSize = poDS->ydim; + + + for( j=0,k=0; j < nd; j++ ){ + if( poDS->paDimIds[j] == poDS->nDimXid ){ + poDS->panBandDimPos[0] = j; // Save Position of XDim + k++; + } + if( poDS->paDimIds[j] == poDS->nDimYid ){ + poDS->panBandDimPos[1] = j; // Save Position of YDim + k++; + } + } +/* -------------------------------------------------------------------- */ +/* X and Y Dimension Ids were not found! */ +/* -------------------------------------------------------------------- */ + if( k != 2 ) { + CPLFree( poDS->paDimIds ); + CPLFree( poDS->panBandDimPos ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read Metadata for this variable */ +/* -------------------------------------------------------------------- */ + poDS->ReadAttributes( cdfid, var ); + +/* -------------------------------------------------------------------- */ +/* Read Metadata for each dimension */ +/* -------------------------------------------------------------------- */ + + for( j=0; j < dim_count; j++ ){ + nc_inq_dimname( cdfid, j, poDS->papszDimName[j] ); + status = nc_inq_varid( cdfid, poDS->papszDimName[j], &nDimID ); + if( status == NC_NOERR ) { + poDS->ReadAttributes( cdfid, nDimID ); + } + } + + poDS->SetProjection( var ); +/* -------------------------------------------------------------------- */ +/* Create bands */ +/* -------------------------------------------------------------------- */ + poDS->panBandZLev = (int *)CPLCalloc( sizeof( nd ) - 2, + sizeof( int ) ); + + nTotLevCount = 1; + if ( dim_count > 2 ) { + nDim=2; + for( j=0; j < nd; j++ ){ + if( ( poDS->paDimIds[j] != poDS->nDimXid ) && + ( poDS->paDimIds[j] != poDS->nDimYid ) ){ + nc_inq_dimlen ( cdfid, poDS->paDimIds[j], &lev_count ); + nTotLevCount *= lev_count; + poDS->panBandZLev[ nDim-2 ] = lev_count; + poDS->panBandDimPos[ nDim++ ] = j; //Save Position of ZDim + } + } + } + i=0; + + for ( unsigned int lev = 0; lev < nTotLevCount ; lev++ ) { + char szBandItemName[ MAX_STR_LEN ]; + char ** papszToken; + const char * pszGeo; + papszToken=NULL; + + netCDFRasterBand *poBand=new netCDFRasterBand(poDS, + var, + nDim, + lev, + poDS->panBandZLev, + poDS->panBandDimPos, + i+1 ); + + for( j = 0; j < CSLCount( poDS->papszGeolocation ); j++ ) { + pszGeo = CSLGetField( poDS->papszGeolocation, j ); + papszToken = CSLTokenizeString2( pszGeo, + "=", CSLT_HONOURSTRINGS ); + + strcpy( szBandItemName, "NETCDF_GEOLOCATION_" ); + strcat( szBandItemName, papszToken[0] ); + poBand->SetMetadataItem( szBandItemName, papszToken[1] ); + CSLDestroy( papszToken ); + } + + poDS->SetBand( i+1, poBand ); + i++; + } + + CPLFree( poDS->paDimIds ); + CPLFree( poDS->panBandDimPos ); + CPLFree( poDS->panBandZLev ); + + poDS->nBands = i; + + // Handle angular geographic coordinates here + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML( ); + poDS->SetMetadata( poDS->papszMetadata ); + return( poDS ); +} + + +/************************************************************************/ +/* CopyMetadata() */ +/* */ +/* Create a copy of metadata for NC_GLOBAL or a variable */ +/************************************************************************/ + +void CopyMetadata( void *poDS, int fpImage, int CDFVarID ) { + +/* -------------------------------------------------------------------- */ +/* Add CF-1.0 Conventions Global attribute */ +/* -------------------------------------------------------------------- */ + char **papszMetadata; + char **papszFieldData; + const char *pszField; + char szMetaName[ MAX_STR_LEN ]; + char szMetaValue[ MAX_STR_LEN ]; + int nDataLength; + int nItems; + +/* -------------------------------------------------------------------- */ +/* Global metadata are set with NC_GLOBAL as the varid */ +/* -------------------------------------------------------------------- */ + + if( CDFVarID == NC_GLOBAL ) { + + papszMetadata = GDALGetMetadata( (GDALDataset *) poDS,""); + + nc_put_att_text( fpImage, + NC_GLOBAL, + "Conventions", + 6, + "CF-1.0" ); + } else { + + papszMetadata = GDALGetMetadata( (GDALRasterBandH) poDS, NULL ); + + } + + nItems = CSLCount( papszMetadata ); + + for(int k=0; k < nItems; k++ ) { + pszField = CSLGetField( papszMetadata, k ); + papszFieldData = CSLTokenizeString2 (pszField, "=", + CSLT_HONOURSTRINGS ); + if( papszFieldData[1] != NULL ) { + strcpy( szMetaName, papszFieldData[ 0 ] ); + strcpy( szMetaValue, papszFieldData[ 1 ] ); + +/* -------------------------------------------------------------------- */ +/* netCDF attributes do not like the '#' character. */ +/* -------------------------------------------------------------------- */ + + for( unsigned int h=0; h < strlen( szMetaName ) -1 ; h++ ) { + if( szMetaName[h] == '#' ) szMetaName[h] = '-'; + } + + nDataLength = strlen( szMetaValue ); + nc_put_att_text( fpImage, + CDFVarID, + szMetaName, + nDataLength, + szMetaValue ); + + + } + CSLDestroy( papszFieldData ); + + } +} +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + + +static GDALDataset* +NCDFCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + int nBands = poSrcDS->GetRasterCount(); + int nXSize = poSrcDS->GetRasterXSize(); + int nYSize = poSrcDS->GetRasterYSize(); + int bProgressive = FALSE; + + int anBandDims[ NC_MAX_DIMS ]; + int anBandMap[ NC_MAX_DIMS ]; + + int bWriteGeoTransform = FALSE; + char pszNetcdfProjection[ NC_MAX_NAME ]; + + + if( !pfnProgress( 0.0, NULL, pProgressData ) ) + return NULL; + + + bProgressive = CSLFetchBoolean( papszOptions, "PROGRESSIVE", FALSE ); + +/* -------------------------------------------------------------------- */ +/* Create the dataset. */ +/* -------------------------------------------------------------------- */ + int fpImage; + int status; + int nXDimID = 0; + int nYDimID = 0; + + status = nc_create( pszFilename, NC_CLOBBER, &fpImage ); + + if( status != NC_NOERR ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to create netCDF file %s.\n", + pszFilename ); + return NULL; + } + + GDALDataType eDT; + + status = nc_def_dim( fpImage, "x", nXSize, &nXDimID ); + CPLDebug( "GDAL_netCDF", "status nc_def_dim X = %d\n", status ); + + status = nc_def_dim( fpImage, "y", nYSize, &nYDimID ); + CPLDebug( "GDAL_netCDF", "status nc_def_dim Y = %d\n", status ); + + CPLDebug( "GDAL_netCDF", "nYDimID = %d\n", nXDimID ); + CPLDebug( "GDAL_netCDF", "nXDimID = %d\n", nYDimID ); + CPLDebug( "GDAL_netCDF", "nXSize = %d\n", nXSize ); + CPLDebug( "GDAL_netCDF", "nYSize = %d\n", nYSize ); + + + CopyMetadata((void *) poSrcDS, fpImage, NC_GLOBAL ); + +/* -------------------------------------------------------------------- */ +/* Set Projection for netCDF data CF-1 Convention */ +/* -------------------------------------------------------------------- */ + + OGRSpatialReference oSRS; + char *pszWKT = (char *) poSrcDS->GetProjectionRef(); + + + if( pszWKT != NULL ) + oSRS.importFromWkt( &pszWKT ); + + if( oSRS.IsProjected() ) + { + const char *pszParamStr, *pszParamVal; + const OGR_SRSNode *poPROJCS = oSRS.GetAttrNode( "PROJCS" ); + int status; + int i; + int NCDFVarID; + const char *pszProjection; + double dfNN=0.0; + double dfSN=0.0; + double dfEE=0.0; + double dfWE=0.0; + double adfGeoTransform[6]; + char szGeoTransform[ MAX_STR_LEN ]; + char szTemp[ MAX_STR_LEN ]; + + poSrcDS->GetGeoTransform( adfGeoTransform ); + + *szGeoTransform = '\0'; + for( i=0; i<6; i++ ) { + sprintf( szTemp, "%g ", + adfGeoTransform[i] ); + strcat( szGeoTransform, szTemp ); + } + + CPLDebug( "GDAL_netCDF", "szGeoTranform = %s", szGeoTransform ); + + pszProjection = oSRS.GetAttrValue( "PROJECTION" ); + bWriteGeoTransform = TRUE; + + + for(i=0; poNetcdfSRS[i].netCDFSRS != NULL; i++ ) { + if( EQUAL( poNetcdfSRS[i].SRS, pszProjection ) ) { + CPLDebug( "GDAL_netCDF", "PROJECTION = %s", + poNetcdfSRS[i].netCDFSRS); + strcpy( pszNetcdfProjection, poNetcdfSRS[i].netCDFSRS ); + + break; + } + } + + status = nc_def_var( fpImage, + poNetcdfSRS[i].netCDFSRS, + NC_CHAR, + 0, NULL, &NCDFVarID ); + + dfNN = adfGeoTransform[3]; + dfSN = ( adfGeoTransform[5] * nYSize ) + dfNN; + dfWE = adfGeoTransform[0]; + dfEE = ( adfGeoTransform[1] * nXSize ) + dfWE; + + status = nc_put_att_double( fpImage, + NCDFVarID, + "Northernmost_Northing", + NC_DOUBLE, + 1, + &dfNN ); + status = nc_put_att_double( fpImage, + NCDFVarID, + "Southernmost_Northing", + NC_DOUBLE, + 1, + &dfSN ); + status = nc_put_att_double( fpImage, + NCDFVarID, + "Easternmost_Easting", + NC_DOUBLE, + 1, + &dfEE ); + status = nc_put_att_double( fpImage, + NCDFVarID, + "Westernmost_Easting", + NC_DOUBLE, + 1, + &dfWE ); + pszWKT = (char *) poSrcDS->GetProjectionRef() ; + + nc_put_att_text( fpImage, + NCDFVarID, + "spatial_ref", + strlen( pszWKT ), + pszWKT ); + + nc_put_att_text( fpImage, + NCDFVarID, + "GeoTransform", + strlen( szGeoTransform ), + szGeoTransform ); + + nc_put_att_text( fpImage, + NCDFVarID, + GRD_MAPPING_NAME, + strlen( pszNetcdfProjection ), + pszNetcdfProjection ); + + + for( int iChild = 0; iChild < poPROJCS->GetChildCount(); iChild++ ) + { + const OGR_SRSNode *poNode; + float fValue; + + poNode = poPROJCS->GetChild( iChild ); + if( !EQUAL(poNode->GetValue(),"PARAMETER") + || poNode->GetChildCount() != 2 ) + continue; + +/* -------------------------------------------------------------------- */ +/* Look for projection attributes */ +/* -------------------------------------------------------------------- */ + pszParamStr = poNode->GetChild(0)->GetValue(); + pszParamVal = poNode->GetChild(1)->GetValue(); + + + for(i=0; poNetcdfSRS[i].netCDFSRS != NULL; i++ ) { + if( EQUAL( poNetcdfSRS[i].SRS, pszParamStr ) ) { + CPLDebug( "GDAL_netCDF", "%s = %s", + poNetcdfSRS[i].netCDFSRS, + pszParamVal ); + break; + } + } +/* -------------------------------------------------------------------- */ +/* Write Projection attribute */ +/* -------------------------------------------------------------------- */ + sscanf( pszParamVal, "%f", &fValue ); + if( poNetcdfSRS[i].netCDFSRS != NULL ) { + nc_put_att_float( fpImage, + NCDFVarID, + poNetcdfSRS[i].netCDFSRS, + NC_FLOAT, + 1, + &fValue ); + + } + } + } + +/* -------------------------------------------------------------------- */ +/* Initialize Band Map */ +/* -------------------------------------------------------------------- */ + + for(int j=1; j <= nBands; j++ ) { + anBandMap[j-1]=j; + } + +/* -------------------------------------------------------------------- */ +/* Create netCDF variable */ +/* -------------------------------------------------------------------- */ + + for( int i=1; i <= nBands; i++ ) { + + char szBandName[ NC_MAX_NAME ]; + GByte *pabScanline = NULL; + GInt16 *pasScanline = NULL; + GInt32 *panScanline = NULL; + float *pafScanline = NULL; + double *padScanline = NULL; + int NCDFVarID; + size_t start[ GDALNBDIM ]; + size_t count[ GDALNBDIM ]; + size_t nBandNameLen; + double dfNoDataValue; + GDALRasterBandH hBand; + + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( i ); + hBand = GDALGetRasterBand( poSrcDS, i ); + + sprintf( szBandName, "Band%d", i ); + + eDT = poSrcDS->GetRasterBand(i)->GetRasterDataType(); + anBandDims[0] = nYDimID; + anBandDims[1] = nXDimID; + CPLErr eErr = CE_None; + + if( eDT == GDT_Byte ) { + CPLDebug( "GDAL_netCDF", "%s = GDT_Byte ", szBandName ); + + status = nc_def_var( fpImage, szBandName, NC_BYTE, + GDALNBDIM, anBandDims, &NCDFVarID ); + +/* -------------------------------------------------------------------- */ +/* Write Projection for band */ +/* -------------------------------------------------------------------- */ + if( bWriteGeoTransform == TRUE ) { + nc_put_att_text( fpImage, NCDFVarID, + COORDINATES, + 7, + LONLAT ); + + nc_put_att_text( fpImage, NCDFVarID, + GRD_MAPPING, + strlen( pszNetcdfProjection ), + pszNetcdfProjection ); + } + +/* -------------------------------------------------------------------- */ +/* Write data line per line */ +/* -------------------------------------------------------------------- */ + + pabScanline = (GByte *) CPLMalloc( nBands * nXSize * nYSize * + sizeof( GByte ) ); + for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) { + +/* -------------------------------------------------------------------- */ +/* Read data from band i */ +/* -------------------------------------------------------------------- */ + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + pabScanline, nXSize, 1, GDT_Byte, + 0,0); + +/* -------------------------------------------------------------------- */ +/* Write Data from Band i */ +/* -------------------------------------------------------------------- */ + start[0]=iLine; + start[1]=0; + count[0]=1; + count[1]=nXSize; + +/* -------------------------------------------------------------------- */ +/* Put NetCDF file in data mode. */ +/* -------------------------------------------------------------------- */ + status = nc_enddef( fpImage ); + status = nc_put_vara_uchar (fpImage, NCDFVarID, start, + count, pabScanline); + + +/* -------------------------------------------------------------------- */ +/* Put NetCDF file back in define mode. */ +/* -------------------------------------------------------------------- */ + status = nc_redef( fpImage ); + + } + CPLFree( pabScanline ); +/* -------------------------------------------------------------------- */ +/* Int16 */ +/* -------------------------------------------------------------------- */ + + } else if( eDT == GDT_UInt16 ) { + CPLDebug( "GDAL_netCDF", "%s = GDT_UInt16 ",szBandName ); + status = nc_def_var( fpImage, szBandName, NC_SHORT, + GDALNBDIM, anBandDims, &NCDFVarID ); + + pasScanline = (GInt16 *) CPLMalloc( nBands * nXSize * nYSize * + sizeof( GInt16 ) ); + for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) { + + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + pasScanline, nXSize, 1, GDT_Byte, + 0,0); + + start[0]=iLine; + start[1]=0; + count[0]=1; + count[1]=nXSize; + + + status = nc_enddef( fpImage ); + status = nc_put_vara_short( fpImage, NCDFVarID, start, + count, pasScanline); + status = nc_redef( fpImage ); + } + CPLFree( pasScanline ); +/* -------------------------------------------------------------------- */ +/* Int32 */ +/* -------------------------------------------------------------------- */ + + } else if( (eDT == GDT_UInt32) || (eDT == GDT_Int32) ) { + CPLDebug( "GDAL_netCDF", "%s = GDT_Int32 ",szBandName ); + status = nc_def_var( fpImage, szBandName, NC_INT, + GDALNBDIM, anBandDims, &NCDFVarID ); + + panScanline = (GInt32 *) CPLMalloc( nBands * nXSize * nYSize * + sizeof( GInt32 ) ); + for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) { + + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + panScanline, nXSize, 1, GDT_Int32, + 0,0); + + start[0]=iLine; + start[1]=0; + count[0]=1; + count[1]=nXSize; + + + status = nc_enddef( fpImage ); + status = nc_put_vara_int( fpImage, NCDFVarID, start, + count, panScanline); + status = nc_redef( fpImage ); + } + CPLFree( panScanline ); +/* -------------------------------------------------------------------- */ +/* float */ +/* -------------------------------------------------------------------- */ + } else if( (eDT == GDT_Float32) ) { + CPLDebug( "GDAL_netCDF", "%s = GDT_Float32 ",szBandName ); + status = nc_def_var( fpImage, szBandName, NC_FLOAT, + GDALNBDIM, anBandDims, &NCDFVarID ); + + pafScanline = (float *) CPLMalloc( nBands * nXSize * nYSize * + sizeof( float ) ); + + for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) { + + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + pafScanline, nXSize, 1, + GDT_Float32, + 0,0); + + start[0]=iLine; + start[1]=0; + count[0]=1; + count[1]=nXSize; + + + status = nc_enddef( fpImage ); + status = nc_put_vara_float( fpImage, NCDFVarID, start, + count, pafScanline); + status = nc_redef( fpImage ); + } + CPLFree( pafScanline ); +/* -------------------------------------------------------------------- */ +/* double */ +/* -------------------------------------------------------------------- */ + } else if( (eDT == GDT_Float64) ) { + CPLDebug( "GDAL_netCDF", "%s = GDT_Float64 ",szBandName ); + status = nc_def_var( fpImage, szBandName, NC_DOUBLE, + GDALNBDIM, anBandDims, &NCDFVarID ); + + padScanline = (double *) CPLMalloc( nBands * nXSize * nYSize * + sizeof( double ) ); + for( int iLine = 0; iLine < nYSize && eErr == CE_None; iLine++ ) { + + eErr = poSrcBand->RasterIO( GF_Read, 0, iLine, nXSize, 1, + padScanline, nXSize, 1, + GDT_Float64, + 0,0); + + start[0]=iLine; + start[1]=0; + count[0]=1; + count[1]=nXSize; + + + status = nc_enddef( fpImage ); + status = nc_put_vara_double( fpImage, NCDFVarID, start, + count, padScanline); + status = nc_redef( fpImage ); + } + CPLFree( padScanline ); + } + + sprintf( szBandName, "GDAL Band Number %d", i); + nBandNameLen = strlen( szBandName ); + nc_put_att_text( fpImage, + NCDFVarID, + "long_name", + nBandNameLen, + szBandName ); + + CopyMetadata( (void *) hBand, fpImage, NCDFVarID ); + + dfNoDataValue = poSrcBand->GetNoDataValue(0); + nc_put_att_double( fpImage, + NCDFVarID, + _FillValue, + NC_DOUBLE, + 1, + &dfNoDataValue ); + + + } + + + + // poDstDS->SetGeoTransform( adfGeoTransform ); + + +/* -------------------------------------------------------------------- */ +/* Cleanup and close. */ +/* -------------------------------------------------------------------- */ +// CPLFree( pabScanline ); + + nc_close( fpImage ); +/* -------------------------------------------------------------------- */ +/* Re-open dataset, and copy any auxilary pam information. */ +/* -------------------------------------------------------------------- */ + netCDFDataset *poDS = (netCDFDataset *) GDALOpen( pszFilename, GA_ReadOnly ); + + if( poDS ) + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; + + + } + +/************************************************************************/ +/* GDALRegister_netCDF() */ +/************************************************************************/ + +void GDALRegister_netCDF() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "netCDF" ) == NULL ) + { + poDriver = new GDALDriver( ); + + poDriver->SetDescription( "netCDF" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Network Common Data Format" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#netCDF" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "nc" ); + + poDriver->pfnOpen = netCDFDataset::Open; + poDriver->pfnCreateCopy = NCDFCreateCopy; + + + GetGDALDriverManager( )->RegisterDriver( poDriver ); + } +} + + + +/* -------------------------------------------------------------------- */ +/* Set Lambert Conformal Conic Projection */ +/* -------------------------------------------------------------------- */ + + + +//Albers equal area +// +//grid_mapping_name = albers_conical_equal_area +// +//Map parameters: +// +// * standard_parallel - There may be 1 or 2 values. +// * longitude_of_central_meridian +// * latitude_of_projection_origin +// * false_easting +// * false_northing +//Lambert azimuthal equal area +// +//grid_mapping_name = lambert_azimuthal_equal_area +// +//Map parameters: +// +// * longitude_of_projection_origin +// * latitude_of_projection_origin +// * false_easting +// * false_northing +//Lambert conformal +// +//grid_mapping_name = lambert_conformal_conic +// +//Map parameters: +// +// * standard_parallel - There may be 1 or 2 values. +// * longitude_of_central_meridian +// * latitude_of_projection_origin +// * false_easting +// * false_northing +//Polar stereographic +// +//grid_mapping_name = polar_stereographic +// +//Map parameters: +// +// * straight_vertical_longitude_from_pole +// * latitude_of_projection_origin - Either +90. or -90. +// * Either standard_parallel or scale_factor_at_projection_origin +// * false_easting +// * false_northing +//Rotated pole +// +//grid_mapping_name = rotated_latitude_longitude +// +//Map parameters: +// +// * grid_north_pole_latitude +// * grid_north_pole_longitude +// * north_pole_grid_longitude - This parameter is optional (default is 0.). +//Stereographic +// +//grid_mapping_name = stereographic +// +//Map parameters: +// +// * longitude_of_projection_origin +// * latitude_of_projection_origin +// * scale_factor_at_projection_origin +// * false_easting +// * false_northing +//Transverse Mercator +// +//grid_mapping_name = transverse_mercator +// +//Map parameters: +// +// * scale_factor_at_central_meridian +// * longitude_of_central_meridian +// * latitude_of_projection_origin +// * false_easting +// * false_northing +// +// +// +//Grid mapping attributes +// +//false_easting +//false_northing +//grid_mapping_name +//grid_north_pole_latitude +//grid_north_pole_longitude +//latitude_of_projection_origin +//longitude_of_central_meridian +//longitude_of_projection_origin +//north_pole_grid_longitude +//scale_factor_at_central_meridian +//scale_factor_at_projection_origin +//standard_parallel +//straight_vertical_longitude_from_pole + + diff --git a/Utilities/GDAL/frmts/netcdf/netcdfdataset.h b/Utilities/GDAL/frmts/netcdf/netcdfdataset.h new file mode 100644 index 0000000000..119e1b6a90 --- /dev/null +++ b/Utilities/GDAL/frmts/netcdf/netcdfdataset.h @@ -0,0 +1,178 @@ +/****************************************************************************** + * $Id$ + * + * Project: netCDF read/write Driver + * Purpose: GDAL bindings over netCDF library. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, 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: netcdfdataset.h,v $ + * Revision 1.1 2006/04/28 19:29:42 dnadeau + * NetCDF header file + * + */ + +#ifndef _NETCDFDATASET_H_INCLUDED_ +#define _NETCDFATASET_H_INCLUDED_ + +#include <float.h> +#include "gdal_pam.h" +#include "gdal_priv.h" +#include "gdal_frmts.h" +#include "cpl_string.h" +#include "ogr_spatialref.h" +#include "netcdf.h" + + +/************************************************************************/ +/* ==================================================================== */ +/* netCDFDataset */ +/* ==================================================================== */ +/************************************************************************/ +#define MAX_STR_LEN 8192 +#define L_C_CONIC "lambert_conformal_conic" +#define TM "transverse_mercator" + +#define GRD_MAPPING_NAME "grid_mapping_name" +#define GRD_MAPPING "grid_mapping" +#define COORDINATES "coordinates" +#define LONLAT "lon lat" + +#define STD_PARALLEL_1 "standard_parallel_1" +#define STD_PARALLEL_2 "standard_parallel_2" +#define LONG_CENTRAL_MERIDIAN "central_meridian" +#define LAT_PROJ_ORIGIN "latitude_of_projection_origin" +#define EARTH_SHAPE "GRIB_earth_shape" +#define EARTH_SHAPE_CODE "GRIB_earth_shape_code" +#define SCALE_FACTOR "scale_factor_at_central_meridian" +#define FALSE_EASTING "false_easting" +#define FALSE_NORTHING "false_northing" + +#define STD_NAME "standard_name" +#define LNG_NAME "long_name" +#define UNITS "units" +#define AXIS "axis" +#define BOUNDS "bounds" +#define ORIG_AXIS "original_units" + +#define GDALNBDIM 2 + + +typedef struct { + char *netCDFSRS; + char *SRS; } +oNetcdfSRS; + +oNetcdfSRS poNetcdfSRS[] = { + {"albers_conical_equal_area", SRS_PT_ALBERS_CONIC_EQUAL_AREA }, + {"azimuthal_equidistant", SRS_PT_AZIMUTHAL_EQUIDISTANT }, + {"cassini_soldner", SRS_PT_CASSINI_SOLDNER }, + {"cylindrical_equal_area", SRS_PT_CYLINDRICAL_EQUAL_AREA }, + {"eckert_iv", SRS_PT_ECKERT_IV }, + {"eckert_vi", SRS_PT_ECKERT_VI }, + {"equidistant_conic", SRS_PT_EQUIDISTANT_CONIC }, + {"equirectangular", SRS_PT_EQUIRECTANGULAR }, + {"gall_stereographic", SRS_PT_GALL_STEREOGRAPHIC }, + {"geostationary_satellite", SRS_PT_GEOSTATIONARY_SATELLITE }, + {"goode_homolosine", SRS_PT_GOODE_HOMOLOSINE }, + {"gnomonic", SRS_PT_GNOMONIC }, + {"hotine_oblique_mercator", SRS_PT_HOTINE_OBLIQUE_MERCATOR}, + {"hotine_oblique_marcator_2P", + SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN}, + {"laborde_oblique_mercator", SRS_PT_LABORDE_OBLIQUE_MERCATOR }, + {"lambert_conformal_conic1", SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP }, + {"lambert_conformal_conic", SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP }, + {"lambert_azimuthal_equal_area", SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA }, + {"mercator_1sp", SRS_PT_MERCATOR_1SP }, + {"mercator_2sp", SRS_PT_MERCATOR_2SP }, + {"miller_cylindrical", SRS_PT_MILLER_CYLINDRICAL }, + {"mollweide", SRS_PT_MOLLWEIDE }, + {"new_zealand_map_grid", SRS_PT_NEW_ZEALAND_MAP_GRID }, + {"oblique_stereographic", SRS_PT_OBLIQUE_STEREOGRAPHIC }, + {"orthographic", SRS_PT_ORTHOGRAPHIC }, + {"polar_stereographic", SRS_PT_POLAR_STEREOGRAPHIC }, + {"polyconic", SRS_PT_POLYCONIC }, + {"robinson", SRS_PT_ROBINSON }, + {"sinusoidal", SRS_PT_SINUSOIDAL }, + {"stereographic", SRS_PT_STEREOGRAPHIC }, + {"swiss_oblique_cylindrical", SRS_PT_SWISS_OBLIQUE_CYLINDRICAL}, + {"transverse_mercator", SRS_PT_TRANSVERSE_MERCATOR }, + {"TM_south_oriented", SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED }, + {"central_meridian", SRS_PP_CENTRAL_MERIDIAN }, + {"scale_factor_at_projection_origin", SRS_PP_SCALE_FACTOR }, + {"standard_parallel_1", SRS_PP_STANDARD_PARALLEL_1 }, + {"standard_parallel_2", SRS_PP_STANDARD_PARALLEL_2 }, + {"longitude_of_central_meridian", SRS_PP_LONGITUDE_OF_CENTER }, + {"longitude_of_projection_origin", SRS_PP_LONGITUDE_OF_ORIGIN }, + {"latitude_of_projection_origin", SRS_PP_LATITUDE_OF_ORIGIN }, + {"false_easting", SRS_PP_FALSE_EASTING }, + {"false_northing", SRS_PP_FALSE_NORTHING }, + {NULL, NULL }, + }; + +class netCDFRasterBand; + +class netCDFDataset : public GDALPamDataset +{ + double adfGeoTransform[6]; + char **papszSubDatasets; + char **papszGeolocation; + char **papszName; + char *pszFilename; + int *panBandDimPos; // X, Y, Z postion in array + int *panBandZLev; + char *pszProjection; + int bGotGeoTransform; + double rint( double ); + + public: + int cdfid; + char **papszMetadata; + char papszDimName[NC_MAX_NAME][1024]; + char papszDimXName[1024]; + char papszDimYName[1024]; + int *paDimIds; + size_t xdim, ydim; + int nDimXid, nDimYid; + + netCDFDataset( ); + ~netCDFDataset( ); + + static GDALDataset *Open( GDALOpenInfo * ); + + CPLErr ReadAttributes( int, int ); + + CPLErr GetGeoTransform( double * ); + + const char * GetProjectionRef(); + + char ** GetMetadata( const char * ); + + void CreateSubDatasetList( ); + + void SetProjection( int ); + +}; + +#endif diff --git a/Utilities/GDAL/frmts/nitf/.cvsignore b/Utilities/GDAL/frmts/nitf/.cvsignore new file mode 100644 index 0000000000..f48da3807e --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/.cvsignore @@ -0,0 +1 @@ +nitfdump diff --git a/Utilities/GDAL/frmts/nitf/makefile.vc b/Utilities/GDAL/frmts/nitf/makefile.vc new file mode 100644 index 0000000000..3f7c550c68 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/makefile.vc @@ -0,0 +1,22 @@ + +GDAL_OBJ = nitfdataset.obj +NITFLIB_OBJ = nitffile.obj nitfimage.obj mgrs.obj + +OBJ = $(GDAL_OBJ) $(NITFLIB_OBJ) + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + +nitfdump.exe: nitfdump.obj $(NITFLIB_OBJ) + cl nitfdump.obj $(NITFLIB_OBJ) ..\..\port\cpl.lib ..\..\gdal.lib + + + + diff --git a/Utilities/GDAL/frmts/nitf/mgrs.c b/Utilities/GDAL/frmts/nitf/mgrs.c new file mode 100644 index 0000000000..9b1edff468 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/mgrs.c @@ -0,0 +1,1112 @@ +/*************************************************************************** + * $Id$ + * + * Project: MGRS Converter + * Purpose: Geotrans code for MGRS translation (slightly adapted) + * Author: Unknown (NIMA) + * + *************************************************************************** + * $Log: mgrs.c,v $ + * Revision 1.2 2004/02/20 01:39:05 warmerda + * Avoid warnings. + * + * 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 + * 02-05-03 Corrected latitude band bug in GRID_UTM + * 08-20-03 Reengineered lower layers + */ + + +/***************************************************************************/ +/* + * INCLUDES + */ +#include <ctype.h> +#include <math.h> +#include <stdio.h> +#include <string.h> +#include "mgrs.h" + +/* + * ctype.h - Standard C character handling library + * math.h - Standard C math library + * stdio.h - Standard C input/output library + * string.h - Standard C string handling library + * ups.h - Universal Polar Stereographic (UPS) projection + * utm.h - Universal Transverse Mercator (UTM) projection + * mgrs.h - function prototype error checking + */ + + +/***************************************************************************/ +/* + * GLOBAL DECLARATIONS + */ +#define DEG_TO_RAD 0.017453292519943295 /* PI/180 */ +#define RAD_TO_DEG 57.29577951308232087 /* 180/PI */ +#define LETTER_A 0 /* ARRAY INDEX FOR LETTER A */ +#define LETTER_B 1 /* ARRAY INDEX FOR LETTER B */ +#define LETTER_C 2 /* ARRAY INDEX FOR LETTER C */ +#define LETTER_D 3 /* ARRAY INDEX FOR LETTER D */ +#define LETTER_E 4 /* ARRAY INDEX FOR LETTER E */ +#define LETTER_F 5 /* ARRAY INDEX FOR LETTER E */ +#define LETTER_G 6 /* ARRAY INDEX FOR LETTER H */ +#define LETTER_H 7 /* ARRAY INDEX FOR LETTER H */ +#define LETTER_I 8 /* ARRAY INDEX FOR LETTER I */ +#define LETTER_J 9 /* ARRAY INDEX FOR LETTER J */ +#define LETTER_K 10 /* ARRAY INDEX FOR LETTER J */ +#define LETTER_L 11 /* ARRAY INDEX FOR LETTER L */ +#define LETTER_M 12 /* ARRAY INDEX FOR LETTER M */ +#define LETTER_N 13 /* ARRAY INDEX FOR LETTER N */ +#define LETTER_O 14 /* ARRAY INDEX FOR LETTER O */ +#define LETTER_P 15 /* ARRAY INDEX FOR LETTER P */ +#define LETTER_Q 16 /* ARRAY INDEX FOR LETTER Q */ +#define LETTER_R 17 /* ARRAY INDEX FOR LETTER R */ +#define LETTER_S 18 /* ARRAY INDEX FOR LETTER S */ +#define LETTER_T 19 /* ARRAY INDEX FOR LETTER S */ +#define LETTER_U 20 /* ARRAY INDEX FOR LETTER U */ +#define LETTER_V 21 /* ARRAY INDEX FOR LETTER V */ +#define LETTER_W 22 /* ARRAY INDEX FOR LETTER W */ +#define LETTER_X 23 /* ARRAY INDEX FOR LETTER X */ +#define LETTER_Y 24 /* ARRAY INDEX FOR LETTER Y */ +#define LETTER_Z 25 /* ARRAY INDEX FOR LETTER Z */ +#define MGRS_LETTERS 3 /* NUMBER OF LETTERS IN MGRS */ +#define ONEHT 100000.e0 /* ONE HUNDRED THOUSAND */ +#define TWOMIL 2000000.e0 /* TWO MILLION */ +#define TRUE 1 /* CONSTANT VALUE FOR TRUE VALUE */ +#define FALSE 0 /* CONSTANT VALUE FOR FALSE VALUE */ +#define PI 3.14159265358979323e0 /* PI */ +#define PI_OVER_2 (PI / 2.0e0) + +#define MIN_EASTING 100000 +#define MAX_EASTING 900000 +#define MIN_NORTHING 0 +#define MAX_NORTHING 10000000 +#define MAX_PRECISION 5 /* Maximum precision of easting & northing */ +#define MIN_UTM_LAT ( (-80 * PI) / 180.0 ) /* -80 degrees in radians */ +#define MAX_UTM_LAT ( (84 * PI) / 180.0 ) /* 84 degrees in radians */ + +#define MIN_EAST_NORTH 0 +#define MAX_EAST_NORTH 4000000 + + +/* Ellipsoid parameters, default to WGS 84 */ +double MGRS_a = 6378137.0; /* Semi-major axis of ellipsoid in meters */ +double MGRS_f = 1 / 298.257223563; /* Flattening of ellipsoid */ +double MGRS_recpf = 298.257223563; +char MGRS_Ellipsoid_Code[3] = {'W','E',0}; + + +/* + * CLARKE_1866 : Ellipsoid code for CLARKE_1866 + * CLARKE_1880 : Ellipsoid code for CLARKE_1880 + * BESSEL_1841 : Ellipsoid code for BESSEL_1841 + * BESSEL_1841_NAMIBIA : Ellipsoid code for BESSEL 1841 (NAMIBIA) + */ +const char* CLARKE_1866 = "CC"; +const char* CLARKE_1880 = "CD"; +const char* BESSEL_1841 = "BR"; +const char* BESSEL_1841_NAMIBIA = "BN"; + + +typedef struct Latitude_Band_Value +{ + long letter; /* letter representing latitude band */ + double min_northing; /* minimum northing for latitude band */ + double north; /* upper latitude for latitude band */ + double south; /* lower latitude for latitude band */ +} Latitude_Band; + +static const Latitude_Band Latitude_Band_Table[20] = + {{LETTER_C, 1100000.0, -72.0, -80.5}, + {LETTER_D, 2000000.0, -64.0, -72.0}, + {LETTER_E, 2800000.0, -56.0, -64.0}, + {LETTER_F, 3700000.0, -48.0, -56.0}, + {LETTER_G, 4600000.0, -40.0, -48.0}, + {LETTER_H, 5500000.0, -32.0, -40.0}, + {LETTER_J, 6400000.0, -24.0, -32.0}, + {LETTER_K, 7300000.0, -16.0, -24.0}, + {LETTER_L, 8200000.0, -8.0, -16.0}, + {LETTER_M, 9100000.0, 0.0, -8.0}, + {LETTER_N, 0.0, 8.0, 0.0}, + {LETTER_P, 800000.0, 16.0, 8.0}, + {LETTER_Q, 1700000.0, 24.0, 16.0}, + {LETTER_R, 2600000.0, 32.0, 24.0}, + {LETTER_S, 3500000.0, 40.0, 32.0}, + {LETTER_T, 4400000.0, 48.0, 40.0}, + {LETTER_U, 5300000.0, 56.0, 48.0}, + {LETTER_V, 6200000.0, 64.0, 56.0}, + {LETTER_W, 7000000.0, 72.0, 64.0}, + {LETTER_X, 7900000.0, 84.5, 72.0}}; + + +typedef struct UPS_Constant_Value +{ + long letter; /* letter representing latitude band */ + long ltr2_low_value; /* 2nd letter range - high number */ + long ltr2_high_value; /* 2nd letter range - low number */ + long ltr3_high_value; /* 3rd letter range - high number (UPS) */ + double false_easting; /* False easting based on 2nd letter */ + double false_northing; /* False northing based on 3rd letter */ +} UPS_Constant; + +static const UPS_Constant UPS_Constant_Table[4] = + {{LETTER_A, LETTER_J, LETTER_Z, LETTER_Z, 800000.0, 800000.0}, + {LETTER_B, LETTER_A, LETTER_R, LETTER_Z, 2000000.0, 800000.0}, + {LETTER_Y, LETTER_J, LETTER_Z, LETTER_P, 800000.0, 1300000.0}, + {LETTER_Z, LETTER_A, LETTER_J, LETTER_P, 2000000.0, 1300000.0}}; + +/***************************************************************************/ +/* + * FUNCTIONS + */ + +long Get_Latitude_Band_Min_Northing(long letter, double* min_northing) +/* + * The function Get_Latitude_Band_Min_Northing receives a latitude band letter + * and uses the Latitude_Band_Table to determine the minimum northing for that + * latitude band letter. + * + * letter : Latitude band letter (input) + * min_northing : Minimum northing for that letter (output) + */ +{ /* Get_Latitude_Band_Min_Northing */ + long error_code = MGRS_NO_ERROR; + + if ((letter >= LETTER_C) && (letter <= LETTER_H)) + *min_northing = Latitude_Band_Table[letter-2].min_northing; + else if ((letter >= LETTER_J) && (letter <= LETTER_N)) + *min_northing = Latitude_Band_Table[letter-3].min_northing; + else if ((letter >= LETTER_P) && (letter <= LETTER_X)) + *min_northing = Latitude_Band_Table[letter-4].min_northing; + else + error_code |= MGRS_STRING_ERROR; + + return error_code; +} /* Get_Latitude_Band_Min_Northing */ + + +long Get_Latitude_Range(long letter, double* north, double* south) +/* + * The function Get_Latitude_Range receives a latitude band letter + * and uses the Latitude_Band_Table to determine the latitude band + * boundaries for that latitude band letter. + * + * letter : Latitude band letter (input) + * north : Northern latitude boundary for that letter (output) + * north : Southern latitude boundary for that letter (output) + */ +{ /* Get_Latitude_Range */ + long error_code = MGRS_NO_ERROR; + + if ((letter >= LETTER_C) && (letter <= LETTER_H)) + { + *north = Latitude_Band_Table[letter-2].north * DEG_TO_RAD; + *south = Latitude_Band_Table[letter-2].south * DEG_TO_RAD; + } + else if ((letter >= LETTER_J) && (letter <= LETTER_N)) + { + *north = Latitude_Band_Table[letter-3].north * DEG_TO_RAD; + *south = Latitude_Band_Table[letter-3].south * DEG_TO_RAD; + } + else if ((letter >= LETTER_P) && (letter <= LETTER_X)) + { + *north = Latitude_Band_Table[letter-4].north * DEG_TO_RAD; + *south = Latitude_Band_Table[letter-4].south * DEG_TO_RAD; + } + else + error_code |= MGRS_STRING_ERROR; + + return error_code; +} /* Get_Latitude_Range */ + + +long Get_Latitude_Letter(double latitude, int* letter) +/* + * The function Get_Latitude_Letter receives a latitude value + * and uses the Latitude_Band_Table to determine the latitude band + * letter for that latitude. + * + * latitude : Latitude (input) + * letter : Latitude band letter (output) + */ +{ /* Get_Latitude_Letter */ + double temp = 0.0; + long error_code = MGRS_NO_ERROR; + double lat_deg = latitude * RAD_TO_DEG; + + if (lat_deg >= 72 && lat_deg < 84.5) + *letter = LETTER_X; + else if (lat_deg > -80.5 && lat_deg < 72) + { + temp = ((latitude + (80.0 * DEG_TO_RAD)) / (8.0 * DEG_TO_RAD)) + 1.0e-12; + *letter = Latitude_Band_Table[(int)temp].letter; + } + else + error_code |= MGRS_LAT_ERROR; + + return error_code; +} /* Get_Latitude_Letter */ + + +long Check_Zone(char* MGRS, long* zone_exists) +/* + * The function Check_Zone receives an MGRS coordinate string. + * If a zone is given, TRUE is returned. Otherwise, FALSE + * is returned. + * + * MGRS : MGRS coordinate string (input) + * zone_exists : TRUE if a zone is given, + * FALSE if a zone is not given (output) + */ +{ /* Check_Zone */ + int i = 0; + int j = 0; + int num_digits = 0; + long error_code = MGRS_NO_ERROR; + + /* skip any leading blanks */ + while (MGRS[i] == ' ') + i++; + j = i; + while (isdigit(MGRS[i])) + i++; + num_digits = i - j; + if (num_digits <= 2) + if (num_digits > 0) + *zone_exists = TRUE; + else + *zone_exists = FALSE; + else + error_code |= MGRS_STRING_ERROR; + + return error_code; +} /* Check_Zone */ + + +long Round_MGRS (double value) +/* + * The function Round_MGRS rounds the input value to the + * nearest integer, using the standard engineering rule. + * The rounded integer value is then returned. + * + * value : Value to be rounded (input) + */ +{ /* Round_MGRS */ + double ivalue; + long ival; + double fraction = modf (value, &ivalue); + ival = (long)(ivalue); + if ((fraction > 0.5) || ((fraction == 0.5) && (ival%2 == 1))) + ival++; + return (ival); +} /* Round_MGRS */ + + +long Make_MGRS_String (char* MGRS, + long Zone, + int Letters[MGRS_LETTERS], + double Easting, + double Northing, + long Precision) +/* + * The function Make_MGRS_String constructs an MGRS string + * from its component parts. + * + * MGRS : MGRS coordinate string (output) + * Zone : UTM Zone (input) + * Letters : MGRS coordinate string letters (input) + * Easting : Easting value (input) + * Northing : Northing value (input) + * Precision : Precision level of MGRS string (input) + */ +{ /* Make_MGRS_String */ + long i; + long j; + double divisor; + long east; + long north; + char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + long error_code = MGRS_NO_ERROR; + + i = 0; + if (Zone) + i = sprintf (MGRS+i,"%2.2ld",Zone); + else + strncpy(MGRS, " ", 2); // 2 spaces + + for (j=0;j<3;j++) + MGRS[i++] = alphabet[Letters[j]]; + divisor = pow (10.0, (5 - Precision)); + Easting = fmod (Easting, 100000.0); + if (Easting >= 99999.5) + Easting = 99999.0; + east = (long)(Easting/divisor); + i += sprintf (MGRS+i, "%*.*ld", (int) Precision, (int) Precision, east); + Northing = fmod (Northing, 100000.0); + if (Northing >= 99999.5) + Northing = 99999.0; + north = (long)(Northing/divisor); + i += sprintf (MGRS+i, "%*.*ld", (int) Precision, (int) Precision, north); + return (error_code); +} /* Make_MGRS_String */ + + +long Break_MGRS_String (char* MGRS, + long* Zone, + long Letters[MGRS_LETTERS], + double* Easting, + double* Northing, + long* Precision) +/* + * The function Break_MGRS_String breaks down an MGRS + * coordinate string into its component parts. + * + * MGRS : MGRS coordinate string (input) + * Zone : UTM Zone (output) + * Letters : MGRS coordinate string letters (output) + * Easting : Easting value (output) + * Northing : Northing value (output) + * Precision : Precision level of MGRS string (output) + */ +{ /* Break_MGRS_String */ + long num_digits; + long num_letters; + long i = 0; + long j = 0; + long error_code = MGRS_NO_ERROR; + + while (MGRS[i] == ' ') + i++; /* skip any leading blanks */ + j = i; + while (isdigit(MGRS[i])) + i++; + num_digits = i - j; + if (num_digits <= 2) + if (num_digits > 0) + { + char zone_string[3]; + /* get zone */ + strncpy (zone_string, MGRS+j, 2); + zone_string[2] = 0; + sscanf (zone_string, "%ld", Zone); + if ((*Zone < 1) || (*Zone > 60)) + error_code |= MGRS_STRING_ERROR; + } + else + *Zone = 0; + else + error_code |= MGRS_STRING_ERROR; + j = i; + + while (isalpha(MGRS[i])) + i++; + num_letters = i - j; + if (num_letters == 3) + { + /* get letters */ + Letters[0] = (toupper(MGRS[j]) - (long)'A'); + if ((Letters[0] == LETTER_I) || (Letters[0] == LETTER_O)) + error_code |= MGRS_STRING_ERROR; + Letters[1] = (toupper(MGRS[j+1]) - (long)'A'); + if ((Letters[1] == LETTER_I) || (Letters[1] == LETTER_O)) + error_code |= MGRS_STRING_ERROR; + Letters[2] = (toupper(MGRS[j+2]) - (long)'A'); + if ((Letters[2] == LETTER_I) || (Letters[2] == LETTER_O)) + error_code |= MGRS_STRING_ERROR; + } + else + error_code |= MGRS_STRING_ERROR; + j = i; + while (isdigit(MGRS[i])) + i++; + num_digits = i - j; + if ((num_digits <= 10) && (num_digits%2 == 0)) + { + long n; + char east_string[6]; + char north_string[6]; + long east; + long north; + double multiplier; + /* get easting & northing */ + n = num_digits/2; + *Precision = n; + if (n > 0) + { + strncpy (east_string, MGRS+j, n); + east_string[n] = 0; + sscanf (east_string, "%ld", &east); + strncpy (north_string, MGRS+j+n, n); + north_string[n] = 0; + sscanf (north_string, "%ld", &north); + multiplier = pow (10.0, 5 - n); + *Easting = east * multiplier; + *Northing = north * multiplier; + } + else + { + *Easting = 0.0; + *Northing = 0.0; + } + } + else + error_code |= MGRS_STRING_ERROR; + + return (error_code); +} /* Break_MGRS_String */ + + +void Get_Grid_Values (long zone, + long* ltr2_low_value, + long* ltr2_high_value, + double *false_northing) +/* + * The function Get_Grid_Values sets the letter range used for + * the 2nd letter in the MGRS coordinate string, based on the set + * number of the utm zone. It also sets the false northing using a + * value of A for the second letter of the grid square, based on + * the grid pattern and set number of the utm zone. + * + * zone : Zone number (input) + * ltr2_low_value : 2nd letter low number (output) + * ltr2_high_value : 2nd letter high number (output) + * false_northing : False northing (output) + */ +{ /* BEGIN Get_Grid_Values */ + long set_number; /* Set number (1-6) based on UTM zone number */ + long aa_pattern; /* Pattern based on ellipsoid code */ + + set_number = zone % 6; + + if (!set_number) + set_number = 6; + + if (!strcmp(MGRS_Ellipsoid_Code,CLARKE_1866) || !strcmp(MGRS_Ellipsoid_Code, CLARKE_1880) || + !strcmp(MGRS_Ellipsoid_Code,BESSEL_1841) || !strcmp(MGRS_Ellipsoid_Code,BESSEL_1841_NAMIBIA)) + aa_pattern = FALSE; + else + aa_pattern = TRUE; + + if ((set_number == 1) || (set_number == 4)) + { + *ltr2_low_value = LETTER_A; + *ltr2_high_value = LETTER_H; + } + else if ((set_number == 2) || (set_number == 5)) + { + *ltr2_low_value = LETTER_J; + *ltr2_high_value = LETTER_R; + } + else if ((set_number == 3) || (set_number == 6)) + { + *ltr2_low_value = LETTER_S; + *ltr2_high_value = LETTER_Z; + } + + /* False northing at A for second letter of grid square */ + if (aa_pattern) + { + if ((set_number % 2) == 0) + *false_northing = 1500000.0; + else + *false_northing = 0.0; + } + else + { + if ((set_number % 2) == 0) + *false_northing = 500000.0; + else + *false_northing = 1000000.00; + } +} /* END OF Get_Grid_Values */ + + +long UTM_To_MGRS (long Zone, + double Latitude, + double Easting, + double Northing, + long Precision, + char *MGRS) +/* + * The function UTM_To_MGRS calculates an MGRS coordinate string + * based on the zone, latitude, easting and northing. + * + * Zone : Zone number (input) + * Latitude : Latitude in radians (input) + * Easting : Easting (input) + * Northing : Northing (input) + * Precision : Precision (input) + * MGRS : MGRS coordinate string (output) + */ +{ /* BEGIN UTM_To_MGRS */ + double false_northing; /* False northing for 3rd letter */ + double grid_easting; /* Easting used to derive 2nd letter of MGRS */ + double grid_northing; /* Northing used to derive 3rd letter of MGRS */ + long ltr2_low_value; /* 2nd letter range - low number */ + long ltr2_high_value; /* 2nd letter range - high number */ + int letters[MGRS_LETTERS]; /* Number location of 3 letters in alphabet */ + double divisor; + long error_code = MGRS_NO_ERROR; + + /* Round easting and northing values */ + divisor = pow (10.0, (5 - Precision)); + Easting = Round_MGRS (Easting/divisor) * divisor; + Northing = Round_MGRS (Northing/divisor) * divisor; + + Get_Grid_Values(Zone, <r2_low_value, <r2_high_value, &false_northing); + + error_code = Get_Latitude_Letter(Latitude, &letters[0]); + + if (!error_code) + { + grid_northing = Northing; + if (grid_northing == 1.e7) + grid_northing = grid_northing - 1.0; + + while (grid_northing >= TWOMIL) + { + grid_northing = grid_northing - TWOMIL; + } + grid_northing = grid_northing - false_northing; + + if (grid_northing < 0.0) + grid_northing = grid_northing + TWOMIL; + + letters[2] = (long)(grid_northing / ONEHT); + if (letters[2] > LETTER_H) + letters[2] = letters[2] + 1; + + if (letters[2] > LETTER_N) + letters[2] = letters[2] + 1; + + grid_easting = Easting; + if (((letters[0] == LETTER_V) && (Zone == 31)) && (grid_easting == 500000.0)) + grid_easting = grid_easting - 1.0; /* SUBTRACT 1 METER */ + + letters[1] = ltr2_low_value + ((long)(grid_easting / ONEHT) -1); + if ((ltr2_low_value == LETTER_J) && (letters[1] > LETTER_N)) + letters[1] = letters[1] + 1; + + Make_MGRS_String (MGRS, Zone, letters, Easting, Northing, Precision); + } + return error_code; +} /* END UTM_To_MGRS */ + + +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) + */ +{ /* Set_MGRS_Parameters */ + + double inv_f = 1 / f; + long Error_Code = MGRS_NO_ERROR; + + if (a <= 0.0) + { /* Semi-major axis must be greater than zero */ + Error_Code |= MGRS_A_ERROR; + } + if ((inv_f < 250) || (inv_f > 350)) + { /* Inverse flattening must be between 250 and 350 */ + Error_Code |= MGRS_INV_F_ERROR; + } + if (!Error_Code) + { /* no errors */ + MGRS_a = a; + MGRS_f = f; + MGRS_recpf = inv_f; + strcpy (MGRS_Ellipsoid_Code, Ellipsoid_Code); + } + return (Error_Code); +} /* Set_MGRS_Parameters */ + + +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) + */ +{ /* Get_MGRS_Parameters */ + *a = MGRS_a; + *f = MGRS_f; + strcpy (Ellipsoid_Code, MGRS_Ellipsoid_Code); + return; +} /* Get_MGRS_Parameters */ + +#ifdef notdef +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) + */ +{ /* Convert_UTM_To_MGRS */ + double latitude; /* Latitude of UTM point */ + double longitude; /* Longitude of UTM point */ + long temp_error = MGRS_NO_ERROR; + long error_code = MGRS_NO_ERROR; + + if ((Zone < 1) || (Zone > 60)) + error_code |= MGRS_ZONE_ERROR; + if ((Hemisphere != 'S') && (Hemisphere != 'N')) + error_code |= MGRS_HEMISPHERE_ERROR; + if ((Easting < MIN_EASTING) || (Easting > MAX_EASTING)) + error_code |= MGRS_EASTING_ERROR; + if ((Northing < MIN_NORTHING) || (Northing > MAX_NORTHING)) + error_code |= MGRS_NORTHING_ERROR; + if ((Precision < 0) || (Precision > MAX_PRECISION)) + error_code |= MGRS_PRECISION_ERROR; + if (!error_code) + { + Set_UTM_Parameters (MGRS_a, MGRS_f, 0); + temp_error = Convert_UTM_To_Geodetic (Zone, Hemisphere, Easting, Northing, &latitude, &longitude); + + /* Special check for rounding to (truncated) eastern edge of zone 31V */ + if ((Zone == 31) && (latitude >= 56.0 * DEG_TO_RAD) && (latitude < 64.0 * DEG_TO_RAD) && + (longitude >= 3.0 * DEG_TO_RAD)) + { /* Reconvert to UTM zone 32 */ + Set_UTM_Parameters (MGRS_a, MGRS_f, 32); + temp_error = Convert_Geodetic_To_UTM (latitude, longitude, &Zone, &Hemisphere, &Easting, &Northing); + } + + error_code = UTM_To_MGRS (Zone, latitude, Easting, Northing, Precision, MGRS); + } + return (error_code); +} /* Convert_UTM_To_MGRS */ +#endif + +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) + */ +{ /* Convert_MGRS_To_UTM */ + double scaled_min_northing; + double min_northing; + long ltr2_low_value; + long ltr2_high_value; + double false_northing; + double grid_easting; /* Easting for 100,000 meter grid square */ + double grid_northing; /* Northing for 100,000 meter grid square */ + long letters[MGRS_LETTERS]; + long in_precision; +#ifdef notdef + double upper_lat_limit; /* North latitude limits based on 1st letter */ + double lower_lat_limit; /* South latitude limits based on 1st letter */ + double latitude = 0.0; + double longitude = 0.0; + double divisor = 1.0; +#endif + long error_code = MGRS_NO_ERROR; + + error_code = Break_MGRS_String (MGRS, Zone, letters, Easting, Northing, &in_precision); + if (!*Zone) + error_code |= MGRS_STRING_ERROR; + else + { + if (!error_code) + { + if ((letters[0] == LETTER_X) && ((*Zone == 32) || (*Zone == 34) || (*Zone == 36))) + error_code |= MGRS_STRING_ERROR; + else + { + if (letters[0] < LETTER_N) + *Hemisphere = 'S'; + else + *Hemisphere = 'N'; + + Get_Grid_Values(*Zone, <r2_low_value, <r2_high_value, &false_northing); + + /* Check that the second letter of the MGRS string is within + * the range of valid second letter values + * Also check that the third letter is valid */ + if ((letters[1] < ltr2_low_value) || (letters[1] > ltr2_high_value) || (letters[2] > LETTER_V)) + error_code |= MGRS_STRING_ERROR; + + if (!error_code) + { + grid_northing = (double)(letters[2]) * ONEHT + false_northing; + grid_easting = (double)((letters[1]) - ltr2_low_value + 1) * ONEHT; + if ((ltr2_low_value == LETTER_J) && (letters[1] > LETTER_O)) + grid_easting = grid_easting - ONEHT; + + if (letters[2] > LETTER_O) + grid_northing = grid_northing - ONEHT; + + if (letters[2] > LETTER_I) + grid_northing = grid_northing - ONEHT; + + if (grid_northing >= TWOMIL) + grid_northing = grid_northing - TWOMIL; + + error_code = Get_Latitude_Band_Min_Northing(letters[0], &min_northing); + if (!error_code) + { + scaled_min_northing = min_northing; + while (scaled_min_northing >= TWOMIL) + { + scaled_min_northing = scaled_min_northing - TWOMIL; + } + + grid_northing = grid_northing - scaled_min_northing; + if (grid_northing < 0.0) + grid_northing = grid_northing + TWOMIL; + + grid_northing = min_northing + grid_northing; + + *Easting = grid_easting + *Easting; + *Northing = grid_northing + *Northing; +#ifdef notdef + /* check that point is within Zone Letter bounds */ + error_code = Set_UTM_Parameters(MGRS_a,MGRS_f,*Zone); + if (!error_code) + { + error_code = Convert_UTM_To_Geodetic(*Zone,*Hemisphere,*Easting,*Northing,&latitude,&longitude); + if (!error_code) + { + divisor = pow (10.0, in_precision); + error_code = Get_Latitude_Range(letters[0], &upper_lat_limit, &lower_lat_limit); + if (!error_code) + { + if (!(((lower_lat_limit - DEG_TO_RAD/divisor) <= latitude) && (latitude <= (upper_lat_limit + DEG_TO_RAD/divisor)))) + error_code |= MGRS_LAT_ERROR; + } + } + } +#endif /* notdef */ + } + } + } + } + } + return (error_code); +} /* Convert_MGRS_To_UTM */ + + +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) + */ +{ /* Convert_UPS_To_MGRS */ + double false_easting; /* False easting for 2nd letter */ + double false_northing; /* False northing for 3rd letter */ + double grid_easting; /* Easting used to derive 2nd letter of MGRS */ + double grid_northing; /* Northing used to derive 3rd letter of MGRS */ + long ltr2_low_value; /* 2nd letter range - low number */ + int letters[MGRS_LETTERS]; /* Number location of 3 letters in alphabet */ + double divisor; + int index = 0; + long error_code = MGRS_NO_ERROR; + + if ((Hemisphere != 'N') && (Hemisphere != 'S')) + error_code |= MGRS_HEMISPHERE_ERROR; + if ((Easting < MIN_EAST_NORTH) || (Easting > MAX_EAST_NORTH)) + error_code |= MGRS_EASTING_ERROR; + if ((Northing < MIN_EAST_NORTH) || (Northing > MAX_EAST_NORTH)) + error_code |= MGRS_NORTHING_ERROR; + if ((Precision < 0) || (Precision > MAX_PRECISION)) + error_code |= MGRS_PRECISION_ERROR; + if (!error_code) + { + divisor = pow (10.0, (5 - Precision)); + Easting = Round_MGRS (Easting/divisor) * divisor; + Northing = Round_MGRS (Northing/divisor) * divisor; + + if (Hemisphere == 'N') + { + if (Easting >= TWOMIL) + letters[0] = LETTER_Z; + else + letters[0] = LETTER_Y; + + index = letters[0] - 22; + ltr2_low_value = UPS_Constant_Table[index].ltr2_low_value; + false_easting = UPS_Constant_Table[index].false_easting; + false_northing = UPS_Constant_Table[index].false_northing; + } + else + { + if (Easting >= TWOMIL) + letters[0] = LETTER_B; + else + letters[0] = LETTER_A; + + ltr2_low_value = UPS_Constant_Table[letters[0]].ltr2_low_value; + false_easting = UPS_Constant_Table[letters[0]].false_easting; + false_northing = UPS_Constant_Table[letters[0]].false_northing; + } + + grid_northing = Northing; + grid_northing = grid_northing - false_northing; + letters[2] = (long)(grid_northing / ONEHT); + + if (letters[2] > LETTER_H) + letters[2] = letters[2] + 1; + + if (letters[2] > LETTER_N) + letters[2] = letters[2] + 1; + + grid_easting = Easting; + grid_easting = grid_easting - false_easting; + letters[1] = ltr2_low_value + ((long)(grid_easting / ONEHT)); + + if (Easting < TWOMIL) + { + if (letters[1] > LETTER_L) + letters[1] = letters[1] + 3; + + if (letters[1] > LETTER_U) + letters[1] = letters[1] + 2; + } + else + { + if (letters[1] > LETTER_C) + letters[1] = letters[1] + 2; + + if (letters[1] > LETTER_H) + letters[1] = letters[1] + 1; + + if (letters[1] > LETTER_L) + letters[1] = letters[1] + 3; + } + + Make_MGRS_String (MGRS, 0, letters, Easting, Northing, Precision); + } + return (error_code); +} /* Convert_UPS_To_MGRS */ + + +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) + */ +{ /* Convert_MGRS_To_UPS */ + long ltr2_high_value; /* 2nd letter range - high number */ + long ltr3_high_value; /* 3rd letter range - high number (UPS) */ + long ltr2_low_value; /* 2nd letter range - low number */ + double false_easting; /* False easting for 2nd letter */ + double false_northing; /* False northing for 3rd letter */ + double grid_easting; /* easting for 100,000 meter grid square */ + double grid_northing; /* northing for 100,000 meter grid square */ + long zone; + long letters[MGRS_LETTERS]; + long in_precision; + int index = 0; + long error_code = MGRS_NO_ERROR; + + error_code = Break_MGRS_String (MGRS, &zone, letters, Easting, Northing, &in_precision); + if (zone) + error_code |= MGRS_STRING_ERROR; + else + { + if (!error_code) + { + if (letters[0] >= LETTER_Y) + { + *Hemisphere = 'N'; + + index = letters[0] - 22; + ltr2_low_value = UPS_Constant_Table[index].ltr2_low_value; + ltr2_high_value = UPS_Constant_Table[index].ltr2_high_value; + ltr3_high_value = UPS_Constant_Table[index].ltr3_high_value; + false_easting = UPS_Constant_Table[index].false_easting; + false_northing = UPS_Constant_Table[index].false_northing; + } + else + { + *Hemisphere = 'S'; + + ltr2_low_value = UPS_Constant_Table[letters[0]].ltr2_low_value; + ltr2_high_value = UPS_Constant_Table[letters[0]].ltr2_high_value; + ltr3_high_value = UPS_Constant_Table[letters[0]].ltr3_high_value; + false_easting = UPS_Constant_Table[letters[0]].false_easting; + false_northing = UPS_Constant_Table[letters[0]].false_northing; + } + + /* Check that the second letter of the MGRS string is within + * the range of valid second letter values + * Also check that the third letter is valid */ + if ((letters[1] < ltr2_low_value) || (letters[1] > ltr2_high_value) || + ((letters[1] == LETTER_D) || (letters[1] == LETTER_E) || + (letters[1] == LETTER_M) || (letters[1] == LETTER_N) || + (letters[1] == LETTER_V) || (letters[1] == LETTER_W)) || + (letters[2] > ltr3_high_value)) + error_code = MGRS_STRING_ERROR; + + if (!error_code) + { + grid_northing = (double)letters[2] * ONEHT + false_northing; + if (letters[2] > LETTER_I) + grid_northing = grid_northing - ONEHT; + + if (letters[2] > LETTER_O) + grid_northing = grid_northing - ONEHT; + + grid_easting = (double)((letters[1]) - ltr2_low_value) * ONEHT + false_easting; + if (ltr2_low_value != LETTER_A) + { + if (letters[1] > LETTER_L) + grid_easting = grid_easting - 300000.0; + + if (letters[1] > LETTER_U) + grid_easting = grid_easting - 200000.0; + } + else + { + if (letters[1] > LETTER_C) + grid_easting = grid_easting - 200000.0; + + if (letters[1] > LETTER_I) + grid_easting = grid_easting - ONEHT; + + if (letters[1] > LETTER_L) + grid_easting = grid_easting - 300000.0; + } + + *Easting = grid_easting + *Easting; + *Northing = grid_northing + *Northing; + } + } + } + return (error_code); +} /* Convert_MGRS_To_UPS */ + + + diff --git a/Utilities/GDAL/frmts/nitf/nitffile.c b/Utilities/GDAL/frmts/nitf/nitffile.c new file mode 100644 index 0000000000..c9defb4176 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/nitffile.c @@ -0,0 +1,963 @@ +/****************************************************************************** + * $Id$ + * + * Project: NITF Read/Write Library + * Purpose: Module responsible for opening NITF file, populating NITFFile + * structure, and instantiating segment specific access objects. + * 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: nitffile.c,v $ + * Revision 1.21 2005/09/21 16:11:21 fwarmerdam + * Compute complexity level (Brent Fraser) + * + * Revision 1.20 2005/07/28 20:00:57 fwarmerdam + * upgrade to support 2-4GB files, use large file api + * + * Revision 1.19 2004/12/10 21:35:00 fwarmerdam + * preliminary support for writing JPEG2000 compressed data + * + * Revision 1.18 2004/04/30 17:38:28 warmerda + * clean up metadata + * + * Revision 1.17 2004/04/28 16:43:23 warmerda + * added simplified geocentric to geodetic cvonersion + * + * Revision 1.16 2004/04/16 15:26:04 warmerda + * completed metadata support + * + * Revision 1.15 2004/04/15 20:52:44 warmerda + * added metadata extraction + * + * Revision 1.14 2003/09/11 19:51:55 warmerda + * avoid type casting warnings + * + * Revision 1.13 2003/06/23 18:31:39 warmerda + * fixed field alignment for a few fields on write + * + * Revision 1.12 2003/06/06 17:10:14 warmerda + * Improved header size test to support large headers, even those as large as + * the whole file. + * + * Revision 1.11 2003/06/06 16:52:32 warmerda + * changes based on better understanding of conditional FSDEVT field + * + * Revision 1.10 2003/06/06 15:07:53 warmerda + * fixed security area sizing for NITF 2.0 images, its like NITF 1.1. + * + * Revision 1.9 2003/05/29 19:50:39 warmerda + * added improved TRE handling + * + * Revision 1.8 2003/05/05 17:57:54 warmerda + * added blocked writing support + * + * Revision 1.7 2002/12/18 20:16:20 warmerda + * allow lots of fields to be overridden with passed in options + * + * Revision 1.6 2002/12/17 21:23:15 warmerda + * implement LUT reading and writing + * + * Revision 1.5 2002/12/17 20:03:08 warmerda + * added rudimentary NITF 1.1 support + * + * Revision 1.4 2002/12/17 05:26:26 warmerda + * implement basic write support + * + * Revision 1.3 2002/12/03 18:07:59 warmerda + * load VQLUTs + * + * 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_vsi.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id$"); + +static int +NITFCollectSegmentInfo( NITFFile *psFile, int nOffset, char *pszType, + int nHeaderLenSize, int nDataLenSize, + int *pnNextData ); +static void NITFLoadLocationTable( NITFFile *psFile ); +static int NITFLoadVQTables( NITFFile *psFile ); + +/************************************************************************/ +/* NITFOpen() */ +/************************************************************************/ + +NITFFile *NITFOpen( const char *pszFilename, int bUpdatable ) + +{ + FILE *fp; + char *pachHeader; + NITFFile *psFile; + int nHeaderLen, nOffset, nNextData, nHeaderLenOffset; + char szTemp[128], achFSDWNG[6]; + GIntBig nFileLength; + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + if( bUpdatable ) + fp = VSIFOpenL( pszFilename, "r+b" ); + else + fp = VSIFOpenL( pszFilename, "rb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open file %s.", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Check file type. */ +/* -------------------------------------------------------------------- */ + VSIFReadL( szTemp, 1, 9, fp ); + + if( !EQUALN(szTemp,"NITF",4) && !EQUALN(szTemp,"NSIF",4) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The file %s is not an NITF file.", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read the FSDWNG field. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeekL( fp, 280, SEEK_SET ) != 0 + || VSIFReadL( achFSDWNG, 1, 6, fp ) != 6 ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Unable to read FSDWNG field from NITF file. File is either corrupt\n" + "or empty." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Get header length. */ +/* -------------------------------------------------------------------- */ + if( EQUALN(szTemp,"NITF01.",7) || EQUALN(achFSDWNG,"999998",6) ) + nHeaderLenOffset = 394; + else + nHeaderLenOffset = 354; + + if( VSIFSeekL( fp, nHeaderLenOffset, SEEK_SET ) != 0 + || VSIFReadL( szTemp, 1, 6, fp ) != 6 ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Unable to read header length from NITF file. File is either corrupt\n" + "or empty." ); + return NULL; + } + + szTemp[6] = '\0'; + nHeaderLen = atoi(szTemp); + + VSIFSeekL( fp, 0, SEEK_END ); + nFileLength = VSIFTellL( fp ) ; + if( nHeaderLen < nHeaderLenOffset || nHeaderLen > nFileLength ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "NITF Header Length (%d) seems to be corrupt.", + nHeaderLen ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Read the whole file header. */ +/* -------------------------------------------------------------------- */ + pachHeader = (char *) CPLMalloc(nHeaderLen); + VSIFSeekL( fp, 0, SEEK_SET ); + VSIFReadL( pachHeader, 1, nHeaderLen, fp ); + +/* -------------------------------------------------------------------- */ +/* Create and initialize info structure about file. */ +/* -------------------------------------------------------------------- */ + psFile = (NITFFile *) CPLCalloc(sizeof(NITFFile),1); + psFile->fp = fp; + psFile->pachHeader = pachHeader; + +/* -------------------------------------------------------------------- */ +/* Get version. */ +/* -------------------------------------------------------------------- */ + NITFGetField( psFile->szVersion, pachHeader, 0, 9 ); + +/* -------------------------------------------------------------------- */ +/* Collect a variety of information as metadata. */ +/* -------------------------------------------------------------------- */ +#define GetMD( target, hdr, start, length, name ) \ + NITFExtractMetadata( &(target->papszMetadata), hdr, \ + start, length, \ + "NITF_" #name ); + + if( EQUAL(psFile->szVersion,"NITF02.10") ) + { + char szWork[100]; + + GetMD( psFile, pachHeader, 0, 9, FHDR ); + GetMD( psFile, pachHeader, 9, 2, CLEVEL ); + GetMD( psFile, pachHeader, 11, 4, STYPE ); + GetMD( psFile, pachHeader, 15, 10, OSTAID ); + GetMD( psFile, pachHeader, 25, 14, FDT ); + GetMD( psFile, pachHeader, 39, 80, FTITLE ); + GetMD( psFile, pachHeader, 119, 1, FSCLAS ); + GetMD( psFile, pachHeader, 120, 2, FSCLSY ); + GetMD( psFile, pachHeader, 122, 11, FSCODE ); + GetMD( psFile, pachHeader, 133, 2, FSCTLH ); + GetMD( psFile, pachHeader, 135, 20, FSREL ); + GetMD( psFile, pachHeader, 155, 2, FSDCTP ); + GetMD( psFile, pachHeader, 157, 8, FSDCDT ); + GetMD( psFile, pachHeader, 165, 4, FSDCXM ); + GetMD( psFile, pachHeader, 169, 1, FSDG ); + GetMD( psFile, pachHeader, 170, 8, FSDGDT ); + GetMD( psFile, pachHeader, 178, 43, FSCLTX ); + GetMD( psFile, pachHeader, 221, 1, FSCATP ); + GetMD( psFile, pachHeader, 222, 40, FSCAUT ); + GetMD( psFile, pachHeader, 262, 1, FSCRSN ); + GetMD( psFile, pachHeader, 263, 8, FSSRDT ); + GetMD( psFile, pachHeader, 271, 15, FSCTLN ); + GetMD( psFile, pachHeader, 286, 5, FSCOP ); + GetMD( psFile, pachHeader, 291, 5, FSCPYS ); + GetMD( psFile, pachHeader, 296, 1, ENCRYP ); + sprintf( szWork, "%3d,%3d,%3d", + ((GByte *)pachHeader)[297], + ((GByte *)pachHeader)[298], + ((GByte *)pachHeader)[299] ); + GetMD( psFile, szWork, 0, 11, FBKGC ); + GetMD( psFile, pachHeader, 300, 24, ONAME ); + GetMD( psFile, pachHeader, 324, 18, OPHONE ); + } + else if( EQUAL(psFile->szVersion,"NITF02.00") ) + { + int nCOff = 0; + + GetMD( psFile, pachHeader, 0, 9, FHDR ); + GetMD( psFile, pachHeader, 9, 2, CLEVEL ); + GetMD( psFile, pachHeader, 11, 4, STYPE ); + GetMD( psFile, pachHeader, 15, 10, OSTAID ); + GetMD( psFile, pachHeader, 25, 14, FDT ); + GetMD( psFile, pachHeader, 39, 80, FTITLE ); + GetMD( psFile, pachHeader, 119, 1, FSCLAS ); + GetMD( psFile, pachHeader, 120, 40, FSCODE ); + GetMD( psFile, pachHeader, 160, 40, FSCTLH ); + GetMD( psFile, pachHeader, 200, 40, FSREL ); + GetMD( psFile, pachHeader, 240, 20, FSCAUT ); + GetMD( psFile, pachHeader, 260, 20, FSCTLN ); + GetMD( psFile, pachHeader, 280, 6, FSDWNG ); + if( EQUALN(pachHeader+280,"999998",6) ) + { + GetMD( psFile, pachHeader, 286, 40, FSDEVT ); + nCOff += 40; + } + GetMD( psFile, pachHeader, 286+nCOff, 5, FSCOP ); + GetMD( psFile, pachHeader, 291+nCOff, 5, FSCPYS ); + GetMD( psFile, pachHeader, 296+nCOff, 1, ENCRYP ); + GetMD( psFile, pachHeader, 297+nCOff, 27, ONAME ); + GetMD( psFile, pachHeader, 324+nCOff, 18, OPHONE ); + } + +/* -------------------------------------------------------------------- */ +/* Collect segment info for the types we care about. */ +/* -------------------------------------------------------------------- */ + nNextData = nHeaderLen; + + nOffset = nHeaderLenOffset + 6; + + nOffset = NITFCollectSegmentInfo( psFile, nOffset,"IM",6, 10, &nNextData ); + + nOffset = NITFCollectSegmentInfo( psFile, nOffset, "GR", 4, 6, &nNextData); + + nOffset += 3; /* NUMX reserved field */ + + nOffset = NITFCollectSegmentInfo( psFile, nOffset, "TX", 4, 5, &nNextData); + + nOffset = NITFCollectSegmentInfo( psFile, nOffset, "DE", 4, 9, &nNextData); + + nOffset = NITFCollectSegmentInfo( psFile, nOffset, "RE", 4, 7, &nNextData); + +/* -------------------------------------------------------------------- */ +/* Is there a TRE to suck up? */ +/* -------------------------------------------------------------------- */ + psFile->nTREBytes = + atoi(NITFGetField( szTemp, pachHeader, nOffset, 5 )); + nOffset += 5; + + nOffset += 3; /* UDHOFL */ + + if( psFile->nTREBytes != 0 ) + { + psFile->pachTRE = pachHeader + nOffset; + psFile->nTREBytes -= 3; + } + +/* -------------------------------------------------------------------- */ +/* Are the VQ tables to load up? */ +/* -------------------------------------------------------------------- */ + NITFLoadLocationTable( psFile ); + NITFLoadVQTables( psFile ); + + return psFile; +} + +/************************************************************************/ +/* NITFClose() */ +/************************************************************************/ + +void NITFClose( NITFFile *psFile ) + +{ + int iSegment, i; + + for( iSegment = 0; iSegment < psFile->nSegmentCount; iSegment++ ) + { + NITFSegmentInfo *psSegInfo = psFile->pasSegmentInfo + iSegment; + + if( psSegInfo->hAccess == NULL ) + continue; + + if( EQUAL(psSegInfo->szSegmentType,"IM")) + NITFImageDeaccess( (NITFImage *) psSegInfo->hAccess ); + else + { + CPLAssert( FALSE ); + } + } + + CPLFree( psFile->pasSegmentInfo ); + CPLFree( psFile->pasLocations ); + for( i = 0; i < 4; i++ ) + CPLFree( psFile->apanVQLUT[i] ); + + if( psFile->fp != NULL ) + VSIFCloseL( psFile->fp ); + CPLFree( psFile->pachHeader ); + CSLDestroy( psFile->papszMetadata ); + CPLFree( psFile ); +} + +/************************************************************************/ +/* NITFCreate() */ +/* */ +/* Create a new uncompressed NITF file. */ +/************************************************************************/ + +int NITFCreate( const char *pszFilename, + int nPixels, int nLines, int nBands, + int nBitsPerSample, const char *pszPVType, + char **papszOptions ) + +{ + FILE *fp; + char *pachIMHDR; + char achHeader[5000]; + int nOffset = 0, iBand, nIHSize, nNPPBH, nNPPBV; + GIntBig nImageSize; + int nNBPR, nNBPC; + const char *pszIREP; + const char *pszIC = CSLFetchNameValue(papszOptions,"IC"); + const char *pszCLevel; + + + if( pszIC == NULL ) + pszIC = "NC"; + +/* -------------------------------------------------------------------- */ +/* Open new file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpenL( pszFilename, "wb+" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to create file %s,\n" + "check path and permissions.", + pszFilename ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Fetch some parameter overrides. */ +/* -------------------------------------------------------------------- */ + pszIREP = CSLFetchNameValue( papszOptions, "IREP" ); + if( pszIREP == NULL ) + pszIREP = "MONO"; + +/* -------------------------------------------------------------------- */ +/* Compute raw image size, blocking factors and so forth. */ +/* -------------------------------------------------------------------- */ + nNPPBH = nPixels; + nNPPBV = nLines; + + if( CSLFetchNameValue( papszOptions, "BLOCKSIZE" ) != NULL ) + nNPPBH = nNPPBV = atoi(CSLFetchNameValue( papszOptions, "BLOCKSIZE" )); + + if( CSLFetchNameValue( papszOptions, "BLOCKXSIZE" ) != NULL ) + nNPPBH = atoi(CSLFetchNameValue( papszOptions, "BLOCKXSIZE" )); + + if( CSLFetchNameValue( papszOptions, "BLOCKYSIZE" ) != NULL ) + nNPPBV = atoi(CSLFetchNameValue( papszOptions, "BLOCKYSIZE" )); + + if( CSLFetchNameValue( papszOptions, "NPPBH" ) != NULL ) + nNPPBH = atoi(CSLFetchNameValue( papszOptions, "NPPBH" )); + + if( CSLFetchNameValue( papszOptions, "NPPBV" ) != NULL ) + nNPPBV = atoi(CSLFetchNameValue( papszOptions, "NPPBV" )); + + if( nNPPBH > 9999 || nNPPBV > 9999 ) + nNPPBH = nNPPBV = 256; + + nNBPR = (nPixels + nNPPBH - 1) / nNPPBH; + nNBPC = (nLines + nNPPBV - 1) / nNPPBV; + + nImageSize = + ((nBitsPerSample)/8) + * ((GIntBig) nNBPR * nNBPC) + * nNPPBH * nNPPBV * nBands; + +/* -------------------------------------------------------------------- */ +/* Compute CLEVEL ("complexity" level). */ +/* See: http://164.214.2.51/ntb/baseline/docs/2500b/2500b_not2.pdf */ +/* page 96u */ +/* TBD: Set CLEVEL based on file size too */ +/* -------------------------------------------------------------------- */ + pszCLevel = "03"; + if (nPixels > 2048 || nLines > 2048 ) pszCLevel = "05"; + if (nPixels > 8192 || nLines > 8192 ) pszCLevel = "06"; + if (nPixels > 65536 || nLines > 65536 ) pszCLevel = "07"; + +/* -------------------------------------------------------------------- */ +/* Prepare the file header. */ +/* -------------------------------------------------------------------- */ + memset( achHeader, ' ', sizeof(achHeader) ); + +#define PLACE(location,name,text) strncpy(location,text,strlen(text)) +#define OVR(width,location,name,text) { \ + const char *pszParmValue; \ + pszParmValue = CSLFetchNameValue( papszOptions, #name ); \ + if( pszParmValue == NULL ) \ + pszParmValue = text; \ + strncpy(location,pszParmValue,MIN(width,strlen(pszParmValue))); } + + PLACE (achHeader+ 0, FDHR_FVER, "NITF02.10" ); + OVR( 2,achHeader+ 9, CLEVEL, pszCLevel ); + PLACE (achHeader+ 11, STYPE ,"BF01" ); + OVR(10,achHeader+ 15, OSTAID ,"GDAL" ); + OVR(14,achHeader+ 25, FDT ,"20021216151629" ); + OVR(80,achHeader+ 39, FTITLE ,"" ); + OVR( 1,achHeader+119, FSCLAS ,"U" ); + OVR( 2,achHeader+120, FSCLSY ,"" ); + OVR(11,achHeader+122, FSCODE ,"" ); + OVR( 2,achHeader+133, FSCTLH ,"" ); + OVR(20,achHeader+135, FSREL ,"" ); + OVR( 2,achHeader+155, FSDCTP ,"" ); + OVR( 8,achHeader+157, FSDCDT ,"" ); + OVR( 4,achHeader+165, FSDCXM ,"" ); + OVR( 1,achHeader+169, FSDG ,"" ); + OVR( 8,achHeader+170, FSDGDT ,"" ); + OVR(43,achHeader+178, FSCLTX ,"" ); + OVR( 1,achHeader+221, FSCATP ,"" ); + OVR(40,achHeader+222, FSCAUT ,"" ); + OVR( 1,achHeader+262, FSCRSN ,"" ); + OVR( 8,achHeader+263, FSSRDT ,"" ); + OVR(15,achHeader+271, FSCTLN ,"" ); + OVR( 5,achHeader+286, FSCOP ,"00000" ); + OVR( 5,achHeader+291, FSCPYS ,"00000" ); + PLACE (achHeader+296, ENCRYP ,"0" ); + achHeader[297] = achHeader[298] = achHeader[299] = 0x00; /* FBKGC */ + OVR(24,achHeader+300, ONAME ,"" ); + OVR(18,achHeader+324, OPHONE ,"" ); + PLACE (achHeader+342, FL ,"????????????" ); + PLACE (achHeader+354, HL ,"000404" ); + PLACE (achHeader+360, NUMI ,"001" ); + PLACE (achHeader+363, LISH1 ,"??????" ); + PLACE (achHeader+369, LI1 ,CPLSPrintf("%010ud",(GUInt32) nImageSize) ); + PLACE (achHeader+379, NUMS ,"000" ); + PLACE (achHeader+382, NUMX ,"000" ); + PLACE (achHeader+385, NUMT ,"000" ); + PLACE (achHeader+388, NUMDES ,"000" ); + PLACE (achHeader+391, NUMRES ,"000" ); + PLACE (achHeader+394, UDHDL ,"00000" ); + PLACE (achHeader+399, XHDL ,"00000" ); + +/* -------------------------------------------------------------------- */ +/* Prepare the image header. */ +/* -------------------------------------------------------------------- */ + pachIMHDR = achHeader + 404; + + PLACE (pachIMHDR+ 0, IM , "IM" ); + OVR(10,pachIMHDR+ 2, IID1 , "Missing" ); + OVR(14,pachIMHDR+ 12, IDATIM , "20021216151629" ); + OVR(17,pachIMHDR+ 26, TGTID , "" ); + OVR(80,pachIMHDR+ 43, IID2 , "" ); + OVR( 1,pachIMHDR+123, ISCLAS , "U" ); + OVR( 2,pachIMHDR+124, ISCLSY , "" ); + OVR(11,pachIMHDR+126, ISCODE , "" ); + OVR( 2,pachIMHDR+137, ISCTLH , "" ); + OVR(20,pachIMHDR+139, ISREL , "" ); + OVR( 2,pachIMHDR+159, ISDCTP , "" ); + OVR( 8,pachIMHDR+161, ISDCDT , "" ); + OVR( 4,pachIMHDR+169, ISDCXM , "" ); + OVR( 1,pachIMHDR+173, ISDG , "" ); + OVR( 8,pachIMHDR+174, ISDGDT , "" ); + OVR(43,pachIMHDR+182, ISCLTX , "" ); + OVR( 1,pachIMHDR+225, ISCATP , "" ); + OVR(40,pachIMHDR+226, ISCAUT , "" ); + OVR( 1,pachIMHDR+266, ISCRSN , "" ); + OVR( 8,pachIMHDR+267, ISSRDT , "" ); + OVR(15,pachIMHDR+275, ISCTLN , "" ); + PLACE (pachIMHDR+290, ENCRYP , "0" ); + OVR(42,pachIMHDR+291, ISORCE , "Unknown" ); + PLACE (pachIMHDR+333, NROWS , CPLSPrintf("%08d", nLines) ); + PLACE (pachIMHDR+341, NCOLS , CPLSPrintf("%08d", nPixels) ); + PLACE (pachIMHDR+349, PVTYPE , pszPVType ); + PLACE (pachIMHDR+352, IREP , pszIREP ); + OVR( 8,pachIMHDR+360, ICAT , "VIS" ); + OVR( 2,pachIMHDR+368, ABPP , CPLSPrintf("%02d",nBitsPerSample) ); + OVR( 1,pachIMHDR+370, PJUST , "R" ); + OVR( 1,pachIMHDR+371, ICORDS , " " ); + + nOffset = 372; + if( pachIMHDR[371] != ' ' ) + { + OVR(60,pachIMHDR+nOffset, IGEOLO, "" ); + nOffset += 60; + } + + PLACE (pachIMHDR+nOffset, NICOM , "0" ); + OVR( 2,pachIMHDR+nOffset+1, IC , "NC" ); + + if( pszIC[0] != 'N' ) + { + OVR( 4,pachIMHDR+nOffset+3, COMRAT , " " ); + nOffset += 4; + } + + PLACE (pachIMHDR+nOffset+3, NBANDS , CPLSPrintf("%d",nBands) ); + + nOffset += 4; + +/* -------------------------------------------------------------------- */ +/* Per band info */ +/* -------------------------------------------------------------------- */ + for( iBand = 0; iBand < nBands; iBand++ ) + { + const char *pszIREPBAND = "M"; + + if( EQUAL(pszIREP,"RGB/LUT") ) + pszIREPBAND = "LU"; + else if( EQUAL(pszIREP,"RGB") ) + { + if( iBand == 0 ) + pszIREPBAND = "R"; + else if( iBand == 1 ) + pszIREPBAND = "G"; + else if( iBand == 2 ) + pszIREPBAND = "B"; + } + + PLACE(pachIMHDR+nOffset+ 0, IREPBANDn, pszIREPBAND ); + PLACE(pachIMHDR+nOffset+ 2, ISUBCATn, "" ); + PLACE(pachIMHDR+nOffset+ 8, IFCn , "N" ); + PLACE(pachIMHDR+nOffset+ 9, IMFLTn, "" ); + + if( !EQUAL(pszIREP,"RGB/LUT") ) + { + PLACE(pachIMHDR+nOffset+12, NLUTSn, "0" ); + nOffset += 13; + } + else + { + int iC, nCount=256; + + if( CSLFetchNameValue(papszOptions,"LUT_SIZE") != NULL ) + nCount = atoi(CSLFetchNameValue(papszOptions,"LUT_SIZE")); + + PLACE(pachIMHDR+nOffset+12, NLUTSn, "3" ); + PLACE(pachIMHDR+nOffset+13, NELUTn, CPLSPrintf("%05d",nCount) ); + + for( iC = 0; iC < nCount; iC++ ) + { + pachIMHDR[nOffset+18+iC+ 0] = (char) iC; + pachIMHDR[nOffset+18+iC+nCount*1] = (char) iC; + pachIMHDR[nOffset+18+iC+nCount*2] = (char) iC; + } + nOffset += 18 + nCount*3; + } + } + +/* -------------------------------------------------------------------- */ +/* Remainder of image header info. */ +/* -------------------------------------------------------------------- */ + PLACE(pachIMHDR+nOffset+ 0, ISYNC , "0" ); + PLACE(pachIMHDR+nOffset+ 1, IMODE , "B" ); + PLACE(pachIMHDR+nOffset+ 2, NBPR , CPLSPrintf("%04d",nNBPR) ); + PLACE(pachIMHDR+nOffset+ 6, NBPC , CPLSPrintf("%04d",nNBPC) ); + PLACE(pachIMHDR+nOffset+ 10, NPPBH , CPLSPrintf("%04d",nNPPBH) ); + PLACE(pachIMHDR+nOffset+ 14, NPPBV , CPLSPrintf("%04d",nNPPBV) ); + PLACE(pachIMHDR+nOffset+ 18, NBPP , CPLSPrintf("%02d",nBitsPerSample) ); + PLACE(pachIMHDR+nOffset+ 20, IDLVL , "001" ); + PLACE(pachIMHDR+nOffset+ 23, IALVL , "000" ); + PLACE(pachIMHDR+nOffset+ 26, ILOC , "0000000000" ); + PLACE(pachIMHDR+nOffset+ 36, IMAG , "1.0 " ); + PLACE(pachIMHDR+nOffset+ 40, UDIDL , "00000" ); + PLACE(pachIMHDR+nOffset+ 45, IXSHDL, "00000" ); + + nOffset += 53; + + nIHSize = nOffset; + +/* -------------------------------------------------------------------- */ +/* Update the image header length in the file header and the */ +/* total file size. */ +/* -------------------------------------------------------------------- */ + PLACE(achHeader+ 363, LISH1, CPLSPrintf("%06d",nIHSize) ); + PLACE(achHeader+ 342, FL, + CPLSPrintf( "%012d", 404 + nIHSize + nImageSize ) ); + +/* -------------------------------------------------------------------- */ +/* Write header info to file. */ +/* -------------------------------------------------------------------- */ + VSIFWriteL( achHeader, 1, nIHSize+404, fp ); + +/* -------------------------------------------------------------------- */ +/* Grow file to full required size by writing one byte at the end. */ +/* -------------------------------------------------------------------- */ + { + const char *pszIC = CSLFetchNameValue(papszOptions,"IC"); + + if( pszIC != NULL && EQUAL(pszIC,"C8") ) + /* don't extend file */; + else + { + VSIFSeekL( fp, nImageSize-1, SEEK_CUR ); + achHeader[0] = '\0'; + VSIFWriteL( achHeader, 1, 1, fp ); + } + } + + VSIFCloseL( fp ); + + return TRUE; +} + +/************************************************************************/ +/* NITFCollectSegmentInfo() */ +/* */ +/* Collect the information about a set of segments of a */ +/* particular type from the NITF file header, and add them to */ +/* the segment list in the NITFFile object. */ +/************************************************************************/ + +static int +NITFCollectSegmentInfo( NITFFile *psFile, int nOffset, char *pszType, + int nHeaderLenSize, int nDataLenSize, int *pnNextData ) + +{ + char szTemp[12]; + char *pachSegDef; + int nCount, nSegDefSize, iSegment; + +/* -------------------------------------------------------------------- */ +/* Get the segment count, and grow the segmentinfo array */ +/* accordingly. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( psFile->fp, nOffset, SEEK_SET ); + VSIFReadL( szTemp, 1, 3, psFile->fp ); + szTemp[3] = '\0'; + + nCount = atoi(szTemp); + + if( nCount == 0 ) + return nOffset + 3; + + if( psFile->pasSegmentInfo == NULL ) + psFile->pasSegmentInfo = (NITFSegmentInfo *) + CPLMalloc( sizeof(NITFSegmentInfo) * nCount ); + else + psFile->pasSegmentInfo = (NITFSegmentInfo *) + CPLRealloc( psFile->pasSegmentInfo, + sizeof(NITFSegmentInfo) + * (psFile->nSegmentCount+nCount) ); + +/* -------------------------------------------------------------------- */ +/* Read the detailed information about the segments. */ +/* -------------------------------------------------------------------- */ + nSegDefSize = nCount * (nHeaderLenSize + nDataLenSize); + pachSegDef = (char *) CPLMalloc(nCount * (nHeaderLenSize + nDataLenSize)); + + VSIFReadL( pachSegDef, 1, nSegDefSize, psFile->fp ); + +/* -------------------------------------------------------------------- */ +/* Collect detailed about segment. */ +/* -------------------------------------------------------------------- */ + for( iSegment = 0; iSegment < nCount; iSegment++ ) + { + NITFSegmentInfo *psInfo = psFile->pasSegmentInfo+psFile->nSegmentCount; + + psInfo->hAccess = NULL; + strcpy( psInfo->szSegmentType, pszType ); + + psInfo->nSegmentHeaderSize = + atoi(NITFGetField(szTemp,pachSegDef, + iSegment * (nHeaderLenSize+nDataLenSize), + nHeaderLenSize)); + psInfo->nSegmentSize = + atoi(NITFGetField(szTemp,pachSegDef, + iSegment * (nHeaderLenSize+nDataLenSize) + + nHeaderLenSize, + nDataLenSize)); + + psInfo->nSegmentHeaderStart = *pnNextData; + psInfo->nSegmentStart = *pnNextData + psInfo->nSegmentHeaderSize; + + *pnNextData += (psInfo->nSegmentHeaderSize+psInfo->nSegmentSize); + psFile->nSegmentCount++; + } + + CPLFree( pachSegDef ); + + return nOffset + nSegDefSize + 3; +} + +/************************************************************************/ +/* NITFLoadLocationTable() */ +/************************************************************************/ + +static void NITFLoadLocationTable( NITFFile *psFile ) + +{ + GUInt32 nLocTableOffset; + GUInt16 nLocCount; + int iLoc; + const char *pszTRE; + +/* -------------------------------------------------------------------- */ +/* Get the location table position from within the RPFHDR TRE */ +/* structure. */ +/* -------------------------------------------------------------------- */ + pszTRE= NITFFindTRE( psFile->pachTRE, psFile->nTREBytes, "RPFHDR", NULL ); + if( pszTRE == NULL ) + return; + + memcpy( &nLocTableOffset, pszTRE + 44, 4 ); + nLocTableOffset = CPL_MSBWORD32( nLocTableOffset ); + + if( nLocTableOffset == 0 ) + return; + +/* -------------------------------------------------------------------- */ +/* Read the count of entries in the location table. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( psFile->fp, nLocTableOffset + 6, SEEK_SET ); + VSIFReadL( &nLocCount, 1, 2, psFile->fp ); + nLocCount = CPL_MSBWORD16( nLocCount ); + psFile->nLocCount = nLocCount; + + psFile->pasLocations = (NITFLocation *) + CPLCalloc(sizeof(NITFLocation), nLocCount); + +/* -------------------------------------------------------------------- */ +/* Process the locations. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( psFile->fp, 6, SEEK_CUR ); + for( iLoc = 0; iLoc < nLocCount; iLoc++ ) + { + unsigned char abyEntry[10]; + + VSIFReadL( abyEntry, 1, 10, psFile->fp ); + + psFile->pasLocations[iLoc].nLocId = abyEntry[0] * 256 + abyEntry[1]; + + CPL_MSBPTR32( abyEntry + 2 ); + memcpy( &(psFile->pasLocations[iLoc].nLocSize), abyEntry + 2, 4 ); + + CPL_MSBPTR32( abyEntry + 6 ); + memcpy( &(psFile->pasLocations[iLoc].nLocOffset), abyEntry + 6, 4 ); + } +} + +/************************************************************************/ +/* NITFLoadVQTables() */ +/************************************************************************/ + +static int NITFLoadVQTables( NITFFile *psFile ) + +{ + int i, nVQOffset=0, nVQSize=0; + +/* -------------------------------------------------------------------- */ +/* Do we already have the VQ tables? */ +/* -------------------------------------------------------------------- */ + if( psFile->apanVQLUT[0] != NULL ) + return TRUE; + +/* -------------------------------------------------------------------- */ +/* Do we have the location information? */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psFile->nLocCount; i++ ) + { + if( psFile->pasLocations[i].nLocId == 132 ) + { + nVQOffset = psFile->pasLocations[i].nLocOffset; + nVQSize = psFile->pasLocations[i].nLocSize; + } + } + + if( nVQOffset == 0 ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Load the tables. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < 4; i++ ) + { + GUInt32 nVQVector; + + psFile->apanVQLUT[i] = (GUInt32 *) CPLCalloc(4096,sizeof(GUInt32)); + + VSIFSeekL( psFile->fp, nVQOffset + 6 + i*14 + 10, SEEK_SET ); + VSIFReadL( &nVQVector, 1, 4, psFile->fp ); + nVQVector = CPL_MSBWORD32( nVQVector ); + + VSIFSeekL( psFile->fp, nVQOffset + nVQVector, SEEK_SET ); + VSIFReadL( psFile->apanVQLUT[i], 4, 4096, psFile->fp ); + } + + return TRUE; +} + +/************************************************************************/ +/* NITFGetField() */ +/* */ +/* Copy a field from a passed in header buffer into a temporary */ +/* buffer and zero terminate it. */ +/************************************************************************/ + +char *NITFGetField( char *pszTarget, const char *pszSource, + int nStart, int nLength ) + +{ + memcpy( pszTarget, pszSource + nStart, nLength ); + pszTarget[nLength] = '\0'; + + return pszTarget; +} + +/************************************************************************/ +/* NITFFindTRE() */ +/************************************************************************/ + +const char *NITFFindTRE( const char *pszTREData, int nTREBytes, + const char *pszTag, int *pnFoundTRESize ) + +{ + char szTemp[100]; + + while( nTREBytes >= 11 ) + { + int nThisTRESize = atoi(NITFGetField(szTemp, pszTREData, 6, 5 )); + + if( EQUALN(pszTREData,pszTag,6) ) + { + if( pnFoundTRESize != NULL ) + *pnFoundTRESize = nThisTRESize; + + return pszTREData + 11; + } + + nTREBytes -= (nThisTRESize + 11); + pszTREData += (nThisTRESize + 11); + } + + return NULL; +} + +/************************************************************************/ +/* NITFExtractMetadata() */ +/************************************************************************/ + +void NITFExtractMetadata( char ***ppapszMetadata, const char *pachHeader, + int nStart, int nLength, const char *pszName ) + +{ + char szWork[400]; + + /* trim white space */ + while( nLength > 0 && pachHeader[nStart + nLength - 1] == ' ' ) + nLength--; + + memcpy( szWork, pachHeader + nStart, nLength ); + szWork[nLength] = '\0'; + + *ppapszMetadata = CSLSetNameValue( *ppapszMetadata, pszName, szWork ); +} + +/************************************************************************/ +/* NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude() */ +/* */ +/* The input is a geocentric latitude in degrees. The output */ +/* is a geodetic latitude in degrees. */ +/************************************************************************/ + +/* + * "The angle L' is called "geocentric latitude" and is defined as the + * angle between the equatorial plane and the radius from the geocenter. + * + * The angle L is called "geodetic latitude" and is defined as the angle + * between the equatorial plane and the normal to the surface of the + * ellipsoid. The word "latitude" usually means geodetic latitude. This + * is the basis for most of the maps and charts we use. The normal to the + * surface is the direction that a plumb bob would hang were it not for + * local anomalies in the earth's gravitational field." + */ + +double NITF_WGS84_Geocentric_Latitude_To_Geodetic_Latitude( double dfLat ) + +{ + /* WGS84 Ellipsoid */ + double a = 6378137.0; + double b = 6356752.3142; + double dfPI = 3.14159265358979323; + + /* convert to radians */ + dfLat = dfLat * dfPI / 180.0; + + /* convert to geodetic */ + dfLat = atan( ((a*a)/(b*b)) * tan(dfLat) ); + + /* convert back to degrees */ + dfLat = dfLat * 180.0 / dfPI; + + return dfLat; +} + diff --git a/Utilities/GDAL/frmts/nitf/nitfimage.c b/Utilities/GDAL/frmts/nitf/nitfimage.c new file mode 100644 index 0000000000..a3a49e23b1 --- /dev/null +++ b/Utilities/GDAL/frmts/nitf/nitfimage.c @@ -0,0 +1,2076 @@ +/****************************************************************************** + * $Id$ + * + * Project: NITF Read/Write Library + * Purpose: Module responsible for implementation of most NITFImage + * implementation. + * 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: nitfimage.c,v $ + * Revision 1.40 2006/02/19 22:36:46 fwarmerdam + * avoid swap words unused warning + * + * Revision 1.39 2005/12/09 18:54:35 fwarmerdam + * fixed ICORDS=N for NITF 1.x + * + * Revision 1.38 2005/10/03 19:58:25 fwarmerdam + * bug 920: fixed gcp related memory leak + * + * Revision 1.37 2005/07/28 20:00:57 fwarmerdam + * upgrade to support 2-4GB files, use large file api + * + * Revision 1.36 2005/04/18 17:53:57 fwarmerdam + * ICORDS=N means different things in NITF2.1 and 2.0 + * + * Revision 1.35 2005/03/21 16:24:34 fwarmerdam + * IGEOLO now interpreted as being the corner coordinates at the center + * of the corner coordinates. It is transformed into outer corners + * in NITFImage structure in a way that is proper even for rotated images. + * Patch primarily generated by David Carter / ERMapper. + * + * Revision 1.34 2005/03/15 08:16:47 fwarmerdam + * Improve rounding of seconds when writing IGEOLO. + * + * Revision 1.33 2005/02/25 14:49:31 fwarmerdam + * Fixed offset to NICOM in NITFIHFieldOffset(). + * + * Revision 1.32 2005/02/21 03:57:43 fwarmerdam + * Declare variables at beginning of blocks as required by C standard. + * + * Revision 1.31 2005/02/18 19:28:15 fwarmerdam + * added NITFIHFieldOffset + * + * Revision 1.30 2005/02/02 21:52:41 fwarmerdam + * Avoid ununused variable warning. + * + * Revision 1.29 2004/12/21 04:57:36 fwarmerdam + * added support for writing UTM ICORDS/IGEOLO values + * + * Revision 1.28 2004/12/10 21:25:57 fwarmerdam + * added ICHIPB reader + * + * Revision 1.27 2004/05/06 14:58:06 warmerda + * added USE00A and STDIDC parsing and reporting as metadata + * + * Revision 1.26 2004/04/30 17:38:28 warmerda + * clean up metadata + * + * Revision 1.25 2004/04/16 15:26:04 warmerda + * completed metadata support + * + * Revision 1.24 2004/04/15 20:52:31 warmerda + * treat geocentic like geographic + * + * Revision 1.23 2004/04/02 20:44:37 warmerda + * preserve APBB (actual bits per pixel) field as metadata + * + * Revision 1.22 2004/02/09 05:43:11 warmerda + * Fixed typo. + * + * Revision 1.21 2004/02/09 05:18:07 warmerda + * fixed up north/south MGRS support + * + * Revision 1.20 2004/02/09 05:03:42 warmerda + * added ICORDS=U (MGRS) support + * + * Revision 1.19 2003/09/11 19:51:55 warmerda + * avoid type casting warnings + * + * Revision 1.18 2003/08/21 19:27:07 warmerda + * fixed byte swaping issue + * + * Revision 1.17 2003/06/06 16:52:32 warmerda + * changes based on better understanding of conditional FSDEVT field + * + * Revision 1.16 2003/06/06 15:07:53 warmerda + * fixed security area sizing for NITF 2.0 images, its like NITF 1.1. + * + * Revision 1.15 2003/06/06 13:48:13 warmerda + * Corrected problem with pixel interleaved (IMODE=P) images that include + * block maps like the v_3301f.ntf "stdset" file. + * + * Revision 1.14 2003/05/29 19:50:57 warmerda + * added TRE in image, and RPC00B support + * + * Revision 1.13 2003/05/05 17:57:54 warmerda + * added blocked writing support + * + * Revision 1.12 2003/04/09 07:10:47 warmerda + * Added byte swapping for non-eight bit data on little endian platforms. + * Multi-byte NITF image data is always bigendian. + * http://bugzilla.remotesensing.org/show_bug.cgi?id=316 + * + * Revision 1.11 2003/03/28 13:57:12 warmerda + * fixed C++ comment (per bug 311) + * + * Revision 1.10 2002/12/18 21:18:11 warmerda + * read RPF CoverageSection for more exact geotransform + * + * Revision 1.9 2002/12/18 20:16:04 warmerda + * support writing IGEOLO + * + * Revision 1.8 2002/12/18 06:49:21 warmerda + * implement support for mapped files without a map (BMRLNTH==0) + * + * Revision 1.7 2002/12/18 06:35:15 warmerda + * implement nodata support for mapped data + * + * Revision 1.6 2002/12/17 22:01:27 warmerda + * implemented support for IC=M4 overview.ovr + * + * 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 18:08:16 warmerda + * implemented nitf VQ decompression + * + * Revision 1.1 2002/12/03 04:43:41 warmerda + * New + * + */ + +#include "gdal.h" +#include "nitflib.h" +#include "mgrs.h" +#include "cpl_vsi.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id$"); + +static char *NITFTrimWhite( char * ); +#ifdef CPL_LSB +static void NITFSwapWords( void *pData, int nWordSize, int nWordCount, + int nWordSkip ); +#endif + +/************************************************************************/ +/* NITFImageAccess() */ +/************************************************************************/ + +NITFImage *NITFImageAccess( NITFFile *psFile, int iSegment ) + +{ + NITFImage *psImage; + char *pachHeader; + NITFSegmentInfo *psSegInfo; + char szTemp[128]; + int nOffset, iBand, i; + int nIGEOLOGCPCount = 4; + double adfGeoTransform[6] = { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; + GDAL_GCP *psIGEOLOGCPs; + +/* -------------------------------------------------------------------- */ +/* Verify segment, and return existing image accessor if there */ +/* is one. */ +/* -------------------------------------------------------------------- */ + if( iSegment < 0 || iSegment >= psFile->nSegmentCount ) + return NULL; + + psSegInfo = psFile->pasSegmentInfo + iSegment; + + if( !EQUAL(psSegInfo->szSegmentType,"IM") ) + return NULL; + + if( psSegInfo->hAccess != NULL ) + return (NITFImage *) psSegInfo->hAccess; + +/* -------------------------------------------------------------------- */ +/* Read the image subheader. */ +/* -------------------------------------------------------------------- */ + pachHeader = (char*) CPLMalloc(psSegInfo->nSegmentHeaderSize); + if( VSIFSeekL( psFile->fp, psSegInfo->nSegmentHeaderStart, + SEEK_SET ) != 0 + || VSIFReadL( pachHeader, 1, psSegInfo->nSegmentHeaderSize, + psFile->fp ) != psSegInfo->nSegmentHeaderSize ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to read %d byte image subheader from %d.", + psSegInfo->nSegmentHeaderSize, + psSegInfo->nSegmentHeaderStart ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Initialize image object. */ +/* -------------------------------------------------------------------- */ + psImage = (NITFImage *) CPLCalloc(sizeof(NITFImage),1); + + psImage->psFile = psFile; + psImage->iSegment = iSegment; + psImage->pachHeader = pachHeader; + + psSegInfo->hAccess = psImage; + +/* -------------------------------------------------------------------- */ +/* Collect a variety of information as metadata. */ +/* -------------------------------------------------------------------- */ +#define GetMD( target, hdr, start, length, name ) \ + NITFExtractMetadata( &(target->papszMetadata), hdr, \ + start, length, \ + "NITF_" #name ); + + if( EQUAL(psFile->szVersion,"NITF02.10") ) + { + GetMD( psImage, pachHeader, 2, 10, IID1 ); + GetMD( psImage, pachHeader, 12, 14, IDATIM ); + GetMD( psImage, pachHeader, 26, 17, TGTID ); + GetMD( psImage, pachHeader, 43, 80, IID2 ); + GetMD( psImage, pachHeader, 123, 1, ISCLAS ); + GetMD( psImage, pachHeader, 124, 2, ISCLSY ); + GetMD( psImage, pachHeader, 126, 11, ISCODE ); + GetMD( psImage, pachHeader, 137, 2, ISCTLH ); + GetMD( psImage, pachHeader, 139, 20, ISREL ); + GetMD( psImage, pachHeader, 159, 2, ISDCTP ); + GetMD( psImage, pachHeader, 161, 8, ISDCDT ); + GetMD( psImage, pachHeader, 169, 4, ISDCXM ); + GetMD( psImage, pachHeader, 173, 1, ISDG ); + GetMD( psImage, pachHeader, 174, 8, ISDGDT ); + GetMD( psImage, pachHeader, 182, 43, ISCLTX ); + GetMD( psImage, pachHeader, 225, 1, ISCATP ); + GetMD( psImage, pachHeader, 226, 40, ISCAUT ); + GetMD( psImage, pachHeader, 266, 1, ISCRSN ); + GetMD( psImage, pachHeader, 267, 8, ISSRDT ); + GetMD( psImage, pachHeader, 275, 15, ISCTLN ); + /* skip ENCRYPT - 1 character */ + GetMD( psImage, pachHeader, 291, 42, ISORCE ); + /* skip NROWS (8), and NCOLS (8) */ + GetMD( psImage, pachHeader, 349, 3, PVTYPE ); + GetMD( psImage, pachHeader, 352, 8, IREP ); + GetMD( psImage, pachHeader, 360, 8, ICAT ); + GetMD( psImage, pachHeader, 368, 2, ABPP ); + GetMD( psImage, pachHeader, 370, 1, PJUST ); + } + else if( EQUAL(psFile->szVersion,"NITF02.00") ) + { + int nOffset = 0; + GetMD( psImage, pachHeader, 2, 10, IID1 ); + GetMD( psImage, pachHeader, 12, 14, IDATIM ); + GetMD( psImage, pachHeader, 26, 17, TGTID ); + GetMD( psImage, pachHeader, 43, 80, ITITLE ); + GetMD( psImage, pachHeader, 123, 1, ISCLAS ); + GetMD( psImage, pachHeader, 124, 40, ISCODE ); + GetMD( psImage, pachHeader, 164, 40, ISCTLH ); + GetMD( psImage, pachHeader, 204, 40, ISREL ); + GetMD( psImage, pachHeader, 244, 20, ISCAUT ); + GetMD( psImage, pachHeader, 264, 20, ISCTLN ); + GetMD( psImage, pachHeader, 284, 6, ISDWNG ); + + if( EQUALN(pachHeader+284,"999998",6) ) + { + GetMD( psImage, pachHeader, 290, 40, ISDEVT ); + nOffset += 40; + } + + /* skip ENCRYPT - 1 character */ + GetMD( psImage, pachHeader, 291+nOffset, 42, ISORCE ); + /* skip NROWS (8), and NCOLS (8) */ + GetMD( psImage, pachHeader, 349+nOffset, 3, PVTYPE ); + GetMD( psImage, pachHeader, 352+nOffset, 8, IREP ); + GetMD( psImage, pachHeader, 360+nOffset, 8, ICAT ); + GetMD( psImage, pachHeader, 368+nOffset, 2, ABPP ); + GetMD( psImage, pachHeader, 370+nOffset, 1, PJUST ); + } + +/* -------------------------------------------------------------------- */ +/* Does this header have the FSDEVT field? */ +/* -------------------------------------------------------------------- */ + nOffset = 333; + + if( EQUALN(psFile->szVersion,"NITF01.",7) + || EQUALN(pachHeader+284,"999998",6) ) + nOffset += 40; + +/* -------------------------------------------------------------------- */ +/* Read lots of header fields. */ +/* -------------------------------------------------------------------- */ + if( !EQUALN(psFile->szVersion,"NITF01.",7) ) + { + psImage->nRows = atoi(NITFGetField(szTemp,pachHeader,nOffset,8)); + psImage->nCols = atoi(NITFGetField(szTemp,pachHeader,nOffset+8,8)); + + NITFTrimWhite( NITFGetField( psImage->szPVType, pachHeader, + nOffset+16, 3) ); + NITFTrimWhite( NITFGetField( psImage->szIREP, pachHeader, + nOffset+19, 8) ); + NITFTrimWhite( NITFGetField( psImage->szICAT, pachHeader, + nOffset+27, 8) ); + psImage->nABPP = atoi(NITFGetField(szTemp,pachHeader,nOffset+35,2)); + } + + nOffset += 38; + +/* -------------------------------------------------------------------- */ +/* Do we have IGEOLO information? In NITF 2.0 (and 1.x) 'N' means */ +/* no information, while in 2.1 this is indicated as ' ', and 'N' */ +/* means UTM (north). So for 2.0 products we change 'N' to ' ' */ +/* to conform to 2.1 conventions. */ +/* -------------------------------------------------------------------- */ + psImage->chICORDS = pachHeader[nOffset++]; + psImage->bHaveIGEOLO = FALSE; + + if( (EQUALN(psFile->szVersion,"NITF02.0",8) + || EQUALN(psFile->szVersion,"NITF01.",7)) + && psImage->chICORDS == 'N' ) + psImage->chICORDS = ' '; + +/* -------------------------------------------------------------------- */ +/* Read the image bounds. */ +/* -------------------------------------------------------------------- */ + psIGEOLOGCPs = (GDAL_GCP *) CPLMalloc(sizeof(GDAL_GCP) * nIGEOLOGCPCount); + GDALInitGCPs( nIGEOLOGCPCount, psIGEOLOGCPs ); + + if( psImage->chICORDS != ' ' ) + { + int iCoord; + + psImage->bHaveIGEOLO = TRUE; + for( iCoord = 0; iCoord < 4; iCoord++ ) + { + const char *pszCoordPair = pachHeader + nOffset + iCoord*15; + + if( psImage->chICORDS == 'N' || psImage->chICORDS == 'S' ) + { + psImage->nZone = + atoi(NITFGetField( szTemp, pszCoordPair, 0, 2 )); + + psIGEOLOGCPs[iCoord].dfGCPX = atof(NITFGetField( szTemp, pszCoordPair, 2, 6 )); + psIGEOLOGCPs[iCoord].dfGCPY = atof(NITFGetField( szTemp, pszCoordPair, 8, 7 )); + } + else if( psImage->chICORDS == 'G' || psImage->chICORDS == 'C' ) + { + psIGEOLOGCPs[iCoord].dfGCPY = + atof(NITFGetField( szTemp, pszCoordPair, 0, 2 )) + + atof(NITFGetField( szTemp, pszCoordPair, 2, 2 )) / 60.0 + + atof(NITFGetField( szTemp, pszCoordPair, 4, 2 )) / 3600.0; + if( pszCoordPair[6] == 's' || pszCoordPair[6] == 'S' ) + psIGEOLOGCPs[iCoord].dfGCPY *= -1; + + psIGEOLOGCPs[iCoord].dfGCPX = + atof(NITFGetField( szTemp, pszCoordPair, 7, 3 )) + + atof(NITFGetField( szTemp, pszCoordPair,10, 2 )) / 60.0 + + atof(NITFGetField( szTemp, pszCoordPair,12, 2 )) / 3600.0; + + if( pszCoordPair[14] == 'w' || pszCoordPair[14] == 'W' ) + psIGEOLOGCPs[iCoord].dfGCPX *= -1; + } + else if( psImage->chICORDS == 'U' ) + { + int err; + long nZone; + char chHemisphere; + NITFGetField( szTemp, pszCoordPair, 0, 15 ); + + CPLDebug( "NITF", "IGEOLO = %15.15s", pszCoordPair ); + err = Convert_MGRS_To_UTM( szTemp, &nZone, &chHemisphere, + &(psIGEOLOGCPs[iCoord].dfGCPX), + &(psIGEOLOGCPs[iCoord].dfGCPY) ); + + if( chHemisphere == 'S' ) + nZone = -1 * nZone; + + if( psImage->nZone != 0 && psImage->nZone != -100 ) + { + if( nZone != psImage->nZone ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Some IGEOLO points are in different UTM\n" + "zones, but this configuration isn't currently\n" + "supported by GDAL, ignoring IGEOLO." ); + psImage->nZone = -100; + } + } + else if( psImage->nZone == 0 ) + { + psImage->nZone = nZone; + } + } + } + + if( psImage->nZone == -100 ) + psImage->nZone = 0; + + nOffset += 60; + } + +/* -------------------------------------------------------------------- */ +/* Read the image comments. */ +/* -------------------------------------------------------------------- */ + { + int nNICOM; + + nNICOM = atoi(NITFGetField( szTemp, pachHeader, nOffset++, 1)); + + psImage->pszComments = (char *) CPLMalloc(nNICOM*80+1); + NITFGetField( psImage->pszComments, pachHeader, + nOffset, 80 * nNICOM ); + nOffset += nNICOM * 80; + } + +/* -------------------------------------------------------------------- */ +/* Read more stuff. */ +/* -------------------------------------------------------------------- */ + NITFGetField( psImage->szIC, pachHeader, nOffset, 2 ); + nOffset += 2; + + if( psImage->szIC[0] != 'N' ) + { + NITFGetField( psImage->szCOMRAT, pachHeader, nOffset, 4 ); + nOffset += 4; + } + + /* NBANDS */ + psImage->nBands = atoi(NITFGetField(szTemp,pachHeader,nOffset,1)); + nOffset++; + + /* XBANDS */ + if( psImage->nBands == 0 ) + { + psImage->nBands = atoi(NITFGetField(szTemp,pachHeader,nOffset,5)); + nOffset += 5; + } + +/* -------------------------------------------------------------------- */ +/* Read per-band information. */ +/* -------------------------------------------------------------------- */ + psImage->pasBandInfo = (NITFBandInfo *) + CPLCalloc(sizeof(NITFBandInfo),psImage->nBands); + + for( iBand = 0; iBand < psImage->nBands; iBand++ ) + { + NITFBandInfo *psBandInfo = psImage->pasBandInfo + iBand; + int nLUTS; + + NITFTrimWhite( + NITFGetField( psBandInfo->szIREPBAND, pachHeader, nOffset, 2 ) ); + nOffset += 2; + + NITFTrimWhite( + NITFGetField( psBandInfo->szISUBCAT, pachHeader, nOffset, 6 ) ); + nOffset += 6; + + nOffset += 4; /* Skip IFCn and IMFLTn */ + + nLUTS = atoi(NITFGetField( szTemp, pachHeader, nOffset, 1 )); + nOffset += 1; + + if( nLUTS == 0 ) + continue; + + psBandInfo->nSignificantLUTEntries = + atoi(NITFGetField( szTemp, pachHeader, nOffset, 5 )); + nOffset += 5; + + psBandInfo->nLUTLocation = nOffset + psSegInfo->nSegmentHeaderStart; + + psBandInfo->pabyLUT = (unsigned char *) CPLCalloc(768,1); + memcpy( psBandInfo->pabyLUT, pachHeader + nOffset, + psBandInfo->nSignificantLUTEntries ); + nOffset += psBandInfo->nSignificantLUTEntries; + + if( nLUTS == 3 ) + { + memcpy( psBandInfo->pabyLUT+256, pachHeader + nOffset, + psBandInfo->nSignificantLUTEntries ); + nOffset += psBandInfo->nSignificantLUTEntries; + + memcpy( psBandInfo->pabyLUT+512, pachHeader + nOffset, + psBandInfo->nSignificantLUTEntries ); + nOffset += psBandInfo->nSignificantLUTEntries; + } + else + { + /* morph greyscale lut into RGB LUT. */ + memcpy( psBandInfo->pabyLUT+256, psBandInfo->pabyLUT, 256 ); + memcpy( psBandInfo->pabyLUT+512, psBandInfo->pabyLUT, 256 ); + } + } + +/* -------------------------------------------------------------------- */ +/* Read more header fields. */ +/* -------------------------------------------------------------------- */ + psImage->chIMODE = pachHeader[nOffset + 1]; + + psImage->nBlocksPerRow = + atoi(NITFGetField(szTemp, pachHeader, nOffset+2, 4)); + psImage->nBlocksPerColumn = + atoi(NITFGetField(szTemp, pachHeader, nOffset+6, 4)); + psImage->nBlockWidth = + atoi(NITFGetField(szTemp, pachHeader, nOffset+10, 4)); + psImage->nBlockHeight = + atoi(NITFGetField(szTemp, pachHeader, nOffset+14, 4)); + psImage->nBitsPerSample = + atoi(NITFGetField(szTemp, pachHeader, nOffset+18, 2)); + + if( psImage->nABPP == 0 ) + psImage->nABPP = psImage->nBitsPerSample; + + nOffset += 20; + + if( EQUALN(psFile->szVersion,"NITF01.",7) ) + { + psImage->nCols = psImage->nBlocksPerRow * psImage->nBlockWidth; + psImage->nRows = psImage->nBlocksPerColumn * psImage->nBlockHeight; + } + +/* -------------------------------------------------------------------- */ +/* Skip some unused fields. */ +/* -------------------------------------------------------------------- */ + else + { + int nUserTREBytes; + + nOffset += 3; /* IDLVL */ + nOffset += 3; /* IALVL */ + nOffset += 10; /* ILOC */ + nOffset += 4; /* IMAG */ + +/* -------------------------------------------------------------------- */ +/* Are there user TRE bytes to skip? */ +/* -------------------------------------------------------------------- */ + nUserTREBytes = atoi(NITFGetField( szTemp, pachHeader, nOffset, 5 )); + nOffset += 5; + + if( nUserTREBytes > 0 ) + nOffset += nUserTREBytes; + +/* -------------------------------------------------------------------- */ +/* Are there managed TRE bytes to recognise? */ +/* -------------------------------------------------------------------- */ + psImage->nTREBytes = atoi(NITFGetField(szTemp,pachHeader,nOffset,5)); + nOffset += 5; + + if( psImage->nTREBytes != 0 ) + { + nOffset += 3; + psImage->pachTRE = pachHeader + nOffset; + psImage->nTREBytes -= 3; + + nOffset += psImage->nTREBytes; + } + } + +/* -------------------------------------------------------------------- */ +/* Setup some image access values. Some of these may not apply */ +/* for compressed images, or band interleaved by block images. */ +/* -------------------------------------------------------------------- */ + psImage->nWordSize = psImage->nBitsPerSample / 8; + if( psImage->chIMODE == 'S' ) + { + psImage->nPixelOffset = psImage->nWordSize; + psImage->nLineOffset = psImage->nBlockWidth * psImage->nPixelOffset; + psImage->nBlockOffset = psImage->nLineOffset * psImage->nBlockHeight; + psImage->nBandOffset = psImage->nBlockOffset * psImage->nBlocksPerRow + * psImage->nBlocksPerColumn; + } + else if( psImage->chIMODE == 'P' ) + { + psImage->nPixelOffset = psImage->nWordSize * psImage->nBands; + psImage->nLineOffset = psImage->nBlockWidth * psImage->nPixelOffset; + psImage->nBandOffset = psImage->nWordSize; + psImage->nBlockOffset = psImage->nLineOffset * psImage->nBlockHeight; + } + else if( psImage->chIMODE == 'R' ) + { + psImage->nPixelOffset = psImage->nWordSize; + psImage->nBandOffset = psImage->nBlockWidth * psImage->nPixelOffset; + psImage->nLineOffset = psImage->nBandOffset * psImage->nBands; + psImage->nBlockOffset = psImage->nLineOffset * psImage->nBlockHeight; + } + else if( psImage->chIMODE == 'B' ) + { + psImage->nPixelOffset = psImage->nWordSize; + psImage->nLineOffset = psImage->nBlockWidth * psImage->nPixelOffset; + psImage->nBandOffset = psImage->nBlockHeight * psImage->nLineOffset; + psImage->nBlockOffset = psImage->nBandOffset * psImage->nBands; + } + else + { + psImage->nPixelOffset = psImage->nWordSize; + psImage->nLineOffset = psImage->nBlockWidth * psImage->nPixelOffset; + psImage->nBandOffset = psImage->nBlockHeight * psImage->nLineOffset; + psImage->nBlockOffset = psImage->nBandOffset * psImage->nBands; + } + +/* -------------------------------------------------------------------- */ +/* Setup block map. */ +/* -------------------------------------------------------------------- */ + psImage->panBlockStart = (GUInt32 *) + CPLCalloc( psImage->nBlocksPerRow * psImage->nBlocksPerColumn + * psImage->nBands, sizeof(GUInt32) ); + +/* -------------------------------------------------------------------- */ +/* Offsets to VQ compressed tiles are based on a fixed block */ +/* size, and are offset from the spatial data location kept in */ +/* the location table ... which is generally not the beginning */ +/* of the image data segment. */ +/* -------------------------------------------------------------------- */ + if( EQUAL(psImage->szIC,"C4") ) + { + GUInt32 nLocBase = psSegInfo->nSegmentStart; + + for( i = 0; i < psFile->nLocCount; i++ ) + { + if( psFile->pasLocations[i].nLocId == 140 ) + nLocBase = psFile->pasLocations[i].nLocOffset; + } + + if( nLocBase == psSegInfo->nSegmentStart ) + CPLError( CE_Warning, CPLE_AppDefined, + "Failed to find spatial data location, guessing." ); + + for( i=0; i < psImage->nBlocksPerRow * psImage->nBlocksPerColumn; i++ ) + psImage->panBlockStart[i] = nLocBase + 6144 * i; + } + +/* -------------------------------------------------------------------- */ +/* If there is no block map, just compute directly assuming the */ +/* blocks start at the beginning of the image segment, and are */ +/* packed tightly with the IMODE organization. */ +/* -------------------------------------------------------------------- */ + else if( psImage->szIC[0] != 'M' && psImage->szIC[1] != 'M' ) + { + int iBlockX, iBlockY, iBand; + + for( iBlockY = 0; iBlockY < psImage->nBlocksPerColumn; iBlockY++ ) + { + for( iBlockX = 0; iBlockX < psImage->nBlocksPerRow; iBlockX++ ) + { + for( iBand = 0; iBand < psImage->nBands; iBand++ ) + { + int iBlock; + + iBlock = iBlockX + iBlockY * psImage->nBlocksPerRow + + iBand * psImage->nBlocksPerRow + * psImage->nBlocksPerColumn; + + psImage->panBlockStart[iBlock] = + psSegInfo->nSegmentStart + + ((iBlockX + iBlockY * psImage->nBlocksPerRow) + * psImage->nBlockOffset) + + (iBand * psImage->nBandOffset ); + } + } + } + } + +/* -------------------------------------------------------------------- */ +/* Otherwise we need to read the block map from the beginning */ +/* of the image segment. */ +/* -------------------------------------------------------------------- */ + else + { + GUInt32 nIMDATOFF; + GUInt16 nBMRLNTH, nTMRLNTH, nTPXCDLNTH; + int nBlockCount; + + nBlockCount = psImage->nBlocksPerRow * psImage->nBlocksPerColumn + * psImage->nBands; + + CPLAssert( psImage->szIC[0] == 'M' || psImage->szIC[1] == 'M' ); + + VSIFSeekL( psFile->fp, psSegInfo->nSegmentStart, SEEK_SET ); + VSIFReadL( &nIMDATOFF, 1, 4, psFile->fp ); + VSIFReadL( &nBMRLNTH, 1, 2, psFile->fp ); + VSIFReadL( &nTMRLNTH, 1, 2, psFile->fp ); + VSIFReadL( &nTPXCDLNTH, 1, 2, psFile->fp ); + + CPL_MSBPTR32( &nIMDATOFF ); + CPL_MSBPTR16( &nBMRLNTH ); + CPL_MSBPTR16( &nTMRLNTH ); + CPL_MSBPTR16( &nTPXCDLNTH ); + + if( nTPXCDLNTH == 8 ) + { + GByte byNodata; + + psImage->bNoDataSet = TRUE; + VSIFReadL( &byNodata, 1, 1, psFile->fp ); + psImage->nNoDataValue = byNodata; + } + else + VSIFSeekL( psFile->fp, (nTPXCDLNTH+7)/8, SEEK_CUR ); + + if( nBMRLNTH == 4 && psImage->chIMODE == 'P' ) + { + int nStoredBlocks = psImage->nBlocksPerRow + * psImage->nBlocksPerColumn; + int iBand; + + VSIFReadL( psImage->panBlockStart, 4, nStoredBlocks, psFile->fp ); + + for( i = 0; i < nStoredBlocks; i++ ) + { + CPL_MSBPTR32( psImage->panBlockStart + i ); + if( psImage->panBlockStart[i] != 0xffffffff ) + { + psImage->panBlockStart[i] + += psSegInfo->nSegmentStart + nIMDATOFF; + + for( iBand = 1; iBand < psImage->nBands; iBand++ ) + { + psImage->panBlockStart[i + iBand * nStoredBlocks] = + psImage->panBlockStart[i] + + iBand * psImage->nBandOffset; + } + } + else + { + for( iBand = 1; iBand < psImage->nBands; iBand++ ) + psImage->panBlockStart[i + iBand * nStoredBlocks] = + 0xffffffff; + } + } + } + else if( nBMRLNTH == 4 ) + { + VSIFReadL( psImage->panBlockStart, 4, nBlockCount, psFile->fp ); + for( i=0; i < nBlockCount; i++ ) + { + CPL_MSBPTR32( psImage->panBlockStart + i ); + if( psImage->panBlockStart[i] != 0xffffffff ) + psImage->panBlockStart[i] + += psSegInfo->nSegmentStart + nIMDATOFF; + } + } + else + { + for( i=0; i < nBlockCount; i++ ) + { + if( EQUAL(psImage->szIC,"M4") ) + psImage->panBlockStart[i] = 6144 * i + + psSegInfo->nSegmentStart + nIMDATOFF; + else if( EQUAL(psImage->szIC,"NM") ) + psImage->panBlockStart[i] = + psImage->nBlockOffset * i + + psSegInfo->nSegmentStart + nIMDATOFF; + } + } + } + +/* -------------------------------------------------------------------- */ +/* We can't set dfGCPPixel and dfGCPPixel until we know */ +/* psImage->nRows and psImage->nCols. */ +/* -------------------------------------------------------------------- */ + if( psImage->chICORDS != ' ' ) + { + psIGEOLOGCPs[0].dfGCPPixel = 0.5; + psIGEOLOGCPs[0].dfGCPLine = 0.5; + psIGEOLOGCPs[1].dfGCPPixel = psImage->nCols - 0.5; + psIGEOLOGCPs[1].dfGCPLine = 0.5; + psIGEOLOGCPs[2].dfGCPPixel = psImage->nCols - 0.5; + psIGEOLOGCPs[2].dfGCPLine = psImage->nRows - 0.5; + psIGEOLOGCPs[3].dfGCPPixel = 0.5; + psIGEOLOGCPs[3].dfGCPLine = psImage->nRows - 0.5; + +/* -------------------------------------------------------------------- */ +/* Convert the GCPs into a geotransform definition, if possible. */ +/* -------------------------------------------------------------------- */ + if( !GDALGCPsToGeoTransform( nIGEOLOGCPCount, psIGEOLOGCPs, + adfGeoTransform, TRUE ) ) + { + CPLDebug( "GDAL", "NITFImageAccess() wasn't able to derive a\n" + "first order geotransform."); + } + + psImage->dfULX = adfGeoTransform[0]; + psImage->dfULY = adfGeoTransform[3]; + psImage->dfURX = psImage->dfULX + adfGeoTransform[1] * psImage->nCols; + psImage->dfURY = psImage->dfULY + adfGeoTransform[4] * psImage->nCols; + psImage->dfLRX = psImage->dfULX + adfGeoTransform[1] * psImage->nCols + + adfGeoTransform[2] * psImage->nRows; + psImage->dfLRY = psImage->dfULY + adfGeoTransform[4] * psImage->nCols + + adfGeoTransform[5] * psImage->nRows; + psImage->dfLLX = psImage->dfULX + adfGeoTransform[2] * psImage->nRows; + psImage->dfLLY = psImage->dfULY + adfGeoTransform[5] * psImage->nRows; + } + + GDALDeinitGCPs( nIGEOLOGCPCount, psIGEOLOGCPs ); + CPLFree( psIGEOLOGCPs ); + +/* -------------------------------------------------------------------- */ +/* If we have an RPF CoverageSectionSubheader, read the more */ +/* precise bounds from it. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < psFile->nLocCount; i++ ) + { + if( psFile->pasLocations[i].nLocId == LID_CoverageSectionSubheader ) + { + double adfTarget[8]; + + VSIFSeekL( psFile->fp, psFile->pasLocations[i].nLocOffset, + SEEK_SET ); + VSIFReadL( adfTarget, 8, 8, psFile->fp ); + for( i = 0; i < 8; i++ ) + CPL_MSBPTR64( (adfTarget + i) ); + + psImage->dfULX = adfTarget[1]; + psImage->dfULY = adfTarget[0]; + psImage->dfLLX = adfTarget[3]; + psImage->dfLLY = adfTarget[2]; + psImage->dfURX = adfTarget[5]; + psImage->dfURY = adfTarget[4]; + psImage->dfLRX = adfTarget[7]; + psImage->dfLRY = adfTarget[6]; + + CPLDebug( "NITF", "Got spatial info from CoverageSection" ); + break; + } + } + + return psImage; +} + +/************************************************************************/ +/* NITFImageDeaccess() */ +/************************************************************************/ + +void NITFImageDeaccess( NITFImage *psImage ) + +{ + int iBand; + + CPLAssert( psImage->psFile->pasSegmentInfo[psImage->iSegment].hAccess + == psImage ); + + psImage->psFile->pasSegmentInfo[psImage->iSegment].hAccess = NULL; + + for( iBand = 0; iBand < psImage->nBands; iBand++ ) + CPLFree( psImage->pasBandInfo[iBand].pabyLUT ); + CPLFree( psImage->pasBandInfo ); + CPLFree( psImage->panBlockStart ); + CPLFree( psImage->pszComments ); + CPLFree( psImage->pachHeader ); + CSLDestroy( psImage->papszMetadata ); + + CPLFree( psImage ); +} + +/************************************************************************/ +/* NITFUncompressVQTile() */ +/* */ +/* This code was derived from OSSIM which in turn derived it */ +/* from OpenMap ... open source means sharing! */ +/************************************************************************/ + +static void NITFUncompressVQTile( NITFImage *psImage, + GByte *pabyVQBuf, + GByte *pabyResult ) + +{ + int i, j, t, iSrcByte = 0; + + for (i = 0; i < 256; i += 4) + { + for (j = 0; j < 256; j += 8) + { + GUInt16 firstByte = pabyVQBuf[iSrcByte++]; + GUInt16 secondByte = pabyVQBuf[iSrcByte++]; + GUInt16 thirdByte = pabyVQBuf[iSrcByte++]; + + /* + * because dealing with half-bytes is hard, we + * uncompress two 4x4 tiles at the same time. (a + * 4x4 tile compressed is 12 bits ) + * this little code was grabbed from openmap software. + */ + + /* Get first 12-bit value as index into VQ table */ + + GUInt16 val1 = (firstByte << 4) | (secondByte >> 4); + + /* Get second 12-bit value as index into VQ table*/ + + GUInt16 val2 = ((secondByte & 0x000F) << 8) | thirdByte; + + for ( t = 0; t < 4; ++t) + { + GByte *pabyTarget = pabyResult + (i+t) * 256 + j; + + memcpy( pabyTarget, psImage->psFile->apanVQLUT[t] + val1, 4 ); + memcpy( pabyTarget+4, psImage->psFile->apanVQLUT[t] + val2, 4); + } + } /* for j */ + } /* for i */ +} + +/************************************************************************/ +/* NITFReadImageBlock() */ +/************************************************************************/ + +int NITFReadImageBlock( NITFImage *psImage, int nBlockX, int nBlockY, + int nBand, void *pData ) + +{ + int nWrkBufSize; + int iBaseBlock = nBlockX + nBlockY * psImage->nBlocksPerRow; + int iFullBlock = iBaseBlock + + (nBand-1) * psImage->nBlocksPerRow * psImage->nBlocksPerColumn; + + if( nBand == 0 ) + return BLKREAD_FAIL; + + nWrkBufSize = psImage->nLineOffset * (psImage->nBlockHeight-1) + + psImage->nPixelOffset * (psImage->nBlockWidth-1) + + psImage->nWordSize; + + if( psImage->panBlockStart[iFullBlock] == 0xffffffff ) + return BLKREAD_NULL; + +/* -------------------------------------------------------------------- */ +/* Can we do a direct read into our buffer? */ +/* -------------------------------------------------------------------- */ + if( psImage->nWordSize == psImage->nPixelOffset + && psImage->nWordSize * psImage->nBlockWidth == psImage->nLineOffset + && psImage->szIC[0] != 'C' && psImage->szIC[0] != 'M' + && psImage->chIMODE != 'P' ) + { + if( VSIFSeekL( psImage->psFile->fp, + psImage->panBlockStart[iFullBlock], + SEEK_SET ) != 0 + || (int) VSIFReadL( pData, 1, nWrkBufSize, + psImage->psFile->fp ) != nWrkBufSize ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Unable to read %d byte block from %d.", + nWrkBufSize, psImage->panBlockStart[iFullBlock] ); + return BLKREAD_FAIL; + } + else + { +#ifdef CPL_LSB + NITFSwapWords( pData, psImage->nWordSize, + psImage->nBlockWidth * psImage->nBlockHeight, + psImage->nWordSize ); +#endif + + return BLKREAD_OK; + } + } + +/* -------------------------------------------------------------------- */ +/* Read the requested information into a temporary buffer and */ +/* pull out what we want. */ +/* -------------------------------------------------------------------- */ + if( psImage->szIC[0] == 'N' ) + { + GByte *pabyWrkBuf = (GByte *) CPLMalloc(nWrkBufSize); + int iPixel, iLine; + + /* read all the data needed to get our requested band-block */ + if( VSIFSeekL( psImage->psFile->fp, psImage->panBlockStart[iFullBlock], + SEEK_SET ) != 0 + || (int) VSIFReadL( pabyWrkBuf, 1, nWrkBufSize, + psImage->psFile->fp ) != nWrkBufSize ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Unable to read %d byte block from %d.", + nWrkBufSize, psImage->panBlockStart[iFullBlock] ); + return BLKREAD_FAIL; + } + + for( iLine = 0; iLine < psImage->nBlockHeight; iLine++ ) + { + GByte *pabySrc, *pabyDst; + + pabySrc = pabyWrkBuf + iLine * psImage->nLineOffset; + pabyDst = ((GByte *) pData) + + iLine * (psImage->nWordSize * psImage->nBlockWidth); + + for( iPixel = 0; iPixel < psImage->nBlockWidth; iPixel++ ) + { + memcpy( pabyDst + iPixel * psImage->nWordSize, + pabySrc + iPixel * psImage->nPixelOffset, + psImage->nWordSize ); + } + } + +#ifdef CPL_LSB + NITFSwapWords( pData, psImage->nWordSize, + psImage->nBlockWidth * psImage->nBlockHeight, + psImage->nWordSize ); +#endif + + CPLFree( pabyWrkBuf ); + + return BLKREAD_OK; + } + +/* -------------------------------------------------------------------- */ +/* Handle VQ compression. The VQ compression basically keeps a */ +/* 64x64 array of 12bit code words. Each code word expands to */ +/* a predefined 4x4 8 bit per pixel pattern. */ +/* -------------------------------------------------------------------- */ + else if( EQUAL(psImage->szIC,"C4") || EQUAL(psImage->szIC,"M4") ) + { + GByte abyVQCoded[6144]; + + /* Read the codewords */ + if( VSIFSeekL(psImage->psFile->fp, psImage->panBlockStart[iFullBlock], + SEEK_SET ) != 0 + || VSIFReadL(abyVQCoded, 1, sizeof(abyVQCoded), + psImage->psFile->fp ) != sizeof(abyVQCoded) ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Unable to read %d byte block from %d.", + sizeof(abyVQCoded), psImage->panBlockStart[iFullBlock] ); + return BLKREAD_FAIL; + } + + NITFUncompressVQTile( psImage, abyVQCoded, pData ); + + return BLKREAD_OK; + } + +/* -------------------------------------------------------------------- */ +/* Report unsupported compression scheme(s). */ +/* -------------------------------------------------------------------- */ + else if( atoi(psImage->szIC + 1) > 0 ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Unsupported imagery compression format %s in NITF library.", + psImage->szIC ); + return BLKREAD_FAIL; + } + + return BLKREAD_FAIL; +} + +/************************************************************************/ +/* NITFWriteImageBlock() */ +/************************************************************************/ + +int NITFWriteImageBlock( NITFImage *psImage, int nBlockX, int nBlockY, + int nBand, void *pData ) + +{ + int nWrkBufSize; + int iBaseBlock = nBlockX + nBlockY * psImage->nBlocksPerRow; + int iFullBlock = iBaseBlock + + (nBand-1) * psImage->nBlocksPerRow * psImage->nBlocksPerColumn; + + if( nBand == 0 ) + return BLKREAD_FAIL; + + nWrkBufSize = psImage->nLineOffset * (psImage->nBlockHeight-1) + + psImage->nPixelOffset * (psImage->nBlockWidth-1) + + psImage->nWordSize; + +/* -------------------------------------------------------------------- */ +/* Can we do a direct read into our buffer? */ +/* -------------------------------------------------------------------- */ + if( psImage->nWordSize == psImage->nPixelOffset + && psImage->nWordSize * psImage->nBlockWidth == psImage->nLineOffset + && psImage->szIC[0] != 'C' && psImage->szIC[0] != 'M' ) + { +#ifdef CPL_LSB + NITFSwapWords( pData, psImage->nWordSize, + psImage->nBlockWidth * psImage->nBlockHeight, + psImage->nWordSize ); +#endif + + if( VSIFSeekL( psImage->psFile->fp, psImage->panBlockStart[iFullBlock], + SEEK_SET ) != 0 + || (int) VSIFWriteL( pData, 1, nWrkBufSize, + psImage->psFile->fp ) != nWrkBufSize ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Unable to write %d byte block from %d.", + nWrkBufSize, psImage->panBlockStart[iFullBlock] ); + return BLKREAD_FAIL; + } + else + { +#ifdef CPL_LSB + /* restore byte order to original */ + NITFSwapWords( pData, psImage->nWordSize, + psImage->nBlockWidth * psImage->nBlockHeight, + psImage->nWordSize ); +#endif + + return BLKREAD_OK; + } + } + +/* -------------------------------------------------------------------- */ +/* Other forms not supported at this time. */ +/* -------------------------------------------------------------------- */ + CPLError( CE_Failure, CPLE_NotSupported, + "Mapped, interleaved and compressed NITF forms not supported\n" + "for writing at this time." ); + + return BLKREAD_FAIL; +} + +/************************************************************************/ +/* NITFReadImageLine() */ +/************************************************************************/ + +int NITFReadImageLine( NITFImage *psImage, int nLine, int nBand, void *pData ) + +{ + int nLineOffsetInFile, nLineSize; + unsigned char *pabyLineBuf; + + if( nBand == 0 ) + return BLKREAD_FAIL; + + if( psImage->nBlocksPerRow != 1 || psImage->nBlocksPerColumn != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Scanline access not supported on tiled NITF files." ); + return BLKREAD_FAIL; + } + + if( !EQUAL(psImage->szIC,"NC") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Scanline access not supported on compressed NITF files." ); + return BLKREAD_FAIL; + } + +/* -------------------------------------------------------------------- */ +/* Workout location and size of data in file. */ +/* -------------------------------------------------------------------- */ + nLineOffsetInFile = psImage->panBlockStart[0] + + psImage->nLineOffset * nLine + + psImage->nBandOffset * (nBand-1); + + nLineSize = psImage->nPixelOffset * (psImage->nCols - 1) + + psImage->nWordSize; + + VSIFSeekL( psImage->psFile->fp, nLineOffsetInFile, SEEK_SET ); + +/* -------------------------------------------------------------------- */ +/* Can we do a direct read into our buffer. */ +/* -------------------------------------------------------------------- */ + if( psImage->nWordSize == psImage->nPixelOffset + && psImage->nWordSize * psImage->nBlockWidth == psImage->nLineOffset ) + { + VSIFReadL( pData, 1, nLineSize, psImage->psFile->fp ); + +#ifdef CPL_LSB + NITFSwapWords( pData, psImage->nWordSize, + psImage->nBlockWidth, psImage->nWordSize ); +#endif + + return BLKREAD_OK; + } + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer for all the interleaved data, and read */ +/* it. */ +/* -------------------------------------------------------------------- */ + pabyLineBuf = (unsigned char *) CPLMalloc(nLineSize); + VSIFReadL( pabyLineBuf, 1, nLineSize, psImage->psFile->fp ); + +/* -------------------------------------------------------------------- */ +/* Copy the desired data out of the interleaved buffer. */ +/* -------------------------------------------------------------------- */ + { + GByte *pabySrc, *pabyDst; + int iPixel; + + pabySrc = pabyLineBuf; + pabyDst = ((GByte *) pData); + + for( iPixel = 0; iPixel < psImage->nBlockWidth; iPixel++ ) + { + memcpy( pabyDst + iPixel * psImage->nWordSize, + pabySrc + iPixel * psImage->nPixelOffset, + psImage->nWordSize ); + } + +#ifdef CPL_LSB + NITFSwapWords( (void *) pabyDst, psImage->nWordSize, + psImage->nBlockWidth, psImage->nWordSize ); +#endif + } + + CPLFree( pabyLineBuf ); + + return BLKREAD_OK; +} + +/************************************************************************/ +/* NITFWriteImageLine() */ +/************************************************************************/ + +int NITFWriteImageLine( NITFImage *psImage, int nLine, int nBand, void *pData ) + +{ + int nLineOffsetInFile, nLineSize; + unsigned char *pabyLineBuf; + + if( nBand == 0 ) + return BLKREAD_FAIL; + + if( psImage->nBlocksPerRow != 1 || psImage->nBlocksPerColumn != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Scanline access not supported on tiled NITF files." ); + return BLKREAD_FAIL; + } + + if( !EQUAL(psImage->szIC,"NC") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Scanline access not supported on compressed NITF files." ); + return BLKREAD_FAIL; + } + +/* -------------------------------------------------------------------- */ +/* Workout location and size of data in file. */ +/* -------------------------------------------------------------------- */ + nLineOffsetInFile = psImage->panBlockStart[0] + + psImage->nLineOffset * nLine + + psImage->nBandOffset * (nBand-1); + + nLineSize = psImage->nPixelOffset * (psImage->nCols - 1) + + psImage->nWordSize; + + VSIFSeekL( psImage->psFile->fp, nLineOffsetInFile, SEEK_SET ); + +/* -------------------------------------------------------------------- */ +/* Can we do a direct write into our buffer. */ +/* -------------------------------------------------------------------- */ + if( psImage->nWordSize == psImage->nPixelOffset + && psImage->nWordSize * psImage->nBlockWidth == psImage->nLineOffset ) + { +#ifdef CPL_LSB + NITFSwapWords( (void *) pData, psImage->nWordSize, + psImage->nCols, psImage->nWordSize ); +#endif + + VSIFWriteL( pData, 1, nLineSize, psImage->psFile->fp ); + +#ifdef CPL_LSB + NITFSwapWords( (void *) pData, psImage->nWordSize, + psImage->nCols, psImage->nWordSize ); +#endif + + return BLKREAD_OK; + } + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer for all the interleaved data, and read */ +/* it. */ +/* -------------------------------------------------------------------- */ + pabyLineBuf = (unsigned char *) CPLMalloc(nLineSize); + VSIFReadL( pabyLineBuf, 1, nLineSize, psImage->psFile->fp ); + +/* -------------------------------------------------------------------- */ +/* Copy the desired data into the interleaved buffer. */ +/* -------------------------------------------------------------------- */ + { + GByte *pabySrc, *pabyDst; + int iPixel; + + pabySrc = pabyLineBuf; + pabyDst = ((GByte *) pData); + + for( iPixel = 0; iPixel < psImage->nBlockWidth; iPixel++ ) + { + memcpy( pabySrc + iPixel * psImage->nPixelOffset, + pabyDst + iPixel * psImage->nWordSize, + psImage->nWordSize ); +#ifdef CPL_LSB + NITFSwapWords( pabyDst + iPixel * psImage->nWordSize, + psImage->nWordSize, 1, psImage->nWordSize ); +#endif + } + } + +/* -------------------------------------------------------------------- */ +/* Write the results back out. */ +/* -------------------------------------------------------------------- */ + VSIFSeekL( psImage->psFile->fp, nLineOffsetInFile, SEEK_SET ); + VSIFWriteL( pabyLineBuf, 1, nLineSize, psImage->psFile->fp ); + CPLFree( pabyLineBuf ); + + return BLKREAD_OK; +} + +/************************************************************************/ +/* NITFEncodeDMSLoc() */ +/************************************************************************/ + +static void NITFEncodeDMSLoc( char *pszTarget, double dfValue, + const char *pszAxis ) + +{ + char chHemisphere; + int nDegrees, nMinutes, nSeconds; + + if( EQUAL(pszAxis,"Lat") ) + { + if( dfValue < 0.0 ) + chHemisphere = 'S'; + else + chHemisphere = 'N'; + } + else + { + if( dfValue < 0.0 ) + chHemisphere = 'W'; + else + chHemisphere = 'E'; + } + + dfValue = fabs(dfValue); + + nDegrees = (int) dfValue; + dfValue = (dfValue-nDegrees) * 60.0; + + nMinutes = (int) dfValue; + dfValue = (dfValue-nMinutes) * 60.0; + +/* -------------------------------------------------------------------- */ +/* Do careful rounding on seconds so that 59.9->60 is properly */ +/* rolled into minutes and degrees. */ +/* -------------------------------------------------------------------- */ + nSeconds = (int) (dfValue + 0.5); + if (nSeconds == 60) + { + nSeconds = 0; + nMinutes += 1; + if (nMinutes == 60) + { + nMinutes = 0; + nDegrees += 1; + } + } + + if( EQUAL(pszAxis,"Lat") ) + sprintf( pszTarget, "%02d%02d%02d%c", + nDegrees, nMinutes, nSeconds, chHemisphere ); + else + sprintf( pszTarget, "%03d%02d%02d%c", + nDegrees, nMinutes, nSeconds, chHemisphere ); +} + +/************************************************************************/ +/* NITFWriteIGEOLO() */ +/************************************************************************/ + +int NITFWriteIGEOLO( NITFImage *psImage, char chICORDS, + int nZone, + double dfULX, double dfULY, + double dfURX, double dfURY, + double dfLRX, double dfLRY, + double dfLLX, double dfLLY ) + +{ + char szIGEOLO[61]; + +/* -------------------------------------------------------------------- */ +/* Do some checking. */ +/* -------------------------------------------------------------------- */ + if( psImage->chICORDS == ' ' ) + { + CPLError(CE_Failure, CPLE_NotSupported, + "Apparently no space reserved for IGEOLO info in NITF file.\n" + "NITFWriteIGEOGLO() fails." ); + return FALSE; + } + + if( chICORDS != 'G' && chICORDS != 'N' && chICORDS != 'S' ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Currently NITFWriteIGEOLO() only supports writing ICORDS=G, N and S corners." ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Format geographic coordinates. */ +/* -------------------------------------------------------------------- */ + if( chICORDS == 'G' ) + { + if( fabs(dfULX) > 180 || fabs(dfURX) > 180 + || fabs(dfLRX) > 180 || fabs(dfLLX) > 180 + || fabs(dfULY) > 90 || fabs(dfURY) > 90 + || fabs(dfLRY) > 90 || fabs(dfLLY) > 90 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to write geographic bound outside of legal range." ); + return FALSE; + } + + NITFEncodeDMSLoc( szIGEOLO + 0, dfULY, "Lat" ); + NITFEncodeDMSLoc( szIGEOLO + 7, dfULX, "Long" ); + NITFEncodeDMSLoc( szIGEOLO + 15, dfURY, "Lat" ); + NITFEncodeDMSLoc( szIGEOLO + 22, dfURX, "Long" ); + NITFEncodeDMSLoc( szIGEOLO + 30, dfLRY, "Lat" ); + NITFEncodeDMSLoc( szIGEOLO + 37, dfLRX, "Long" ); + NITFEncodeDMSLoc( szIGEOLO + 45, dfLLY, "Lat" ); + NITFEncodeDMSLoc( szIGEOLO + 52, dfLLX, "Long" ); + } + +/* -------------------------------------------------------------------- */ +/* Format UTM coordinates. */ +/* -------------------------------------------------------------------- */ + else if( chICORDS == 'N' || chICORDS == 'S' ) + { + sprintf( szIGEOLO + 0, "%02d%06d%07d", + nZone, (int) floor(dfULX+0.5), (int) floor(dfULY+0.5) ); + sprintf( szIGEOLO + 15, "%02d%06d%07d", + nZone, (int) floor(dfURX+0.5), (int) floor(dfURY+0.5) ); + sprintf( szIGEOLO + 30, "%02d%06d%07d", + nZone, (int) floor(dfLRX+0.5), (int) floor(dfLRY+0.5) ); + sprintf( szIGEOLO + 45, "%02d%06d%07d", + nZone, (int) floor(dfLLX+0.5), (int) floor(dfLLY+0.5) ); + } + +/* -------------------------------------------------------------------- */ +/* Write IGEOLO data to disk. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeekL( psImage->psFile->fp, + psImage->psFile->pasSegmentInfo[psImage->iSegment].nSegmentHeaderStart + 372, SEEK_SET ) == 0 + && VSIFWriteL( szIGEOLO, 1, 60, psImage->psFile->fp ) == 60 ) + { + return TRUE; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "I/O Error writing IGEOLO segment.\n%s", + VSIStrerror( errno ) ); + return FALSE; + } +} + +/************************************************************************/ +/* NITFWriteLUT() */ +/************************************************************************/ + +int NITFWriteLUT( NITFImage *psImage, int nBand, int nColors, + unsigned char *pabyLUT ) + +{ + NITFBandInfo *psBandInfo; + int bSuccess = TRUE; + + if( nBand < 1 || nBand > psImage->nBands ) + return FALSE; + + psBandInfo = psImage->pasBandInfo + (nBand-1); + + if( nColors > psBandInfo->nSignificantLUTEntries ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to write all %d LUT entries, only able to write %d.", + nColors, psBandInfo->nSignificantLUTEntries ); + nColors = psBandInfo->nSignificantLUTEntries; + bSuccess = FALSE; + } + + VSIFSeekL( psImage->psFile->fp, psBandInfo->nLUTLocation, SEEK_SET ); + VSIFWriteL( pabyLUT, 1, nColors, psImage->psFile->fp ); + VSIFSeekL( psImage->psFile->fp, + psBandInfo->nLUTLocation + psBandInfo->nSignificantLUTEntries, + SEEK_SET ); + VSIFWriteL( pabyLUT+256, 1, nColors, psImage->psFile->fp ); + VSIFSeekL( psImage->psFile->fp, + psBandInfo->nLUTLocation + 2*psBandInfo->nSignificantLUTEntries, + SEEK_SET ); + VSIFWriteL( pabyLUT+512, 1, nColors, psImage->psFile->fp ); + + return bSuccess; +} + + + +/************************************************************************/ +/* NITFTrimWhite() */ +/* */ +/* Trim any white space off the white of the passed string in */ +/* place. */ +/************************************************************************/ + +char *NITFTrimWhite( char *pszTarget ) + +{ + int i; + + i = strlen(pszTarget)-1; + while( i >= 0 && pszTarget[i] == ' ' ) + pszTarget[i--] = '\0'; + + return pszTarget; +} + +/************************************************************************/ +/* NITFSwapWords() */ +/************************************************************************/ + +#ifdef CPL_LSB +static void NITFSwapWords( void *pData, int nWordSize, int nWordCount, + int nWordSkip ) + +{ + int i; + GByte *pabyData = (GByte *) pData; + + switch( nWordSize ) + { + case 1: + break; + + case 2: + CPLAssert( nWordSize >= 2 ); + for( i = 0; i < nWordCount; i++ ) + { + GByte byTemp; + + byTemp = pabyData[0]; + pabyData[0] = pabyData[1]; + pabyData[1] = byTemp; + + pabyData += nWordSkip; + } + break; + + case 4: + CPLAssert( nWordSize >= 4 ); + for( i = 0; i < nWordCount; i++ ) + { + GByte byTemp; + + byTemp = pabyData[0]; + pabyData[0] = pabyData[3]; + pabyData[3] = byTemp; + + byTemp = pabyData[1]; + pabyData[1] = pabyData[2]; + pabyData[2] = byTemp; + + pabyData += nWordSkip; + } + break; + + case 8: + CPLAssert( nWordSize >= 8 ); + for( i = 0; i < nWordCount; i++ ) + { + GByte byTemp; + + byTemp = pabyData[0]; + pabyData[0] = pabyData[7]; + pabyData[7] = byTemp; + + byTemp = pabyData[1]; + pabyData[1] = pabyData[6]; + pabyData[6] = byTemp; + + byTemp = pabyData[2]; + pabyData[2] = pabyData[5]; + pabyData[5] = byTemp; + + byTemp = pabyData[3]; + pabyData[3] = pabyData[4]; + pabyData[4] = byTemp; + + pabyData += nWordSkip; + } + break; + + default: + CPLAssert( FALSE ); + } +} + +#endif /* def CPL_LSB */ + +/************************************************************************/ +/* NITFReadRPC00B() */ +/* */ +/* Read an RPC00B structure if the TRE is available. */ +/************************************************************************/ + +int NITFReadRPC00B( NITFImage *psImage, NITFRPC00BInfo *psRPC ) + +{ + const char *pachTRE; + char szTemp[100]; + int i; + + psRPC->SUCCESS = 0; + +/* -------------------------------------------------------------------- */ +/* Do we have the TRE? */ +/* -------------------------------------------------------------------- */ + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "RPC00B", NULL ); + + if( pachTRE == NULL ) + { + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "RPC00A", NULL ); + } + + if( pachTRE == NULL ) + { + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Parse out field values. */ +/* -------------------------------------------------------------------- */ + psRPC->SUCCESS = atoi(NITFGetField(szTemp, pachTRE, 0, 1 )); + + if ( !psRPC->SUCCESS ) + fprintf( stdout, "RPC Extension not Populated!\n"); + + psRPC->ERR_BIAS = atof(NITFGetField(szTemp, pachTRE, 1, 7 )); + psRPC->ERR_RAND = atof(NITFGetField(szTemp, pachTRE, 8, 7 )); + + psRPC->LINE_OFF = atof(NITFGetField(szTemp, pachTRE, 15, 6 )); + psRPC->SAMP_OFF = atof(NITFGetField(szTemp, pachTRE, 21, 5 )); + psRPC->LAT_OFF = atof(NITFGetField(szTemp, pachTRE, 26, 8 )); + psRPC->LONG_OFF = atof(NITFGetField(szTemp, pachTRE, 34, 9 )); + psRPC->HEIGHT_OFF = atof(NITFGetField(szTemp, pachTRE, 43, 5 )); + + psRPC->LINE_SCALE = atof(NITFGetField(szTemp, pachTRE, 48, 6 )); + psRPC->SAMP_SCALE = atof(NITFGetField(szTemp, pachTRE, 54, 5 )); + psRPC->LAT_SCALE = atof(NITFGetField(szTemp, pachTRE, 59, 8 )); + psRPC->LONG_SCALE = atof(NITFGetField(szTemp, pachTRE, 67, 9 )); + psRPC->HEIGHT_SCALE = atof(NITFGetField(szTemp, pachTRE, 76, 5 )); + +/* -------------------------------------------------------------------- */ +/* Parse out coefficients. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < 20; i++ ) + { + psRPC->LINE_NUM_COEFF[i] = + atof(NITFGetField(szTemp, pachTRE, 81+i*12, 12)); + psRPC->LINE_DEN_COEFF[i] = + atof(NITFGetField(szTemp, pachTRE, 321+i*12, 12)); + psRPC->SAMP_NUM_COEFF[i] = + atof(NITFGetField(szTemp, pachTRE, 561+i*12, 12)); + psRPC->SAMP_DEN_COEFF[i] = + atof(NITFGetField(szTemp, pachTRE, 801+i*12, 12)); + } + + return TRUE; +} + +/************************************************************************/ +/* NITFReadICHIPB() */ +/* */ +/* Read an ICHIPB structure if the TRE is available. */ +/************************************************************************/ + +int NITFReadICHIPB( NITFImage *psImage, NITFICHIPBInfo *psICHIP ) + +{ + const char *pachTRE; + char szTemp[32]; + +/* -------------------------------------------------------------------- */ +/* Do we have the TRE? */ +/* -------------------------------------------------------------------- */ + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "ICHIPB", NULL ); + + if( pachTRE == NULL ) + { + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "ICHIPA", NULL ); + } + + if( pachTRE == NULL ) + { + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Parse out field values. */ +/* -------------------------------------------------------------------- */ + psICHIP->XFRM_FLAG = atoi(NITFGetField(szTemp, pachTRE, 0, 2 )); + + if ( psICHIP->XFRM_FLAG == 0 ) + { + psICHIP->SCALE_FACTOR = atof(NITFGetField(szTemp, pachTRE, 2, 10 )); + psICHIP->ANAMORPH_CORR = atoi(NITFGetField(szTemp, pachTRE, 12, 2 )); + psICHIP->SCANBLK_NUM = atoi(NITFGetField(szTemp, pachTRE, 14, 2 )); + + psICHIP->OP_ROW_11 = atof(NITFGetField(szTemp, pachTRE, 16, 12 )); + psICHIP->OP_COL_11 = atof(NITFGetField(szTemp, pachTRE, 28, 12 )); + + psICHIP->OP_ROW_12 = atof(NITFGetField(szTemp, pachTRE, 40, 12 )); + psICHIP->OP_COL_12 = atof(NITFGetField(szTemp, pachTRE, 52, 12 )); + + psICHIP->OP_ROW_21 = atof(NITFGetField(szTemp, pachTRE, 64, 12 )); + psICHIP->OP_COL_21 = atof(NITFGetField(szTemp, pachTRE, 76, 12 )); + + psICHIP->OP_ROW_22 = atof(NITFGetField(szTemp, pachTRE, 88, 12 )); + psICHIP->OP_COL_22 = atof(NITFGetField(szTemp, pachTRE, 100, 12 )); + + psICHIP->FI_ROW_11 = atof(NITFGetField(szTemp, pachTRE, 112, 12 )); + psICHIP->FI_COL_11 = atof(NITFGetField(szTemp, pachTRE, 124, 12 )); + + psICHIP->FI_ROW_12 = atof(NITFGetField(szTemp, pachTRE, 136, 12 )); + psICHIP->FI_COL_12 = atof(NITFGetField(szTemp, pachTRE, 148, 12 )); + + psICHIP->FI_ROW_21 = atof(NITFGetField(szTemp, pachTRE, 160, 12 )); + psICHIP->FI_COL_21 = atof(NITFGetField(szTemp, pachTRE, 172, 12 )); + + psICHIP->FI_ROW_22 = atof(NITFGetField(szTemp, pachTRE, 184, 12 )); + psICHIP->FI_COL_22 = atof(NITFGetField(szTemp, pachTRE, 196, 12 )); + + psICHIP->FI_ROW = atoi(NITFGetField(szTemp, pachTRE, 208, 8 )); + psICHIP->FI_COL = atoi(NITFGetField(szTemp, pachTRE, 216, 8 )); + } + else + { + fprintf( stdout, "Chip is already de-warpped?\n" ); + } + + return TRUE; +} + +/************************************************************************/ +/* NITFReadUSE00A() */ +/* */ +/* Read a USE00A TRE and return contents as metadata strings. */ +/************************************************************************/ + +char **NITFReadUSE00A( NITFImage *psImage ) + +{ + const char *pachTRE; + int nTRESize; + char **papszMD = NULL; + + +/* -------------------------------------------------------------------- */ +/* Do we have the TRE? */ +/* -------------------------------------------------------------------- */ + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "USE00A", &nTRESize ); + + if( pachTRE == NULL ) + return NULL; + + if( nTRESize != 107 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "USE00A TRE wrong size, ignoring." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Parse out field values. */ +/* -------------------------------------------------------------------- */ + NITFExtractMetadata( &papszMD, pachTRE, 0, 3, + "NITF_USE00A_ANGLE_TO_NORTH" ); + NITFExtractMetadata( &papszMD, pachTRE, 3, 5, + "NITF_USE00A_MEAN_GSD" ); + /* reserved: 1 */ + NITFExtractMetadata( &papszMD, pachTRE, 9, 5, + "NITF_USE00A_DYNAMIC_RANGE" ); + /* reserved: 3+1+3 */ + NITFExtractMetadata( &papszMD, pachTRE, 21, 5, + "NITF_USE00A_OBL_ANG" ); + NITFExtractMetadata( &papszMD, pachTRE, 26, 6, + "NITF_USE00A_ROLL_ANG" ); + /* reserved: 12+15+4+1+3+1+1 = 37 */ + NITFExtractMetadata( &papszMD, pachTRE, 69, 2, + "NITF_USE00A_N_REF" ); + NITFExtractMetadata( &papszMD, pachTRE, 71, 5, + "NITF_USE00A_REV_NUM" ); + NITFExtractMetadata( &papszMD, pachTRE, 76, 3, + "NITF_USE00A_N_SEG" ); + NITFExtractMetadata( &papszMD, pachTRE, 79, 6, + "NITF_USE00A_MAX_LP_SEG" ); + /* reserved: 6+6 */ + NITFExtractMetadata( &papszMD, pachTRE, 97, 5, + "NITF_USE00A_SUN_EL" ); + NITFExtractMetadata( &papszMD, pachTRE, 102, 5, + "NITF_USE00A_SUN_AZ" ); + + return papszMD; +} + +/************************************************************************/ +/* NITFReadSTDIDC() */ +/* */ +/* Read a STDIDC TRE and return contents as metadata strings. */ +/************************************************************************/ + +char **NITFReadSTDIDC( NITFImage *psImage ) + +{ + const char *pachTRE; + int nTRESize; + char **papszMD = NULL; + +/* -------------------------------------------------------------------- */ +/* Do we have the TRE? */ +/* -------------------------------------------------------------------- */ + pachTRE = NITFFindTRE( psImage->pachTRE, psImage->nTREBytes, + "STDIDC", &nTRESize ); + + if( pachTRE == NULL ) + return NULL; + + if( nTRESize != 89 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "STDIDC TRE wrong size, ignoring." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Parse out field values. */ +/* -------------------------------------------------------------------- */ + NITFExtractMetadata( &papszMD, pachTRE, 0, 14, + "NITF_STDIDC_ACQUISITION_DATE" ); + NITFExtractMetadata( &papszMD, pachTRE, 14, 14, + "NITF_STDIDC_MISSION" ); + NITFExtractMetadata( &papszMD, pachTRE, 28, 2, + "NITF_STDIDC_PASS" ); + NITFExtractMetadata( &papszMD, pachTRE, 30, 3, + "NITF_STDIDC_OP_NUM" ); + NITFExtractMetadata( &papszMD, pachTRE, 33, 2, + "NITF_STDIDC_START_SEGMENT" ); + NITFExtractMetadata( &papszMD, pachTRE, 35, 2, + "NITF_STDIDC_REPRO_NUM" ); + NITFExtractMetadata( &papszMD, pachTRE, 37, 3, + "NITF_STDIDC_REPLAY_REGEN" ); + /* reserved: 1 */ + NITFExtractMetadata( &papszMD, pachTRE, 41, 3, + "NITF_STDIDC_START_COLUMN" ); + NITFExtractMetadata( &papszMD, pachTRE, 44, 5, + "NITF_STDIDC_START_ROW" ); + NITFExtractMetadata( &papszMD, pachTRE, 49, 2, + "NITF_STDIDC_END_SEGMENT" ); + NITFExtractMetadata( &papszMD, pachTRE, 51, 3, + "NITF_STDIDC_END_COLUMN" ); + NITFExtractMetadata( &papszMD, pachTRE, 54, 5, + "NITF_STDIDC_END_ROW" ); + NITFExtractMetadata( &papszMD, pachTRE, 59, 2, + "NITF_STDIDC_COUNTRY" ); + NITFExtractMetadata( &papszMD, pachTRE, 61, 4, + "NITF_STDIDC_WAC" ); + NITFExtractMetadata( &papszMD, pachTRE, 65, 11, + "NITF_STDIDC_LOCATION" ); + /* reserved: 5+8 */ + + return papszMD; +} + +/************************************************************************/ +/* NITFRPCGeoToImage() */ +/************************************************************************/ + +int NITFRPCGeoToImage( NITFRPC00BInfo *psRPC, + double dfLong, double dfLat, double dfHeight, + double *pdfPixel, double *pdfLine ) + +{ + double dfLineNumerator, dfLineDenominator, + dfPixelNumerator, dfPixelDenominator; + double dfPolyTerm[20]; + int i; + +/* -------------------------------------------------------------------- */ +/* Normalize Lat/Long position. */ +/* -------------------------------------------------------------------- */ + dfLong = (dfLong - psRPC->LONG_OFF) / psRPC->LONG_SCALE; + dfLat = (dfLat - psRPC->LAT_OFF) / psRPC->LAT_SCALE; + dfHeight = (dfHeight - psRPC->HEIGHT_OFF) / psRPC->HEIGHT_SCALE; + +/* -------------------------------------------------------------------- */ +/* Compute the 20 terms. */ +/* -------------------------------------------------------------------- */ + + dfPolyTerm[0] = 1.0; + dfPolyTerm[1] = dfLong; + dfPolyTerm[2] = dfLat; + dfPolyTerm[3] = dfHeight; + dfPolyTerm[4] = dfLong * dfLat; + dfPolyTerm[5] = dfLong * dfHeight; + dfPolyTerm[6] = dfLat * dfHeight; + dfPolyTerm[7] = dfLong * dfLong; + dfPolyTerm[8] = dfLat * dfLat; + dfPolyTerm[9] = dfHeight * dfHeight; + + dfPolyTerm[10] = dfLong * dfLat * dfHeight; + dfPolyTerm[11] = dfLong * dfLong * dfLong; + dfPolyTerm[12] = dfLong * dfLat * dfLat; + dfPolyTerm[13] = dfLong * dfHeight * dfHeight; + dfPolyTerm[14] = dfLong * dfLong * dfLat; + dfPolyTerm[15] = dfLat * dfLat * dfLat; + dfPolyTerm[16] = dfLat * dfHeight * dfHeight; + dfPolyTerm[17] = dfLong * dfLong * dfHeight; + dfPolyTerm[18] = dfLat * dfLat * dfHeight; + dfPolyTerm[19] = dfHeight * dfHeight * dfHeight; + + +/* -------------------------------------------------------------------- */ +/* Compute numerator and denominator sums. */ +/* -------------------------------------------------------------------- */ + dfPixelNumerator = 0.0; + dfPixelDenominator = 0.0; + dfLineNumerator = 0.0; + dfLineDenominator = 0.0; + + for( i = 0; i < 20; i++ ) + { + dfPixelNumerator += psRPC->SAMP_NUM_COEFF[i] * dfPolyTerm[i]; + dfPixelDenominator += psRPC->SAMP_DEN_COEFF[i] * dfPolyTerm[i]; + dfLineNumerator += psRPC->LINE_NUM_COEFF[i] * dfPolyTerm[i]; + dfLineDenominator += psRPC->LINE_DEN_COEFF[i] * dfPolyTerm[i]; + } + +/* -------------------------------------------------------------------- */ +/* Compute normalized pixel and line values. */ +/* -------------------------------------------------------------------- */ + *pdfPixel = dfPixelNumerator / dfPixelDenominator; + *pdfLine = dfLineNumerator / dfLineDenominator; + +/* -------------------------------------------------------------------- */ +/* Denormalize. */ +/* -------------------------------------------------------------------- */ + *pdfPixel = *pdfPixel * psRPC->SAMP_SCALE + psRPC->SAMP_OFF; + *pdfLine = *pdfLine * psRPC->LINE_SCALE + psRPC->LINE_OFF; + + return TRUE; +} + +/************************************************************************/ +/* NITFIHFieldOffset() */ +/* */ +/* Find the file offset for the beginning of a particular field */ +/* in this image header. Only implemented for selected fields. */ +/************************************************************************/ + +GUInt32 NITFIHFieldOffset( NITFImage *psImage, const char *pszFieldName ) + +{ + char szTemp[128]; + int nNICOM; + GUInt32 nWrkOffset; + GUInt32 nIMOffset = + psImage->psFile->pasSegmentInfo[psImage->iSegment].nSegmentHeaderStart; + + // We only support files we created. + CPLAssert( EQUALN(psImage->psFile->szVersion,"NITF02.1",8) ); + + if( EQUAL(pszFieldName,"IM") ) + return nIMOffset; + + if( EQUAL(pszFieldName,"PJUST") ) + return nIMOffset + 370; + + if( EQUAL(pszFieldName,"ICORDS") ) + return nIMOffset + 371; + + if( EQUAL(pszFieldName,"IGEOLO") ) + { + if( !psImage->bHaveIGEOLO ) + return 0; + else + return nIMOffset + 372; + } + +/* -------------------------------------------------------------------- */ +/* Keep working offset from here on in since everything else is */ +/* variable. */ +/* -------------------------------------------------------------------- */ + nWrkOffset = 372 + nIMOffset; + + if( psImage->bHaveIGEOLO ) + nWrkOffset += 60; + +/* -------------------------------------------------------------------- */ +/* Comments. */ +/* -------------------------------------------------------------------- */ + nNICOM = atoi(NITFGetField(szTemp,psImage->pachHeader, + nWrkOffset - nIMOffset,1)); + + if( EQUAL(pszFieldName,"NICOM") ) + return nWrkOffset; + + nWrkOffset++; + + if( EQUAL(pszFieldName,"ICOM") ) + return nWrkOffset; + + nWrkOffset += 80 * nNICOM; + +/* -------------------------------------------------------------------- */ +/* IC */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszFieldName,"IC") ) + return nWrkOffset; + + nWrkOffset += 2; + +/* -------------------------------------------------------------------- */ +/* COMRAT */ +/* -------------------------------------------------------------------- */ + + if( psImage->szIC[0] != 'N' ) + { + if( EQUAL(pszFieldName,"COMRAT") ) + return nWrkOffset; + nWrkOffset += 4; + } + +/* -------------------------------------------------------------------- */ +/* NBANDS */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszFieldName,"NBANDS") ) + return nWrkOffset; + + nWrkOffset += 1; + +/* -------------------------------------------------------------------- */ +/* XBANDS */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszFieldName,"XBANDS") ) + return nWrkOffset; + + if( psImage->nBands > 9 ) + nWrkOffset += 5; + +/* -------------------------------------------------------------------- */ +/* IREPBAND */ +/* -------------------------------------------------------------------- */ + if( EQUAL(pszFieldName,"IREPBAND") ) + return nWrkOffset; + +// nWrkOffset += 2 * psImage->nBands; + + return 0; +} diff --git a/Utilities/GDAL/frmts/raw/GNUmakefile b/Utilities/GDAL/frmts/raw/GNUmakefile new file mode 100644 index 0000000000..1a54240abb --- /dev/null +++ b/Utilities/GDAL/frmts/raw/GNUmakefile @@ -0,0 +1,23 @@ + + +include ../../GDALmake.opt + +OBJ = rawdataset.o ehdrdataset.o pauxdataset.o doq1dataset.o \ + doq2dataset.o mffdataset.o hkvdataset.o pnmdataset.o \ + fujibasdataset.o envidataset.o gscdataset.o fastdataset.o \ + atlsci_spheroid.o btdataset.o landataset.o cpgdataset.o \ + idadataset.o ndfdataset.o dipxdataset.o isis2dataset.o + +CPPFLAGS := $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o $(O_OBJ) + +install-obj: $(O_OBJ) + +$(OBJ) $(O_OBJ): rawdataset.h + +install: + $(INSTALL_DATA) rawdataset.h $(INST_INCLUDE) diff --git a/Utilities/GDAL/frmts/raw/atlsci_spheroid.cpp b/Utilities/GDAL/frmts/raw/atlsci_spheroid.cpp new file mode 100644 index 0000000000..89d2a18513 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/atlsci_spheroid.cpp @@ -0,0 +1,177 @@ +/****************************************************************************** + * $Id: atlsci_spheroid.cpp,v 1.1 2003/03/03 20:10:05 gwalter Exp $ + * + * Project: Spheroid classes + * Purpose: Provide spheroid lookup table base classes. + * Author: Gillian Walter + * + ****************************************************************************** + * Copyright (c) 1999, 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: atlsci_spheroid.cpp,v $ + * Revision 1.1 2003/03/03 20:10:05 gwalter + * Updated MFF and HKV (MFF2) georeferencing support. + * + */ + +#include "atlsci_spheroid.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: atlsci_spheroid.cpp,v 1.1 2003/03/03 20:10:05 gwalter Exp $"); + +/**********************************************************************/ +/* ================================================================== */ +/* Spheroid definitions */ +/* ================================================================== */ +/**********************************************************************/ + + +void SpheroidItem :: SetValuesByRadii(const char *spheroidname, double eq_radius, double p_radius) +{ + spheroid_name = CPLStrdup(spheroidname); + equitorial_radius=eq_radius; + polar_radius=p_radius; + inverse_flattening=eq_radius/(eq_radius - polar_radius); +} + +void SpheroidItem :: SetValuesByEqRadiusAndInvFlattening(const char *spheroidname, double eq_radius, double inverseflattening) +{ + spheroid_name = CPLStrdup(spheroidname); + equitorial_radius=eq_radius; + polar_radius=eq_radius*(1.0 - (1.0/inverse_flattening)); + inverse_flattening=inverseflattening; +} +SpheroidItem :: SpheroidItem() +{ + spheroid_name=NULL; + equitorial_radius=-1.0; + polar_radius=-1.0; + inverse_flattening=-1.0; +} + +SpheroidItem :: ~SpheroidItem() +{ + if (spheroid_name != NULL) + CPLFree(spheroid_name); +} + +SpheroidList :: SpheroidList() +{ + num_spheroids=0; +} + +SpheroidList :: ~SpheroidList() +{ +} + +char *SpheroidList :: GetSpheroidNameByRadii( double eq_radius, double polar_radius ) +{ + int index=0; + double er=0.0; + double pr=0.0; + + for(index=0;index<num_spheroids;index++) + { + er = spheroids[index].equitorial_radius; + pr = spheroids[index].polar_radius; + if ((fabs(er - eq_radius) < epsilonR) && (fabs(pr - polar_radius) < epsilonR)) + return CPLStrdup(spheroids[index].spheroid_name); + } + + return NULL; + +} + +char *SpheroidList :: GetSpheroidNameByEqRadiusAndInvFlattening( double eq_radius, double inverse_flattening ) +{ + int index=0; + double er=0.0; + double invf=0.0; + + for(index=0;index<num_spheroids;index++) + { + er = spheroids[index].equitorial_radius; + invf = spheroids[index].inverse_flattening; + if ((fabs(er - eq_radius) < epsilonR) && (fabs(invf - inverse_flattening) < epsilonI)) + return CPLStrdup(spheroids[index].spheroid_name); + } + + return NULL; + +} + +double SpheroidList :: GetSpheroidEqRadius( const char *spheroid_name ) +{ + int index=0; + + for(index=0;index<num_spheroids;index++) + { + if EQUAL(spheroids[index].spheroid_name,spheroid_name) + return spheroids[index].equitorial_radius; + } + + return -1.0; + +} + +int SpheroidList :: SpheroidInList( const char *spheroid_name ) +{ + /* Return 1 if the spheroid name is recognized; 0 otherwise */ + int index=0; + + for(index=0;index<num_spheroids;index++) + { + if EQUAL(spheroids[index].spheroid_name,spheroid_name) + return 1; + } + + return 0; +} + +double SpheroidList :: GetSpheroidInverseFlattening( const char *spheroid_name ) +{ + int index=0; + + for(index=0;index<num_spheroids;index++) + { + if EQUAL(spheroids[index].spheroid_name,spheroid_name) + return spheroids[index].inverse_flattening; + } + + return -1.0; + +} + +double SpheroidList :: GetSpheroidPolarRadius( const char *spheroid_name ) +{ + int index=0; + + for(index=0;index<num_spheroids;index++) + { + if (strcmp(spheroids[index].spheroid_name,spheroid_name) == 0) + return spheroids[index].polar_radius; + } + + return -1.0; + +} + diff --git a/Utilities/GDAL/frmts/raw/atlsci_spheroid.h b/Utilities/GDAL/frmts/raw/atlsci_spheroid.h new file mode 100644 index 0000000000..cc7b8c62ce --- /dev/null +++ b/Utilities/GDAL/frmts/raw/atlsci_spheroid.h @@ -0,0 +1,87 @@ +/****************************************************************************** + * $Id$ + * + * Project: Spheroid classes + * Purpose: Provide spheroid lookup table base classes. + * Author: Gillian Walter + * + ****************************************************************************** + * Copyright (c) 1999, 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: atlsci_spheroid.h,v $ + * Revision 1.1 2003/03/03 20:10:05 gwalter + * Updated MFF and HKV (MFF2) georeferencing support. + * + */ + +/**********************************************************************/ +/* ================================================================== */ +/* Spheroid definitions */ +/* ================================================================== */ +/**********************************************************************/ + + +/* Maximum number of expected spheroids */ +# define MAX_RECOGNIZED_SPHEROIDS 256 + +class SpheroidItem +{ + +public: + SpheroidItem(); + ~SpheroidItem(); + + char *spheroid_name; + double equitorial_radius; + double polar_radius; + double inverse_flattening; + + void SetValuesByRadii(const char *spheroidname, double eq_radius, double p_radius); + void SetValuesByEqRadiusAndInvFlattening(const char *spheroidname, double eq_radius, double inverseflattening); + +}; + +class SpheroidList +{ + +public: + int num_spheroids; + // Acceptable errors for radii, inverse flattening + double epsilonR; + double epsilonI; + + + SpheroidItem spheroids[MAX_RECOGNIZED_SPHEROIDS]; + + SpheroidList(); + ~SpheroidList(); + + char* GetSpheroidNameByRadii( double eq_radius, double polar_radius ); + char* GetSpheroidNameByEqRadiusAndInvFlattening( double eq_radius, double inverse_flatting ); + + int SpheroidInList( const char *spheroid_name ); + double GetSpheroidEqRadius( const char *spheroid_name ); + double GetSpheroidPolarRadius( const char *spheroid_name ); + double GetSpheroidInverseFlattening( const char *spheroid_name ); + +}; + diff --git a/Utilities/GDAL/frmts/raw/btdataset.cpp b/Utilities/GDAL/frmts/raw/btdataset.cpp new file mode 100644 index 0000000000..5ab27d0dd6 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/btdataset.cpp @@ -0,0 +1,970 @@ +/****************************************************************************** + * $Id: btdataset.cpp,v 1.9 2006/04/11 00:33:15 fwarmerdam Exp $ + * + * Project: VTP .bt Driver + * Purpose: Implementation of VTP .bt elevation format read/write support. + * http://www.vterrain.org/Implementation/Formats/BT.html + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2003, 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: btdataset.cpp,v $ + * Revision 1.9 2006/04/11 00:33:15 fwarmerdam + * Added SetUnitType(), contributed by Ray Gardener. + * + * Revision 1.8 2006/04/09 04:22:28 fwarmerdam + * Implement GetUnitType() support when reading, from Ray Gardner. + * + * Revision 1.7 2005/05/05 13:55:41 fwarmerdam + * PAM Enable + * + * Revision 1.6 2004/05/11 17:27:33 warmerda + * Set eAccess properly in Open(). + * + * Revision 1.5 2004/03/02 15:14:07 warmerda + * Fixed CPL_MSB case. + * + * Revision 1.4 2004/03/01 17:55:10 warmerda + * rewrote to *not* use raw layer + * + * Revision 1.3 2004/01/08 20:13:33 warmerda + * Fixed bugs with georeferencing (on read), and with imagery access + * (was diagonally flipped). Note, that BT imagery is column organized, + * like USGS DEMs, not row oriented as the raw driver is optimized for. + * + * Revision 1.2 2003/12/11 22:44:11 warmerda + * ensure external .prj flag gets set + * + * Revision 1.1 2003/12/11 06:18:18 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: btdataset.cpp,v 1.9 2006/04/11 00:33:15 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_BT(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* BTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class BTDataset : public GDALPamDataset +{ + friend class BTRasterBand; + + FILE *fpImage; // image data file. + + int bGeoTransformValid; + double adfGeoTransform[6]; + + char *pszProjection; + + double dfVScale; + + int nVersionCode; // version times 10. + + int bHeaderModified; + unsigned char abyHeader[256]; + + float m_fVscale; + + public: + + BTDataset(); + ~BTDataset(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual void FlushCache(); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszOptions ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* BTRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class BTRasterBand : public GDALRasterBand +{ + FILE *fpImage; + + public: + + BTRasterBand( GDALDataset * poDS, FILE * fp, + GDALDataType eType ); + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual const char* GetUnitType(); + virtual CPLErr SetUnitType(const char*); +}; + + +/************************************************************************/ +/* BTRasterBand() */ +/************************************************************************/ + +BTRasterBand::BTRasterBand( GDALDataset *poDS, FILE *fp, GDALDataType eType ) + +{ + this->poDS = poDS; + this->nBand = 1; + this->eDataType = eType; + this->fpImage = fp; + + nBlockXSize = 1; + nBlockYSize = poDS->GetRasterYSize(); +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr BTRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int nDataSize = GDALGetDataTypeSize( eDataType ) / 8; + int i; + + CPLAssert( nBlockYOff == 0 ); + +/* -------------------------------------------------------------------- */ +/* Seek to profile. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeekL( fpImage, + 256 + nBlockXOff * nDataSize * nRasterYSize, + SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + ".bt Seek failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Read the profile. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( pImage, nDataSize, nRasterYSize, fpImage ) != + (size_t) nRasterYSize ) + { + CPLError( CE_Failure, CPLE_FileIO, + ".bt Read failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Swap on MSB platforms. */ +/* -------------------------------------------------------------------- */ +#ifdef CPL_MSB + GDALSwapWords( pImage, nDataSize, nRasterYSize, nDataSize ); +#endif + +/* -------------------------------------------------------------------- */ +/* Vertical flip, since GDAL expects values from top to bottom, */ +/* but in .bt they are bottom to top. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nRasterYSize / 2; i++ ) + { + GByte abyWrk[8]; + + memcpy( abyWrk, ((GByte *) pImage) + i * nDataSize, nDataSize ); + memcpy( ((GByte *) pImage) + i * nDataSize, + ((GByte *) pImage) + (nRasterYSize - i - 1) * nDataSize, + nDataSize ); + memcpy( ((GByte *) pImage) + (nRasterYSize - i - 1) * nDataSize, + abyWrk, nDataSize ); + } + + return CE_None; +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr BTRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int nDataSize = GDALGetDataTypeSize( eDataType ) / 8; + GByte *pabyWrkBlock; + int i; + + CPLAssert( nBlockYOff == 0 ); + +/* -------------------------------------------------------------------- */ +/* Seek to profile. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeekL( fpImage, + 256 + nBlockXOff * nDataSize * nRasterYSize, + SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + ".bt Seek failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Allocate working buffer. */ +/* -------------------------------------------------------------------- */ + pabyWrkBlock = (GByte *) CPLMalloc(nDataSize * nRasterYSize); + +/* -------------------------------------------------------------------- */ +/* Vertical flip data into work buffer, since GDAL expects */ +/* values from top to bottom, but in .bt they are bottom to */ +/* top. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nRasterYSize; i++ ) + { + memcpy( pabyWrkBlock + (nRasterYSize - i - 1) * nDataSize, + ((GByte *) pImage) + i * nDataSize, nDataSize ); + } + +/* -------------------------------------------------------------------- */ +/* Swap on MSB platforms. */ +/* -------------------------------------------------------------------- */ +#ifdef CPL_MSB + GDALSwapWords( pabyWrkBlock, nDataSize, nRasterYSize, nDataSize ); +#endif + +/* -------------------------------------------------------------------- */ +/* Read the profile. */ +/* -------------------------------------------------------------------- */ + if( VSIFWriteL( pabyWrkBlock, nDataSize, nRasterYSize, fpImage ) != + (size_t) nRasterYSize ) + { + CPLFree( pabyWrkBlock ); + CPLError( CE_Failure, CPLE_FileIO, + ".bt Write failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + + CPLFree( pabyWrkBlock ); + + return CE_None; +} + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ + +static bool approx_equals(float a, float b) +{ + const float epsilon = (float)1e-5; + return (fabs(a-b) <= epsilon); +} + +const char* BTRasterBand::GetUnitType(void) +{ + const BTDataset& ds = *(BTDataset*)poDS; + float f = ds.m_fVscale; + if(f == 1.0f) + return "m"; + if(approx_equals(f, 0.3048f)) + return "ft"; + if(approx_equals(f, 1200.0f/3937.0f)) + return "sft"; + + // todo: the BT spec allows for any value for + // ds.m_fVscale, so rigorous adherence would + // require testing for all possible units you + // may want to support, such as km, yards, miles, etc. + // But m/ft/sft seem to be the top three. + + return ""; +} + +/************************************************************************/ +/* SetUnitType() */ +/************************************************************************/ + +CPLErr BTRasterBand::SetUnitType(const char* psz) +{ + BTDataset& ds = *(BTDataset*)poDS; + if(EQUAL(psz, "m")) + ds.m_fVscale = 1.0f; + else if(EQUAL(psz, "ft")) + ds.m_fVscale = 0.3048f; + else if(EQUAL(psz, "sft")) + ds.m_fVscale = 1200.0f / 3937.0f; + else + return CE_Failure; + + + float fScale = ds.m_fVscale; + + CPL_LSBPTR32(&fScale); + + // Update header's elevation scale field. + memcpy(ds.abyHeader + 62, &fScale, sizeof(fScale)); + + ds.bHeaderModified = TRUE; + return CE_None; +} + +/************************************************************************/ +/* ==================================================================== */ +/* BTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* BTDataset() */ +/************************************************************************/ + +BTDataset::BTDataset() +{ + fpImage = NULL; + bGeoTransformValid = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + pszProjection = NULL; + + bHeaderModified = FALSE; +} + +/************************************************************************/ +/* ~BTDataset() */ +/************************************************************************/ + +BTDataset::~BTDataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFCloseL( fpImage ); + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* FlushCache() */ +/* */ +/* We override this to include flush out the header block. */ +/************************************************************************/ + +void BTDataset::FlushCache() + +{ + GDALDataset::FlushCache(); + + if( !bHeaderModified ) + return; + + bHeaderModified = FALSE; + + VSIFSeekL( fpImage, 0, SEEK_SET ); + VSIFWriteL( abyHeader, 256, 1, fpImage ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr BTDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + + if( bGeoTransformValid ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr BTDataset::SetGeoTransform( double *padfTransform ) + +{ + CPLErr eErr = CE_None; + + memcpy( adfGeoTransform, padfTransform, sizeof(double) * 6 ); + if( adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + ".bt format does not support rotational coefficients in geotransform, ignoring." ); + eErr = CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Compute bounds, and update header info. */ +/* -------------------------------------------------------------------- */ + double dfLeft, dfRight, dfTop, dfBottom; + + dfLeft = adfGeoTransform[0]; + dfRight = dfLeft + adfGeoTransform[1] * nRasterXSize; + dfTop = adfGeoTransform[3]; + dfBottom = dfTop + adfGeoTransform[5] * nRasterYSize; + + memcpy( abyHeader + 28, &dfLeft, 8 ); + memcpy( abyHeader + 36, &dfRight, 8 ); + memcpy( abyHeader + 44, &dfBottom, 8 ); + memcpy( abyHeader + 52, &dfTop, 8 ); + + CPL_LSBPTR64( abyHeader + 28 ); + CPL_LSBPTR64( abyHeader + 36 ); + CPL_LSBPTR64( abyHeader + 44 ); + CPL_LSBPTR64( abyHeader + 52 ); + + bHeaderModified = TRUE; + + return eErr; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *BTDataset::GetProjectionRef() + +{ + if( pszProjection == NULL ) + return ""; + else + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr BTDataset::SetProjection( const char *pszNewProjection ) + +{ + CPLErr eErr = CE_None; + + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszNewProjection ); + + bHeaderModified = TRUE; + +/* -------------------------------------------------------------------- */ +/* Parse projection. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS( pszProjection ); + GInt16 nShortTemp; + +/* -------------------------------------------------------------------- */ +/* Linear units. */ +/* -------------------------------------------------------------------- */ + if( oSRS.IsGeographic() ) + nShortTemp = 0; + else + { + double dfLinear = oSRS.GetLinearUnits(); + + if( ABS(dfLinear - 0.3048) < 0.0000001 ) + nShortTemp = 2; + else if( ABS(dfLinear - atof(SRS_UL_US_FOOT_CONV)) < 0.00000001 ) + nShortTemp = 3; + else + nShortTemp = 1; + } + + nShortTemp = CPL_LSBWORD16( 1 ); + memcpy( abyHeader + 22, &nShortTemp, 2 ); + +/* -------------------------------------------------------------------- */ +/* UTM Zone */ +/* -------------------------------------------------------------------- */ + int bNorth; + + nShortTemp = oSRS.GetUTMZone( &bNorth ); + if( bNorth ) + nShortTemp = -nShortTemp; + + nShortTemp = CPL_LSBWORD16( nShortTemp ); + memcpy( abyHeader + 24, &nShortTemp, 2 ); + +/* -------------------------------------------------------------------- */ +/* Datum */ +/* -------------------------------------------------------------------- */ + if( oSRS.GetAuthorityName( "GEOGCS|DATUM" ) != NULL + && EQUAL(oSRS.GetAuthorityName( "GEOGCS|DATUM" ),"EPSG") ) + nShortTemp = atoi(oSRS.GetAuthorityName( "GEOGCS|DATUM" )) + 2000; + else + nShortTemp = -2; + nShortTemp = CPL_LSBWORD16( nShortTemp ); /* datum unknown */ + memcpy( abyHeader + 26, &nShortTemp, 2 ); + +/* -------------------------------------------------------------------- */ +/* Write out the projection to a .prj file. */ +/* -------------------------------------------------------------------- */ + const char *pszPrjFile = CPLResetExtension( GetDescription(), "prj" ); + FILE * fp; + + fp = VSIFOpen( pszPrjFile, "wt" ); + if( fp != NULL ) + { + VSIFPrintf( fp, "%s\n", pszProjection ); + VSIFClose( fp ); + abyHeader[60] = 1; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to write out .prj file." ); + eErr = CE_Failure; + } + + return eErr; +} + + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *BTDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify that this is some form of binterr file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 256 || poOpenInfo->fp == NULL ) + return NULL; + + if( strncmp( (const char *) poOpenInfo->pabyHeader, "binterr", 7 ) != 0 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create the dataset. */ +/* -------------------------------------------------------------------- */ + BTDataset *poDS; + + poDS = new BTDataset(); + + memcpy( poDS->abyHeader, poOpenInfo->pabyHeader, 256 ); + +/* -------------------------------------------------------------------- */ +/* Get the version. */ +/* -------------------------------------------------------------------- */ + char szVersion[4]; + + strncpy( szVersion, (char *) (poDS->abyHeader + 7), 3 ); + szVersion[3] = '\0'; + poDS->nVersionCode = (int) (atof(szVersion) * 10); + +/* -------------------------------------------------------------------- */ +/* Extract core header information, being careful about the */ +/* version. */ +/* -------------------------------------------------------------------- */ + GInt32 nIntTemp; + GInt16 nDataSize; + GDALDataType eType; + + memcpy( &nIntTemp, poDS->abyHeader + 10, 4 ); + poDS->nRasterXSize = CPL_LSBWORD32( nIntTemp ); + + memcpy( &nIntTemp, poDS->abyHeader + 14, 4 ); + poDS->nRasterYSize = CPL_LSBWORD32( nIntTemp ); + + memcpy( &nDataSize, poDS->abyHeader+18, 2 ); + nDataSize = CPL_LSBWORD16( nDataSize ); + + if( poDS->abyHeader[20] != 0 && nDataSize == 4 ) + eType = GDT_Float32; + else if( poDS->abyHeader[20] == 0 && nDataSize == 4 ) + eType = GDT_Int32; + else if( poDS->abyHeader[20] == 0 && nDataSize == 2 ) + eType = GDT_Int16; + else + { + CPLError( CE_Failure, CPLE_AppDefined, + ".bt file data type unknown, got datasize=%d.", + nDataSize ); + return NULL; + } + + /* + rcg, apr 7/06: read offset 62 for vert. units. + If zero, assume 1.0 as per spec. + + */ + memcpy( &poDS->m_fVscale, poDS->abyHeader + 62, 4 ); + CPL_LSBPTR32(&poDS->m_fVscale); + if(poDS->m_fVscale == 0.0f) + poDS->m_fVscale = 1.0f; + +/* -------------------------------------------------------------------- */ +/* Try to read a .prj file if it is indicated. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS; + + if( poDS->nVersionCode >= 12 && poDS->abyHeader[60] != 0 ) + { + const char *pszPrjFile = CPLResetExtension( poOpenInfo->pszFilename, + "prj" ); + FILE *fp; + + fp = VSIFOpen( pszPrjFile, "rt" ); + if( fp != NULL ) + { + char *pszBuffer, *pszBufPtr; + int nBufMax = 100000; + int nBytes; + + pszBuffer = (char *) CPLMalloc(nBufMax); + nBytes = VSIFRead( pszBuffer, 1, nBufMax-1, fp ); + VSIFClose( fp ); + + pszBuffer[nBytes] = '\0'; + + pszBufPtr = pszBuffer; + if( oSRS.importFromWkt( &pszBufPtr ) != OGRERR_NONE ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unable to parse .prj file, coordinate system missing." ); + } + CPLFree( pszBuffer ); + } + } + +/* -------------------------------------------------------------------- */ +/* If we didn't find a .prj file, try to use internal info. */ +/* -------------------------------------------------------------------- */ + if( oSRS.GetRoot() == NULL ) + { + GInt16 nUTMZone, nDatum, nHUnits; + + memcpy( &nUTMZone, poDS->abyHeader + 24, 2 ); + nUTMZone = CPL_LSBWORD16( nUTMZone ); + + memcpy( &nDatum, poDS->abyHeader + 26, 2 ); + nDatum = CPL_LSBWORD16( nDatum ); + + memcpy( &nHUnits, poDS->abyHeader + 22, 2 ); + nHUnits = CPL_LSBWORD16( nHUnits ); + + if( nUTMZone != 0 ) + oSRS.SetUTM( ABS(nUTMZone), nUTMZone > 0 ); + else if( nHUnits != 0 ) + oSRS.SetLocalCS( "Unknown" ); + + if( nHUnits == 1 ) + oSRS.SetLinearUnits( SRS_UL_METER, 1.0 ); + else if( nHUnits == 2 ) + oSRS.SetLinearUnits( SRS_UL_FOOT, atof(SRS_UL_FOOT_CONV) ); + else if( nHUnits == 3 ) + oSRS.SetLinearUnits( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) ); + + // Translate some of the more obvious old USGS datum codes + if( nDatum == 0 ) + nDatum = 6201; + else if( nDatum == 1 ) + nDatum = 6209; + else if( nDatum == 2 ) + nDatum = 6210; + else if( nDatum == 3 ) + nDatum = 6202; + else if( nDatum == 4 ) + nDatum = 6203; + else if( nDatum == 4 ) + nDatum = 6203; + else if( nDatum == 6 ) + nDatum = 6222; + else if( nDatum == 7 ) + nDatum = 6230; + else if( nDatum == 13 ) + nDatum = 6267; + else if( nDatum == 14 ) + nDatum = 6269; + else if( nDatum == 17 ) + nDatum = 6277; + else if( nDatum == 19 ) + nDatum = 6284; + else if( nDatum == 21 ) + nDatum = 6301; + else if( nDatum == 22 ) + nDatum = 6322; + else if( nDatum == 23 ) + nDatum = 6326; + + if( !oSRS.IsLocal() ) + { + if( nDatum >= 6000 ) + { + char szName[32]; + sprintf( szName, "EPSG:%d", nDatum-2000 ); + oSRS.SetWellKnownGeogCS( szName ); + } + else + oSRS.SetWellKnownGeogCS( "WGS84" ); + } + } + +/* -------------------------------------------------------------------- */ +/* Convert coordinate system back to WKT. */ +/* -------------------------------------------------------------------- */ + if( oSRS.GetRoot() != NULL ) + oSRS.exportToWkt( &poDS->pszProjection ); + +/* -------------------------------------------------------------------- */ +/* Get georeferencing bounds. */ +/* -------------------------------------------------------------------- */ + if( poDS->nVersionCode >= 11 ) + { + double dfLeft, dfRight, dfTop, dfBottom; + + memcpy( &dfLeft, poDS->abyHeader + 28, 8 ); + CPL_LSBPTR64( &dfLeft ); + + memcpy( &dfRight, poDS->abyHeader + 36, 8 ); + CPL_LSBPTR64( &dfRight ); + + memcpy( &dfBottom, poDS->abyHeader + 44, 8 ); + CPL_LSBPTR64( &dfBottom ); + + memcpy( &dfTop, poDS->abyHeader + 52, 8 ); + CPL_LSBPTR64( &dfTop ); + + poDS->adfGeoTransform[0] = dfLeft; + poDS->adfGeoTransform[1] = (dfRight - dfLeft) / poDS->nRasterXSize; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfTop; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = (dfBottom - dfTop) / poDS->nRasterYSize; + + poDS->bGeoTransformValid = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Re-open the file with the desired access. */ +/* -------------------------------------------------------------------- */ + VSIFClose( poOpenInfo->fp ); + poOpenInfo->fp = NULL; + + if( poOpenInfo->eAccess == GA_Update ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to re-open %s within BT driver.\n", + poOpenInfo->pszFilename ); + return NULL; + } + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Create band information objects */ +/* -------------------------------------------------------------------- */ + poDS->SetBand( 1, new BTRasterBand( poDS, poDS->fpImage, eType ) ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +#ifdef notdef + poDS->bGeoTransformValid = + GDALReadWorldFile( poOpenInfo->pszFilename, ".wld", + poDS->adfGeoTransform ); +#endif + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *BTDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszOptions ) + +{ + +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_Float32 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create .bt dataset with an illegal\n" + "data type (%s), only Int16, Int32 and Float32 supported.\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + + if( nBands != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create .bt dataset with %d bands, only 1 supported", + nBands ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpenL( pszFilename, "wb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Setup base header. */ +/* -------------------------------------------------------------------- */ + unsigned char abyHeader[256]; + GInt32 nTemp; + GInt16 nShortTemp; + + memset( abyHeader, 0, 256 ); + memcpy( abyHeader, "binterr1.3", 10 ); + + nTemp = CPL_LSBWORD32( nXSize ); + memcpy( abyHeader+10, &nTemp, 4 ); + + nTemp = CPL_LSBWORD32( nYSize ); + memcpy( abyHeader+14, &nTemp, 4 ); + + nShortTemp = CPL_LSBWORD16( GDALGetDataTypeSize( eType ) / 8 ); + memcpy( abyHeader + 18, &nShortTemp, 2 ); + + if( eType == GDT_Float32 ) + abyHeader[20] = 1; + else + abyHeader[20] = 0; + + nShortTemp = CPL_LSBWORD16( 1 ); /* meters */ + memcpy( abyHeader + 22, &nShortTemp, 2 ); + + nShortTemp = CPL_LSBWORD16( 0 ); /* not utm */ + memcpy( abyHeader + 24, &nShortTemp, 2 ); + + nShortTemp = CPL_LSBWORD16( -2 ); /* datum unknown */ + memcpy( abyHeader + 26, &nShortTemp, 2 ); + +/* -------------------------------------------------------------------- */ +/* Set dummy extents. */ +/* -------------------------------------------------------------------- */ + double dfLeft=0, dfRight=nXSize, dfTop=nYSize, dfBottom=0; + + memcpy( abyHeader + 28, &dfLeft, 8 ); + memcpy( abyHeader + 36, &dfRight, 8 ); + memcpy( abyHeader + 44, &dfBottom, 8 ); + memcpy( abyHeader + 52, &dfTop, 8 ); + + CPL_LSBPTR64( abyHeader + 28 ); + CPL_LSBPTR64( abyHeader + 36 ); + CPL_LSBPTR64( abyHeader + 44 ); + CPL_LSBPTR64( abyHeader + 52 ); + +/* -------------------------------------------------------------------- */ +/* Set dummy scale. */ +/* -------------------------------------------------------------------- */ + float fScale = 1.0; + + memcpy( abyHeader + 62, &fScale, 4 ); + CPL_LSBPTR32( abyHeader + 62 ); + +/* -------------------------------------------------------------------- */ +/* Write to disk. */ +/* -------------------------------------------------------------------- */ + VSIFWriteL( (void *) abyHeader, 256, 1, fp ); + if( VSIFSeekL( fp, (GDALGetDataTypeSize(eType)/8) * nXSize * nYSize - 1, + SEEK_CUR ) != 0 + || VSIFWriteL( abyHeader+255, 1, 1, fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to extent file to its full size, out of disk space?" + ); + + VSIFCloseL( fp ); + VSIUnlink( pszFilename ); + return NULL; + } + + VSIFCloseL( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* GDALRegister_BT() */ +/************************************************************************/ + +void GDALRegister_BT() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "BT" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "BT" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "VTP .bt (Binary Terrain) 1.3 Format" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#BT" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "bt" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Int16 Int32 Float32" ); + poDriver->pfnOpen = BTDataset::Open; + poDriver->pfnCreate = BTDataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/raw/cpgdataset.cpp b/Utilities/GDAL/frmts/raw/cpgdataset.cpp new file mode 100644 index 0000000000..860e2f2271 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/cpgdataset.cpp @@ -0,0 +1,1676 @@ +/****************************************************************************** + * $Id: cpgdataset.cpp,v 1.8 2005/10/21 14:22:08 gwalter Exp $ + * + * Project: Polarimetric Workstation + * Purpose: Convair PolGASP data (.img/.hdr format). + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: cpgdataset.cpp,v $ + * Revision 1.8 2005/10/21 14:22:08 gwalter + * Updated to support more types of convair datasets. + * + * Revision 1.7 2005/05/05 13:55:41 fwarmerdam + * PAM Enable + * + * Revision 1.6 2004/12/17 22:45:55 gwalter + * Added support for sirc-style convair flat + * binary datasets. + * + * Revision 1.5 2004/11/11 00:16:01 gwalter + * Polarmetric->Polarimetric. + * + * Revision 1.4 2004/10/21 18:15:25 gwalter + * Added gcp id's- the lack of them + * was causing weird export problems. + * + * Revision 1.3 2004/10/20 23:27:45 gwalter + * Added geocoding. + * + * Revision 1.2 2004/09/07 15:36:58 gwalter + * Updated to recognize more convair + * file naming conventions; change + * band ordering from hh,hv,vh,vv to + * hh,hv,vv,vh. + * + * Revision 1.1 2004/09/03 19:07:25 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: cpgdataset.cpp,v 1.8 2005/10/21 14:22:08 gwalter Exp $"); + +CPL_C_START +void GDALRegister_CPG(void); +CPL_C_END + + +enum Interleave {BSQ, BIL, BIP}; + +/************************************************************************/ +/* ==================================================================== */ +/* CPGDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class SIRC_QSLCRasterBand; +class CPG_STOKESRasterBand; + +class CPGDataset : public RawDataset +{ + friend class SIRC_QSLCRasterBand; + friend class CPG_STOKESRasterBand; + + FILE *afpImage[4]; + + int nGCPCount; + GDAL_GCP *pasGCPList; + char *pszGCPProjection; + + double adfGeoTransform[6]; + char *pszProjection; + + int nLoadedStokesLine; + float *padfStokesMatrix; + + int nInterleave; + static int AdjustFilename( char **, const char *, const char * ); + static int FindType1( char *pszWorkname ); + static int FindType2( char *pszWorkname ); + static int FindType3( char *pszWorkname ); + static GDALDataset *InitializeType1Or2Dataset( char *pszWorkname ); + static GDALDataset *InitializeType3Dataset( char *pszWorkname ); + CPLErr LoadStokesLine( int iLine, int bNativeOrder ); + + public: + CPGDataset(); + ~CPGDataset(); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr GetGeoTransform( double * ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* CPGDataset() */ +/************************************************************************/ + +CPGDataset::CPGDataset() +{ + int iBand; + + nGCPCount = 0; + pasGCPList = NULL; + pszProjection = CPLStrdup(""); + pszGCPProjection = CPLStrdup(""); + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + + nLoadedStokesLine = -1; + padfStokesMatrix = NULL; + + for( iBand = 0; iBand < 4; iBand++ ) + afpImage[iBand] = NULL; +} + +/************************************************************************/ +/* ~CPGDataset() */ +/************************************************************************/ + +CPGDataset::~CPGDataset() + +{ + int iBand; + + FlushCache(); + + for( iBand = 0; iBand < 4; iBand++ ) + { + if( afpImage[iBand] != NULL ) + VSIFClose( afpImage[iBand] ); + } + + if( nGCPCount > 0 ) + { + for( int i = 0; i < nGCPCount; i++ ) + CPLFree( pasGCPList[i].pszId ); + + CPLFree( pasGCPList ); + } + + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + + if (padfStokesMatrix != NULL) + CPLFree( padfStokesMatrix ); + +} + +/************************************************************************/ +/* ==================================================================== */ +/* SIRC_QSLCPRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class SIRC_QSLCRasterBand : public GDALRasterBand +{ + friend class CPGDataset; + + public: + SIRC_QSLCRasterBand( CPGDataset *, int, GDALDataType ); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + +#define M11 0 +#define M12 1 +#define M13 2 +#define M14 3 +#define M21 4 +#define M22 5 +#define M23 6 +#define M24 7 +#define M31 8 +#define M32 9 +#define M33 10 +#define M34 11 +#define M41 12 +#define M42 13 +#define M43 14 +#define M44 15 + +/************************************************************************/ +/* ==================================================================== */ +/* CPG_STOKESRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class CPG_STOKESRasterBand : public GDALRasterBand +{ + friend class CPGDataset; + + int nBand; + int bNativeOrder; + + public: + CPG_STOKESRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType, + int bNativeOrder ); + virtual ~CPG_STOKESRasterBand(); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + +/************************************************************************/ +/* AdjustFilename() */ +/* */ +/* Try to find the file with the request polarization and */ +/* extention and update the passed filename accordingly. */ +/* */ +/* Return TRUE if file found otherwise FALSE. */ +/************************************************************************/ + +int CPGDataset::AdjustFilename( char **pszFilename, + const char *pszPolarization, + const char *pszExtension ) + +{ + VSIStatBuf sStatBuf; + const char *pszNewName; + char *subptr; + + /* eventually we should handle upper/lower case ... */ + + if ( EQUAL(pszPolarization,"stokes") ) + { + pszNewName = CPLResetExtension((const char *) *pszFilename, + (const char *) pszExtension); + CPLFree(*pszFilename); + *pszFilename = CPLStrdup(pszNewName); + } + else if (strlen(pszPolarization) == 2) + { + subptr = strstr(*pszFilename,"hh"); + if (subptr == NULL) + subptr = strstr(*pszFilename,"hv"); + if (subptr == NULL) + subptr = strstr(*pszFilename,"vv"); + if (subptr == NULL) + subptr = strstr(*pszFilename,"vh"); + if (subptr == NULL) + return FALSE; + + strncpy( subptr, pszPolarization, 2); + pszNewName = CPLResetExtension((const char *) *pszFilename, + (const char *) pszExtension); + CPLFree(*pszFilename); + *pszFilename = CPLStrdup(pszNewName); + + } + else + { + pszNewName = CPLResetExtension((const char *) *pszFilename, + (const char *) pszExtension); + CPLFree(*pszFilename); + *pszFilename = CPLStrdup(pszNewName); + } + return VSIStat( *pszFilename, &sStatBuf ) == 0; +} + +/************************************************************************/ +/* Search for the various types of Convair filesets */ +/* Return TRUE for a match, FALSE for no match */ +/************************************************************************/ +int CPGDataset::FindType1( char *pszFilename ) +{ + int nNameLen; + + nNameLen = strlen(pszFilename); + + if ((strstr(pszFilename,"sso") == NULL) && + (strstr(pszFilename,"polgasp") == NULL)) + return FALSE; + + if (( strlen(pszFilename) < 5) || + (!EQUAL(pszFilename+nNameLen-4,".hdr") + && !EQUAL(pszFilename+nNameLen-4,".img"))) + return FALSE; + + /* Expect all bands and headers to be present */ + if ( !AdjustFilename( &pszFilename, "hh", "img" ) + || !AdjustFilename( &pszFilename, "hh", "hdr" ) + || !AdjustFilename( &pszFilename, "hv", "img" ) + || !AdjustFilename( &pszFilename, "hv", "hdr" ) + || !AdjustFilename( &pszFilename, "vh", "img" ) + || !AdjustFilename( &pszFilename, "vh", "hdr" ) + || !AdjustFilename( &pszFilename, "vv", "img" ) + || !AdjustFilename( &pszFilename, "vv", "hdr" ) ) + return FALSE; + + return TRUE; +} + +int CPGDataset::FindType2( char *pszFilename ) +{ + int nNameLen; + + nNameLen = strlen( pszFilename ); + + if (( strlen(pszFilename) < 9) || + (!EQUAL(pszFilename+nNameLen-8,"SIRC.hdr") + && !EQUAL(pszFilename+nNameLen-8,"SIRC.img"))) + return FALSE; + + if ( !AdjustFilename( &pszFilename, "", "img" ) + || !AdjustFilename( &pszFilename, "", "hdr" )) + return FALSE; + + return TRUE; +} + +int CPGDataset::FindType3( char *pszFilename ) +{ + int nNameLen; + + nNameLen = strlen( pszFilename ); + + if ((strstr(pszFilename,"sso") == NULL) && + (strstr(pszFilename,"polgasp") == NULL)) + return FALSE; + + if (( strlen(pszFilename) < 9) || + (!EQUAL(pszFilename+nNameLen-4,".img") + && !EQUAL(pszFilename+nNameLen-8,".img_def"))) + return FALSE; + + if ( !AdjustFilename( &pszFilename, "stokes", "img" ) + || !AdjustFilename( &pszFilename, "stokes", "img_def" )) + return FALSE; + + return TRUE; +} + +/************************************************************************/ +/* LoadStokesLine() */ +/************************************************************************/ + +CPLErr CPGDataset::LoadStokesLine( int iLine, int bNativeOrder ) + +{ + int offset, nBytesToRead, band_index; + int nDataSize = GDALGetDataTypeSize(GDT_Float32)/8; + + if( iLine == nLoadedStokesLine ) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* allocate working buffers if we don't have them already. */ +/* -------------------------------------------------------------------- */ + if( padfStokesMatrix == NULL ) + { + padfStokesMatrix = (float *) CPLMalloc(sizeof(float) * nRasterXSize*16); + } + +/* -------------------------------------------------------------------- */ +/* Load all the pixel data associated with this scanline. */ +/* Retains same interleaving as original dataset. */ +/* -------------------------------------------------------------------- */ + if ( nInterleave == BIP ) + { + offset = nRasterXSize*iLine*nDataSize*16; + nBytesToRead = nDataSize*nRasterXSize*16; + if (( VSIFSeek( afpImage[0], offset, SEEK_SET ) != 0 ) || + (int) VSIFRead( ( GByte *) padfStokesMatrix, 1, nBytesToRead, + afpImage[0] ) != nBytesToRead ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Error reading %d bytes of Stokes Convair at offset %d.\n" + "Reading file %s failed.", + nBytesToRead, offset, GetDescription() ); + CPLFree( padfStokesMatrix ); + padfStokesMatrix = NULL; + nLoadedStokesLine = -1; + return CE_Failure; + } + } + else if ( nInterleave == BIL ) + { + for ( band_index = 0; band_index < 16; band_index++) + { + offset = nDataSize * (nRasterXSize*iLine + + nRasterXSize*band_index); + nBytesToRead = nDataSize*nRasterXSize; + if (( VSIFSeek( afpImage[0], offset, SEEK_SET ) != 0 ) || + (int) VSIFRead( + ( GByte *) padfStokesMatrix + nBytesToRead*band_index, + 1, nBytesToRead, + afpImage[0] ) != nBytesToRead ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Error reading %d bytes of Stokes Convair at offset %d.\n" + "Reading file %s failed.", + nBytesToRead, offset, GetDescription() ); + CPLFree( padfStokesMatrix ); + padfStokesMatrix = NULL; + nLoadedStokesLine = -1; + return CE_Failure; + + } + } + } + else + { + for ( band_index = 0; band_index < 16; band_index++) + { + offset = nDataSize * (nRasterXSize*iLine + + nRasterXSize*nRasterYSize*band_index); + nBytesToRead = nDataSize*nRasterXSize; + if (( VSIFSeek( afpImage[0], offset, SEEK_SET ) != 0 ) || + (int) VSIFRead( + ( GByte *) padfStokesMatrix + nBytesToRead*band_index, + 1, nBytesToRead, + afpImage[0] ) != nBytesToRead ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Error reading %d bytes of Stokes Convair at offset %d.\n" + "Reading file %s failed.", + nBytesToRead, offset, GetDescription() ); + CPLFree( padfStokesMatrix ); + padfStokesMatrix = NULL; + nLoadedStokesLine = -1; + return CE_Failure; + + } + } + } + + if (!bNativeOrder) + GDALSwapWords( padfStokesMatrix,nDataSize,nRasterXSize*16, nDataSize ); + + nLoadedStokesLine = iLine; + + return CE_None; +} + +/************************************************************************/ +/* Parse header information and initialize dataset for the */ +/* appropriate Convair dataset style. */ +/* Returns dataset if successful; NULL if there was a problem. */ +/************************************************************************/ + +GDALDataset* CPGDataset::InitializeType1Or2Dataset( char *pszWorkname ) +{ + +/* -------------------------------------------------------------------- */ +/* Read the .hdr file (the hh one for the .sso and polgasp cases) */ +/* and parse it. */ +/* -------------------------------------------------------------------- */ + char **papszHdrLines; + int iLine; + int nLines = 0, nSamples = 0; + int nError = 0; + int nNameLen = 0; + + /* Parameters required for pseudo-geocoding. GCPs map */ + /* slant range to ground range at 16 points. */ + int iGeoParamsFound = 0, itransposed = 0; + double dfaltitude = 0.0, dfnear_srd = 0.0; + double dfsample_size = 0.0, dfsample_size_az = 0.0; + + /* Parameters in geogratis geocoded images */ + int iUTMParamsFound = 0, iUTMZone=0, iCorner=0; + double dfnorth = 0.0, dfeast = 0.0; + + AdjustFilename( &pszWorkname, "hh", "hdr" ); + papszHdrLines = CSLLoad( pszWorkname ); + + for( iLine = 0; papszHdrLines && papszHdrLines[iLine] != NULL; iLine++ ) + { + char **papszTokens = CSLTokenizeString( papszHdrLines[iLine] ); + + /* Note: some cv580 file seem to have comments with #, hence the >= + * instead of = for token checking, and the equalN for the corner. + */ + + if( CSLCount( papszTokens ) < 2 ) + { + /* ignore */; + } + else if ( ( CSLCount( papszTokens ) >= 3 ) && + EQUAL(papszTokens[0],"reference") && + EQUAL(papszTokens[1],"north") ) + { + dfnorth = atof(papszTokens[2]); + iUTMParamsFound++; + } + else if ( ( CSLCount( papszTokens ) >= 3 ) && + EQUAL(papszTokens[0],"reference") && + EQUAL(papszTokens[1],"east") ) + { + dfeast = atof(papszTokens[2]); + iUTMParamsFound++; + } + else if ( ( CSLCount( papszTokens ) >= 5 ) && + EQUAL(papszTokens[0],"reference") && + EQUAL(papszTokens[1],"projection") && + EQUAL(papszTokens[2],"UTM") && + EQUAL(papszTokens[3],"zone") ) + { + iUTMZone = atoi(papszTokens[4]); + iUTMParamsFound++; + } + else if ( ( CSLCount( papszTokens ) >= 3 ) && + EQUAL(papszTokens[0],"reference") && + EQUAL(papszTokens[1],"corner") && + EQUALN(papszTokens[2],"Upper_Left",10) ) + { + iCorner = 0; + iUTMParamsFound++; + } + else if( EQUAL(papszTokens[0],"number_lines") ) + nLines = atoi(papszTokens[1]); + + else if( EQUAL(papszTokens[0],"number_samples") ) + nSamples = atoi(papszTokens[1]); + + else if( (EQUAL(papszTokens[0],"header_offset") + && atoi(papszTokens[1]) != 0) + || (EQUAL(papszTokens[0],"number_channels") + && (atoi(papszTokens[1]) != 1) + && (atoi(papszTokens[1]) != 10)) + || (EQUAL(papszTokens[0],"datatype") + && atoi(papszTokens[1]) != 1) + || (EQUAL(papszTokens[0],"number_format") + && !EQUAL(papszTokens[1],"float32") + && !EQUAL(papszTokens[1],"int8"))) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Keyword %s has value %s which does not match CPG driver expectation.", + papszTokens[0], papszTokens[1] ); + nError = 1; + } + else if( EQUAL(papszTokens[0],"altitude") ) + { + dfaltitude = atof(papszTokens[1]); + iGeoParamsFound++; + } + else if( EQUAL(papszTokens[0],"near_srd") ) + { + dfnear_srd = atof(papszTokens[1]); + iGeoParamsFound++; + } + + else if( EQUAL(papszTokens[0],"sample_size") ) + { + dfsample_size = atof(papszTokens[1]); + iGeoParamsFound++; + iUTMParamsFound++; + } + else if( EQUAL(papszTokens[0],"sample_size_az") ) + { + dfsample_size_az = atof(papszTokens[1]); + iGeoParamsFound++; + iUTMParamsFound++; + } + else if( EQUAL(papszTokens[0],"transposed") ) + { + itransposed = atoi(papszTokens[1]); + iGeoParamsFound++; + iUTMParamsFound++; + } + + + + CSLDestroy( papszTokens ); + } + CSLDestroy( papszHdrLines ); +/* -------------------------------------------------------------------- */ +/* Check for successful completion. */ +/* -------------------------------------------------------------------- */ + if( nError ) + return NULL; + + if( nLines == 0 || nSamples == 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Did not find valid number_lines or number_samples keywords in %s.", + pszWorkname ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Initialize dataset. */ +/* -------------------------------------------------------------------- */ + int iBand=0; + CPGDataset *poDS; + + poDS = new CPGDataset(); + + poDS->nRasterXSize = nSamples; + poDS->nRasterYSize = nLines; + +/* -------------------------------------------------------------------- */ +/* Open the four bands. */ +/* -------------------------------------------------------------------- */ + char *apszPolarizations[4] = { "hh", "hv", "vv", "vh" }; + + nNameLen = strlen(pszWorkname); + + if ( EQUAL(pszWorkname+nNameLen-7,"IRC.hdr") || + EQUAL(pszWorkname+nNameLen-7,"IRC.img") ) + { + + AdjustFilename( &pszWorkname, "" , "img" ); + poDS->afpImage[0] = VSIFOpen( pszWorkname, "rb" ); + if( poDS->afpImage[0] == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open .img file: %s", + pszWorkname ); + return NULL; + } + for( iBand = 0; iBand < 4; iBand++ ) + { + SIRC_QSLCRasterBand *poBand; + + poBand = new SIRC_QSLCRasterBand( poDS, iBand+1, GDT_CFloat32 ); + poDS->SetBand( iBand+1, poBand ); + poBand->SetMetadataItem( "POLARIMETRIC_INTERP", + apszPolarizations[iBand] ); + } + } + else + { + for( iBand = 0; iBand < 4; iBand++ ) + { + RawRasterBand *poBand; + + AdjustFilename( &pszWorkname, apszPolarizations[iBand], "img" ); + + poDS->afpImage[iBand] = VSIFOpen( pszWorkname, "rb" ); + if( poDS->afpImage[iBand] == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open .img file: %s", + pszWorkname ); + return NULL; + } + + poBand = + new RawRasterBand( poDS, iBand+1, poDS->afpImage[iBand], + 0, 8, 8*nSamples, + GDT_CFloat32, !CPL_IS_LSB, FALSE ); + poDS->SetBand( iBand+1, poBand ); + + poBand->SetMetadataItem( "POLARIMETRIC_INTERP", + apszPolarizations[iBand] ); + } + } + +/* ------------------------------------------------------------------------- */ +/* Add georeferencing or pseudo-geocoding, if enough information found. */ +/* ------------------------------------------------------------------------- */ + if (iUTMParamsFound == 7) + { + OGRSpatialReference oUTM; + double dfnorth_center; + + poDS->adfGeoTransform[1] = 0.0; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = 0.0; + + if (itransposed == 1) + { + printf("Warning- did not have a convair SIRC-style test dataset\n" + "with transposed=1 for testing. Georefencing may be wrong.\n"); + dfnorth_center = dfnorth - nSamples*dfsample_size/2.0; + poDS->adfGeoTransform[0] = dfeast; + poDS->adfGeoTransform[2] = dfsample_size_az; + poDS->adfGeoTransform[3] = dfnorth; + poDS->adfGeoTransform[4] = -1*dfsample_size; + } + else + { + dfnorth_center = dfnorth - nLines*dfsample_size/2.0; + poDS->adfGeoTransform[0] = dfeast; + poDS->adfGeoTransform[1] = dfsample_size_az; + poDS->adfGeoTransform[3] = dfnorth; + poDS->adfGeoTransform[5] = -1*dfsample_size; + } + if (dfnorth_center < 0) + oUTM.SetUTM(iUTMZone, 0); + else + oUTM.SetUTM(iUTMZone, 1); + + /* Assuming WGS84 */ + oUTM.SetWellKnownGeogCS( "WGS84" ); + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + oUTM.exportToWkt( &(poDS->pszProjection) ); + + + + } + else if (iGeoParamsFound == 5) + { + int ngcp; + double dfgcpLine, dfgcpPixel, dfgcpX, dfgcpY, dftemp; + + poDS->nGCPCount = 16; + poDS->pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),16); + + for( ngcp = 0; ngcp < 16; ngcp ++ ) + { + char szID[32]; + + sprintf(szID,"%d",ngcp+1); + if (itransposed == 1) + { + if (ngcp < 4) + dfgcpPixel = 0.0; + else if (ngcp < 8) + dfgcpPixel = nSamples/3.0; + else if (ngcp < 12) + dfgcpPixel = 2.0*nSamples/3.0; + else + dfgcpPixel = nSamples; + + dfgcpLine = nLines*( ngcp % 4 )/3.0; + + dftemp = dfnear_srd + (dfsample_size*dfgcpLine); + /* -1 so that 0,0 maps to largest Y */ + dfgcpY = -1*sqrt( dftemp*dftemp - dfaltitude*dfaltitude ); + dfgcpX = dfgcpPixel*dfsample_size_az; + + } + else + { + if (ngcp < 4) + dfgcpLine = 0.0; + else if (ngcp < 8) + dfgcpLine = nLines/3.0; + else if (ngcp < 12) + dfgcpLine = 2.0*nLines/3.0; + else + dfgcpLine = nLines; + + dfgcpPixel = nSamples*( ngcp % 4 )/3.0; + + dftemp = dfnear_srd + (dfsample_size*dfgcpPixel); + dfgcpX = sqrt( dftemp*dftemp - dfaltitude*dfaltitude ); + dfgcpY = (nLines - dfgcpLine)*dfsample_size_az; + + } + poDS->pasGCPList[ngcp].dfGCPX = dfgcpX; + poDS->pasGCPList[ngcp].dfGCPY = dfgcpY; + poDS->pasGCPList[ngcp].dfGCPZ = 0.0; + + poDS->pasGCPList[ngcp].dfGCPPixel = dfgcpPixel; + poDS->pasGCPList[ngcp].dfGCPLine = dfgcpLine; + + poDS->pasGCPList[ngcp].pszId = CPLStrdup( szID ); + poDS->pasGCPList[ngcp].pszInfo = ""; + + } + poDS->pszGCPProjection = (char *) CPLStrdup("LOCAL_CS[\"Ground range view / unreferenced meters\",UNIT[\"Meter\",1.0]]"); + + } + + return poDS; +} + +GDALDataset *CPGDataset::InitializeType3Dataset( char *pszWorkname ) +{ + + char **papszHdrLines; + int iLine, iBytesPerPixel = 0, iInterleave=-1; + int nLines = 0, nSamples = 0, nBands = 0; + int nError = 0; + + /* Parameters in geogratis geocoded images */ + int iUTMParamsFound = 0, iUTMZone=0; + double dfnorth = 0.0, dfeast = 0.0, dfOffsetX = 0.0, dfOffsetY = 0.0; + double dfxsize = 0.0, dfysize = 0.0; + + AdjustFilename( &pszWorkname, "stokes", "img_def" ); + papszHdrLines = CSLLoad( pszWorkname ); + + for( iLine = 0; papszHdrLines && papszHdrLines[iLine] != NULL; iLine++ ) + { + char **papszTokens = CSLTokenizeString2( papszHdrLines[iLine], + " \t", + CSLT_HONOURSTRINGS & CSLT_ALLOWEMPTYTOKENS ); + + /* Note: some cv580 file seem to have comments with #, hence the >= + * instead of = for token checking, and the equalN for the corner. + */ + + if ( ( CSLCount( papszTokens ) >= 3 ) && + EQUAL(papszTokens[0],"data") && + EQUAL(papszTokens[1],"organization:")) + { + + if( EQUALN(papszTokens[2], "BSQ", 3) ) + iInterleave = BSQ; + else if( EQUALN(papszTokens[2], "BIL", 3) ) + iInterleave = BIL; + else if( EQUALN(papszTokens[2], "BIP", 3) ) + iInterleave = BIP; + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "The interleaving type of the file (%s) is not supported.", + papszTokens[2] ); + nError = 1; + } + + } + else if ( ( CSLCount( papszTokens ) >= 3 ) && + EQUAL(papszTokens[0],"data") && + EQUAL(papszTokens[1],"state:") ) + { + + if( !EQUALN(papszTokens[2], "RAW", 3) && + !EQUALN(papszTokens[2], "GEO", 3) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The data state of the file (%s) is not supported.\n. Only RAW and GEO are currently recognized.", + papszTokens[2] ); + nError = 1; + } + + + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"data") && + EQUAL(papszTokens[1],"origin") && + EQUAL(papszTokens[2],"point:") ) + { + if (!EQUALN(papszTokens[3], "Upper_Left", 10)) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unexpected value (%s) for data origin point- expect Upper_Left.", + papszTokens[3] ); + nError = 1; + } + iUTMParamsFound++; + } + else if ( ( CSLCount( papszTokens ) >= 5 ) && + EQUAL(papszTokens[0],"map") && + EQUAL(papszTokens[1],"projection:") && + EQUAL(papszTokens[2],"UTM") && + EQUAL(papszTokens[3],"zone") ) + { + iUTMZone = atoi(papszTokens[4]); + iUTMParamsFound++; + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"project") && + EQUAL(papszTokens[1],"origin:") ) + { + dfeast = atof(papszTokens[2]); + dfnorth = atof(papszTokens[3]); + iUTMParamsFound+=2; + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"file") && + EQUAL(papszTokens[1],"start:")) + { + dfOffsetX = atof(papszTokens[2]); + dfOffsetY = atof(papszTokens[3]); + iUTMParamsFound+=2; + } + else if ( ( CSLCount( papszTokens ) >= 6 ) && + EQUAL(papszTokens[0],"pixel") && + EQUAL(papszTokens[1],"size") && + EQUAL(papszTokens[2],"on") && + EQUAL(papszTokens[3],"ground:")) + { + dfxsize = atof(papszTokens[4]); + dfysize = atof(papszTokens[5]); + iUTMParamsFound+=2; + + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"number") && + EQUAL(papszTokens[1],"of") && + EQUAL(papszTokens[2],"pixels:")) + { + nSamples = atoi(papszTokens[3]); + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"number") && + EQUAL(papszTokens[1],"of") && + EQUAL(papszTokens[2],"lines:")) + { + nLines = atoi(papszTokens[3]); + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"number") && + EQUAL(papszTokens[1],"of") && + EQUAL(papszTokens[2],"bands:")) + { + nBands = atoi(papszTokens[3]); + if ( nBands != 16) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Number of bands has a value %s which does not match CPG driver\nexpectation (expect a value of 16).", + papszTokens[3] ); + nError = 1; + } + } + else if ( ( CSLCount( papszTokens ) >= 4 ) && + EQUAL(papszTokens[0],"bytes") && + EQUAL(papszTokens[1],"per") && + EQUAL(papszTokens[2],"pixel:")) + { + iBytesPerPixel = atoi(papszTokens[3]); + if (iBytesPerPixel != 4) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Bytes per pixel has a value %s which does not match CPG driver\nexpectation (expect a value of 4).", + papszTokens[1] ); + nError = 1; + } + } + CSLDestroy( papszTokens ); + } + + CSLDestroy( papszHdrLines ); + +/* -------------------------------------------------------------------- */ +/* Check for successful completion. */ +/* -------------------------------------------------------------------- */ + if( nError ) + return NULL; + + if( nLines == 0 || nSamples == 0 || iInterleave == -1 || + nBands == 0 || iBytesPerPixel == 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s is missing a required parameter (number of pixels, number of lines,\nnumber of bands, bytes per pixel, or data organization).", + pszWorkname ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Initialize dataset. */ +/* -------------------------------------------------------------------- */ + int iBand=0; + CPGDataset *poDS; + + poDS = new CPGDataset(); + + poDS->nRasterXSize = nSamples; + poDS->nRasterYSize = nLines; + + if( iInterleave == BSQ ) + poDS->nInterleave = BSQ; + else if( iInterleave == BIL ) + poDS->nInterleave = BIL; + else + poDS->nInterleave = BIP; + +/* -------------------------------------------------------------------- */ +/* Open the 16 bands. */ +/* -------------------------------------------------------------------- */ + + AdjustFilename( &pszWorkname, "stokes" , "img" ); + poDS->afpImage[0] = VSIFOpen( pszWorkname, "rb" ); + if( poDS->afpImage[0] == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open .img file: %s", + pszWorkname ); + return NULL; + } + for( iBand = 0; iBand < 16; iBand++ ) + { + CPG_STOKESRasterBand *poBand; + + poBand = new CPG_STOKESRasterBand( poDS, iBand+1, GDT_CFloat32, + !CPL_IS_LSB ); + poDS->SetBand( iBand+1, poBand ); + } + +/* ------------------------------------------------------------------------- */ +/* Add georeferencing, if enough information found. */ +/* ------------------------------------------------------------------------- */ + if (iUTMParamsFound == 8) + { + OGRSpatialReference oUTM; + double dfnorth_center; + + + dfnorth_center = dfnorth - nLines*dfysize/2.0; + poDS->adfGeoTransform[0] = dfeast + dfOffsetX; + poDS->adfGeoTransform[1] = dfxsize; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfnorth + dfOffsetY; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = -1*dfysize; + + if (dfnorth_center < 0) + oUTM.SetUTM(iUTMZone, 0); + else + oUTM.SetUTM(iUTMZone, 1); + + /* Assuming WGS84 */ + oUTM.SetWellKnownGeogCS( "WGS84" ); + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + oUTM.exportToWkt( &(poDS->pszProjection) ); + } + + return poDS; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *CPGDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Is this a PolGASP fileset? We expect fileset to follow */ +/* one of these patterns: */ +/* 1) <stuff>hh<stuff2>.img, <stuff>hh<stuff2>.hdr, */ +/* <stuff>hv<stuff2>.img, <stuff>hv<stuff2>.hdr, */ +/* <stuff>vh<stuff2>.img, <stuff>vh<stuff2>.hdr, */ +/* <stuff>vv<stuff2>.img, <stuff>vv<stuff2>.hdr, */ +/* where <stuff> or <stuff2> should contain the */ +/* substring "sso" or "polgasp" */ +/* 2) <stuff>SIRC.hdr and <stuff>SIRC.img */ +/* 3) <stuff>.img and <stuff>.img_def */ +/* where <stuff> should contain the */ +/* substring "sso" or "polgasp" */ +/* -------------------------------------------------------------------- */ + int nNameLen = strlen(poOpenInfo->pszFilename); + int CPGType = 0; + + /* scratch workspace that gets freed and reallocated by the tests */ + char *pszWorkname = CPLStrdup(poOpenInfo->pszFilename); + + if ( FindType1( pszWorkname )) + CPGType = 1; + else if ( FindType2( pszWorkname )) + CPGType = 2; + + /* Stokes matrix convair data: not quite working yet- something + * is wrong in the interpretation of the matrix elements in terms + * of hh, hv, vv, vh. Data will load if the next two lines are + * uncommented, but values will be incorrect. Expect C11 = hh*conj(hh), + * C12 = hh*conj(hv), etc. Used geogratis data in both scattering + * matrix and stokes format for comparison. + */ + //else if ( FindType3( pszWorkname )) + // CPGType = 3; + + /* Set working name back to original */ + CPLFree( pszWorkname ); + pszWorkname = CPLStrdup(poOpenInfo->pszFilename); + + if ( CPGType == 0 ) + { + nNameLen = strlen(pszWorkname); + if ( (nNameLen > 8) && + ( ( strstr(pszWorkname,"sso") != NULL ) || + ( strstr(pszWorkname,"polgasp") != NULL ) ) && + ( EQUAL(pszWorkname+nNameLen-4,"img") || + EQUAL(pszWorkname+nNameLen-4,"hdr") || + EQUAL(pszWorkname+nNameLen-7,"img_def") ) ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Apparent attempt to open Convair PolGASP data failed as\n" + "one or more of the required files is missing (eight files\n" + "are expected for scattering matrix format, two for Stokes)." ); + } + else if ( (nNameLen > 8) && + ( strstr(pszWorkname,"SIRC") != NULL ) && + ( EQUAL(pszWorkname+nNameLen-4,"img") || + EQUAL(pszWorkname+nNameLen-4,"hdr"))) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Apparent attempt to open SIRC Convair PolGASP data failed \n" + "as one of the expected files is missing (hdr or img)!" ); + } + CPLFree( pszWorkname ); + return NULL; + } + + /* Read the header info and create the dataset */ + CPGDataset *poDS; + + if ( CPGType < 3 ) + poDS = (CPGDataset *) InitializeType1Or2Dataset( pszWorkname ); + else + poDS = (CPGDataset *) InitializeType3Dataset( pszWorkname ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + // Need to think about this. + // poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int CPGDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *CPGDataset::GetGCPProjection() + +{ + return pszGCPProjection; +} + +/************************************************************************/ +/* GetGCPs() */ +/************************************************************************/ + +const GDAL_GCP *CPGDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *CPGDataset::GetProjectionRef() + +{ + return( pszProjection ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr CPGDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return( CE_None ); +} + +/************************************************************************/ +/* SIRC_QSLCRasterBand() */ +/************************************************************************/ + +SIRC_QSLCRasterBand::SIRC_QSLCRasterBand( CPGDataset *poGDS, int nBand, + GDALDataType eType ) + +{ + this->poDS = poGDS; + this->nBand = nBand; + + eDataType = eType; + + nBlockXSize = poGDS->nRasterXSize; + nBlockYSize = 1; + + if( nBand == 1 ) + SetMetadataItem( "POLARIMETRIC_INTERP", "HH" ); + else if( nBand == 2 ) + SetMetadataItem( "POLARIMETRIC_INTERP", "HV" ); + else if( nBand == 3 ) + SetMetadataItem( "POLARIMETRIC_INTERP", "VH" ); + else if( nBand == 4 ) + SetMetadataItem( "POLARIMETRIC_INTERP", "VV" ); +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +/* From: http://southport.jpl.nasa.gov/software/dcomp/dcomp.html + +ysca = sqrt{ [ (Byte(2) / 254 ) + 1.5] 2Byte(1) } + +Re(SHH) = byte(3) ysca/127 + +Im(SHH) = byte(4) ysca/127 + +Re(SHV) = byte(5) ysca/127 + +Im(SHV) = byte(6) ysca/127 + +Re(SVH) = byte(7) ysca/127 + +Im(SVH) = byte(8) ysca/127 + +Re(SVV) = byte(9) ysca/127 + +Im(SVV) = byte(10) ysca/127 + +*/ + +CPLErr SIRC_QSLCRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int offset, nBytesPerSample=10; + GByte *pabyRecord; + CPGDataset *poGDS = (CPGDataset *) poDS; + static float afPowTable[256]; + static int bPowTableInitialized = FALSE; + + offset = nBlockXSize* nBlockYOff*nBytesPerSample; + +/* -------------------------------------------------------------------- */ +/* Load all the pixel data associated with this scanline. */ +/* -------------------------------------------------------------------- */ + int nBytesToRead = nBytesPerSample * nBlockXSize; + + pabyRecord = (GByte *) CPLMalloc( nBytesToRead ); + + if( VSIFSeek( poGDS->afpImage[0], offset, SEEK_SET ) != 0 + || (int) VSIFRead( pabyRecord, 1, nBytesToRead, + poGDS->afpImage[0] ) != nBytesToRead ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Error reading %d bytes of SIRC Convair at offset %d.\n" + "Reading file %s failed.", + nBytesToRead, offset, poGDS->GetDescription() ); + CPLFree( pabyRecord ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Initialize our power table if this is our first time through. */ +/* -------------------------------------------------------------------- */ + if( !bPowTableInitialized ) + { + int i; + + bPowTableInitialized = TRUE; + + for( i = 0; i < 256; i++ ) + { + afPowTable[i] = pow( 2.0, i-128 ); + } + } + +/* -------------------------------------------------------------------- */ +/* Copy the desired band out based on the size of the type, and */ +/* the interleaving mode. */ +/* -------------------------------------------------------------------- */ + int iX; + + for( iX = 0; iX < nBlockXSize; iX++ ) + { + unsigned char *pabyGroup = pabyRecord + iX * nBytesPerSample; + signed char *Byte = (signed char*)pabyGroup-1; /* A ones based alias */ + double dfReSHH, dfImSHH, dfReSHV, dfImSHV, + dfReSVH, dfImSVH, dfReSVV, dfImSVV, dfScale; + + dfScale = sqrt( (Byte[2] / 254 + 1.5) * afPowTable[Byte[1] + 128] ); + + if( nBand == 1 ) + { + dfReSHH = Byte[3] * dfScale / 127.0; + dfImSHH = Byte[4] * dfScale / 127.0; + + ((float *) pImage)[iX*2 ] = dfReSHH; + ((float *) pImage)[iX*2+1] = dfImSHH; + } + else if( nBand == 2 ) + { + dfReSHV = Byte[5] * dfScale / 127.0; + dfImSHV = Byte[6] * dfScale / 127.0; + + ((float *) pImage)[iX*2 ] = dfReSHV; + ((float *) pImage)[iX*2+1] = dfImSHV; + } + else if( nBand == 3 ) + { + dfReSVH = Byte[7] * dfScale / 127.0; + dfImSVH = Byte[8] * dfScale / 127.0; + + ((float *) pImage)[iX*2 ] = dfReSVH; + ((float *) pImage)[iX*2+1] = dfImSVH; + } + else if( nBand == 4 ) + { + dfReSVV = Byte[9] * dfScale / 127.0; + dfImSVV = Byte[10]* dfScale / 127.0; + + ((float *) pImage)[iX*2 ] = dfReSVV; + ((float *) pImage)[iX*2+1] = dfImSVV; + } + } + + CPLFree( pabyRecord ); + + return CE_None; +} + +/************************************************************************/ +/* CPG_STOKESRasterBand() */ +/************************************************************************/ + +CPG_STOKESRasterBand::CPG_STOKESRasterBand( GDALDataset *poDS, int nBand, + GDALDataType eType, + int bNativeOrder ) + +{ + char *apszPolarizations[16] = { "Covariance_11", + "Covariance_12", + "Covariance_13", + "Covariance_14", + "Covariance_21", + "Covariance_22", + "Covariance_23", + "Covariance_24", + "Covariance_31", + "Covariance_32", + "Covariance_33", + "Covariance_34", + "Covariance_41", + "Covariance_42", + "Covariance_43", + "Covariance_44" }; + + this->poDS = poDS; + this->nBand = nBand; + this->eDataType = eType; + this->bNativeOrder = bNativeOrder; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; + + SetMetadataItem( "POLARIMETRIC_INTERP",apszPolarizations[nBand-1] ); + SetDescription( apszPolarizations[nBand-1] ); +} + +/************************************************************************/ +/* ~CPG_STOKESRasterBand() */ +/************************************************************************/ + +CPG_STOKESRasterBand::~CPG_STOKESRasterBand() + +{ +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +/* Convert from Stokes to Covariance representation */ + +CPLErr CPG_STOKESRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + int iPixel; + int m11, m12, m13, m14, m21, m22, m23, m24, step; + int m31, m32, m33, m34, m41, m42, m43, m44; + CPGDataset *poGDS = (CPGDataset *) poDS; + float *M; + float *pafLine; + CPLErr eErr; + + CPLAssert( nBlockXOff == 0 ); + + eErr = poGDS->LoadStokesLine(nBlockYOff, bNativeOrder); + if( eErr != CE_None ) + return eErr; + + M = poGDS->padfStokesMatrix; + pafLine = ( float * ) pImage; + + if ( poGDS->nInterleave == BIP) + { + step = 16; + m11 = M11; + m12 = M12; + m13 = M13; + m14 = M14; + m21 = M21; + m22 = M22; + m23 = M23; + m24 = M24; + m31 = M31; + m32 = M32; + m33 = M33; + m34 = M34; + m41 = M41; + m42 = M42; + m43 = M43; + m44 = M44; + } + else + { + step = 1; + m11=0; + m12=nRasterXSize; + m13=nRasterXSize*2; + m14=nRasterXSize*3; + m21=nRasterXSize*4; + m22=nRasterXSize*5; + m23=nRasterXSize*6; + m24=nRasterXSize*7; + m31=nRasterXSize*8; + m32=nRasterXSize*9; + m33=nRasterXSize*10; + m34=nRasterXSize*11; + m41=nRasterXSize*12; + m42=nRasterXSize*13; + m43=nRasterXSize*14; + m44=nRasterXSize*15; + } + if ( nBand == 1 ) /* C11 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m11]-M[m22]-M[m33]+M[m44]; + pafLine[iPixel*2+1] = 0.0; + m11 += step; + m22 += step; + m33 += step; + m44 += step; + } + } + else if ( nBand == 2 ) /* C12 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m13]-M[m23]; + pafLine[iPixel*2+1] = M[m14]-M[m24]; + m13 += step; + m23 += step; + m14 += step; + m24 += step; + } + } + else if ( nBand == 3 ) /* C13 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m33]-M[m44]; + pafLine[iPixel*2+1] = M[m43]+M[m34]; + m33 += step; + m44 += step; + m43 += step; + m34 += step; + } + } + else if ( nBand == 4 ) /* C14 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m31]-M[m32]; + pafLine[iPixel*2+1] = M[m41]-M[m42]; + m31 += step; + m32 += step; + m41 += step; + m42 += step; + } + } + else if ( nBand == 5 ) /* C21 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m13]-M[m23]; + pafLine[iPixel*2+1] = M[m24]-M[m14]; + m13 += step; + m23 += step; + m14 += step; + m24 += step; + } + } + else if ( nBand == 6 ) /* C22 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m11]+M[m22]-M[m33]-M[m44]; + pafLine[iPixel*2+1] = 0.0; + m11 += step; + m22 += step; + m33 += step; + m44 += step; + } + } + else if ( nBand == 7 ) /* C23 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m31]+M[m32]; + pafLine[iPixel*2+1] = M[m41]+M[m42]; + m31 += step; + m32 += step; + m41 += step; + m42 += step; + } + } + else if ( nBand == 8 ) /* C24 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m33]+M[m44]; + pafLine[iPixel*2+1] = M[m43]-M[m34]; + m33 += step; + m44 += step; + m43 += step; + m34 += step; + } + } + else if ( nBand == 9 ) /* C31 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m33]-M[m44]; + pafLine[iPixel*2+1] = -1*M[m43]-M[m34]; + m33 += step; + m44 += step; + m43 += step; + m34 += step; + } + } + else if ( nBand == 10 ) /* C32 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m31]+M[m32]; + pafLine[iPixel*2+1] = -1*M[m41]-M[m42]; + m31 += step; + m32 += step; + m41 += step; + m42 += step; + } + } + else if ( nBand == 11 ) /* C33 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m11]+M[m22]+M[m33]+M[m44]; + pafLine[iPixel*2+1] = 0.0; + m11 += step; + m22 += step; + m33 += step; + m44 += step; + } + + } + else if ( nBand == 12 ) /* C34 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m13]-M[m23]; + pafLine[iPixel*2+1] = -1*M[m14]-M[m24]; + m13 += step; + m23 += step; + m14 += step; + m24 += step; + } + } + else if ( nBand == 13 ) /* C41 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m31]-M[m32]; + pafLine[iPixel*2+1] = M[m42]-M[m41]; + m31 += step; + m32 += step; + m41 += step; + m42 += step; + } + } + else if ( nBand == 14 ) /* C42 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m33]+M[m44]; + pafLine[iPixel*2+1] = M[m34]-M[m43]; + m33 += step; + m44 += step; + m43 += step; + m34 += step; + } + } + else if ( nBand == 15 ) /* C43 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m13]-M[m23]; + pafLine[iPixel*2+1] = M[m14]+M[m24]; + m13 += step; + m23 += step; + m14 += step; + m24 += step; + } + } + else /* C44 */ + { + for ( iPixel = 0; iPixel < nRasterXSize; iPixel++ ) + { + pafLine[iPixel*2+0] = M[m11]-M[m22]+M[m33]-M[m44]; + pafLine[iPixel*2+1] = 0.0; + m11 += step; + m22 += step; + m33 += step; + m44 += step; + } + } + + return CE_None; +} + +/************************************************************************/ +/* GDALRegister_CPG() */ +/************************************************************************/ + +void GDALRegister_CPG() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "CPG" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "CPG" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Convair PolGASP" ); + + poDriver->pfnOpen = CPGDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/dipxdataset.cpp b/Utilities/GDAL/frmts/raw/dipxdataset.cpp new file mode 100644 index 0000000000..db3870a133 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/dipxdataset.cpp @@ -0,0 +1,354 @@ +/****************************************************************************** + * $Id: dipxdataset.cpp,v 1.4 2006/02/09 05:38:56 fwarmerdam Exp $ + * + * Project: GDAL + * Purpose: Implementation for ELAS DIPEx format variant. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2006, 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: dipxdataset.cpp,v $ + * Revision 1.4 2006/02/09 05:38:56 fwarmerdam + * Added SRID support. + * + * Revision 1.3 2006/02/07 21:44:43 fwarmerdam + * DIPX->DIPEx + * + * Revision 1.2 2006/02/07 01:22:57 fwarmerdam + * Switch XOffset and YOffset per email from Drew. + * + * Revision 1.1 2006/02/01 17:22:34 fwarmerdam + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: dipxdataset.cpp,v 1.4 2006/02/09 05:38:56 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_DIPEx(void); +CPL_C_END + +typedef struct { + GInt32 NBIH; /* bytes in header, normaly 1024 */ + GInt32 NBPR; /* bytes per data record (all bands of scanline) */ + GInt32 IL; /* initial line - normally 1 */ + GInt32 LL; /* last line */ + GInt32 IE; /* initial element (pixel), normally 1 */ + GInt32 LE; /* last element (pixel) */ + GInt32 NC; /* number of channels (bands) */ + GInt32 H4322; /* header record identifier - always 4322. */ + char unused1[40]; + GByte IH19[4];/* data type, and size flags */ + GInt32 IH20; /* number of secondary headers */ + GInt32 SRID; + char unused2[12]; + double YOffset; + double XOffset; + double YPixSize; + double XPixSize; + double Matrix[4]; + char unused3[344]; + GUInt16 ColorTable[256]; /* RGB packed with 4 bits each */ + char unused4[32]; +} DIPExHeader; + +/************************************************************************/ +/* ==================================================================== */ +/* DIPExDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class DIPExRasterBand; + +class DIPExDataset : public GDALPamDataset +{ + friend class DIPExRasterBand; + + FILE *fp; + CPLString osSRS; + + DIPExHeader sHeader; + + GDALDataType eRasterDataType; + + double adfGeoTransform[6]; + + public: + DIPExDataset(); + ~DIPExDataset(); + + virtual CPLErr GetGeoTransform( double * ); + + virtual const char *GetProjectionRef( void ); + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* DIPExDataset */ +/* ==================================================================== */ +/************************************************************************/ + + +/************************************************************************/ +/* DIPExDataset() */ +/************************************************************************/ + +DIPExDataset::DIPExDataset() + +{ + fp = 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; +} + +/************************************************************************/ +/* ~DIPExDataset() */ +/************************************************************************/ + +DIPExDataset::~DIPExDataset() + +{ + VSIFCloseL( fp ); + fp = NULL; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *DIPExDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* First we check to see if the file has the expected header */ +/* bytes. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 256 ) + return NULL; + + if( CPL_LSBWORD32(*((GInt32 *) (poOpenInfo->pabyHeader+0))) != 1024 ) + return NULL; + + if( CPL_LSBWORD32(*((GInt32 *) (poOpenInfo->pabyHeader+28))) != 4322 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + DIPExDataset *poDS; + const char *pszAccess; + + if( poOpenInfo->eAccess == GA_Update ) + pszAccess = "r+b"; + else + pszAccess = "rb"; + + poDS = new DIPExDataset(); + + poDS->fp = VSIFOpenL( poOpenInfo->pszFilename, pszAccess ); + if( poDS->fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to open `%s' with acces `%s' failed.\n", + poOpenInfo->pszFilename, pszAccess ); + return NULL; + } + + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Read the header information. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( &(poDS->sHeader), 1024, 1, poDS->fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Attempt to read 1024 byte header filed on file:\n", + "%s\n", poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Extract information of interest from the header. */ +/* -------------------------------------------------------------------- */ + int nStart, nEnd, nDIPExDataType, nBytesPerSample; + int nLineOffset; + + nLineOffset = CPL_LSBWORD32( poDS->sHeader.NBPR ); + + nStart = CPL_LSBWORD32( poDS->sHeader.IL ); + nEnd = CPL_LSBWORD32( poDS->sHeader.LL ); + poDS->nRasterYSize = nEnd - nStart + 1; + + nStart = CPL_LSBWORD32( poDS->sHeader.IE ); + nEnd = CPL_LSBWORD32( poDS->sHeader.LE ); + poDS->nRasterXSize = nEnd - nStart + 1; + + poDS->nBands = CPL_LSBWORD32( poDS->sHeader.NC ); + + nDIPExDataType = (poDS->sHeader.IH19[1] & 0x7e) >> 2; + nBytesPerSample = poDS->sHeader.IH19[0]; + + if( nDIPExDataType == 0 && nBytesPerSample == 1 ) + poDS->eRasterDataType = GDT_Byte; + else if( nDIPExDataType == 1 && nBytesPerSample == 1 ) + poDS->eRasterDataType = GDT_Byte; + else if( nDIPExDataType == 16 && nBytesPerSample == 4 ) + poDS->eRasterDataType = GDT_Float32; + else if( nDIPExDataType == 17 && nBytesPerSample == 8 ) + poDS->eRasterDataType = GDT_Float64; + else + { + delete poDS; + CPLError( CE_Failure, CPLE_AppDefined, + "Unrecognised image data type %d, with BytesPerSample=%d.\n", + nDIPExDataType, nBytesPerSample ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + int iBand; + + for( iBand = 0; iBand < poDS->nBands; iBand++ ) + { + poDS->SetBand( iBand+1, + new RawRasterBand( poDS, iBand+1, poDS->fp, + 1024 + iBand * nLineOffset, + nBytesPerSample, + nLineOffset * poDS->nBands, + poDS->eRasterDataType, + CPL_IS_LSB, TRUE ) ); + } + +/* -------------------------------------------------------------------- */ +/* Extract the projection coordinates, if present. */ +/* -------------------------------------------------------------------- */ + CPL_LSBPTR64(&(poDS->sHeader.XPixSize)); + CPL_LSBPTR64(&(poDS->sHeader.YPixSize)); + CPL_LSBPTR64(&(poDS->sHeader.XOffset)); + CPL_LSBPTR64(&(poDS->sHeader.YOffset)); + + if( poDS->sHeader.XOffset != 0 ) + { + poDS->adfGeoTransform[0] = poDS->sHeader.XOffset; + poDS->adfGeoTransform[1] = poDS->sHeader.XPixSize; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = poDS->sHeader.YOffset; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = -1.0 * ABS(poDS->sHeader.YPixSize); + + poDS->adfGeoTransform[0] -= poDS->adfGeoTransform[1] * 0.5; + poDS->adfGeoTransform[3] -= poDS->adfGeoTransform[5] * 0.5; + } + else + { + poDS->adfGeoTransform[0] = 0.0; + poDS->adfGeoTransform[1] = 1.0; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = 1.0; + } + +/* -------------------------------------------------------------------- */ +/* Look for SRID. */ +/* -------------------------------------------------------------------- */ + CPL_LSBPTR32( &(poDS->sHeader.SRID) ); + + if( poDS->sHeader.SRID > 0 && poDS->sHeader.SRID < 33000 ) + { + OGRSpatialReference oSR; + + if( oSR.importFromEPSG( poDS->sHeader.SRID ) == OGRERR_NONE ) + { + char *pszWKT = NULL; + oSR.exportToWkt( &pszWKT ); + poDS->osSRS = pszWKT; + CPLFree( pszWKT ); + } + } + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *DIPExDataset::GetProjectionRef() + +{ + return osSRS.c_str(); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr DIPExDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + + return( CE_None ); +} + +/************************************************************************/ +/* GDALRegister_DIPEx() */ +/************************************************************************/ + +void GDALRegister_DIPEx() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "DIPEx" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "DIPEx" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "DIPEx" ); + + poDriver->pfnOpen = DIPExDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/raw/doq1dataset.cpp b/Utilities/GDAL/frmts/raw/doq1dataset.cpp new file mode 100644 index 0000000000..84b7a48d01 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/doq1dataset.cpp @@ -0,0 +1,437 @@ +/****************************************************************************** + * $Id: doq1dataset.cpp,v 1.15 2005/07/25 18:07:48 fwarmerdam Exp $ + * + * Project: USGS DOQ Driver (First Generation Format) + * Purpose: Implementation of DOQ1Dataset + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: doq1dataset.cpp,v $ + * Revision 1.15 2005/07/25 18:07:48 fwarmerdam + * Fixed up description handling. + * + * Revision 1.14 2005/05/05 13:55:41 fwarmerdam + * PAM Enable + * + * Revision 1.13 2002/09/17 13:09:28 warmerda + * fix zone in WKT description - bugzilla 199 + * + * Revision 1.12 2002/09/16 16:17:53 warmerda + * XY_ORIGIN is the top left corner of pixel! + * + * Revision 1.11 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.10 2002/06/25 14:57:43 warmerda + * Added overview support. + * + * Revision 1.9 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.8 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.7 2000/09/25 21:20:13 warmerda + * avoid initialization warnings + * + * Revision 1.6 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.5 2000/02/28 16:32:20 warmerda + * use SetBand method + * + * Revision 1.4 2000/01/24 03:08:16 shadow + * add description reading + * + * Revision 1.3 2000/01/06 20:58:21 warmerda + * Fixed initial poOpenInfo check. + * + * Revision 1.2 1999/12/30 02:39:43 warmerda + * Added projections support. + * + * Revision 1.1 1999/12/29 20:43:05 warmerda + * New + */ + +#include "rawdataset.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: doq1dataset.cpp,v 1.15 2005/07/25 18:07:48 fwarmerdam Exp $"); + +static double DOQGetField( unsigned char *, int ); +static void DOQGetDescription( GDALDataset *, unsigned char * ); + +CPL_C_START +void GDALRegister_DOQ1(void); +CPL_C_END + +#define UTM_FORMAT \ +"PROJCS[\"%s / UTM zone %dN\",GEOGCS[%s,PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",%d],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],%s]" + +#define WGS84_DATUM \ +"\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563]]" + +#define WGS72_DATUM \ +"\"WGS 72\",DATUM[\"WGS_1972\",SPHEROID[\"NWL 10D\",6378135,298.26]]" + +#define NAD27_DATUM \ +"\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901]]" + +#define NAD83_DATUM \ +"\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101]]" + +/************************************************************************/ +/* ==================================================================== */ +/* DOQ1Dataset */ +/* ==================================================================== */ +/************************************************************************/ + +class DOQ1Dataset : public RawDataset +{ + FILE *fpImage; // image data file. + + double dfULX, dfULY; + double dfXPixelSize, dfYPixelSize; + + char *pszProjection; + + public: + DOQ1Dataset(); + ~DOQ1Dataset(); + + CPLErr GetGeoTransform( double * padfTransform ); + const char *GetProjectionRef( void ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* DOQ1Dataset() */ +/************************************************************************/ + +DOQ1Dataset::DOQ1Dataset() +{ + pszProjection = NULL; + fpImage = NULL; +} + +/************************************************************************/ +/* ~DOQ1Dataset() */ +/************************************************************************/ + +DOQ1Dataset::~DOQ1Dataset() + +{ + FlushCache(); + + CPLFree( pszProjection ); + if( fpImage != NULL ) + VSIFClose( fpImage ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr DOQ1Dataset::GetGeoTransform( double * padfTransform ) + +{ + padfTransform[0] = dfULX; + padfTransform[1] = dfXPixelSize; + padfTransform[2] = 0.0; + padfTransform[3] = dfULY; + padfTransform[4] = 0.0; + padfTransform[5] = -1 * dfYPixelSize; + + return( CE_None ); +} + +/************************************************************************/ +/* GetProjectionString() */ +/************************************************************************/ + +const char *DOQ1Dataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *DOQ1Dataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int nWidth, nHeight, nBandStorage, nBandTypes; + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the binary (ie. .bil) file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 212 || poOpenInfo->fp == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Attempt to extract a few key values from the header. */ +/* -------------------------------------------------------------------- */ + nWidth = (int) DOQGetField(poOpenInfo->pabyHeader + 150, 6); + nHeight = (int) DOQGetField(poOpenInfo->pabyHeader + 144, 6); + nBandStorage = (int) DOQGetField(poOpenInfo->pabyHeader + 162, 3); + nBandTypes = (int) DOQGetField(poOpenInfo->pabyHeader + 156, 3); + +/* -------------------------------------------------------------------- */ +/* Do these values look coherent for a DOQ file? It would be */ +/* nice to do a more comprehensive test than this! */ +/* -------------------------------------------------------------------- */ + if( nWidth < 500 || nWidth > 25000 + || nHeight < 500 || nHeight > 25000 + || nBandStorage < 0 || nBandStorage > 4 + || nBandTypes < 1 || nBandTypes > 9 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Check the configuration. We don't currently handle all */ +/* variations, only the common ones. */ +/* -------------------------------------------------------------------- */ + if( nBandTypes > 5 ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "DOQ Data Type (%d) is not a supported configuration.\n", + nBandTypes ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + DOQ1Dataset *poDS; + + poDS = new DOQ1Dataset(); + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nWidth; + poDS->nRasterYSize = nHeight; + +/* -------------------------------------------------------------------- */ +/* Assume ownership of the file handled from the GDALOpenInfo. */ +/* -------------------------------------------------------------------- */ + poDS->fpImage = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +/* -------------------------------------------------------------------- */ +/* Compute layout of data. */ +/* -------------------------------------------------------------------- */ + int nSkipBytes, nBytesPerPixel=0, nBytesPerLine, i; + + if( nBandTypes < 5 ) + nBytesPerPixel = 1; + else if( nBandTypes == 5 ) + nBytesPerPixel = 3; + + nBytesPerLine = nBytesPerPixel * nWidth; + nSkipBytes = 4 * nBytesPerLine; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = nBytesPerPixel; + for( i = 0; i < poDS->nBands; i++ ) + { + poDS->SetBand( i+1, + new RawRasterBand( poDS, i+1, poDS->fpImage, + nSkipBytes + i, nBytesPerPixel, nBytesPerLine, + GDT_Byte, TRUE ) ); + } + +/* -------------------------------------------------------------------- */ +/* Set the description. */ +/* -------------------------------------------------------------------- */ + DOQGetDescription(poDS, poOpenInfo->pabyHeader); + +/* -------------------------------------------------------------------- */ +/* Establish the projection string. */ +/* -------------------------------------------------------------------- */ + if( ((int) DOQGetField(poOpenInfo->pabyHeader + 195, 3)) != 1 ) + poDS->pszProjection = VSIStrdup(""); + else + { + const char *pszDatumLong, *pszDatumShort; + const char *pszUnits; + int nZone; + + nZone = (int) DOQGetField(poOpenInfo->pabyHeader + 198, 6); + + if( ((int) DOQGetField(poOpenInfo->pabyHeader + 204, 3)) == 1 ) + pszUnits = "UNIT[\"US survey foot\",0.304800609601219]"; + else + pszUnits = "UNIT[\"metre\",1]"; + + switch( (int) DOQGetField(poOpenInfo->pabyHeader + 167, 2) ) + { + case 1: + pszDatumLong = NAD27_DATUM; + pszDatumShort = "NAD 27"; + break; + + case 2: + pszDatumLong = WGS72_DATUM; + pszDatumShort = "WGS 72"; + break; + + case 3: + pszDatumLong = WGS84_DATUM; + pszDatumShort = "WGS 84"; + break; + + case 4: + pszDatumLong = NAD83_DATUM; + pszDatumShort = "NAD 83"; + break; + + default: + pszDatumLong = "DATUM[\"unknown\"]"; + pszDatumShort = "unknown"; + break; + } + + poDS->pszProjection = + CPLStrdup(CPLSPrintf( UTM_FORMAT, pszDatumShort, nZone, + pszDatumLong, nZone * 6 - 183, pszUnits )); + } + +/* -------------------------------------------------------------------- */ +/* Read the georeferencing information. */ +/* -------------------------------------------------------------------- */ + unsigned char abyRecordData[500]; + + if( VSIFSeek( poDS->fpImage, nBytesPerLine * 2, SEEK_SET ) != 0 + || VSIFRead(abyRecordData,sizeof(abyRecordData),1,poDS->fpImage) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Header read error on %s.\n", + poOpenInfo->pszFilename ); + return NULL; + } + + poDS->dfULX = DOQGetField( abyRecordData + 288, 24 ); + poDS->dfULY = DOQGetField( abyRecordData + 312, 24 ); + + if( VSIFSeek( poDS->fpImage, nBytesPerLine * 3, SEEK_SET ) != 0 + || VSIFRead(abyRecordData,sizeof(abyRecordData),1,poDS->fpImage) != 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Header read error on %s.\n", + poOpenInfo->pszFilename ); + return NULL; + } + + poDS->dfXPixelSize = DOQGetField( abyRecordData + 59, 12 ); + poDS->dfYPixelSize = DOQGetField( abyRecordData + 71, 12 ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_DOQ1() */ +/************************************************************************/ + +void GDALRegister_DOQ1() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "DOQ1" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "DOQ1" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "USGS DOQ (Old Style)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#DOQ1" ); + + poDriver->pfnOpen = DOQ1Dataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + +/************************************************************************/ +/* DOQGetField() */ +/************************************************************************/ + +static double DOQGetField( unsigned char *pabyData, int nBytes ) + +{ + char szWork[128]; + int i; + + strncpy( szWork, (const char *) pabyData, nBytes ); + szWork[nBytes] = '\0'; + + for( i = 0; i < nBytes; i++ ) + { + if( szWork[i] == 'D' || szWork[i] == 'd' ) + szWork[i] = 'E'; + } + + return atof(szWork); +} + +/************************************************************************/ +/* DOQGetDescription() */ +/************************************************************************/ + +static void DOQGetDescription( GDALDataset *poDS, unsigned char *pabyData ) + +{ + char szWork[128]; + int i = 0; + + memset( szWork, ' ', 128 ); + strncpy( szWork, "USGS GeoTIFF DOQ 1:12000 Q-Quad of ", 35 ); + strncpy( szWork + 35, (const char *) pabyData + 0, 38 ); + while ( *(szWork + 72 - i) == ' ' ) { + i++; + } + i--; + strncpy( szWork + 73 - i, (const char *) pabyData + 38, 2 ); + strncpy( szWork + 76 - i, (const char *) pabyData + 44, 2 ); + szWork[77-i] = '\0'; + + poDS->SetMetadataItem( "DOQ_DESC", szWork ); +} diff --git a/Utilities/GDAL/frmts/raw/doq2dataset.cpp b/Utilities/GDAL/frmts/raw/doq2dataset.cpp new file mode 100644 index 0000000000..e8246a3d07 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/doq2dataset.cpp @@ -0,0 +1,492 @@ +/****************************************************************************** + * $Id: doq2dataset.cpp,v 1.19 2005/05/05 13:55:41 fwarmerdam Exp $ + * + * Project: USGS DOQ Driver (Second Generation Format) + * Purpose: Implementation of DOQ2Dataset + * Author: Derrick J Brashear, shadow@dementia.org + * + ****************************************************************************** + * Copyright (c) 2000, Derrick J Brashear + * + * 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: doq2dataset.cpp,v $ + * Revision 1.19 2005/05/05 13:55:41 fwarmerdam + * PAM Enable + * + * Revision 1.18 2003/08/12 14:57:41 warmerda + * dont use CPLReadLine to preread the first line + * + * Revision 1.17 2002/10/07 19:31:47 warmerda + * Flush CPLReadLine() internal buffer. + * + * Revision 1.16 2002/09/17 13:09:28 warmerda + * fix zone in WKT description - bugzilla 199 + * + * Revision 1.15 2002/09/16 16:17:53 warmerda + * XY_ORIGIN is the top left corner of pixel! + * + * Revision 1.14 2002/09/16 14:16:28 warmerda + * XY_ORIGIN is center of pixel, not top left corner. + * + * Revision 1.13 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.12 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.11 2001/09/21 16:40:08 warmerda + * fixed case with one band + * + * Revision 1.10 2001/09/19 20:56:19 warmerda + * handle multiple BAND_CONTENT fields, improve metadata handling + * + * Revision 1.9 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.8 2000/09/25 21:20:13 warmerda + * avoid initialization warnings + * + * Revision 1.7 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.6 2000/02/28 16:32:20 warmerda + * use SetBand method + * + * Revision 1.5 2000/01/24 05:54:00 shadow + * fix minor logic bug + * + * Revision 1.4 2000/01/24 03:08:16 shadow + * add description reading + * + * Revision 1.3 2000/01/17 08:16:41 shadow + * stupid errors + * + * Revision 1.2 2000/01/17 08:07:41 shadow + * check just for the string, not the whole line + * + * Revision 1.1 2000/01/17 08:01:16 shadow + * first cut - untested + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: doq2dataset.cpp,v 1.19 2005/05/05 13:55:41 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_DOQ2(void); +CPL_C_END + +#define UTM_FORMAT \ +"PROJCS[\"%s / UTM zone %dN\",GEOGCS[%s,PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",%d],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],%s]" + +#define WGS84_DATUM \ +"\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563]]" + +#define WGS72_DATUM \ +"\"WGS 72\",DATUM[\"WGS_1972\",SPHEROID[\"NWL 10D\",6378135,298.26]]" + +#define NAD27_DATUM \ +"\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901]]" + +#define NAD83_DATUM \ +"\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101]]" + +/************************************************************************/ +/* ==================================================================== */ +/* DOQ2Dataset */ +/* ==================================================================== */ +/************************************************************************/ + +class DOQ2Dataset : public RawDataset +{ + FILE *fpImage; // image data file. + + double dfULX, dfULY; + double dfXPixelSize, dfYPixelSize; + + char *pszProjection; + + public: + DOQ2Dataset(); + ~DOQ2Dataset(); + + CPLErr GetGeoTransform( double * padfTransform ); + const char *GetProjectionRef( void ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* DOQ2Dataset() */ +/************************************************************************/ + +DOQ2Dataset::DOQ2Dataset() +{ + pszProjection = NULL; + fpImage = NULL; +} + +/************************************************************************/ +/* ~DOQ2Dataset() */ +/************************************************************************/ + +DOQ2Dataset::~DOQ2Dataset() + +{ + FlushCache(); + + CPLFree( pszProjection ); + if( fpImage != NULL ) + VSIFClose( fpImage ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr DOQ2Dataset::GetGeoTransform( double * padfTransform ) + +{ + padfTransform[0] = dfULX; + padfTransform[1] = dfXPixelSize; + padfTransform[2] = 0.0; + padfTransform[3] = dfULY; + padfTransform[4] = 0.0; + padfTransform[5] = -1 * dfYPixelSize; + + return( CE_None ); +} + +/************************************************************************/ +/* GetProjectionString() */ +/************************************************************************/ + +const char *DOQ2Dataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *DOQ2Dataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int nWidth=0, nHeight=0, nBandStorage=0, nBandTypes=0; + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the binary (ie. .bil) file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 212 || poOpenInfo->fp == NULL ) + return NULL; + + int nLineCount = 0; + const char *pszLine; + int nBytesPerPixel=0; + const char *pszDatumLong=NULL, *pszDatumShort=NULL; + const char *pszUnits=NULL; + char *pszQuadname = NULL; + char *pszQuadquad = NULL; + char *pszState = NULL; + int nZone=0, nProjType=0; + int nSkipBytes=0, nBytesPerLine, i, nBandCount = 0; + double dfULXMap=0.0, dfULYMap = 0.0; + double dfXDim=0.0, dfYDim=0.0; + char **papszMetadata = NULL; + + if(! EQUALN((const char *) poOpenInfo->pabyHeader, + "BEGIN_USGS_DOQ_HEADER", 21) ) + return NULL; + + /* read and discard the first line */ + pszLine = CPLReadLine( poOpenInfo->fp ); + + while( (pszLine = CPLReadLine( poOpenInfo->fp )) ) + { + char **papszTokens; + + nLineCount++; + + if( EQUAL(pszLine,"END_USGS_DOQ_HEADER") ) + break; + + papszTokens = CSLTokenizeString( pszLine ); + if( CSLCount( papszTokens ) < 2 ) + { + CSLDestroy( papszTokens ); + break; + } + + if( EQUAL(papszTokens[0],"SAMPLES_AND_LINES") ) + { + nWidth = atoi(papszTokens[1]); + nHeight = atoi(papszTokens[2]); + } + else if( EQUAL(papszTokens[0],"BYTE_COUNT") ) + { + nSkipBytes = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"XY_ORIGIN") ) + { + dfULXMap = atof(papszTokens[1]); + dfULYMap = atof(papszTokens[2]); + } + else if( EQUAL(papszTokens[0],"HORIZONTAL_RESOLUTION") ) + { + dfXDim = dfYDim = atof(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"BAND_ORGANIZATION") ) + { + if( EQUAL(papszTokens[1],"SINGLE FILE") ) + nBandStorage = 1; + if( EQUAL(papszTokens[1],"BSQ") ) + nBandStorage = 1; + if( EQUAL(papszTokens[1],"BIL") ) + nBandStorage = 1; + if( EQUAL(papszTokens[1],"BIP") ) + nBandStorage = 4; + } + else if( EQUAL(papszTokens[0],"BAND_CONTENT") ) + { + if( EQUAL(papszTokens[1],"BLACK&WHITE") ) + nBandTypes = 1; + else if( EQUAL(papszTokens[1],"COLOR") ) + nBandTypes = 5; + else if( EQUAL(papszTokens[1],"RGB") ) + nBandTypes = 5; + else if( EQUAL(papszTokens[1],"RED") ) + nBandTypes = 5; + else if( EQUAL(papszTokens[1],"GREEN") ) + nBandTypes = 5; + else if( EQUAL(papszTokens[1],"BLUE") ) + nBandTypes = 5; + + nBandCount++; + } + else if( EQUAL(papszTokens[0],"BITS_PER_PIXEL") ) + { + nBytesPerPixel = (atoi(papszTokens[1]) / 8); + } + else if( EQUAL(papszTokens[0],"HORIZONTAL_COORDINATE_SYSTEM") ) + { + if( EQUAL(papszTokens[1],"UTM") ) + nProjType = 1; + else if( EQUAL(papszTokens[1],"SPCS") ) + nProjType = 2; + else if( EQUAL(papszTokens[1],"GEOGRAPHIC") ) + nProjType = 0; + } + else if( EQUAL(papszTokens[0],"COORDINATE_ZONE") ) + { + nZone = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"HORIZONTAL_UNITS") ) + { + if( EQUAL(papszTokens[1],"METERS") ) + pszUnits = "UNIT[\"metre\",1]"; + else if( EQUAL(papszTokens[1],"FEET") ) + pszUnits = "UNIT[\"US survey foot\",0.304800609601219]"; + } + else if( EQUAL(papszTokens[0],"HORIZONTAL_DATUM") ) + { + if( EQUAL(papszTokens[1],"NAD27") ) + { + pszDatumLong = NAD27_DATUM; + pszDatumShort = "NAD 27"; + } + else if( EQUAL(papszTokens[1],"WGS72") ) + { + pszDatumLong = WGS72_DATUM; + pszDatumShort = "WGS 72"; + } + else if( EQUAL(papszTokens[1],"WGS84") ) + { + pszDatumLong = WGS84_DATUM; + pszDatumShort = "WGS 84"; + } + else if( EQUAL(papszTokens[1],"NAD83") ) + { + pszDatumLong = NAD83_DATUM; + pszDatumShort = "NAD 83"; + } + else + { + pszDatumLong = "DATUM[\"unknown\"]"; + pszDatumShort = "unknown"; + } + } + else + { + /* we want to generically capture all the other metadata */ + + char szMetaDataValue[81]; + int iToken; + + szMetaDataValue[0] = '\0'; + for( iToken = 1; papszTokens[iToken] != NULL; iToken++ ) + { + if( EQUAL(papszTokens[iToken],"*") ) + continue; + + if( iToken > 1 ) + strcat( szMetaDataValue, " " ); + strcat( szMetaDataValue, papszTokens[iToken] ); + } + papszMetadata = CSLAddNameValue( papszMetadata, + papszTokens[0], + szMetaDataValue ); + } + + CSLDestroy( papszTokens ); + } + + CPLReadLine( NULL ); + +/* -------------------------------------------------------------------- */ +/* Do these values look coherent for a DOQ file? It would be */ +/* nice to do a more comprehensive test than this! */ +/* -------------------------------------------------------------------- */ + if( nWidth < 500 || nWidth > 25000 + || nHeight < 500 || nHeight > 25000 + || nBandStorage < 0 || nBandStorage > 4 + || nBandTypes < 1 || nBandTypes > 9 ) + { + CSLDestroy( papszMetadata ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Check the configuration. We don't currently handle all */ +/* variations, only the common ones. */ +/* -------------------------------------------------------------------- */ + if( nBandTypes > 5 ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "DOQ Data Type (%d) is not a supported configuration.\n", + nBandTypes ); + CSLDestroy( papszMetadata ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + DOQ2Dataset *poDS; + + poDS = new DOQ2Dataset(); + + poDS->nRasterXSize = nWidth; + poDS->nRasterYSize = nHeight; + + poDS->SetMetadata( papszMetadata ); + CSLDestroy( papszMetadata ); + +/* -------------------------------------------------------------------- */ +/* Assume ownership of the file handled from the GDALOpenInfo. */ +/* -------------------------------------------------------------------- */ + poDS->fpImage = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +/* -------------------------------------------------------------------- */ +/* Compute layout of data. */ +/* -------------------------------------------------------------------- */ + if( nBandCount < 2 ) + nBandCount = nBytesPerPixel; + else + nBytesPerPixel *= nBandCount; + + nBytesPerLine = nBytesPerPixel * nWidth; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nBandCount; i++ ) + { + poDS->SetBand( i+1, + new RawRasterBand( poDS, i+1, poDS->fpImage, + nSkipBytes + i, nBytesPerPixel, nBytesPerLine, + GDT_Byte, TRUE ) ); + } + + if (nProjType == 1) + { + poDS->pszProjection = + CPLStrdup(CPLSPrintf( UTM_FORMAT, pszDatumShort, nZone, + pszDatumLong, nZone * 6 - 183, pszUnits )); + } + else + { + poDS->pszProjection = CPLStrdup(""); + } + + poDS->dfULX = dfULXMap; + poDS->dfULY = dfULYMap; + + poDS->dfXPixelSize = dfXDim; + poDS->dfYPixelSize = dfYDim; + + if ( pszQuadname ) CPLFree( pszQuadname ); + if ( pszQuadquad) CPLFree( pszQuadquad ); + if ( pszState) CPLFree( pszState ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_DOQ1() */ +/************************************************************************/ + +void GDALRegister_DOQ2() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "DOQ2" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "DOQ2" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "USGS DOQ (New Style)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#DOQ2" ); + + poDriver->pfnOpen = DOQ2Dataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/ehdrdataset.cpp b/Utilities/GDAL/frmts/raw/ehdrdataset.cpp new file mode 100644 index 0000000000..940d309347 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/ehdrdataset.cpp @@ -0,0 +1,995 @@ +/****************************************************************************** + * $Id: ehdrdataset.cpp,v 1.37 2006/03/03 02:35:23 fwarmerdam Exp $ + * + * Project: ESRI .hdr Driver + * Purpose: Implementation of EHdrDataset + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: ehdrdataset.cpp,v $ + * Revision 1.37 2006/03/03 02:35:23 fwarmerdam + * Be careful in constructor about zero band images. + * + * Revision 1.36 2006/02/08 17:10:52 fwarmerdam + * Improved NODATA precision. + * + * Revision 1.35 2006/01/27 18:42:08 fwarmerdam + * added the ability to save nodata and colortable information + * + * Revision 1.34 2006/01/20 13:33:24 fwarmerdam + * Fallback to an assumption of nbits=8 if not specified. + * + * Revision 1.33 2006/01/17 13:16:20 fwarmerdam + * as per Cees suggestions, correct handling of XLL/YLLCORNER + * which is not at the center of the pixel. + * + * Revision 1.32 2006/01/17 12:28:27 fwarmerdam + * Applied changes from Cees to default to signed, not unsigned and + * for 32bit data to default to float, not integer. + * + * Revision 1.31 2006/01/13 00:18:12 fwarmerdam + * Fixed error on failed open. + * + * Revision 1.30 2005/12/21 00:41:48 fwarmerdam + * added support for reading/writing PIXELTYPE. + * Added support for reading/writing writing geotransform and projection. + * + * Revision 1.29 2005/11/10 17:36:15 dron + * _Always_ use 64-bit pointers when parsing header file. + * + * Revision 1.28 2005/11/10 17:24:48 dron + * Use 64-bit pointers when parsing file header. + * + * Revision 1.27 2005/10/04 05:25:13 fwarmerdam + * Added support for XLLCENTER/YLLCENTER. + * + * Revision 1.26 2005/05/05 13:55:41 fwarmerdam + * PAM Enable + * + * Revision 1.25 2005/02/25 19:40:27 fwarmerdam + * Support lower case byteorder values too. + * + * Revision 1.24 2004/07/10 12:19:01 dron + * Read color table, when available (.clr file). + * + * Revision 1.23 2004/05/11 18:07:01 warmerda + * Treat NBITS=32 and 64 as floating point cases. + * + * Revision 1.22 2004/02/12 10:15:33 dron + * Fixed problem when computing band offset for band sequental files. + * + * Revision 1.21 2004/01/23 22:16:09 warmerda + * fixed issue with static buffer overwriting in forming prj name + * + * Revision 1.20 2004/01/23 04:56:01 warmerda + * support worldfiles if no corners in .hdr + * + * Revision 1.19 2004/01/20 16:22:56 dron + * More clean usage of CPLFormCIFilename(). + * + * Revision 1.18 2004/01/04 21:17:11 warmerda + * fixed up to preserve path in CPLFormCIFilename calls + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: ehdrdataset.cpp,v 1.37 2006/03/03 02:35:23 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_EHdr(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* EHdrDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class EHdrDataset : public RawDataset +{ + FILE *fpImage; // image data file. + + int bGotTransform; + double adfGeoTransform[6]; + char *pszProjection; + + int bHDRDirty; + char **papszHDR; + + CPLErr RewriteHDR(); + void ResetKeyValue( const char *pszKey, const char *pszValue ); + void RewriteColorTable( GDALColorTable * ); + + public: + EHdrDataset(); + ~EHdrDataset(); + + virtual CPLErr GetGeoTransform( double * padfTransform ); + virtual CPLErr SetGeoTransform( double *padfTransform ); + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); +}; + +/************************************************************************/ +/* EHdrDataset() */ +/************************************************************************/ + +EHdrDataset::EHdrDataset() +{ + fpImage = NULL; + pszProjection = CPLStrdup(""); + bGotTransform = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + papszHDR = NULL; + bHDRDirty = FALSE; +} + +/************************************************************************/ +/* ~EHdrDataset() */ +/************************************************************************/ + +EHdrDataset::~EHdrDataset() + +{ + FlushCache(); + + if( nBands > 0 && GetAccess() == GA_Update ) + { + int bNoDataSet; + double dfNoData; + RawRasterBand *poBand = (RawRasterBand *) GetRasterBand( 1 ); + + dfNoData = poBand->GetNoDataValue(&bNoDataSet); + if( bNoDataSet ) + { + ResetKeyValue( "NODATA", + CPLString().Printf( "%.8g", dfNoData ) ); + } + + if( poBand->GetColorTable() != NULL ) + RewriteColorTable( poBand->GetColorTable() ); + + if( bHDRDirty ) + RewriteHDR(); + } + + if( fpImage != NULL ) + VSIFCloseL( fpImage ); + + CPLFree( pszProjection ); + CSLDestroy( papszHDR ); +} + +/************************************************************************/ +/* ResetKeyValue() */ +/* */ +/* Replace or add the keyword with the indicated value in the */ +/* papszHDR list. */ +/************************************************************************/ + +void EHdrDataset::ResetKeyValue( const char *pszKey, const char *pszValue ) + +{ + int i; + char szNewLine[82]; + + if( strlen(pszValue) > 65 ) + { + CPLAssert( strlen(pszValue) <= 65 ); + return; + } + + sprintf( szNewLine, "%-15s%s", pszKey, pszValue ); + + for( i = CSLCount(papszHDR)-1; i >= 0; i-- ) + { + if( EQUALN(papszHDR[i],szNewLine,strlen(pszKey)+1 ) ) + { + if( strcmp(papszHDR[i],szNewLine) != 0 ) + { + CPLFree( papszHDR[i] ); + papszHDR[i] = CPLStrdup( szNewLine ); + bHDRDirty = TRUE; + } + return; + } + } + + bHDRDirty = TRUE; + papszHDR = CSLAddString( papszHDR, szNewLine ); +} + +/************************************************************************/ +/* RewriteColorTable() */ +/************************************************************************/ + +void EHdrDataset::RewriteColorTable( GDALColorTable *poTable ) + +{ + CPLString osCLRFilename = CPLResetExtension( GetDescription(), "clr" ); + FILE *fp; + + fp = VSIFOpenL( osCLRFilename, "wt" ); + if( fp != NULL ) + { + int iColor; + + for( iColor = 0; iColor < poTable->GetColorEntryCount(); iColor++ ) + { + CPLString oLine; + GDALColorEntry sEntry; + + poTable->GetColorEntryAsRGB( iColor, &sEntry ); + + // I wish we had a way to mark transparency. + oLine.Printf( "%3d %3d %3d %3d\n", + iColor, sEntry.c1, sEntry.c2, sEntry.c3 ); + VSIFWriteL( (void *) oLine.c_str(), 1, strlen(oLine), fp ); + } + VSIFCloseL( fp ); + } + else + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to create color file %s.", + osCLRFilename.c_str() ); + } +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *EHdrDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr EHdrDataset::SetProjection( const char *pszSRS ) + +{ +/* -------------------------------------------------------------------- */ +/* Reset coordinate system on the dataset. */ +/* -------------------------------------------------------------------- */ + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszSRS ); + + if( strlen(pszSRS) == 0 ) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* Convert to ESRI WKT. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS( pszSRS ); + char *pszESRI_SRS = NULL; + + oSRS.morphToESRI(); + oSRS.exportToWkt( &pszESRI_SRS ); + +/* -------------------------------------------------------------------- */ +/* Write to .prj file. */ +/* -------------------------------------------------------------------- */ + CPLString osPrjFilename = CPLResetExtension( GetDescription(), "prj" ); + FILE *fp; + + fp = VSIFOpen( osPrjFilename.c_str(), "wt" ); + if( fp != NULL ) + { + VSIFWrite( pszESRI_SRS, 1, strlen(pszESRI_SRS), fp ); + VSIFWrite( (void *) "\n", 1, 1, fp ); + VSIFClose( fp ); + } + + CPLFree( pszESRI_SRS ); + + return CE_None; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr EHdrDataset::GetGeoTransform( double * padfTransform ) + +{ + if( bGotTransform ) + { + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; + } + else + { + return GDALPamDataset::GetGeoTransform( padfTransform ); + } +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr EHdrDataset::SetGeoTransform( double *padfGeoTransform ) + +{ +/* -------------------------------------------------------------------- */ +/* We only support non-rotated images with info in the .HDR file. */ +/* -------------------------------------------------------------------- */ + if( padfGeoTransform[2] != 0.0 + || padfGeoTransform[4] != 0.0 ) + { + return GDALPamDataset::SetGeoTransform( padfGeoTransform ); + } + +/* -------------------------------------------------------------------- */ +/* Record new geotransform. */ +/* -------------------------------------------------------------------- */ + bGotTransform = TRUE; + memcpy( adfGeoTransform, padfGeoTransform, sizeof(double) * 6 ); + +/* -------------------------------------------------------------------- */ +/* Strip out all old geotransform keywords from HDR records. */ +/* -------------------------------------------------------------------- */ + int i; + for( i = CSLCount(papszHDR)-1; i >= 0; i-- ) + { + if( EQUALN(papszHDR[i],"ul",2) + || EQUALN(papszHDR[i]+1,"ll",2) + || EQUALN(papszHDR[i],"cell",4) + || EQUALN(papszHDR[i]+1,"dim",3) ) + { + papszHDR = CSLRemoveStrings( papszHDR, i, 1, NULL ); + } + } + +/* -------------------------------------------------------------------- */ +/* Set the transformation information. */ +/* -------------------------------------------------------------------- */ + CPLString oValue; + + oValue.Printf( "%.15g", adfGeoTransform[0] + adfGeoTransform[1] * 0.5 ); + ResetKeyValue( "ULXMAP", oValue ); + + oValue.Printf( "%.15g", adfGeoTransform[3] + adfGeoTransform[5] * 0.5 ); + ResetKeyValue( "ULYMAP", oValue ); + + oValue.Printf( "%.15g", adfGeoTransform[1] ); + ResetKeyValue( "XDIM", oValue ); + + oValue.Printf( "%.15g", fabs(adfGeoTransform[5]) ); + ResetKeyValue( "YDIM", oValue ); + + return CE_None; +} + +/************************************************************************/ +/* RewriteHDR() */ +/************************************************************************/ + +CPLErr EHdrDataset::RewriteHDR() + +{ + CPLString osPath = CPLGetPath( GetDescription() ); + CPLString osName = CPLGetBasename( GetDescription() ); + CPLString osHDRFilename = CPLFormCIFilename( osPath, osName, "hdr" ); + +/* -------------------------------------------------------------------- */ +/* Write .hdr file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + int i; + + fp = VSIFOpen( osHDRFilename, "wt" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to rewrite .hdr file %s.", + osHDRFilename.c_str() ); + return CE_Failure; + } + + for( i = 0; papszHDR[i] != NULL; i++ ) + { + VSIFWrite( papszHDR[i], 1, strlen(papszHDR[i]), fp ); + VSIFWrite( (void *) "\n", 1, 1, fp ); + } + + VSIFClose( fp ); + + bHDRDirty = FALSE; + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *EHdrDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i, bSelectedHDR; + const char *pszHDRFilename; + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the binary (ie. .bil) file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Now we need to tear apart the filename to form a .HDR */ +/* filename. */ +/* -------------------------------------------------------------------- */ + char *pszPath = CPLStrdup( CPLGetPath( poOpenInfo->pszFilename ) ); + char *pszName = CPLStrdup( CPLGetBasename( poOpenInfo->pszFilename ) ); + pszHDRFilename = CPLFormCIFilename( pszPath, pszName, "hdr" ); + + bSelectedHDR = EQUAL( pszHDRFilename, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Do we have a .hdr file? */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszHDRFilename, "r" ); + + if( fp == NULL ) + { + CPLFree( pszName ); + CPLFree( pszPath ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Is this file an ESRI header file? Read a few lines of text */ +/* searching for something starting with nrows or ncols. */ +/* -------------------------------------------------------------------- */ + const char * pszLine; + int nRows = -1, nCols = -1, nBands = 1; + int nSkipBytes = 0; + double dfULXMap=0.5, dfULYMap = 0.5, dfYLLCorner = -123.456; + int bCenter = TRUE; + double dfXDim = 1.0, dfYDim = 1.0, dfNoData = 0.0; + int nLineCount = 0, bNoDataSet = FALSE; + GDALDataType eDataType = GDT_Byte; + int nBits = -1; + char chByteOrder = 'M'; + char chPixelType = 'N'; // not defined + char szLayout[10] = "BIL"; + char **papszHDR = NULL; + + while( (pszLine = CPLReadLine( fp )) ) + { + char **papszTokens; + + nLineCount++; + + if( nLineCount > 50 || strlen(pszLine) > 1000 ) + break; + + papszHDR = CSLAddString( papszHDR, pszLine ); + + papszTokens = CSLTokenizeStringComplex( pszLine, " \t", TRUE, FALSE ); + if( CSLCount( papszTokens ) < 2 ) + { + CSLDestroy( papszTokens ); + continue; + } + + if( EQUAL(papszTokens[0],"ncols") ) + { + nCols = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"nrows") ) + { + nRows = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"skipbytes") ) + { + nSkipBytes = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"ulxmap") + || EQUAL(papszTokens[0],"xllcorner") + || EQUAL(papszTokens[0],"xllcenter") ) + { + dfULXMap = atof(papszTokens[1]); + if( EQUAL(papszTokens[0],"xllcorner") ) + bCenter = FALSE; + } + else if( EQUAL(papszTokens[0],"ulymap") ) + { + dfULYMap = atof(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"yllcorner") + || EQUAL(papszTokens[0],"yllcenter") ) + { + dfYLLCorner = atof(papszTokens[1]); + if( EQUAL(papszTokens[0],"yllcorner") ) + bCenter = FALSE; + } + else if( EQUAL(papszTokens[0],"xdim") ) + { + dfXDim = atof(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"ydim") ) + { + dfYDim = atof(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"cellsize") ) + { + dfXDim = dfYDim = atof(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"nbands") ) + { + nBands = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"layout") ) + { + strncpy( szLayout, papszTokens[1], sizeof(szLayout)-1 ); + } + else if( EQUAL(papszTokens[0],"NODATA_value") + || EQUAL(papszTokens[0],"NODATA") ) + { + dfNoData = atof(papszTokens[1]); + bNoDataSet = TRUE; + } + else if( EQUAL(papszTokens[0],"NBITS") ) + { + nBits = atoi(papszTokens[1]); + } + else if( EQUAL(papszTokens[0],"PIXELTYPE") ) + { + chPixelType = toupper(papszTokens[1][0]); + } + else if( EQUAL(papszTokens[0],"byteorder") ) + { + chByteOrder = toupper(papszTokens[1][0]); + } + + CSLDestroy( papszTokens ); + } + + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Did we get the required keywords? If not we return with */ +/* this never having been considered to be a match. This isn't */ +/* an error! */ +/* -------------------------------------------------------------------- */ + if( nRows == -1 || nCols == -1 ) + { + CSLDestroy( papszHDR ); + CPLFree( pszName ); + CPLFree( pszPath ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Has the user selected the .hdr file to open? */ +/* -------------------------------------------------------------------- */ + if( bSelectedHDR ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The selected file is an ESRI BIL header file, but to\n" + "open ESRI BIL datasets, the data file should be selected\n" + "instead of the .hdr file. Please try again selecting\n" + "the data file (often with the extension .bil) corresponding\n" + "to the header file: %s\n", + poOpenInfo->pszFilename ); + CSLDestroy( papszHDR ); + CPLFree( pszName ); + CPLFree( pszPath ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + EHdrDataset *poDS; + + poDS = new EHdrDataset(); + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nCols; + poDS->nRasterYSize = nRows; + poDS->papszHDR = papszHDR; + +/* -------------------------------------------------------------------- */ +/* Open target binary file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "r+b" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open %s with write permission.\n%s", + pszName, VSIStrerror( errno ) ); + delete poDS; + CPLFree( pszName ); + CPLFree( pszPath ); + return NULL; + } + + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Figure out the data type. */ +/* -------------------------------------------------------------------- */ + if( nBits == 16 ) + { + if ( chPixelType == 'U' ) + eDataType = GDT_UInt16; + else + eDataType = GDT_Int16; // default + } + else if( nBits == 32 ) + { + if( chPixelType == 'S' ) + eDataType = GDT_Int32; + else if( chPixelType == 'U' ) + eDataType = GDT_UInt32; + else if( chPixelType == 'F' ) + eDataType = GDT_Float32; + else + eDataType = GDT_Float32; // apparently common usage? + } + else if( nBits == 8 || nBits == -1 ) + eDataType = GDT_Byte; + + else + { + CPLError( CE_Failure, CPLE_NotSupported, + "EHdr driver does not support %d NBITS value.", + nBits ); + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Compute the line offset. */ +/* -------------------------------------------------------------------- */ + int nItemSize = GDALGetDataTypeSize(eDataType)/8; + int nPixelOffset; + vsi_l_offset nLineOffset, nBandOffset; + + if( EQUAL(szLayout,"BIP") ) + { + nPixelOffset = nItemSize * nBands; + nLineOffset = (vsi_l_offset)nPixelOffset * nCols; + nBandOffset = (vsi_l_offset)nItemSize; + } + else if( EQUAL(szLayout,"BSQ") ) + { + nPixelOffset = nItemSize; + nLineOffset = (vsi_l_offset)nPixelOffset * nCols; + nBandOffset = (vsi_l_offset)nLineOffset * nRows; + } + else /* assume BIL */ + { + nPixelOffset = nItemSize; + nLineOffset = (vsi_l_offset)nItemSize * nBands * nCols; + nBandOffset = (vsi_l_offset)nItemSize * nCols; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = nBands; + for( i = 0; i < poDS->nBands; i++ ) + { + RawRasterBand *poBand; + + poBand = + new RawRasterBand( poDS, i+1, poDS->fpImage, + nSkipBytes + nBandOffset * i, + nPixelOffset, nLineOffset, eDataType, +#ifdef CPL_LSB + chByteOrder == 'I' || chByteOrder == 'L', +#else + chByteOrder == 'M', +#endif + TRUE ); + + if( bNoDataSet ) + poBand->StoreNoDataValue( dfNoData ); + + poDS->SetBand( i+1, poBand ); + } + +/* -------------------------------------------------------------------- */ +/* Check for a .prj file. */ +/* -------------------------------------------------------------------- */ + const char *pszPrjFilename = CPLFormCIFilename( pszPath, pszName, "prj" ); + + fp = VSIFOpen( pszPrjFilename, "r" ); + if( fp != NULL ) + { + char **papszLines; + OGRSpatialReference oSRS; + + VSIFClose( fp ); + + papszLines = CSLLoad( pszPrjFilename ); + + if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE ) + { + CPLFree( poDS->pszProjection ); + oSRS.exportToWkt( &(poDS->pszProjection) ); + } + + CSLDestroy( papszLines ); + } + +/* -------------------------------------------------------------------- */ +/* If we didn't get bounds in the .hdr, look for a worldfile. */ +/* -------------------------------------------------------------------- */ + if( dfYLLCorner != -123.456 ) + { + if( bCenter ) + dfULYMap = dfYLLCorner + (nRows-1) * dfYDim; + else + dfULYMap = dfYLLCorner + nRows * dfYDim; + } + + if( dfULYMap != 0.5 || dfULYMap != 0.5 || dfXDim != 1.0 || dfYDim != 1.0 ) + { + poDS->bGotTransform = TRUE; + + if( bCenter ) + { + poDS->adfGeoTransform[0] = dfULXMap - dfXDim * 0.5; + poDS->adfGeoTransform[1] = dfXDim; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfULYMap + dfYDim * 0.5; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = - dfYDim; + } + else + { + poDS->adfGeoTransform[0] = dfULXMap; + poDS->adfGeoTransform[1] = dfXDim; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfULYMap; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = - dfYDim; + } + } + + if( !poDS->bGotTransform ) + poDS->bGotTransform = + GDALReadWorldFile( poOpenInfo->pszFilename, "blw", + poDS->adfGeoTransform ); + + if( !poDS->bGotTransform ) + poDS->bGotTransform = + GDALReadWorldFile( poOpenInfo->pszFilename, "wld", + poDS->adfGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Check for a color table. */ +/* -------------------------------------------------------------------- */ + const char *pszCLRFilename = CPLFormCIFilename( pszPath, pszName, "clr" ); + + fp = VSIFOpen( pszCLRFilename, "r" ); + if( fp != NULL ) + { + GDALColorTable oColorTable; + + for(i = 0;;) + { + const char *pszLine = CPLReadLine(fp); + if ( !pszLine ) + break; + + char **papszValues = CSLTokenizeString2(pszLine, "\t ", + CSLT_HONOURSTRINGS); + GDALColorEntry oEntry; + + if ( CSLCount(papszValues) == 4 ) + { + oEntry.c1 = atoi( papszValues[1] ); // Red + oEntry.c2 = atoi( papszValues[2] ); // Green + oEntry.c3 = atoi( papszValues[3] ); // Blue + oEntry.c4 = 255; + + oColorTable.SetColorEntry( i++, &oEntry ); + } + + CSLDestroy( papszValues ); + } + + VSIFClose( fp ); + + for( i = 1; i <= poDS->nBands; i++ ) + { + GDALRasterBand *poBand = poDS->GetRasterBand( i ); + poBand->SetColorTable( &oColorTable ); + poBand->SetColorInterpretation( GCI_PaletteIndex ); + } + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + CPLFree( pszName ); + CPLFree( pszPath ); + + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *EHdrDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** /* papszParmList */ ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 + && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_UInt32 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create ESRI .hdr labelled dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszFilename, "wb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Just write out a couple of bytes to establish the binary */ +/* file, and then close it. */ +/* -------------------------------------------------------------------- */ + VSIFWrite( (void *) "\0\0", 2, 1, fp ); + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Create the hdr filename. */ +/* -------------------------------------------------------------------- */ + char *pszHdrFilename; + + pszHdrFilename = + CPLStrdup( CPLResetExtension( pszFilename, "hdr" ) ); + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpen( pszHdrFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszHdrFilename ); + CPLFree( pszHdrFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Write out the raw definition for the dataset as a whole. */ +/* -------------------------------------------------------------------- */ + int nItemSize = GDALGetDataTypeSize(eType) / 8; + + VSIFPrintf( fp, "BYTEORDER I\n" ); + VSIFPrintf( fp, "LAYOUT BIL\n" ); + VSIFPrintf( fp, "NROWS %d\n", nYSize ); + VSIFPrintf( fp, "NCOLS %d\n", nXSize ); + VSIFPrintf( fp, "NBANDS %d\n", nBands ); + VSIFPrintf( fp, "NBITS %d\n", GDALGetDataTypeSize(eType) ); + VSIFPrintf( fp, "BANDROWBYTES %d\n", nItemSize * nXSize ); + VSIFPrintf( fp, "TOTALROWBYTES %d\n", nItemSize * nXSize * nBands ); + + if( eType == GDT_Float32 ) + VSIFPrintf( fp, "PIXELTYPE FLOAT\n"); + else if( eType == GDT_Int16 || eType == GDT_Int32 ) + VSIFPrintf( fp, "PIXELTYPE SIGNEDINT\n"); + else + VSIFPrintf( fp, "PIXELTYPE UNSIGNEDINT\n"); + +/* -------------------------------------------------------------------- */ +/* Cleanup */ +/* -------------------------------------------------------------------- */ + VSIFClose( fp ); + + CPLFree( pszHdrFilename ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* GDALRegister_EHdr() */ +/************************************************************************/ + +void GDALRegister_EHdr() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "EHdr" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "EHdr" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "ESRI .hdr Labelled" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#EHdr" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Int32 UInt32 Float32" ); + + poDriver->pfnOpen = EHdrDataset::Open; + poDriver->pfnCreate = EHdrDataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/raw/envidataset.cpp b/Utilities/GDAL/frmts/raw/envidataset.cpp new file mode 100644 index 0000000000..e492a1bdd6 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/envidataset.cpp @@ -0,0 +1,1405 @@ +/****************************************************************************** + * $Id: envidataset.cpp,v 1.31 2005/11/10 18:03:27 dron Exp $ + * + * Project: ENVI .hdr Driver + * Purpose: Implementation of ENVI .hdr labelled raw raster 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: envidataset.cpp,v $ + * Revision 1.31 2005/11/10 18:03:27 dron + * Added creation options descriptions in the driver's metadata. + * + * Revision 1.30 2005/09/21 19:57:37 fwarmerdam + * 2 bytes in headerbytes is enough, that is what Create() writes to the + * image file. + * + * Revision 1.29 2005/09/21 16:24:36 fwarmerdam + * fixed to avoid using openinfo->fp or large files may not work + * + * Revision 1.28 2005/09/14 01:09:00 fwarmerdam + * Fixed creation data types. + * + * Revision 1.27 2005/08/05 17:40:45 fwarmerdam + * Reformat for clarity. + * + * Revision 1.26 2005/07/25 19:52:43 ssoule + * Changed GDALMajorObject's char *pszDescription to std::string sDescription. + * + * Revision 1.25 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.24 2005/03/16 11:04:00 lichun + * FlushCache() now always writes the whole header file + * in the case of classes the type will be Classified and the class names and colors are written + * + * Revision 1.23 2005/02/28 15:42:05 fwarmerdam + * Call RawDataset::FlushCache() instead of GDALDataset::FlushCache() + * + * Revision 1.22 2005/02/08 15:52:44 gwalter + * Avoid overwriting header when it hasn't changed. + * + * Revision 1.21 2004/11/02 20:21:26 fwarmerdam + * added support for category names and colormaps + * + * Revision 1.20 2004/10/21 15:08:19 fwarmerdam + * Added warning about file compression. + * + * Revision 1.19 2004/08/18 15:31:46 warmerda + * I've fixed a bug in ENVI driver that happened when creating a band with a + * start offset greater that 2 Gbytes. I've also added support for geotransform + * parameters on creation even if there are no projection information. + * Sebastien Grignard (sebastien dot grignard at archivideo dot com). + * + * Revision 1.18 2004/07/28 14:33:27 warmerda + * Added Geograpic lat/lon. + * + * Revision 1.17 2004/01/27 22:38:37 aamici + * Remove CInt* data types from GDAL_DMD_CREATIONDATATYPES since they are + * no supported by this driver. + * + * Revision 1.16 2003/07/24 18:29:35 warmerda + * added oSRS.Fixup() to insert meter as linear units (bug 370) + * + * Revision 1.15 2003/06/05 15:41:08 dron + * Fixed problem with projection name determining. + * + * Revision 1.14 2003/04/30 09:47:29 dron + * Few memory leaks fixed. + * + * Revision 1.13 2003/03/11 16:34:49 gwalter + * Test header before opening dataset to avoid "band names = {" being written + * (during FlushCache in dataset deletion) to non-envi format files that also have + * .hdr header files. + * + * Revision 1.12 2003/03/05 12:52:19 dron + * Added flag for large file creation. + * + * Revision 1.11 2003/02/27 21:17:09 dron + * Writing map info implemented. + * + * Revision 1.10 2003/02/27 09:50:41 dron + * SUFFIX and INTERLEAVE creation options added; reference pixels supported. + * + * Revision 1.9 2003/02/17 21:30:02 dron + * Write support via Create() method added. + * + * Revision 1.8 2003/02/13 14:57:08 warmerda + * Corrected bug in north/south handling for UTM. + * Fix submitted by Vladimir Slepnev. + * + * Revision 1.7 2003/01/27 14:21:28 warmerda + * Fixed byte_order test. + * + * Revision 1.6 2003/01/24 15:05:01 warmerda + * Fixed byte order detection bugs as per bugzilla 261. + * + * Revision 1.5 2003/01/24 15:00:07 warmerda + * Added additional data types as per Bugzilla 262. + * + * Revision 1.4 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.3 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.2 2002/05/11 16:22:01 warmerda + * Also search for .hdr appended to full filename, not just .hdr replacing + * the existing extension - as per Bugzilla bug 127 from Alessandro Amici. + * + * Revision 1.1 2002/03/04 21:52:48 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: envidataset.cpp,v 1.31 2005/11/10 18:03:27 dron Exp $"); + +CPL_C_START +void GDALRegister_ENVI(void); +CPL_C_END + +static int anUsgsEsriZones[] = +{ + 101, 3101, + 102, 3126, + 201, 3151, + 202, 3176, + 203, 3201, + 301, 3226, + 302, 3251, + 401, 3276, + 402, 3301, + 403, 3326, + 404, 3351, + 405, 3376, + 406, 3401, + 407, 3426, + 501, 3451, + 502, 3476, + 503, 3501, + 600, 3526, + 700, 3551, + 901, 3601, + 902, 3626, + 903, 3576, + 1001, 3651, + 1002, 3676, + 1101, 3701, + 1102, 3726, + 1103, 3751, + 1201, 3776, + 1202, 3801, + 1301, 3826, + 1302, 3851, + 1401, 3876, + 1402, 3901, + 1501, 3926, + 1502, 3951, + 1601, 3976, + 1602, 4001, + 1701, 4026, + 1702, 4051, + 1703, 6426, + 1801, 4076, + 1802, 4101, + 1900, 4126, + 2001, 4151, + 2002, 4176, + 2101, 4201, + 2102, 4226, + 2103, 4251, + 2111, 6351, + 2112, 6376, + 2113, 6401, + 2201, 4276, + 2202, 4301, + 2203, 4326, + 2301, 4351, + 2302, 4376, + 2401, 4401, + 2402, 4426, + 2403, 4451, + 2500, 0, + 2501, 4476, + 2502, 4501, + 2503, 4526, + 2600, 0, + 2601, 4551, + 2602, 4576, + 2701, 4601, + 2702, 4626, + 2703, 4651, + 2800, 4676, + 2900, 4701, + 3001, 4726, + 3002, 4751, + 3003, 4776, + 3101, 4801, + 3102, 4826, + 3103, 4851, + 3104, 4876, + 3200, 4901, + 3301, 4926, + 3302, 4951, + 3401, 4976, + 3402, 5001, + 3501, 5026, + 3502, 5051, + 3601, 5076, + 3602, 5101, + 3701, 5126, + 3702, 5151, + 3800, 5176, + 3900, 0, + 3901, 5201, + 3902, 5226, + 4001, 5251, + 4002, 5276, + 4100, 5301, + 4201, 5326, + 4202, 5351, + 4203, 5376, + 4204, 5401, + 4205, 5426, + 4301, 5451, + 4302, 5476, + 4303, 5501, + 4400, 5526, + 4501, 5551, + 4502, 5576, + 4601, 5601, + 4602, 5626, + 4701, 5651, + 4702, 5676, + 4801, 5701, + 4802, 5726, + 4803, 5751, + 4901, 5776, + 4902, 5801, + 4903, 5826, + 4904, 5851, + 5001, 6101, + 5002, 6126, + 5003, 6151, + 5004, 6176, + 5005, 6201, + 5006, 6226, + 5007, 6251, + 5008, 6276, + 5009, 6301, + 5010, 6326, + 5101, 5876, + 5102, 5901, + 5103, 5926, + 5104, 5951, + 5105, 5976, + 5201, 6001, + 5200, 6026, + 5200, 6076, + 5201, 6051, + 5202, 6051, + 5300, 0, + 5400, 0 +}; + +/************************************************************************/ +/* ESRIToUSGSZone() */ +/* */ +/* Convert ESRI style state plane zones to USGS style state */ +/* plane zones. */ +/************************************************************************/ + +static int ESRIToUSGSZone( int nESRIZone ) + +{ + int nPairs = sizeof(anUsgsEsriZones) / (2*sizeof(int)); + int i; + + for( i = 0; i < nPairs; i++ ) + { + if( anUsgsEsriZones[i*2+1] == nESRIZone ) + return anUsgsEsriZones[i*2]; + } + + return 0; +} + +/************************************************************************/ +/* ==================================================================== */ +/* ENVIDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class ENVIDataset : public RawDataset +{ + FILE *fpImage; // image data file. + FILE *fp; // header file + const char *pszHDRFilename; + + int bFoundMapinfo; + + int bHeaderDirty; + + double adfGeoTransform[6]; + + char *pszProjection; + + char **papszHeader; + + int ReadHeader( FILE * ); + int ProcessMapinfo( const char * ); + + char **SplitList( const char * ); + + enum Interleave { BSQ, BIL, BIP } interleave; + static int GetEnviType(GDALDataType eType); + + public: + ENVIDataset(); + ~ENVIDataset(); + + virtual void FlushCache( void ); + virtual CPLErr GetGeoTransform( double * padfTransform ); + virtual CPLErr SetGeoTransform( double * ); + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszOptions ); +}; + +/************************************************************************/ +/* ENVIDataset() */ +/************************************************************************/ + +ENVIDataset::ENVIDataset() +{ + fpImage = NULL; + fp = NULL; + pszHDRFilename = NULL; + pszProjection = CPLStrdup(""); + + papszHeader = NULL; + + bFoundMapinfo = FALSE; + + bHeaderDirty = FALSE; + + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~ENVIDataset() */ +/************************************************************************/ + +ENVIDataset::~ENVIDataset() + +{ + FlushCache(); + if( fpImage ) + VSIFCloseL( fpImage ); + if( fp ) + VSIFClose( fp ); + if ( pszProjection ) + CPLFree( pszProjection ); + if ( papszHeader ) + CSLDestroy( papszHeader ); +} + +/************************************************************************/ +/* FlushCache() */ +/************************************************************************/ + +void ENVIDataset::FlushCache() + +{ + RawDataset::FlushCache(); + + if ( !bHeaderDirty ) + return; + + VSIFSeek( fp, 0, SEEK_SET ); + +/* -------------------------------------------------------------------- */ +/* Rewrite out the header. */ +/* -------------------------------------------------------------------- */ + int iBigEndian; + + const char *pszInterleaving; + char** catNames; + +#ifdef CPL_LSB + iBigEndian = 0; +#else + iBigEndian = 1; +#endif + + VSIFPrintf( fp, "ENVI\n" ); + if ("" != sDescription) + VSIFPrintf( fp, "description = {\n%s}\n", sDescription.c_str()); + VSIFPrintf( fp, "samples = %d\nlines = %d\nbands = %d\n", + nRasterXSize, nRasterYSize, nBands ); + + GDALRasterBand* band = GetRasterBand(1); + catNames = band->GetCategoryNames(); + VSIFPrintf( fp, "header offset = 0\n"); + if (0 == catNames) + VSIFPrintf( fp, "file type = ENVI Standard\n" ); + else + VSIFPrintf( fp, "file type = ENVI Classification\n" ); + int iENVIType = GetEnviType(band->GetRasterDataType()); + VSIFPrintf( fp, "data type = %d\n", iENVIType ); + switch (interleave) + { + case BIP: + pszInterleaving = "bip"; // interleaved by pixel + break; + case BIL: + pszInterleaving = "bil"; // interleaved by line + break; + case BSQ: + pszInterleaving = "bsq"; // band sequental by default + break; + default: + pszInterleaving = "bsq"; + break; + } + VSIFPrintf( fp, "interleave = %s\n", pszInterleaving); + VSIFPrintf( fp, "byte order = %d\n", iBigEndian ); + + +/* -------------------------------------------------------------------- */ +/* Write class and color information */ +/* -------------------------------------------------------------------- */ + catNames = band->GetCategoryNames(); + if (0 != catNames) + { + int nrClasses = 0; + while (*catNames++) + ++nrClasses; + + if (nrClasses > 0) + { + VSIFPrintf( fp, "classes = %d\n", nrClasses ); + + GDALColorTable* colorTable = band->GetColorTable(); + if (0 != colorTable) + { + int nrColors = colorTable->GetColorEntryCount(); + if (nrColors > nrClasses) + nrColors = nrClasses; + VSIFPrintf( fp, "class lookup = {\n"); + for (int i = 0; i < nrColors; ++i) + { + const GDALColorEntry* color = colorTable->GetColorEntry(i); + VSIFPrintf(fp, "%d, %d, %d", color->c1, color->c2, color->c3); + if (i < nrColors - 1) + { + VSIFPrintf(fp, ", "); + if (0 == (i+1) % 5) + VSIFPrintf(fp, "\n"); + } + } + VSIFPrintf(fp, "}\n"); + } + + catNames = band->GetCategoryNames(); + if (0 != *catNames) + { + VSIFPrintf( fp, "class names = {\n%s", *catNames++); + int i = 0; + while (*catNames) { + VSIFPrintf( fp, ","); + if (0 == (++i) % 5) + VSIFPrintf(fp, "\n"); + VSIFPrintf( fp, " %s", *catNames++); + } + VSIFPrintf( fp, "}\n"); + } + } + } + +/* -------------------------------------------------------------------- */ +/* Write the rest of header. */ +/* -------------------------------------------------------------------- */ + if ( pszProjection && !EQUAL(pszProjection, "") ) + { + const char *pszHemisphere; + double dfPixelY; + int bNorth; + int iUTMZone; + OGRSpatialReference oSRS; + + char *pszProj = pszProjection; + + oSRS.importFromWkt( &pszProj ); + iUTMZone = oSRS.GetUTMZone( &bNorth ); + if ( iUTMZone ) + { + if ( bNorth ) + { + pszHemisphere = "North"; + dfPixelY = -adfGeoTransform[5]; + } + else + { + pszHemisphere = "South"; + dfPixelY = adfGeoTransform[5]; + } + VSIFPrintf( fp, "map info = {UTM, 1, 1, %f, %f, %f, %f, %d, %s}\n", + adfGeoTransform[0], adfGeoTransform[3], adfGeoTransform[1], + dfPixelY, iUTMZone, pszHemisphere); + } + } else { + // Suppose we are in North hemisphere. + double dfPixelY = -adfGeoTransform[5]; + const char* pszHemisphere = "North"; + VSIFPrintf( fp, "map info = {Unknown, 1, 1, %f, %f, %f, %f, %d, %s}\n", + adfGeoTransform[0], adfGeoTransform[3], adfGeoTransform[1], + dfPixelY, 0, pszHemisphere); + } + + + VSIFPrintf( fp, "band names = {\n" ); + for ( int i = 1; i <= nBands; i++ ) + { + std::string sBandDesc = GetRasterBand( i )->GetDescription(); + + if ( sBandDesc == "" ) + sBandDesc = CPLSPrintf( "Band %d", i ); + VSIFPrintf( fp, "%s", sBandDesc.c_str() ); + if ( i != nBands ) + VSIFPrintf( fp, ",\n" ); + } + VSIFPrintf( fp, "}\n" ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *ENVIDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr ENVIDataset::SetProjection( const char *pszNewProjection ) + +{ + if ( pszProjection ) + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszNewProjection ); + + bHeaderDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr ENVIDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + + if( bFoundMapinfo ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr ENVIDataset::SetGeoTransform( double * padfTransform ) +{ + memcpy( adfGeoTransform, padfTransform, sizeof(double) * 6 ); + + bHeaderDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* SplitList() */ +/* */ +/* Split an ENVI value list into component fields, and strip */ +/* white space. */ +/************************************************************************/ + +char **ENVIDataset::SplitList( const char *pszCleanInput ) + +{ + char **papszReturn = NULL; + char *pszInput = CPLStrdup(pszCleanInput); + + if( pszInput[0] != '{' ) + return NULL; + + int iChar=1; + + + while( pszInput[iChar] != '}' && pszInput[iChar] != '\0' ) + { + int iFStart=-1, iFEnd=-1; + + // Find start of token. + iFStart = iChar; + while( pszInput[iFStart] == ' ' ) + iFStart++; + + iFEnd = iFStart; + while( pszInput[iFEnd] != ',' + && pszInput[iFEnd] != '}' + && pszInput[iFEnd] != '\0' ) + iFEnd++; + + if( pszInput[iFEnd] == '\0' ) + break; + + iChar = iFEnd + 1; + iFEnd = iFEnd - 1; + + while( iFEnd > iFStart && pszInput[iFEnd] == ' ' ) + iFEnd--; + + pszInput[iFEnd + 1] = '\0'; + papszReturn = CSLAddString( papszReturn, pszInput + iFStart ); + } + + CPLFree( pszInput ); + + return papszReturn; +} + +/************************************************************************/ +/* ProcessMapinfo() */ +/* */ +/* Extract projection, and geotransform from a mapinfo value in */ +/* the header. */ +/************************************************************************/ + +int ENVIDataset::ProcessMapinfo( const char *pszMapinfo ) + +{ + char **papszFields; + int nCount; + OGRSpatialReference oSRS; + + papszFields = SplitList( pszMapinfo ); + nCount = CSLCount(papszFields); + + if( nCount < 7 ) + { + CSLDestroy( papszFields ); + return FALSE; + } + + adfGeoTransform[1] = atof(papszFields[5]); // Pixel width + adfGeoTransform[5] = -atof(papszFields[6]); // Pixel height + adfGeoTransform[0] = // Upper left X coordinate + atof(papszFields[3]) - (atof(papszFields[1]) - 1) * adfGeoTransform[1]; + adfGeoTransform[3] = // Upper left Y coordinate + atof(papszFields[4]) - (atof(papszFields[2]) - 1) * adfGeoTransform[5]; + adfGeoTransform[2] = 0.0; + adfGeoTransform[4] = 0.0; + + if( EQUALN(papszFields[0],"UTM",3) && nCount >= 9 ) + { + oSRS.SetUTM( atoi(papszFields[7]), + !EQUAL(papszFields[8],"South") ); + oSRS.SetWellKnownGeogCS( "WGS84" ); + } + else if( EQUALN(papszFields[0],"State Plane (NAD 27)",19) + && nCount >= 8 ) + { + oSRS.SetStatePlane( ESRIToUSGSZone(atoi(papszFields[7])), FALSE ); + } + else if( EQUALN(papszFields[0],"State Plane (NAD 83)",19) + && nCount >= 8 ) + { + oSRS.SetStatePlane( ESRIToUSGSZone(atoi(papszFields[7])), TRUE ); + } + else if( EQUALN(papszFields[0],"Geographic Lat",14) + && nCount >= 8 ) + { + oSRS.SetWellKnownGeogCS( "WGS84" ); + } + + if( oSRS.GetRoot() == NULL ) + oSRS.SetLocalCS( papszFields[0] ); + + if( EQUAL(papszFields[nCount-1],"units=Feet") ) + { + oSRS.SetLinearUnits( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) ); + } + else if( EQUAL(papszFields[nCount-1],"units=Seconds") + && oSRS.IsGeographic() ) + { + /* convert geographic coordinate systems in seconds to degrees */ + adfGeoTransform[0] /= 3600.0; + adfGeoTransform[1] /= 3600.0; + adfGeoTransform[2] /= 3600.0; + adfGeoTransform[3] /= 3600.0; + adfGeoTransform[4] /= 3600.0; + adfGeoTransform[5] /= 3600.0; + } + + if( oSRS.GetRoot() != NULL ) + { + oSRS.Fixup(); + if ( pszProjection ) + { + CPLFree( pszProjection ); + pszProjection = NULL; + } + oSRS.exportToWkt( &pszProjection ); + } + + CSLDestroy( papszFields ); + return TRUE; +} + +/************************************************************************/ +/* ReadHeader() */ +/************************************************************************/ + +int ENVIDataset::ReadHeader( FILE * fpHdr ) + +{ + + CPLReadLine( fpHdr ); + +/* -------------------------------------------------------------------- */ +/* Now start forming sets of name/value pairs. */ +/* -------------------------------------------------------------------- */ + while( TRUE ) + { + const char *pszNewLine; + char *pszWorkingLine; + + pszNewLine = CPLReadLine( fpHdr ); + if( pszNewLine == NULL ) + break; + + if( strstr(pszNewLine,"=") == NULL ) + continue; + + pszWorkingLine = CPLStrdup(pszNewLine); + + // Collect additional lines if we have open sqiggly bracket. + if( strstr(pszWorkingLine,"{") != NULL + && strstr(pszWorkingLine,"}") == NULL ) + { + do { + pszNewLine = CPLReadLine( fpHdr ); + if( pszNewLine ) + { + pszWorkingLine = (char *) + CPLRealloc(pszWorkingLine, + strlen(pszWorkingLine)+strlen(pszNewLine)+1); + strcat( pszWorkingLine, pszNewLine ); + } + } while( pszNewLine != NULL && strstr(pszNewLine,"}") == NULL ); + } + + // Try to break input into name and value portions. Trim whitespace. + const char *pszValue; + int iEqual; + + for( iEqual = 0; + pszWorkingLine[iEqual] != '\0' && pszWorkingLine[iEqual] != '='; + iEqual++ ) {} + + if( pszWorkingLine[iEqual] == '=' ) + { + int i; + + pszValue = pszWorkingLine + iEqual + 1; + while( *pszValue == ' ' ) + pszValue++; + + pszWorkingLine[iEqual--] = '\0'; + while( iEqual > 0 && pszWorkingLine[iEqual] == ' ' ) + pszWorkingLine[iEqual--] = '\0'; + + // Convert spaces in the name to underscores. + for( i = 0; pszWorkingLine[i] != '\0'; i++ ) + { + if( pszWorkingLine[i] == ' ' ) + pszWorkingLine[i] = '_'; + } + + papszHeader = CSLSetNameValue( papszHeader, + pszWorkingLine, pszValue ); + } + + CPLFree( pszWorkingLine ); + } + + return TRUE; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *ENVIDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i; + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the binary (ie. .bil) file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 2 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Do we have a .hdr file? Try upper and lower case, and */ +/* replacing the extension as well as appending the extension */ +/* to whatever we currently have. */ +/* -------------------------------------------------------------------- */ + const char *pszMode; + const char *pszHdrFilename; + FILE *fpHeader; + + if( poOpenInfo->eAccess == GA_Update ) + pszMode = "r+"; + else + pszMode = "r"; + + pszHdrFilename = CPLResetExtension( poOpenInfo->pszFilename, "hdr" ); + fpHeader = VSIFOpen( pszHdrFilename, pszMode ); + +#ifndef WIN32 + if( fpHeader == NULL ) + { + pszHdrFilename = CPLResetExtension( poOpenInfo->pszFilename, "HDR" ); + fpHeader = VSIFOpen( pszHdrFilename, pszMode ); + } +#endif + if( fpHeader == NULL ) + { + pszHdrFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename, + "hdr" ); + fpHeader = VSIFOpen( pszHdrFilename, pszMode ); + } +#ifndef WIN32 + if( fpHeader == NULL ) + { + pszHdrFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename, + "HDR" ); + fpHeader = VSIFOpen( pszHdrFilename, pszMode ); + } +#endif + + if( fpHeader == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Check that the first line says "ENVI". */ +/* -------------------------------------------------------------------- */ + char szTestHdr[4]; + + if( VSIFRead( szTestHdr, 4, 1, fpHeader ) != 1 ) + { + VSIFClose( fpHeader ); + return NULL; + } + if( strncmp(szTestHdr,"ENVI",4) != 0 ) + { + VSIFClose( fpHeader ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + ENVIDataset *poDS; + + poDS = new ENVIDataset(); + poDS->pszHDRFilename = pszHdrFilename; + poDS->fp = fpHeader; + +/* -------------------------------------------------------------------- */ +/* Read the header. */ +/* -------------------------------------------------------------------- */ + if( !poDS->ReadHeader( fpHeader ) ) + { + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Has the user selected the .hdr file to open? */ +/* -------------------------------------------------------------------- */ + if( EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "hdr") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The selected file is an ENVI header file, but to\n" + "open ENVI datasets, the data file should be selected\n" + "instead of the .hdr file. Please try again selecting\n" + "the data file corresponding to the header file:\n" + " %s\n", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Extract required values from the .hdr. */ +/* -------------------------------------------------------------------- */ + int nLines = 0, nSamples = 0, nBands = 0, nHeaderSize = 0; + const char *pszInterleave = NULL; + + if( CSLFetchNameValue(poDS->papszHeader,"lines") ) + nLines = atoi(CSLFetchNameValue(poDS->papszHeader,"lines")); + + if( CSLFetchNameValue(poDS->papszHeader,"samples") ) + nSamples = atoi(CSLFetchNameValue(poDS->papszHeader,"samples")); + + if( CSLFetchNameValue(poDS->papszHeader,"bands") ) + nBands = atoi(CSLFetchNameValue(poDS->papszHeader,"bands")); + + pszInterleave = CSLFetchNameValue(poDS->papszHeader,"interleave"); + + if( nLines == 0 || nSamples == 0 || nBands == 0 || pszInterleave == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "The file appears to have an associated ENVI header, but\n" + "one or more of the samples, lines, bands and interleave\n" + "keywords appears to be missing." ); + return NULL; + } + + if( CSLFetchNameValue(poDS->papszHeader,"header_offset") ) + nHeaderSize = atoi(CSLFetchNameValue(poDS->papszHeader,"header_offset")); + +/* -------------------------------------------------------------------- */ +/* Translate the datatype. */ +/* -------------------------------------------------------------------- */ + GDALDataType eType = GDT_Byte; + + if( CSLFetchNameValue(poDS->papszHeader,"data_type" ) != NULL ) + { + switch( atoi(CSLFetchNameValue(poDS->papszHeader,"data_type" )) ) + { + case 1: + eType = GDT_Byte; + break; + + case 2: + eType = GDT_Int16; + break; + + case 3: + eType = GDT_Int32; + break; + + case 4: + eType = GDT_Float32; + break; + + case 5: + eType = GDT_Float64; + break; + + case 6: + eType = GDT_CFloat32; + break; + + case 9: + eType = GDT_CFloat64; + break; + + case 12: + eType = GDT_UInt16; + break; + + case 13: + eType = GDT_UInt32; + break; + + /* 14=Int64, 15=UInt64 */ + + default: + CPLError( CE_Failure, CPLE_AppDefined, + "The file has a 'data type' value of '%s'. This value\n" + "isn't recognised by the GDAL ENVI driver.", + CSLFetchNameValue(poDS->papszHeader,"data_type" ) ); + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Translate the byte order. */ +/* -------------------------------------------------------------------- */ + int bNativeOrder = TRUE; + + if( CSLFetchNameValue(poDS->papszHeader,"byte_order" ) != NULL ) + { +#ifdef CPL_LSB + bNativeOrder = atoi(CSLFetchNameValue(poDS->papszHeader, + "byte_order" )) == 0; +#else + bNativeOrder = atoi(CSLFetchNameValue(poDS->papszHeader, + "byte_order" )) != 0; +#endif + } + +/* -------------------------------------------------------------------- */ +/* Warn about compressed datasets. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue(poDS->papszHeader,"file_compression" ) != NULL ) + { + if( atoi(CSLFetchNameValue(poDS->papszHeader,"file_compression" )) + != 0 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "File %s is marked as compressed in the ENVI .hdr\n" + "GDAL does not support auto-decompression of ENVI data\n" + "files. If the data appears corrupt please decompress\n" + "manually and then retry.", + poOpenInfo->pszFilename ); + } + } + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nSamples; + poDS->nRasterYSize = nLines; + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Reopen file in update mode if necessary. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_Update ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to re-open %s within ENVI driver.\n", + poOpenInfo->pszFilename ); + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Compute the line offset. */ +/* -------------------------------------------------------------------- */ + int nDataSize = GDALGetDataTypeSize(eType)/8; + int nPixelOffset, nLineOffset; + vsi_l_offset nBandOffset; + + if( EQUALN(pszInterleave, "bsq", 3) ) + { + poDS->interleave = BSQ; + nLineOffset = nDataSize * nSamples; + nPixelOffset = nDataSize; + nBandOffset = (vsi_l_offset)nLineOffset * nLines; + } + else if( EQUALN(pszInterleave, "bil", 3) ) + { + poDS->interleave = BIL; + nLineOffset = nDataSize * nSamples * nBands; + nPixelOffset = nDataSize; + nBandOffset = (vsi_l_offset)nDataSize * nSamples; + } + else if( EQUALN(pszInterleave, "bip", 3) ) + { + poDS->interleave = BIP; + nLineOffset = nDataSize * nSamples * nBands; + nPixelOffset = nDataSize * nBands; + nBandOffset = nDataSize; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "The interleaving type of the file (%s) is not supported.", + pszInterleave ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = nBands; + for( i = 0; i < poDS->nBands; i++ ) + { + poDS->SetBand( i + 1, + new RawRasterBand(poDS, i + 1, poDS->fpImage, + nHeaderSize + nBandOffset * i, + nPixelOffset, nLineOffset, eType, + bNativeOrder, TRUE) ); + } + +/* -------------------------------------------------------------------- */ +/* Apply band names if we have them. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( poDS->papszHeader, "band_names" ) != NULL ) + { + char **papszBandNames = + poDS->SplitList( CSLFetchNameValue( poDS->papszHeader, + "band_names" ) ); + + for( i = 0; i < MIN(CSLCount(papszBandNames),nBands); i++ ) + poDS->GetRasterBand(i + 1)->SetDescription( papszBandNames[i] ); + + CSLDestroy( papszBandNames ); + } + +/* -------------------------------------------------------------------- */ +/* Apply class names if we have them. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( poDS->papszHeader, "class_names" ) != NULL ) + { + char **papszClassNames = + poDS->SplitList( CSLFetchNameValue( poDS->papszHeader, + "class_names" ) ); + + poDS->GetRasterBand(1)->SetCategoryNames( papszClassNames ); + CSLDestroy( papszClassNames ); + } + +/* -------------------------------------------------------------------- */ +/* Apply colormap if we have one. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( poDS->papszHeader, "class_lookup" ) != NULL ) + { + char **papszClassColors = + poDS->SplitList( CSLFetchNameValue( poDS->papszHeader, + "class_lookup" ) ); + int nColorValueCount = CSLCount(papszClassColors); + GDALColorTable oCT; + + for( i = 0; i*3 < nColorValueCount; i++ ) + { + GDALColorEntry sEntry; + + sEntry.c1 = atoi(papszClassColors[i*3+0]); + sEntry.c2 = atoi(papszClassColors[i*3+1]); + sEntry.c3 = atoi(papszClassColors[i*3+2]); + sEntry.c4 = 255; + oCT.SetColorEntry( i, &sEntry ); + } + + CSLDestroy( papszClassColors ); + + poDS->GetRasterBand(1)->SetColorTable( &oCT ); + poDS->GetRasterBand(1)->SetColorInterpretation( GCI_PaletteIndex ); + } + +/* -------------------------------------------------------------------- */ +/* Look for mapinfo */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( poDS->papszHeader, "map_info" ) != NULL ) + { + poDS->bFoundMapinfo = + poDS->ProcessMapinfo( + CSLFetchNameValue(poDS->papszHeader,"map_info") ); + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +int ENVIDataset::GetEnviType(GDALDataType eType) +{ + int iENVIType; + switch( eType ) + { + case GDT_Byte: + iENVIType = 1; + break; + case GDT_Int16: + iENVIType = 2; + break; + case GDT_Int32: + iENVIType = 3; + break; + case GDT_Float32: + iENVIType = 4; + break; + case GDT_Float64: + iENVIType = 5; + break; + case GDT_CFloat32: + iENVIType = 6; + break; + case GDT_CFloat64: + iENVIType = 9; + break; + case GDT_UInt16: + iENVIType = 12; + break; + case GDT_UInt32: + iENVIType = 13; + break; + + /* 14=Int64, 15=UInt64 */ + + default: + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create ENVI .hdr labelled dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + return 1; + } + return iENVIType; +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *ENVIDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszOptions ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + int iENVIType = GetEnviType(eType); + if (0 == iENVIType) + return 0; + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszFilename, "wb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Just write out a couple of bytes to establish the binary */ +/* file, and then close it. */ +/* -------------------------------------------------------------------- */ + VSIFWrite( (void *) "\0\0", 2, 1, fp ); + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Create the .hdr filename. */ +/* -------------------------------------------------------------------- */ + const char *pszHDRFilename; + const char *pszSuffix; + + pszSuffix = CSLFetchNameValue( papszOptions, "SUFFIX" ); + if ( pszSuffix && EQUALN( pszSuffix, "ADD", 3 )) + pszHDRFilename = CPLFormFilename( NULL, pszFilename, "hdr" ); + else + pszHDRFilename = CPLResetExtension(pszFilename, "hdr" ); + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpen( pszHDRFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszHDRFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Write out the header. */ +/* -------------------------------------------------------------------- */ + int iBigEndian; + const char *pszInterleaving; + +#ifdef CPL_LSB + iBigEndian = 0; +#else + iBigEndian = 1; +#endif + + VSIFPrintf( fp, "ENVI\n" ); + VSIFPrintf( fp, "samples = %d\nlines = %d\nbands = %d\n", + nXSize, nYSize, nBands ); + VSIFPrintf( fp, "header offset = 0\nfile type = ENVI Standard\n" ); + VSIFPrintf( fp, "data type = %d\n", iENVIType ); + pszInterleaving = CSLFetchNameValue( papszOptions, "INTERLEAVE" ); + if ( pszInterleaving ) + { + if ( EQUALN( pszInterleaving, "bip", 3 ) ) + pszInterleaving = "bip"; // interleaved by pixel + else if ( EQUALN( pszInterleaving, "bil", 3 ) ) + pszInterleaving = "bil"; // interleaved by line + else + pszInterleaving = "bsq"; // band sequental by default + } + else + pszInterleaving = "bsq"; + VSIFPrintf( fp, "interleave = %s\n", pszInterleaving); + VSIFPrintf( fp, "byte order = %d\n", iBigEndian ); + + VSIFClose( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* GDALRegister_ENVI() */ +/************************************************************************/ + +void GDALRegister_ENVI() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "ENVI" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "ENVI" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "ENVI .hdr Labelled" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#ENVI" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Int32 UInt32 " + "Float32 Float64 CFloat32 CFloat64" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='SUFFIX' type='string-select'>" +" <Value>ADD</Value>" +" </Option>" +" <Option name='INTERLEAVE' type='string-select'>" +" <Value>BIP</Value>" +" <Value>BIL</Value>" +" <Value>BSQ</Value>" +" </Option>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = ENVIDataset::Open; + poDriver->pfnCreate = ENVIDataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/fastdataset.cpp b/Utilities/GDAL/frmts/raw/fastdataset.cpp new file mode 100644 index 0000000000..6d1b46dd80 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/fastdataset.cpp @@ -0,0 +1,874 @@ +/****************************************************************************** + * $Id: fastdataset.cpp,v 1.19 2005/12/20 20:07:30 dron Exp $ + * + * Project: EOSAT FAST Format reader + * Purpose: Reads Landsat FAST-L7A, IRS 1C/1D + * Author: Andrey Kiselev, dron@at1895.spb.edu + * + ****************************************************************************** + * Copyright (c) 2002, Andrey Kiselev <dron@at1895.spb.edu> + * + * 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: fastdataset.cpp,v $ + * Revision 1.19 2005/12/20 20:07:30 dron + * Added support for 16-bit data. + * + * Revision 1.18 2005/09/14 13:18:32 dron + * Avoid warnings. + * + * Revision 1.17 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.16 2004/07/12 18:24:23 gwalter + * Fixed geotransform calculation. + * + * Revision 1.15 2004/04/27 14:25:41 warmerda + * Cast to avoid warning on Solaris. + * + * Revision 1.14 2004/03/16 18:27:39 dron + * Fixes in projection parameters parsing code. + * + * Revision 1.13 2004/02/18 20:22:10 dron + * Create RawRasterBand objects in "large" mode; more datums and ellipsoids. + * + * Revision 1.12 2004/02/17 08:05:45 dron + * Do not calculate projection definition if corner coordinates are not set. + * + * Revision 1.11 2004/02/03 20:38:50 dron + * Fixes in coordinate hadling; recognize more projections. + * + * Revision 1.10 2004/02/01 17:29:34 dron + * Format parsing logic completely rewritten. Start using importFromUSGS(). + * + * Revision 1.9 2003/10/17 07:08:21 dron + * Use locale selection option in CPLScanDouble(). + * + * Revision 1.8 2003/10/05 15:31:00 dron + * TM projection support implemented. + * + * Revision 1.7 2003/07/08 21:10:19 warmerda + * avoid warnings + * + * Revision 1.6 2003/03/14 17:28:10 dron + * CPLFormCIFilename() used instead of CPLFormFilename() for FAST-L7 datasets. + * + * Revision 1.5 2003/03/05 15:49:59 dron + * Fixed typo when reading SENSOR metadata record. + * + * Revision 1.4 2003/02/18 15:07:49 dron + * IRS-1C/1D support added. + * + * Revision 1.3 2003/02/14 21:05:40 warmerda + * Don't use path for rawdataset.h. + * + * Revision 1.2 2002/12/30 14:55:01 dron + * SetProjCS() removed, added unit setting. + * + * Revision 1.1 2002/10/05 12:35:31 dron + * FAST driver moved to the RAW directory. + * + * Revision 1.5 2002/10/04 16:06:06 dron + * Some redundancy removed. + * + * Revision 1.4 2002/10/04 12:33:02 dron + * Added calibration coefficients extraction. + * + * Revision 1.3 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.2 2002/08/15 09:35:50 dron + * Fixes in georeferencing + * + * Revision 1.1 2002/08/13 16:55:41 dron + * Initial release + * + * + */ + +#include "cpl_string.h" +#include "cpl_conv.h" +#include "ogr_spatialref.h" +#include "rawdataset.h" + +CPL_CVSID("$Id: fastdataset.cpp,v 1.19 2005/12/20 20:07:30 dron Exp $"); + +CPL_C_START +void GDALRegister_FAST(void); +CPL_C_END + +#define ADM_STD_HEADER_SIZE 4608 // XXX: Format specification says it +#define ADM_HEADER_SIZE 5000 // should be 4608, but some vendors + // ship broken large datasets. + +#define ACQUISITION_DATE "ACQUISITION DATE =" +#define ACQUISITION_DATE_SIZE 8 + +#define SATELLITE_NAME "SATELLITE =" +#define SATELLITE_NAME_SIZE 10 + +#define SENSOR_NAME "SENSOR =" +#define SENSOR_NAME_SIZE 10 + +#define FILENAME "FILENAME =" +#define FILENAME_SIZE 29 + +#define PIXELS "PIXELS PER LINE =" +#define PIXELS_SIZE 5 + +#define LINES "LINES PER BAND =" +#define LINES_SIZE 5 + +#define BITS_PER_PIXEL "OUTPUT BITS PER PIXEL =" +#define BITS_PER_PIXEL_SIZE 2 + +#define PROJECTION_NAME "MAP PROJECTION =" +#define PROJECTION_NAME_SIZE 4 + +#define ELLIPSOID_NAME "ELLIPSOID =" +#define ELLIPSOID_NAME_SIZE 18 + +#define DATUM_NAME "DATUM =" +#define DATUM_NAME_SIZE 6 + +#define ZONE_NUMBER "USGS MAP ZONE =" +#define ZONE_NUMBER_SIZE 6 + +#define USGS_PARAMETERS "USGS PROJECTION PARAMETERS =" + +#define CORNER_UPPER_LEFT "UL =" +#define CORNER_UPPER_RIGHT "UR =" +#define CORNER_LOWER_LEFT "LL =" +#define CORNER_LOWER_RIGHT "LR =" +#define CORNER_VALUE_SIZE 13 + +#define VALUE_SIZE 24 + +enum FASTSatellite // Satellites: +{ + LANDSAT, // Landsat 7 + IRS // IRS 1C/1D +}; + +/************************************************************************/ +/* ==================================================================== */ +/* FASTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class FASTDataset : public GDALPamDataset +{ + friend class FASTRasterBand; + + double adfGeoTransform[6]; + char *pszProjection; + + FILE *fpHeader; + FILE *fpChannels[6]; + const char *pszFilename; + char *pszDirname; + GDALDataType eDataType; + FASTSatellite iSatellite; + + public: + FASTDataset(); + ~FASTDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + + CPLErr GetGeoTransform( double * padfTransform ); + const char *GetProjectionRef(); + FILE *FOpenChannel( char *pszFilename, int iBand ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* FASTRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class FASTRasterBand : public RawRasterBand +{ + friend class FASTDataset; + + public: + + FASTRasterBand( FASTDataset *, int, FILE *, vsi_l_offset, + int, int, GDALDataType, int ); +}; + + +/************************************************************************/ +/* FASTRasterBand() */ +/************************************************************************/ + +FASTRasterBand::FASTRasterBand( FASTDataset *poDS, int nBand, FILE * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, GDALDataType eDataType, + int bNativeOrder) : + RawRasterBand( poDS, nBand, fpRaw, nImgOffset, nPixelOffset, + nLineOffset, eDataType, bNativeOrder, TRUE) +{ + +} + +/************************************************************************/ +/* ==================================================================== */ +/* FASTDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* FASTDataset() */ +/************************************************************************/ + +FASTDataset::FASTDataset() + +{ + fpHeader = NULL; + pszDirname = NULL; + pszProjection = CPLStrdup( "" ); + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + nBands = 0; +} + +/************************************************************************/ +/* ~FASTDataset() */ +/************************************************************************/ + +FASTDataset::~FASTDataset() + +{ + int i; + + FlushCache(); + + if ( pszDirname ) + CPLFree( pszDirname ); + if ( pszProjection ) + CPLFree( pszProjection ); + for ( i = 0; i < nBands; i++ ) + if ( fpChannels[i] ) + VSIFCloseL( fpChannels[i] ); + if( fpHeader != NULL ) + VSIFClose( fpHeader ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr FASTDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *FASTDataset::GetProjectionRef() + +{ + if( pszProjection ) + return pszProjection; + else + return ""; +} +/************************************************************************/ +/* FOpenChannel() */ +/************************************************************************/ + +FILE *FASTDataset::FOpenChannel( char *pszFilename, int iBand ) +{ + const char *pszChannelFilename = NULL; + char *pszPrefix = CPLStrdup( CPLGetBasename( this->pszFilename ) ); + char *pszSuffix = CPLStrdup( CPLGetExtension( this->pszFilename ) ); + + switch ( iSatellite ) + { + case LANDSAT: + if ( pszFilename && !EQUAL( pszFilename, "" ) ) + { + pszChannelFilename = + CPLFormCIFilename( pszDirname, pszFilename, NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + } + else + fpChannels[iBand] = NULL; + break; + case IRS: + default: + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "%s.%d", pszPrefix, iBand + 1 ), pszSuffix ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "IMAGERY%d", iBand + 1 ), pszSuffix ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "imagery%d", iBand + 1 ), pszSuffix ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "IMAGERY%d.DAT", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "imagery%d.dat", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "IMAGERY%d.dat", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "imagery%d.DAT", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "BAND%d", iBand + 1 ), pszSuffix ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "band%d", iBand + 1 ), pszSuffix ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "BAND%d.DAT", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "band%d.dat", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "BAND%d.dat", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + if ( fpChannels[iBand] ) + break; + pszChannelFilename = CPLFormFilename( pszDirname, + CPLSPrintf( "band%d.DAT", iBand + 1 ), NULL ); + fpChannels[iBand] = VSIFOpenL( pszChannelFilename, "rb" ); + break; + } + + CPLDebug( "FAST", "Band %d filename=%s", iBand + 1, pszChannelFilename); + + CPLFree( pszPrefix ); + CPLFree( pszSuffix ); + return fpChannels[iBand]; +} + +/************************************************************************/ +/* GetValue() */ +/************************************************************************/ + +static char *GetValue( const char *pszString, const char *pszName, + int iValueSize, int iNormalize ) +{ + char *pszTemp = strstr( (char *) pszString, pszName ); + + if ( pszTemp ) + { + pszTemp += strlen( pszName ); + pszTemp = CPLScanString( pszTemp, iValueSize, TRUE, iNormalize ); + } + + return pszTemp; +} + +/************************************************************************/ +/* USGSMnemonicToCode() */ +/************************************************************************/ + +static long USGSMnemonicToCode( const char* pszMnemonic ) +{ + if ( EQUAL(pszMnemonic, "UTM") ) + return 1L; + else if ( EQUAL(pszMnemonic, "LCC") ) + return 4L; + else if ( EQUAL(pszMnemonic, "PS") ) + return 6L; + else if ( EQUAL(pszMnemonic, "PC") ) + return 7L; + else if ( EQUAL(pszMnemonic, "TM") ) + return 9L; + else if ( EQUAL(pszMnemonic, "OM") ) + return 20L; + else if ( EQUAL(pszMnemonic, "SOM") ) + return 22L; + else + return 1L; // UTM by default +} + +/************************************************************************/ +/* USGSEllipsoidToCode() */ +/************************************************************************/ + +static long USGSEllipsoidToCode( const char* pszMnemonic ) +{ + if ( EQUAL(pszMnemonic, "CLARKE_1866") ) + return 0L; + else if ( EQUAL(pszMnemonic, "CLARKE_1880") ) + return 1L; + else if ( EQUAL(pszMnemonic, "BESSEL") ) + return 2L; + else if ( EQUAL(pszMnemonic, "INTERNATL_1967") ) + return 3L; + else if ( EQUAL(pszMnemonic, "INTERNATL_1909") ) + return 4L; + else if ( EQUAL(pszMnemonic, "WGS72") || EQUAL(pszMnemonic, "WGS_72") ) + return 5L; + else if ( EQUAL(pszMnemonic, "EVEREST") ) + return 6L; + else if ( EQUAL(pszMnemonic, "WGS66") || EQUAL(pszMnemonic, "WGS_66") ) + return 7L; + else if ( EQUAL(pszMnemonic, "GRS_80") ) + return 8L; + else if ( EQUAL(pszMnemonic, "AIRY") ) + return 9L; + else if ( EQUAL(pszMnemonic, "MODIFIED_EVEREST") ) + return 10L; + else if ( EQUAL(pszMnemonic, "MODIFIED_AIRY") ) + return 11L; + else if ( EQUAL(pszMnemonic, "WGS84") || EQUAL(pszMnemonic, "WGS_84") ) + return 12L; + else if ( EQUAL(pszMnemonic, "SOUTHEAST_ASIA") ) + return 13L; + else if ( EQUAL(pszMnemonic, "AUSTRALIAN_NATL") ) + return 14L; + else if ( EQUAL(pszMnemonic, "KRASSOVSKY") ) + return 15L; + else if ( EQUAL(pszMnemonic, "HOUGH") ) + return 16L; + else if ( EQUAL(pszMnemonic, "MERCURY_1960") ) + return 17L; + else if ( EQUAL(pszMnemonic, "MOD_MERC_1968") ) + return 18L; + else if ( EQUAL(pszMnemonic, "6370997_M_SPHERE") ) + return 19L; + else + return 0L; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *FASTDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i; + + if( poOpenInfo->fp == NULL ) + return NULL; + + if( !EQUALN((const char *) poOpenInfo->pabyHeader + 52, + "ACQUISITION DATE =", 18) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + FASTDataset *poDS; + + poDS = new FASTDataset(); + + poDS->fpHeader = poOpenInfo->fp; + poOpenInfo->fp = NULL; + poDS->pszFilename = poOpenInfo->pszFilename; + poDS->pszDirname = CPLStrdup( CPLGetDirname( poOpenInfo->pszFilename ) ); + +/* -------------------------------------------------------------------- */ +/* Read the administrative record. */ +/* -------------------------------------------------------------------- */ + char *pszTemp; + char *pszHeader = (char *) CPLMalloc( ADM_HEADER_SIZE + 1 ); + size_t nBytesRead; + + VSIFSeek( poDS->fpHeader, 0, SEEK_SET ); + nBytesRead = VSIFRead( pszHeader, 1, ADM_HEADER_SIZE, poDS->fpHeader ); + if ( nBytesRead < ADM_STD_HEADER_SIZE ) + { + CPLDebug( "FAST", "Header file too short. Reading failed" ); + delete poDS; + return NULL; + } + pszHeader[nBytesRead] = '\0'; + + // Read acquisition date + pszTemp = GetValue( pszHeader, ACQUISITION_DATE, + ACQUISITION_DATE_SIZE, TRUE ); + poDS->SetMetadataItem( "ACQUISITION_DATE", pszTemp ); + CPLFree( pszTemp ); + + // Read satellite name (will read the first one only) + pszTemp = GetValue( pszHeader, SATELLITE_NAME, SATELLITE_NAME_SIZE, TRUE ); + poDS->SetMetadataItem( "SATELLITE", pszTemp ); + if ( EQUALN(pszTemp, "LANDSAT", 7) ) + poDS->iSatellite = LANDSAT; + else if ( EQUALN(pszTemp, "IRS", 3) ) + poDS->iSatellite = IRS; + else + poDS->iSatellite = IRS; + CPLFree( pszTemp ); + + // Read sensor name (will read the first one only) + pszTemp = GetValue( pszHeader, SENSOR_NAME, SENSOR_NAME_SIZE, TRUE ); + poDS->SetMetadataItem( "SENSOR", pszTemp ); + CPLFree( pszTemp ); + + // Read filenames + pszTemp = pszHeader; + poDS->nBands = 0; + for ( i = 0; i < 6; i++ ) + { + char *pszFilename = NULL ; + + if ( pszTemp ) + pszTemp = strstr( pszTemp, FILENAME ); + if ( pszTemp ) + { + pszTemp += strlen(FILENAME); + pszFilename = CPLScanString( pszTemp, FILENAME_SIZE, TRUE, FALSE ); + } + else + pszTemp = NULL; + if ( poDS->FOpenChannel( pszFilename, poDS->nBands ) ) + poDS->nBands++; + if ( pszFilename ) + CPLFree( pszFilename ); + } + + if ( !poDS->nBands ) + { + CPLDebug( "FAST", "Failed to find and open band data files." ); + delete poDS; + return NULL; + } + + // Read number of pixels/lines and bit depth + pszTemp = strstr( pszHeader, PIXELS ); + if ( pszTemp ) + poDS->nRasterXSize = CPLScanLong( pszTemp + strlen(PIXELS), + PIXELS_SIZE ); + else + { + CPLDebug( "FAST", "Failed to find number of pixels in line." ); + delete poDS; + return NULL; + } + + pszTemp = strstr( pszHeader, LINES ); + if ( pszTemp ) + poDS->nRasterYSize = CPLScanLong( pszTemp + strlen(LINES), LINES_SIZE ); + else + { + CPLDebug( "FAST", "Failed to find number of lines in raster." ); + delete poDS; + return NULL; + } + + pszTemp = strstr( pszHeader, BITS_PER_PIXEL ); + switch( CPLScanLong(pszTemp+strlen(BITS_PER_PIXEL), BITS_PER_PIXEL_SIZE) ) + { + case 8: + default: + poDS->eDataType = GDT_Byte; + break; + case 16: + poDS->eDataType = GDT_UInt16; + break; + } + +/* -------------------------------------------------------------------- */ +/* Read radiometric record. */ +/* -------------------------------------------------------------------- */ + // Read gains and biases. This is a trick! + pszTemp = strstr( pszHeader, "BIASES" );// It may be "BIASES AND GAINS" + // or "GAINS AND BIASES" + // Now search for the first number occurance after that string + for ( i = 1; i <= poDS->nBands; i++ ) + { + char *pszValue = NULL; + + pszTemp = strpbrk( pszTemp, "-.0123456789" ); + if ( pszTemp ) + { + pszValue = CPLScanString( pszTemp, VALUE_SIZE, TRUE, TRUE ); + poDS->SetMetadataItem( CPLSPrintf("BIAS%d", i ), pszValue ); + } + pszTemp += VALUE_SIZE; + if ( pszValue ) + CPLFree( pszValue ); + pszTemp = strpbrk( pszTemp, "-.0123456789" ); + if ( pszTemp ) + { + pszValue = CPLScanString( pszTemp, VALUE_SIZE, TRUE, TRUE ); + poDS->SetMetadataItem( CPLSPrintf("GAIN%d", i ), pszValue ); + } + pszTemp += VALUE_SIZE; + if ( pszValue ) + CPLFree( pszValue ); + } + +/* -------------------------------------------------------------------- */ +/* Read geometric record. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS; + long iProjSys, iZone, iDatum; + // Coordinates of pixel's centers + double dfULX = 0.0, dfULY = 0.0; + double dfURX = 0.0, dfURY = 0.0; + double dfLLX = 0.0, dfLLY = 0.0; + double dfLRX = 0.0, dfLRY = 0.0; + double adfProjParms[15]; + + // Read projection name + pszTemp = GetValue( pszHeader, PROJECTION_NAME, + PROJECTION_NAME_SIZE, FALSE ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + iProjSys = USGSMnemonicToCode( pszTemp ); + else + iProjSys = 1L; // UTM by default + CPLFree( pszTemp ); + + // Read ellipsoid name + pszTemp = GetValue( pszHeader, ELLIPSOID_NAME, ELLIPSOID_NAME_SIZE, FALSE ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + iDatum = USGSEllipsoidToCode( pszTemp ); + else + iDatum = 0L; // Clarke, 1866 (NAD1927) by default + CPLFree( pszTemp ); + + // Read zone number + pszTemp = GetValue( pszHeader, ZONE_NUMBER, ZONE_NUMBER_SIZE, FALSE ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + iZone = atoi( pszTemp ); + else + iZone = 0L; + CPLFree( pszTemp ); + + // Read 15 USGS projection parameters + for ( i = 0; i < 15; i++ ) + adfProjParms[i] = 0.0; + pszTemp = strstr( pszHeader, USGS_PARAMETERS ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + { + pszTemp += strlen( USGS_PARAMETERS ); + for ( i = 0; i < 15; i++ ) + { + pszTemp = strpbrk( pszTemp, "-.0123456789" ); + if ( pszTemp ) + { + adfProjParms[i] = CPLScanDouble( pszTemp, VALUE_SIZE, "C" ); +#if DEBUG + CPLDebug("FAST", "USGS parameter %2d=%f.", i, adfProjParms[i]); +#endif + } + pszTemp = strpbrk( pszTemp, " \t" ); + } + } + + // Read corner coordinates + pszTemp = strstr( pszHeader, CORNER_UPPER_LEFT ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + { + pszTemp += strlen( CORNER_UPPER_LEFT ) + 28; + dfULX = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + pszTemp += CORNER_VALUE_SIZE + 1; + dfULY = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + } + + pszTemp = strstr( pszHeader, CORNER_UPPER_RIGHT ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + { + pszTemp += strlen( CORNER_UPPER_RIGHT ) + 28; + dfURX = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + pszTemp += CORNER_VALUE_SIZE + 1; + dfURY = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + } + + pszTemp = strstr( pszHeader, CORNER_LOWER_LEFT ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + { + pszTemp += strlen( CORNER_LOWER_LEFT ) + 28; + dfLLX = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + pszTemp += CORNER_VALUE_SIZE + 1; + dfLLY = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + } + + pszTemp = strstr( pszHeader, CORNER_LOWER_RIGHT ); + if ( pszTemp && !EQUAL( pszTemp, "" ) ) + { + pszTemp += strlen( CORNER_LOWER_RIGHT ) + 28; + dfLRX = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + pszTemp += CORNER_VALUE_SIZE + 1; + dfLRY = CPLScanDouble( pszTemp, CORNER_VALUE_SIZE, "C" ); + } + + if ( dfULX != 0.0 && dfULY != 0.0 + && dfURX != 0.0 && dfURY != 0.0 + && dfLLX != 0.0 && dfLLY != 0.0 + && dfLRX != 0.0 && dfLRY != 0.0 ) + { + int transform_ok=FALSE; + GDAL_GCP *pasGCPList; + + // Strip out zone number from the easting values, if either + if ( dfULX >= 1000000.0 ) + dfULX -= (double)iZone * 1000000.0; + if ( dfURX >= 1000000.0 ) + dfURX -= (double)iZone * 1000000.0; + if ( dfLLX >= 1000000.0 ) + dfLLX -= (double)iZone * 1000000.0; + if ( dfLRX >= 1000000.0 ) + dfLRX -= (double)iZone * 1000000.0; + + // Create projection definition + oSRS.importFromUSGS( iProjSys, iZone, adfProjParms, iDatum ); + oSRS.SetLinearUnits( SRS_UL_METER, 1.0 ); + + // Read datum name + pszTemp = GetValue( pszHeader, DATUM_NAME, DATUM_NAME_SIZE, FALSE ); + if ( EQUAL( pszTemp, "WGS84" ) ) + oSRS.SetWellKnownGeogCS( "WGS84" ); + else if ( EQUAL( pszTemp, "NAD27" ) ) + oSRS.SetWellKnownGeogCS( "NAD27" ); + else if ( EQUAL( pszTemp, "NAD83" ) ) + oSRS.SetWellKnownGeogCS( "NAD83" ); + CPLFree( pszTemp ); + + if ( poDS->pszProjection ) + CPLFree( poDS->pszProjection ); + oSRS.exportToWkt( &poDS->pszProjection ); + + // Generate GCPs + pasGCPList = (GDAL_GCP *) CPLCalloc( sizeof( GDAL_GCP ), 4 ); + GDALInitGCPs( 4, pasGCPList ); + + pasGCPList[0].pszId = "UPPER_LEFT"; + pasGCPList[0].dfGCPX = dfULX; + pasGCPList[0].dfGCPY = dfULY; + pasGCPList[0].dfGCPZ = 0.0; + pasGCPList[0].dfGCPPixel = 0.5; + pasGCPList[0].dfGCPLine = 0.5; + pasGCPList[1].pszId = "UPPER_RIGHT"; + pasGCPList[1].dfGCPX = dfURX; + pasGCPList[1].dfGCPY = dfURY; + pasGCPList[1].dfGCPZ = 0.0; + pasGCPList[1].dfGCPPixel = poDS->nRasterXSize-0.5; + pasGCPList[1].dfGCPLine = 0.5; + pasGCPList[2].pszId = "LOWER_LEFT"; + pasGCPList[2].dfGCPX = dfLLX; + pasGCPList[2].dfGCPY = dfLLY; + pasGCPList[2].dfGCPZ = 0.0; + pasGCPList[2].dfGCPPixel = 0.5; + pasGCPList[2].dfGCPLine = poDS->nRasterYSize-0.5; + pasGCPList[3].pszId = "LOWER_RIGHT"; + pasGCPList[3].dfGCPX = dfLRX; + pasGCPList[3].dfGCPY = dfLRY; + pasGCPList[3].dfGCPZ = 0.0; + pasGCPList[3].dfGCPPixel = poDS->nRasterXSize-0.5; + pasGCPList[3].dfGCPLine = poDS->nRasterYSize-0.5; + + // Calculate transformation matrix, if accurate + transform_ok = GDALGCPsToGeoTransform(4,pasGCPList,poDS->adfGeoTransform,0); + if (transform_ok == FALSE) + { + + poDS->adfGeoTransform[0] = 0.0; + poDS->adfGeoTransform[1] = 1.0; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = 0.0; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = 1.0; + if ( poDS->pszProjection ) + CPLFree( poDS->pszProjection ); + poDS->pszProjection = CPLStrdup(""); + } + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + int nPixelOffset = GDALGetDataTypeSize(poDS->eDataType) / 8; + int nLineOffset = poDS->nRasterXSize * nPixelOffset; + + for( i = 1; i <= poDS->nBands; i++ ) + poDS->SetBand( i, new FASTRasterBand( poDS, i, poDS->fpChannels[i - 1], + 0, nPixelOffset, nLineOffset, poDS->eDataType, TRUE)); + + CPLFree( pszHeader ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_FAST() */ +/************************************************************************/ + +void GDALRegister_FAST() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "FAST" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "FAST" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "EOSAT FAST Format" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_fast.html" ); + + poDriver->pfnOpen = FASTDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/frmt_fast.html b/Utilities/GDAL/frmts/raw/frmt_fast.html new file mode 100644 index 0000000000..225c43dbe2 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/frmt_fast.html @@ -0,0 +1,179 @@ +<html> +<head> +<title>FAST -- EOSAT FAST Format</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>FAST -- EOSAT FAST Format</h1> + +Supported reading from FAST-L7A format (Landsat TM data) and EOSAT Fast Format +Rev. C (IRS-1C/1D data). If you want to read other datasets in this format (SPOT), +write to me (Andrey Kiselev, <a href=mailto:dron@ak4719.spb.edu>dron@ak4719.spb.edu</a>). +You should share data samples with me.<p> + +Datasets in FAST format represented by several files: one or more +administrative headers and one or more files with actual image data in raw +format. Administrative files contains different information about scene +parameters including filenames of images. You can read files with +administrative headers with any text viewer/editor, it is just plain ASCII +text.<p> + +This driver wants administrative file for input. Filenames of images will be +extracted and data will be imported, every file will be interpreted as band.<p> + +<h2>Data</h2> + +<h3>FAST-L7A</h3> + +FAST-L7A consists form several files: big ones with image data and three +small files with administrative information. You should give to driver one +of the administrative files:<p> + +<ul> +<li>L7fppprrr_rrrYYYYMMDD_HPN.FST: panchromatic band header file with 1 + band +<li>L7fppprrr_rrrYYYYMMDD_HRF.FST: VNIR/ SWIR bands header file with 6 + bands +<li>L7fppprrr_rrrYYYYMMDD_HTM.FST: thermal bands header file with 2 bands +</ul> + +All raw images corresponded to their administrative files will be imported +as GDAL bands.<p> + +From the ``<a href=http://ltpwww.gsfc.nasa.gov/IAS/pdfs/DFCB_V5_B2_R4.pdf> +Level 1 Product Output Files Data Format Control Book</a>'':<p> +<tt> +The file naming convention for the FAST-L7A product files is +<br> +L7fppprrr_rrrYYYYMMDD_AAA.FST<br> +<br> +where<br> +<br> +L7 = Landsat 7 mission<br> +<br> +f = ETM+ format (1 or 2) (data not pertaining to a specific format defaults to 1)<br> +<br> +ppp = starting path of the product<br> +<br> +rrr_rrr = starting and ending rows of the product<br> +<br> +YYYYMMDD = acquisition date of the image<br> +<br> +AAA = file type:<br> +HPN = panchromatic band header file<br> +HRF = VNIR/ SWIR bands header file<br> +HTM = thermal bands header file<br> +B10 = band 1<br> +B20 = band 2<br> +B30 = band 3<br> +B40 = band 4<br> +B50 = band 5<br> +B61 = band 6L<br> +B62 = band 6H<br> +B70 = band 7<br> +B80 = band 8<br> +<br> +FST = FAST file extension<br> +</tt><p> + +So you should give to driver one of the <tt>L7fppprrr_rrrYYYYMMDD_HPN.FST</tt>, +<tt>L7fppprrr_rrrYYYYMMDD_HRF.FST</tt> or +<tt>L7fppprrr_rrrYYYYMMDD_HTM.FST</tt> files. + +<h3>IRS-1C/1D</h3> + +Fast Format REV. C does not contain band filenames in administrative header. +So we should guess band filenames, because different data distributors name +their files differently. Several naming schemes hardcoded in GDAL's FAST +driver. These are:<p> + +<tt> +<header>.<ext><br> +<header>.1.<ext><br> +<header>.2.<ext><br> +...<br> +</tt><p> + +or<p> + +<tt> +<header>.<ext><br> +band1.<ext><br> +band2.<ext><br> +...<br> +</tt><p> + +or<p> + +<tt> +<header>.<ext><br> +band1.dat<br> +band2.dat<br> +...<br> +</tt><p> + +or<p> + +<tt> +<header>.<ext><br> +imagery1.<ext><br> +imagery2.<ext><br> +...<br> +</tt><p> + +or<p> + +<tt> +<header>.<ext><br> +imagery1.dat<br> +imagery2.dat<br> +...<br> +</tt><p> + +in lower or upper case. Header file could be named arbitrarily. This should +cover majority of distributors fantasy in naming files. But if you out of +luck and your datasets named differently you should rename them manually +before importing data with GDAL.<p> + +<h2>Georeference</h2> + +All USGS projections should be supported (namely UTM, LCC, PS, PC, TM, OM, SOM). +Contact me if you have troubles with proper projection extraction. + +<h2>Metadata</h2> + +Calibration coefficients for each band reported as metadata items. + +<ul> + + <li> <b>ACQUISITION_DATE</b>: First scene acquisition date in yyyyddmm + format.<p> + + <li> <b>SATELLITE</b>: First scene satellite name.<p> + + <li> <b>SENSOR</b>: First scene sensor name.<p> + + <li> <b>BIASn</b>: Bias value for the channel <b>n</b>.<p> + + <li> <b>GAINn</b>: Gain value for the channel <b>n</b>.<p> + +</ul> + +<h2>See Also:</h2> + +<ul> +<li> Implemented as <tt>gdal/frmts/fast/fastdataset.cpp</tt>.<p> + +<li> Landsat FAST L7A format description available from +<a href=http://ltpwww.gsfc.nasa.gov/IAS/htmls/l7_review.html> +http://ltpwww.gsfc.nasa.gov/IAS/htmls/l7_review.html</a> +(see <a href=http://ltpwww.gsfc.nasa.gov/IAS/pdfs/DFCB_V5_B2_R4.pdf> +ESDIS Level 1 Product Generation System (LPGS) Output Files DFCB, Vol. 5, Book 2</a>)<p> + +<li> EOSAT Fast Format REV. C description available from +<a href=http://www.euromap.de/doc_001.htm>http://www.euromap.de/doc_001.htm</a> +<p> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/raw/frmt_mff2.html b/Utilities/GDAL/frmts/raw/frmt_mff2.html new file mode 100644 index 0000000000..13e684ebc9 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/frmt_mff2.html @@ -0,0 +1,241 @@ +<html> +<head> +<title>MFF2 -- Vexcel MFF2 Image</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>MFF2 -- Vexcel MFF2 Image</h1> +GDAL supports MFF2 Image raster file format for read, update, and creation. +The MFF2 (Multi-File Format 2) format was designed to fit into +Vexcel Hierarchical Key-Value (HKV) databases, which can store +binary data as well as ASCII parameters. +This format is primarily used internally to the Vexcel InSAR +processing system.<p> + +To select an MFF2 dataset, select the directory containing the <tt>attrib</tt>, +and <tt>image_data</tt> files for the dataset.<p> + +Currently only latitude/longitude and UTM projection are supported +(georef.projection.name = ll or georef.projection.name = utm), +with the affine transform computed from the lat/long control points. In +any event, if GCPs are available in a georef file, they are returned with +the dataset.<p> + +Newly created files (with a type of <tt>MFF2</tt>) are always just raw rasters +with no georeferencing information. For read, and creation all data types +(real, integer and complex in bit depths of 8, 16, 32) should be supported. <p> + +IMPORTANT: When creating a new MFF2, be sure to set the projection before setting the geotransform (this is necessary because the geotransform is stored internally as 5 latitude-longitude ground control points, and the projection is needed to do the conversion).<p> + +NOTE: Implemented as <tt>gdal/frmts/raw/hkvdataset.cpp</tt>.<p> + +<h2>Format Details</h2> + +<h3>MFF2 Top-level Structure</h3> + +An MFF2 "file" is actually a set of files stored in a directory +containing an ASCII header file entitled "attrib", and binary +image data entitled "image_data". Optionally, there may be +an ASCII "georef" file containing georeferencing and projection +information, and an "image_data_ovr" (for "image_data" binary image data) +file containing tiled overviews of the image in TIFF format. +The ASCII files are arranged in key=value pairs. The allowable +pairs for each file are described below. + + +<h3>The "attrib" File</h3> + +As a minimum, the "attrib" file must specify the image extents, +pixel size in bytes, pixel encoding and datatype, and pixel +byte order. For example, + +<pre> +extent.cols = 800 +extent.rows = 1040 +pixel.size = 32 +pixel.encoding = { unsigned twos_complement *ieee_754 } +pixel.field = { *real complex } +pixel.order = { lsbf *msbf } +version = 1.1 +</pre> + +specifies an image that is 1040 lines by 800 pixels in extent. The +pixels are 32 bits of real data in "most significant byte first" (msbf) +order, encoded according to the ieee_754 specification. In MFF2, when +a value must belong to a certain subset (eg. pixel.order must be either +lsbf or msbf), all options are displayed between curly brackets, and +the one appropriate for the current file is indicated with a "*". +<p> +The file may also contain the following lines indicating the number of +channels of data, and how they are interleaved within the binary data +file. + +<pre> +channel.enumeration = 1 +channel.interleave = { *pixel tile sequential } +</pre> + +<h3>The "image_data" File</h3> + +The "image_data" file consists of raw binary data, with extents, +pixel encoding, and number of channels as indicated in the "attrib" file. + +<h3>The "georef" File</h3> + +The "georef" file is used to describe the geocoding and projection +information for the binary data. For example, + +<pre> +top_left.latitude = 32.93333333333334 +top_left.longitude = 130.0 +top_right.latitude = 32.93333333333334 +top_right.longitude = 130.5 +bottom_left.latitude = 32.50000000000001 +bottom_left.longitude = 130.0 +bottom_right.latitude = 32.50000000000001 +bottom_right.longitude = 130.5 +centre.latitude = 32.71666666666668 +centre.longitude = 130.25 +projection.origin_longitude = 0 +projection.name = ll +spheroid.name = wgs-84 + +</pre> + +describes an orthogonal latitude/longitude (ll) projected image, with +latitudes and longitudes based on the wgs-84 ellipsoid. +<p> +Since MFF2 version 1.1, +top_left refers to the top left corner of the top left pixel. +top_right refers to the top right corner of the top right pixel. +bottom_left refers to the bottom left corner of the bottom left pixel. +bottom_right refers to the bottom right corner of the bottom right pixel. +centre refers to the centre of the four corners defined above (center +of the image). +<p> +Mathematically, for an Npix by Nline image, the corners and centre in +(pixel,line) coordinates for MFF2 version 1.1 are: + +<pre> +top_left: (0,0) +top_right: (Npix,0) +bottom_left: (0,Nline) +bottom_right: (Npix,Nline) +centre: (Npix/2.0,Nline/2.0) +</pre> + +These calculations are done using floating point arithmetic (ie. +centre coordinates may take on non-integer values). +<p> +Note that the corners are always expressed in latitudes/longitudes, even +for projected images. +<p> + +<h3>Supported projections</h3> + +ll- Orthogonal latitude/longitude projected image, with latitude +parallel to the rows, longitude parallel to the columns. Parameters: +spheroid name, projection.origin_longitude (longitude at the origin of +the projection coordinates). If not set, this should default to the +central longitude of the output image based on its projection boundaries. +<p> +utm- Universal Transverse Mercator projected image. Parameters: +spheroid name, projection.origin_longitude (central meridian for the +utm projection). The central meridian must be the meridian at the +centre of a UTM zone, ie. 3 degrees, 9 degrees, 12 degrees, etc. If +this is not specified or set a valid UTM central meridian, the reader +should reset the value to the nearest valid central meridian based on +the central longitude of the output image. The latitude at the origin +of the UTM projection is always 0 degrees. +<p> + +<h3>Recognized ellipsoids</h3> + +MFF2 format associates the following names with ellipsoid equatorial +radius and inverse flattening parameters: + +<pre> +airy-18304: 6377563.396 299.3249646 +modified-airy4: 6377340.189 299.3249646 +australian-national4: 6378160 298.25 +bessel-1841-namibia4: 6377483.865 299.1528128 +bessel-18414: 6377397.155 299.1528128 +clarke-18584: 6378294.0 294.297 +clarke-18664: 6378206.4 294.9786982 +clarke-18804: 6378249.145 293.465 +everest-india-18304: 6377276.345 300.8017 +everest-sabah-sarawak4:6377298.556 300.8017 +everest-india-19564: 6377301.243 300.8017 +everest-malaysia-19694:6377295.664 300.8017 +everest-malay-sing4: 6377304.063 300.8017 +everest-pakistan4: 6377309.613 300.8017 +modified-fisher-19604: 6378155 298.3 +helmert-19064: 6378200 298.3 +hough-19604: 6378270 297 +hughes4: 6378273.0 298.279 +indonesian-1974: 6378160 298.247 +international-1924: 6378388 297 +iugc-67: 6378160.0 298.254 +iugc-75: 6378140.0 298.25298 +krassovsky-1940: 6378245 298.3 +kaula: 6378165.0 292.308 +grs-80: 6378137 298.257222101 +south-american-1969: 6378160 298.25 +wgs-72: 6378135 298.26 +wgs-84: 6378137 298.257223563 +ev-wgs-84: 6378137 298.252841 +ev-bessel: 6377397 299.1976073 +</pre> + + +<h3>Explanation of fields</h3> + +<pre> +channel.enumeration: (optional- only needed for multiband) +Number of channels of data (eg. 3 for rgb) + +channel.interleave = { *pixel tile sequential } : (optional- only +needed for multiband) + +For multiband data, indicates how the channels are interleaved. *pixel +indicates that data is stored red value, green value, blue value, red +value, green value, blue value etc. as opposed to (line of red values) +(line of green values) (line of blue values) or (entire red channel) +(entire green channel) (entire blue channel) + +extent.cols: +Number of columns of data. + +extent.rows: +Number of rows of data. + +pixel.encoding = { *unsigned twos-complement ieee-754 }: +Combines with pixel.size and pixel.field to give the data type: +(encoding, field, size)- type +(unsigned, real, 8)- unsigned byte data +(unsigned, real, 16)- unsigned int 16 data +(unsigned, real, 32)- unsigned int 32 data +(twos-complement, real, 16)- signed int 16 data +(twos-complement, real, 32)- signed int 32 data +(twos-complement, complex, 64)- complex signed int 32 data +(ieee-754, real, 32)- real 32 bit floating point data +(ieee-754, real, 64)- real 64 bit floating point data +(ieee-754, complex, 64)- complex 32 bit floating point data +(ieee-754, complex, 128)- complex 64 bit floating point data + +pixel.size: +Size of one pixel of one channel (bits). + +pixel.field = { *real complex }: +Whether the data is real or complex. + +pixel.order = { *lsbf msbf }: +Byte ordering of the data (least or most significant byte first). + +version: (only in newer versions- if not present, older version is +assumed) Version of mff2. +</pre> + +</body> +</html> diff --git a/Utilities/GDAL/frmts/raw/fujibasdataset.cpp b/Utilities/GDAL/frmts/raw/fujibasdataset.cpp new file mode 100644 index 0000000000..94fd4b317e --- /dev/null +++ b/Utilities/GDAL/frmts/raw/fujibasdataset.cpp @@ -0,0 +1,248 @@ +/****************************************************************************** + * $Id: fujibasdataset.cpp,v 1.5 2005/05/05 13:55:42 fwarmerdam Exp $ + * + * Project: eCognition + * Purpose: Implementation of FUJI BAS Format + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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: fujibasdataset.cpp,v $ + * Revision 1.5 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.4 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.3 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.2 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.1 2001/05/15 13:20:45 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: fujibasdataset.cpp,v 1.5 2005/05/05 13:55:42 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_FujiBAS(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* FujiBASDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class FujiBASDataset : public RawDataset +{ + FILE *fpImage; // image data file. + + char **papszHeader; + + public: + FujiBASDataset(); + ~FujiBASDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* FujiBASDataset() */ +/************************************************************************/ + +FujiBASDataset::FujiBASDataset() +{ + fpImage = NULL; + papszHeader = NULL; +} + +/************************************************************************/ +/* ~FujiBASDataset() */ +/************************************************************************/ + +FujiBASDataset::~FujiBASDataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFClose( fpImage ); + CSLDestroy( papszHeader ); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *FujiBASDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the header (.pcb) file. */ +/* Does this appear to be a pcb file? */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 80 || poOpenInfo->fp == NULL ) + return NULL; + + if( !EQUALN((const char *)poOpenInfo->pabyHeader,"[Raw data]",10) + || strstr((const char *)poOpenInfo->pabyHeader, "Fuji BAS") == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Load the header file. */ +/* -------------------------------------------------------------------- */ + char **papszHeader; + int nXSize, nYSize; + const char *pszOrgFile; + + papszHeader = CSLLoad( poOpenInfo->pszFilename ); + + if( papszHeader == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Munge header information into form suitable for CSL functions. */ +/* -------------------------------------------------------------------- */ + int i; + + for( i = 0; papszHeader[i] != NULL; i++ ) + { + char *pszSep = strstr(papszHeader[i]," = "); + + if( pszSep != NULL ) + { + memmove( pszSep + 1, pszSep + 3, strlen(pszSep+3)+1 ); + *pszSep = '='; + } + } + +/* -------------------------------------------------------------------- */ +/* Fetch required fields. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue(papszHeader, "width") == NULL + || CSLFetchNameValue(papszHeader, "height") == NULL + || CSLFetchNameValue(papszHeader, "OrgFile") == NULL ) + { + CSLDestroy( papszHeader ); + return NULL; + } + + nYSize = atoi(CSLFetchNameValue(papszHeader,"width")); + nXSize = atoi(CSLFetchNameValue(papszHeader,"height")); + + pszOrgFile = CSLFetchNameValue(papszHeader,"OrgFile"); + + if( nXSize < 1 || nYSize < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Try to open the original data file. */ +/* -------------------------------------------------------------------- */ + const char *pszRawFile; + char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); + FILE *fpRaw; + + pszRawFile = CPLFormCIFilename( pszPath, pszOrgFile, "IMG" ); + CPLFree( pszPath ); + + fpRaw = VSIFOpen( pszRawFile, "rb" ); + if( fpRaw == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Trying to open Fuji BAS image with the header file:\n" + " Header=%s\n" + "but expected raw image file doesn't appear to exist. Trying to open:\n" + " Raw File=%s\n" + "Perhaps the raw file needs to be renamed to match expected?", + poOpenInfo->pszFilename, + pszRawFile ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + FujiBASDataset *poDS; + + poDS = new FujiBASDataset(); + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nXSize; + poDS->nRasterYSize = nYSize; + poDS->papszHeader = papszHeader; + poDS->fpImage = fpRaw; + +/* -------------------------------------------------------------------- */ +/* Create band information object. */ +/* -------------------------------------------------------------------- */ + poDS->SetBand( 1, + new RawRasterBand( poDS, 1, poDS->fpImage, + 0, 2, nXSize * 2, GDT_UInt16, FALSE )); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_FujiBAS() */ +/************************************************************************/ + +void GDALRegister_FujiBAS() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "FujiBAS" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "FujiBAS" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Fuji BAS Scanner Image" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#FujiBAS" ); + + poDriver->pfnOpen = FujiBASDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/gscdataset.cpp b/Utilities/GDAL/frmts/raw/gscdataset.cpp new file mode 100644 index 0000000000..137cb320d9 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/gscdataset.cpp @@ -0,0 +1,239 @@ +/****************************************************************************** + * $Id: gscdataset.cpp,v 1.3 2005/05/05 13:55:42 fwarmerdam Exp $ + * + * Project: GSC Geogrid format driver. + * Purpose: Implements support for reading and writing GSC Geogrid format. + * Author: Frank Warmerdam <warmerdam@pobox.com> + * + ****************************************************************************** + * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: gscdataset.cpp,v $ + * Revision 1.3 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.2 2002/10/03 06:07:31 warmerda + * Added nodata support. + * + * Revision 1.1 2002/10/03 05:40:48 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: gscdataset.cpp,v 1.3 2005/05/05 13:55:42 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* GSCDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class GSCDataset : public RawDataset +{ + FILE *fpImage; // image data file. + + double adfGeoTransform[6]; + + public: + GSCDataset(); + ~GSCDataset(); + + CPLErr GetGeoTransform( double * padfTransform ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* GSCDataset() */ +/************************************************************************/ + +GSCDataset::GSCDataset() +{ + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + fpImage = NULL; +} + +/************************************************************************/ +/* ~GSCDataset() */ +/************************************************************************/ + +GSCDataset::~GSCDataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFClose( fpImage ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr GSCDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *GSCDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int nPixels, nLines, i, nRecordLen; + +/* -------------------------------------------------------------------- */ +/* Does this plausible look like a GSC Geogrid file? */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 20 || poOpenInfo->fp == NULL ) + return NULL; + + if( poOpenInfo->pabyHeader[12] != 0x02 + || poOpenInfo->pabyHeader[13] != 0x00 + || poOpenInfo->pabyHeader[14] != 0x00 + || poOpenInfo->pabyHeader[15] != 0x00 ) + return NULL; + + nRecordLen = CPL_LSBWORD32(((GInt32 *) poOpenInfo->pabyHeader)[0]); + nPixels = CPL_LSBWORD32(((GInt32 *) poOpenInfo->pabyHeader)[1]); + nLines = CPL_LSBWORD32(((GInt32 *) poOpenInfo->pabyHeader)[2]); + + if( nPixels < 1 || nLines < 1 || nPixels > 100000 || nLines > 100000 ) + return NULL; + + if( nRecordLen != nPixels * 4 ) + return NULL; + + nRecordLen += 8; /* for record length markers */ + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + GSCDataset *poDS; + + poDS = new GSCDataset(); + + poDS->nRasterXSize = nPixels; + poDS->nRasterYSize = nLines; + +/* -------------------------------------------------------------------- */ +/* Assume ownership of the file handled from the GDALOpenInfo. */ +/* -------------------------------------------------------------------- */ + poDS->fpImage = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +/* -------------------------------------------------------------------- */ +/* Read the header information in the second record. */ +/* -------------------------------------------------------------------- */ + float afHeaderInfo[8]; + + if( VSIFSeek( poDS->fpImage, nRecordLen + 12, SEEK_SET ) != 0 + || VSIFRead( afHeaderInfo, sizeof(float), 8, poDS->fpImage ) != 8 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failure reading second record of GSC file with %d record length.", + nRecordLen ); + delete poDS; + return NULL; + } + + for( i = 0; i < 8; i++ ) + { + CPL_LSBPTR32( afHeaderInfo + i ); + } + + poDS->adfGeoTransform[0] = afHeaderInfo[2]; + poDS->adfGeoTransform[1] = afHeaderInfo[0]; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = afHeaderInfo[5]; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = -afHeaderInfo[1]; + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + RawRasterBand *poBand; +#ifdef CPL_LSB + int bNative = TRUE; +#else + int bNative = FALSE; +#endif + + poBand = new RawRasterBand( poDS, 1, poDS->fpImage, + nRecordLen * 2 + 4, + sizeof(float), nRecordLen, + GDT_Float32, bNative, FALSE ); + poDS->SetBand( 1, poBand ); + + poBand->SetNoDataValue( -1.0000000150474662199e+30 ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_GSC() */ +/************************************************************************/ + +void GDALRegister_GSC() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "GSC" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "GSC" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "GSC Geogrid" ); +// poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, +// "frmt_various.html#GSC" ); + + poDriver->pfnOpen = GSCDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/hkvdataset.cpp b/Utilities/GDAL/frmts/raw/hkvdataset.cpp new file mode 100644 index 0000000000..d0685b21c6 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/hkvdataset.cpp @@ -0,0 +1,2013 @@ +/****************************************************************************** + * $Id: hkvdataset.cpp,v 1.40 2006/04/10 16:27:16 fwarmerdam Exp $ + * + * Project: GView + * Purpose: Implementation of Atlantis HKV labelled blob support + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2000, 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: hkvdataset.cpp,v $ + * Revision 1.40 2006/04/10 16:27:16 fwarmerdam + * Fixed contact info. + * + * Revision 1.39 2006/01/16 20:28:56 gwalter + * Fixed cplusplus misuse. + * + * Revision 1.38 2006/01/05 16:21:56 gwalter + * Added nodata write support. + * + * Revision 1.37 2005/12/22 22:08:35 gwalter + * Update MFF2 documentation; Atlantis->Vexcel. + * + * Revision 1.36 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.35 2004/01/23 18:55:01 gwalter + * Remove unnecessary print statement. + * + * Revision 1.34 2003/08/12 15:37:40 gwalter + * Make sure wgs-84 and wgs_84 treated the same way. + * + * Revision 1.33 2003/08/12 15:26:09 gwalter + * Bug fix for wgs_84 LL projection case. + * + * Revision 1.32 2003/07/08 21:10:19 warmerda + * avoid warnings + * + * Revision 1.31 2003/04/10 22:13:40 gwalter + * Updated spheroids: some applications use _ instead of - in spheroid names. + * + * Revision 1.30 2003/04/02 18:46:45 gwalter + * Fixed one-off error in number of spheroids. + * + * Revision 1.29 2003/03/20 19:12:35 gwalter + * Fix identity geotransform check in hkvdataset.cpp. + * + * Revision 1.28 2003/03/18 19:03:44 gwalter + * Add flushing, fix coordinate interpretation. + * + * Revision 1.27 2003/03/13 18:34:02 gwalter + * Fix data type determination in CreateCopy. + * + * Revision 1.26 2003/03/11 21:00:30 gwalter + * More georeferencing-related updates. + * + * Revision 1.25 2003/03/03 20:10:05 gwalter + * Updated MFF and HKV (MFF2) georeferencing support. + * + * Revision 1.24 2002/11/23 18:54:17 warmerda + * added CREATIONDATATYPES metadata for drivers + * + * Revision 1.23 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.22 2002/06/19 18:21:08 warmerda + * removed stat buf from GDALOpenInfo + * + * Revision 1.21 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.20 2002/04/24 19:27:00 warmerda + * Added HKV nodata read support (pixel.no_data). + * + * Revision 1.19 2001/12/12 18:15:46 warmerda + * preliminary update for large raw file support + * + * Revision 1.18 2001/12/12 17:19:06 warmerda + * Use CPLStat for directories. + * + * Revision 1.17 2001/12/08 04:45:59 warmerda + * fixed south setting for UTM + * + * Revision 1.16 2001/11/11 23:51:00 warmerda + * added required class keyword to friend declarations + * + * Revision 1.15 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.14 2001/07/11 18:09:06 warmerda + * Correct corner GCPs. BOTTOM_RIGHT actually refers to the top left corner of + * the bottom right pixel! + * + * Revision 1.13 2001/06/20 16:10:02 warmerda + * overhauled to TIFF style overviews + * + * Revision 1.12 2001/06/13 19:42:10 warmerda + * Changed blob->image_data, and HKV to MFF2. + * + * Revision 1.11 2000/12/14 17:34:13 warmerda + * Added dataset delete method. + * + * Revision 1.10 2000/12/05 22:40:09 warmerda + * Added very limited SetProjection support, includes Bessel + * + * Revision 1.9 2000/11/29 21:31:28 warmerda + * added support for writing georef on SetGeoTransform + * + * Revision 1.8 2000/08/16 15:51:39 warmerda + * added support for reading overviews + * + * Revision 1.7 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.6 2000/07/12 19:21:59 warmerda + * added support for _reading_ georef file + * + * Revision 1.5 2000/06/05 17:24:06 warmerda + * added real complex support + * + * Revision 1.4 2000/05/15 14:18:27 warmerda + * added COMPLEX_INTERPRETATION metadata + * + * Revision 1.3 2000/04/05 19:28:48 warmerda + * Fixed MSB case. + * + * Revision 1.2 2000/03/13 14:34:42 warmerda + * avoid const problem on write + * + * Revision 1.1 2000/03/07 21:33:42 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" +#include <ctype.h> +#include "ogr_spatialref.h" +#include "atlsci_spheroid.h" + +CPL_CVSID("$Id: hkvdataset.cpp,v 1.40 2006/04/10 16:27:16 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_HKV(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* HKVRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class HKVDataset; + +class HKVRasterBand : public RawRasterBand +{ + friend class HKVDataset; + + public: + HKVRasterBand( HKVDataset *poDS, int nBand, FILE * fpRaw, + unsigned int nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder ); + virtual ~HKVRasterBand(); + + virtual CPLErr SetNoDataValue( double ); +}; + +/************************************************************************/ +/* HKV Spheroids */ +/************************************************************************/ + +class HKVSpheroidList : public SpheroidList +{ + +public: + + HKVSpheroidList(); + ~HKVSpheroidList(); + +}; + +HKVSpheroidList :: HKVSpheroidList() +{ + num_spheroids = 58; + epsilonR = 0.1; + epsilonI = 0.000001; + + spheroids[0].SetValuesByEqRadiusAndInvFlattening("airy-1830",6377563.396,299.3249646); + spheroids[1].SetValuesByEqRadiusAndInvFlattening("modified-airy",6377340.189,299.3249646); + spheroids[2].SetValuesByEqRadiusAndInvFlattening("australian-national",6378160,298.25); + spheroids[3].SetValuesByEqRadiusAndInvFlattening("bessel-1841-namibia",6377483.865,299.1528128); + spheroids[4].SetValuesByEqRadiusAndInvFlattening("bessel-1841",6377397.155,299.1528128); + spheroids[5].SetValuesByEqRadiusAndInvFlattening("clarke-1858",6378294.0,294.297); + spheroids[6].SetValuesByEqRadiusAndInvFlattening("clarke-1866",6378206.4,294.9786982); + spheroids[7].SetValuesByEqRadiusAndInvFlattening("clarke-1880",6378249.145,293.465); + spheroids[8].SetValuesByEqRadiusAndInvFlattening("everest-india-1830",6377276.345,300.8017); + spheroids[9].SetValuesByEqRadiusAndInvFlattening("everest-sabah-sarawak",6377298.556,300.8017); + spheroids[10].SetValuesByEqRadiusAndInvFlattening("everest-india-1956",6377301.243,300.8017); + spheroids[11].SetValuesByEqRadiusAndInvFlattening("everest-malaysia-1969",6377295.664,300.8017); + spheroids[12].SetValuesByEqRadiusAndInvFlattening("everest-malay-sing",6377304.063,300.8017); + spheroids[13].SetValuesByEqRadiusAndInvFlattening("everest-pakistan",6377309.613,300.8017); + spheroids[14].SetValuesByEqRadiusAndInvFlattening("modified-fisher-1960",6378155,298.3); + spheroids[15].SetValuesByEqRadiusAndInvFlattening("helmert-1906",6378200,298.3); + spheroids[16].SetValuesByEqRadiusAndInvFlattening("hough-1960",6378270,297); + spheroids[17].SetValuesByEqRadiusAndInvFlattening("hughes",6378273.0,298.279); + spheroids[18].SetValuesByEqRadiusAndInvFlattening("indonesian-1974",6378160,298.247); + spheroids[19].SetValuesByEqRadiusAndInvFlattening("international-1924",6378388,297); + spheroids[20].SetValuesByEqRadiusAndInvFlattening("iugc-67",6378160.0,298.254); + spheroids[21].SetValuesByEqRadiusAndInvFlattening("iugc-75",6378140.0,298.25298); + spheroids[22].SetValuesByEqRadiusAndInvFlattening("krassovsky-1940",6378245,298.3); + spheroids[23].SetValuesByEqRadiusAndInvFlattening("kaula",6378165.0,292.308); + spheroids[24].SetValuesByEqRadiusAndInvFlattening("grs-80",6378137,298.257222101); + spheroids[25].SetValuesByEqRadiusAndInvFlattening("south-american-1969",6378160,298.25); + spheroids[26].SetValuesByEqRadiusAndInvFlattening("wgs-72",6378135,298.26); + spheroids[27].SetValuesByEqRadiusAndInvFlattening("wgs-84",6378137,298.257223563); + spheroids[28].SetValuesByEqRadiusAndInvFlattening("ev-wgs-84",6378137.0,298.252841); + spheroids[29].SetValuesByEqRadiusAndInvFlattening("ev-bessel",6377397.0,299.1976073); + + spheroids[30].SetValuesByEqRadiusAndInvFlattening("airy_1830",6377563.396,299.3249646); + spheroids[31].SetValuesByEqRadiusAndInvFlattening("modified_airy",6377340.189,299.3249646); + spheroids[32].SetValuesByEqRadiusAndInvFlattening("australian_national",6378160,298.25); + spheroids[33].SetValuesByEqRadiusAndInvFlattening("bessel_1841_namibia",6377483.865,299.1528128); + spheroids[34].SetValuesByEqRadiusAndInvFlattening("bessel_1841",6377397.155,299.1528128); + spheroids[35].SetValuesByEqRadiusAndInvFlattening("clarke_1858",6378294.0,294.297); + spheroids[36].SetValuesByEqRadiusAndInvFlattening("clarke_1866",6378206.4,294.9786982); + spheroids[37].SetValuesByEqRadiusAndInvFlattening("clarke_1880",6378249.145,293.465); + spheroids[38].SetValuesByEqRadiusAndInvFlattening("everest_india_1830",6377276.345,300.8017); + spheroids[39].SetValuesByEqRadiusAndInvFlattening("everest_sabah_sarawak",6377298.556,300.8017); + spheroids[40].SetValuesByEqRadiusAndInvFlattening("everest_india_1956",6377301.243,300.8017); + spheroids[41].SetValuesByEqRadiusAndInvFlattening("everest_malaysia_1969",6377295.664,300.8017); + spheroids[42].SetValuesByEqRadiusAndInvFlattening("everest_malay_sing",6377304.063,300.8017); + spheroids[43].SetValuesByEqRadiusAndInvFlattening("everest_pakistan",6377309.613,300.8017); + spheroids[44].SetValuesByEqRadiusAndInvFlattening("modified_fisher_1960",6378155,298.3); + spheroids[45].SetValuesByEqRadiusAndInvFlattening("helmert_1906",6378200,298.3); + spheroids[46].SetValuesByEqRadiusAndInvFlattening("hough_1960",6378270,297); + spheroids[47].SetValuesByEqRadiusAndInvFlattening("indonesian_1974",6378160,298.247); + spheroids[48].SetValuesByEqRadiusAndInvFlattening("international_1924",6378388,297); + spheroids[49].SetValuesByEqRadiusAndInvFlattening("iugc_67",6378160.0,298.254); + spheroids[50].SetValuesByEqRadiusAndInvFlattening("iugc_75",6378140.0,298.25298); + spheroids[51].SetValuesByEqRadiusAndInvFlattening("krassovsky_1940",6378245,298.3); + spheroids[52].SetValuesByEqRadiusAndInvFlattening("grs_80",6378137,298.257222101); + spheroids[53].SetValuesByEqRadiusAndInvFlattening("south_american_1969",6378160,298.25); + spheroids[54].SetValuesByEqRadiusAndInvFlattening("wgs_72",6378135,298.26); + spheroids[55].SetValuesByEqRadiusAndInvFlattening("wgs_84",6378137,298.257223563); + spheroids[56].SetValuesByEqRadiusAndInvFlattening("ev_wgs_84",6378137.0,298.252841); + spheroids[57].SetValuesByEqRadiusAndInvFlattening("ev_bessel",6377397.0,299.1976073); + +} + +HKVSpheroidList::~HKVSpheroidList() + +{ +} + +CPLErr SaveHKVAttribFile( const char *pszFilenameIn, + int nXSize, int nYSize, int nBands, + GDALDataType eType, int bNoDataSet, + double dfNoDataValue ); + +/************************************************************************/ +/* ==================================================================== */ +/* HKVDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class HKVDataset : public RawDataset +{ + friend class HKVRasterBand; + + char *pszPath; + FILE *fpBlob; + + int nGCPCount; + GDAL_GCP *pasGCPList; + + void ProcessGeoref(const char *); + void ProcessGeorefGCP(char **, const char *, double, double); + void SetVersion( float version_number ); + float GetVersion(); + float MFF2version; + + CPLErr SetGCPProjection(const char *); /* for use in CreateCopy */ + + GDALDataType eRasterType; + + void SetNoDataValue( double ); + + char *pszProjection; + char *pszGCPProjection; + double adfGeoTransform[6]; + + char **papszAttrib; + + int bGeorefChanged; + char **papszGeoref; + + /* NOTE: The MFF2 format goes against GDAL's API in that nodata values are set + * per-dataset rather than per-band. To compromise, for writing out, the + * dataset's nodata value will be set to the last value set on any of the + * raster bands. + */ + + int bNoDataSet; + int bNoDataChanged; + double dfNoDataValue; + + public: + HKVDataset(); + virtual ~HKVDataset(); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr GetGeoTransform( double * ); + + virtual CPLErr SetGeoTransform( double * ); + virtual CPLErr SetProjection( const char * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); + static GDALDataset *CreateCopy( const char * pszFilename, + GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressData ); + + static CPLErr Delete( const char * pszName ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* HKVRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HKVRasterBand() */ +/************************************************************************/ + +HKVRasterBand::HKVRasterBand( HKVDataset *poDS, int nBand, FILE * fpRaw, + unsigned int nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder ) + : RawRasterBand( (GDALDataset *) poDS, nBand, + fpRaw, nImgOffset, nPixelOffset, + nLineOffset, eDataType, bNativeOrder, TRUE ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr HKVRasterBand::SetNoDataValue( double dfNewValue ) + +{ + HKVDataset *poHKVDS = (HKVDataset *) poDS; + this->RawRasterBand::SetNoDataValue( dfNewValue ); + poHKVDS->SetNoDataValue( dfNewValue ); + + return CE_None; +} + +/************************************************************************/ +/* ~HKVRasterBand() */ +/************************************************************************/ + +HKVRasterBand::~HKVRasterBand() + +{ +} + +/************************************************************************/ +/* ==================================================================== */ +/* HKVDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* HKVDataset() */ +/************************************************************************/ + +HKVDataset::HKVDataset() +{ + pszPath = NULL; + papszAttrib = NULL; + papszGeoref = NULL; + bGeorefChanged = FALSE; + + nGCPCount = 0; + pasGCPList = NULL; + pszProjection = CPLStrdup(""); + pszGCPProjection = CPLStrdup(""); + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + + bNoDataSet = FALSE; + bNoDataChanged = FALSE; + + /* Initialize datasets to new version; change if necessary */ + MFF2version = (float) 1.1; +} + +/************************************************************************/ +/* ~HKVDataset() */ +/************************************************************************/ + +HKVDataset::~HKVDataset() + +{ + FlushCache(); + if( bGeorefChanged ) + { + const char *pszFilename; + + pszFilename = CPLFormFilename(pszPath, "georef", NULL ); + + CSLSave( papszGeoref, pszFilename ); + } + + if( bNoDataChanged ) + { + SaveHKVAttribFile(pszPath, + this->nRasterXSize, + this->nRasterYSize, + this->nBands, + this->eRasterType, + this->bNoDataSet, + this->dfNoDataValue ); + + } + + if( fpBlob != NULL ) + VSIFCloseL( fpBlob ); + + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + CPLFree( pszPath ); + CSLDestroy( papszGeoref ); + CSLDestroy( papszAttrib ); +} + +/************************************************************************/ +/* SetVersion() */ +/************************************************************************/ + +void HKVDataset::SetVersion(float version_number) + +{ + //update stored info + MFF2version = version_number; +} + +/************************************************************************/ +/* GetVersion() */ +/************************************************************************/ + +float HKVDataset::GetVersion() + +{ + return( MFF2version ); +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +void HKVDataset::SetNoDataValue( double dfNewValue ) + +{ + + this->bNoDataSet = TRUE; + this->bNoDataChanged = TRUE; + this->dfNoDataValue = dfNewValue; +} + +/************************************************************************/ +/* SaveHKVAttribFile() */ +/************************************************************************/ + +CPLErr SaveHKVAttribFile( const char *pszFilenameIn, + int nXSize, int nYSize, int nBands, + GDALDataType eType, int bNoDataSet, + double dfNoDataValue ) + +{ + + FILE *fp; + const char *pszFilename; + + pszFilename = CPLFormFilename( pszFilenameIn, "attrib", NULL ); + + fp = VSIFOpen( pszFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Couldn't create %s.\n", pszFilename ); + return CE_Failure; + } + + fprintf( fp, "channel.enumeration = %d\n", nBands ); + fprintf( fp, "channel.interleave = { *pixel tile sequential }\n" ); + fprintf( fp, "extent.cols = %d\n", nXSize ); + fprintf( fp, "extent.rows = %d\n", nYSize ); + + switch( eType ) + { + case GDT_Byte: + fprintf( fp, "pixel.encoding = " + "{ *unsigned twos-complement ieee-754 }\n" ); + break; + + case GDT_UInt16: + fprintf( fp, "pixel.encoding = " + "{ *unsigned twos-complement ieee-754 }\n" ); + break; + + case GDT_CInt16: + case GDT_Int16: + fprintf( fp, "pixel.encoding = " + "{ unsigned *twos-complement ieee-754 }\n" ); + break; + + case GDT_CFloat32: + case GDT_Float32: + fprintf( fp, "pixel.encoding = " + "{ unsigned twos-complement *ieee-754 }\n" ); + break; + + default: + CPLAssert( FALSE ); + } + + fprintf( fp, "pixel.size = %d\n", GDALGetDataTypeSize(eType) ); + if( GDALDataTypeIsComplex( eType ) ) + fprintf( fp, "pixel.field = { real *complex }\n" ); + else + fprintf( fp, "pixel.field = { *real complex }\n" ); + +#ifdef CPL_MSB + fprintf( fp, "pixel.order = { lsbf *msbf }\n" ); +#else + fprintf( fp, "pixel.order = { *lsbf msbf }\n" ); +#endif + + if ( bNoDataSet ) + fprintf( fp, "pixel.no_data = %f\n", dfNoDataValue ); + + /* version information- only create the new style */ + fprintf( fp, "version = 1.1"); + + + VSIFClose( fp ); + return CE_None; +} + + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *HKVDataset::GetProjectionRef() + +{ + return( pszProjection ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr HKVDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return( CE_None ); +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr HKVDataset::SetGeoTransform( double * padfTransform ) + +{ + char szValue[128]; + + /* NOTE: Geotransform coordinates must match the current projection */ + /* of the dataset being changed (not the geotransform source). */ + /* ie. be in lat/longs for LL projected; UTM for UTM projected. */ + /* SET PROJECTION BEFORE SETTING GEOTRANSFORM TO AVOID SYNCHRONIZATION */ + /* PROBLEMS! */ + + /* Update the geotransform itself */ + memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 ); + + /* Clear previous gcps */ + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + nGCPCount = 0; + pasGCPList = NULL; + + /* Return if the identity transform is set */ + if (adfGeoTransform[0] == 0.0 && adfGeoTransform[1] == 1.0 + && adfGeoTransform[2] == 0.0 && adfGeoTransform[3] == 0.0 + && adfGeoTransform[4] == 0.0 && adfGeoTransform[5] == 1.0 ) + return CE_None; + + /* Update georef text info for saving later, and */ + /* update GCPs to match geotransform. */ + + double temp_lat, temp_long; + OGRSpatialReference oUTM; + OGRSpatialReference oLL; + OGRCoordinateTransformation *poTransform = NULL; + int bSuccess=TRUE; + char *pszPtemp; + char *pszGCPtemp; + + /* clear old gcps, initialize new list */ + + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + pasGCPList = NULL; + } + nGCPCount = 0; + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),5); + + /* Projection parameter checking will have been done */ + /* in SetProjection. */ + if(( CSLFetchNameValue( papszGeoref, "projection.name" ) != NULL ) && + ( EQUAL(CSLFetchNameValue( papszGeoref, "projection.name" ),"UTM" ))) + + { + /* pass copies of projection info, not originals (pointers */ + /* get updated by importFromWkt) */ + pszPtemp = CPLStrdup(pszProjection); + oUTM.importFromWkt(&pszPtemp); + (oUTM.GetAttrNode("GEOGCS"))->exportToWkt(&pszGCPtemp); + oLL.importFromWkt(&pszGCPtemp); + poTransform = OGRCreateCoordinateTransformation( &oUTM, &oLL ); + if( poTransform == NULL ) + bSuccess = FALSE; + + } + else if ((( CSLFetchNameValue( papszGeoref, "projection.name" ) != NULL ) && + ( !EQUAL(CSLFetchNameValue( papszGeoref, "projection.name" ),"LL" ))) || + (CSLFetchNameValue( papszGeoref, "projection.name" ) == NULL )) + { + return CE_Failure; + } + /* -------------------------------------------------------------------- */ + /* top left */ + /* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( "top_left" ); + + if (MFF2version > 1.0) + { + temp_lat = padfTransform[3]; + temp_long = padfTransform[0]; + pasGCPList[nGCPCount].dfGCPPixel = 0.0; + pasGCPList[nGCPCount].dfGCPLine = 0.0; + } + else + { + temp_lat = padfTransform[3] + 0.5 * padfTransform[4] + 0.5 * padfTransform[5]; + temp_long = padfTransform[0] + 0.5 * padfTransform[1]+ 0.5 * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = 0.5; + pasGCPList[nGCPCount].dfGCPLine = 0.5; + } + pasGCPList[nGCPCount].dfGCPX = temp_long; + pasGCPList[nGCPCount].dfGCPY = temp_lat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + nGCPCount++; + + if (poTransform != NULL) + { + if( !bSuccess || !poTransform->Transform( 1, &temp_long, &temp_lat ) ) + bSuccess = FALSE; + } + + if (bSuccess) + { + sprintf( szValue, "%.10f", temp_lat ); + papszGeoref = CSLSetNameValue( papszGeoref, "top_left.latitude", + szValue ); + + sprintf( szValue, "%.10f", temp_long ); + papszGeoref = CSLSetNameValue( papszGeoref, "top_left.longitude", + szValue ); + } + + /* -------------------------------------------------------------------- */ + /* top_right */ + /* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( "top_right" ); + + if (MFF2version > 1.0) + { + temp_lat = padfTransform[3] + GetRasterXSize() * padfTransform[4]; + temp_long = padfTransform[0] + GetRasterXSize() * padfTransform[1]; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize(); + pasGCPList[nGCPCount].dfGCPLine = 0.0; + } + else + { + temp_lat = padfTransform[3] + (GetRasterXSize()-0.5) * padfTransform[4] + 0.5 * padfTransform[5]; + temp_long = padfTransform[0] + (GetRasterXSize()-0.5) * padfTransform[1] + 0.5 * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize()-0.5; + pasGCPList[nGCPCount].dfGCPLine = 0.5; + } + pasGCPList[nGCPCount].dfGCPX = temp_long; + pasGCPList[nGCPCount].dfGCPY = temp_lat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + nGCPCount++; + + if (poTransform != NULL) + { + if( !bSuccess || !poTransform->Transform( 1, &temp_long, &temp_lat ) ) + bSuccess = FALSE; + } + + if (bSuccess) + { + sprintf( szValue, "%.10f", temp_lat ); + papszGeoref = CSLSetNameValue( papszGeoref, "top_right.latitude", + szValue ); + + sprintf( szValue, "%.10f", temp_long ); + papszGeoref = CSLSetNameValue( papszGeoref, "top_right.longitude", + szValue ); + } + + /* -------------------------------------------------------------------- */ + /* bottom_left */ + /* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( "bottom_left" ); + + if (MFF2version > 1.0) + { + temp_lat = padfTransform[3] + GetRasterYSize() * padfTransform[5]; + temp_long = padfTransform[0] + GetRasterYSize() * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = 0.0; + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize(); + } + else + { + temp_lat = padfTransform[3] + 0.5 * padfTransform[4] + (GetRasterYSize()-0.5) * padfTransform[5]; + temp_long = padfTransform[0] + 0.5 * padfTransform[1] + (GetRasterYSize()-0.5) * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = 0.5; + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize()-0.5; + } + pasGCPList[nGCPCount].dfGCPX = temp_long; + pasGCPList[nGCPCount].dfGCPY = temp_lat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + nGCPCount++; + + if (poTransform != NULL) + { + if( !bSuccess || !poTransform->Transform( 1, &temp_long, &temp_lat ) ) + bSuccess = FALSE; + } + + if (bSuccess) + { + sprintf( szValue, "%.10f", temp_lat ); + papszGeoref = CSLSetNameValue( papszGeoref, "bottom_left.latitude", + szValue ); + + sprintf( szValue, "%.10f", temp_long ); + papszGeoref = CSLSetNameValue( papszGeoref, "bottom_left.longitude", + szValue ); + } + + /* -------------------------------------------------------------------- */ + /* bottom_right */ + /* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( "bottom_right" ); + + if (MFF2version > 1.0) + { + temp_lat = padfTransform[3] + GetRasterXSize() * padfTransform[4] + + GetRasterYSize() * padfTransform[5]; + temp_long = padfTransform[0] + GetRasterXSize() * padfTransform[1] + + GetRasterYSize() * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize(); + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize(); + + } + else + { + temp_lat = padfTransform[3] + (GetRasterXSize()-0.5) * padfTransform[4] + + (GetRasterYSize()-0.5) * padfTransform[5]; + temp_long = padfTransform[0] + (GetRasterXSize()-0.5) * padfTransform[1] + + (GetRasterYSize()-0.5) * padfTransform[2]; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize()-0.5; + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize()-0.5; + } + pasGCPList[nGCPCount].dfGCPX = temp_long; + pasGCPList[nGCPCount].dfGCPY = temp_lat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + nGCPCount++; + + if (poTransform != NULL) + { + if( !bSuccess || !poTransform->Transform( 1, &temp_long, &temp_lat ) ) + bSuccess = FALSE; + } + + if (bSuccess) + { + sprintf( szValue, "%.10f", temp_lat ); + papszGeoref = CSLSetNameValue( papszGeoref, "bottom_right.latitude", + szValue ); + + sprintf( szValue, "%.10f", temp_long ); + papszGeoref = CSLSetNameValue( papszGeoref, "bottom_right.longitude", + szValue ); + } + + /* -------------------------------------------------------------------- */ + /* Center */ + /* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( "centre" ); + + if (MFF2version > 1.0) + { + temp_lat = padfTransform[3] + GetRasterXSize() * padfTransform[4] * 0.5 + + GetRasterYSize() * padfTransform[5] * 0.5; + temp_long = padfTransform[0] + GetRasterXSize() * padfTransform[1] * 0.5 + + GetRasterYSize() * padfTransform[2] * 0.5; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize()/2.0; + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize()/2.0; + } + else + { + temp_lat = padfTransform[3] + GetRasterXSize() * padfTransform[4] * 0.5 + + GetRasterYSize() * padfTransform[5] * 0.5; + temp_long = padfTransform[0] + GetRasterXSize() * padfTransform[1] * 0.5 + + GetRasterYSize() * padfTransform[2] * 0.5; + pasGCPList[nGCPCount].dfGCPPixel = GetRasterXSize()/2.0; + pasGCPList[nGCPCount].dfGCPLine = GetRasterYSize()/2.0; + } + pasGCPList[nGCPCount].dfGCPX = temp_long; + pasGCPList[nGCPCount].dfGCPY = temp_lat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + nGCPCount++; + + if (poTransform != NULL) + { + if( !bSuccess || !poTransform->Transform( 1, &temp_long, &temp_lat ) ) + bSuccess = FALSE; + } + + if (bSuccess) + { + sprintf( szValue, "%.10f", temp_lat ); + papszGeoref = CSLSetNameValue( papszGeoref, "centre.latitude", + szValue ); + + sprintf( szValue, "%.10f", temp_long ); + papszGeoref = CSLSetNameValue( papszGeoref, "centre.longitude", + szValue ); + } + + if (!bSuccess) + { + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- error setting header info in SetGeoTransform. Changes may not be saved properly.\n"); + } + + if (poTransform != NULL) + delete poTransform; + + + + bGeorefChanged = TRUE; + + return( CE_None ); +} + +CPLErr HKVDataset::SetGCPProjection( const char *pszNewProjection ) +{ + + CPLFree( pszGCPProjection ); + this->pszGCPProjection = CPLStrdup(pszNewProjection); + + return CE_None; +} + +/************************************************************************/ +/* SetProjection() */ +/* */ +/* We provide very limited support for setting the projection. */ +/************************************************************************/ + +CPLErr HKVDataset::SetProjection( const char * pszNewProjection ) + +{ + OGRSpatialReference *oSRS; + HKVSpheroidList *hkvEllipsoids; + double eq_radius, inv_flattening; + OGRErr ogrerrorEq=OGRERR_NONE; + OGRErr ogrerrorInvf=OGRERR_NONE; + OGRErr ogrerrorOl=OGRERR_NONE; + char *modifiableProjection = NULL; + + char *spheroid_name = NULL; + + /* This function is used to update a georef file */ + + + /* printf( "HKVDataset::SetProjection(%s)\n", pszNewProjection ); */ + + if( !EQUALN(pszNewProjection,"GEOGCS",6) + && !EQUALN(pszNewProjection,"PROJCS",6) + && !EQUAL(pszNewProjection,"") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Only OGC WKT Projections supported for writing to HKV.\n" + "%s not supported.", + pszNewProjection ); + + return CE_Failure; + } + else if (EQUAL(pszNewProjection,"")) + { + CPLFree( pszProjection ); + pszProjection = (char *) CPLStrdup(pszNewProjection); + + return CE_None; + } + CPLFree( pszProjection ); + pszProjection = (char *) CPLStrdup(pszNewProjection); + + + /* importFromWkt updates the pointer, so don't use pszNewProjection directly */ + modifiableProjection=CPLStrdup(pszNewProjection); + + oSRS = new OGRSpatialReference; + oSRS->importFromWkt(&modifiableProjection); + + if ((oSRS->GetAttrValue("PROJECTION") != NULL) && + (EQUAL(oSRS->GetAttrValue("PROJECTION"),SRS_PT_TRANSVERSE_MERCATOR))) + { + char *ol_txt; + ol_txt=(char *) CPLMalloc(255); + papszGeoref = CSLSetNameValue( papszGeoref, "projection.name", "utm" ); + sprintf(ol_txt,"%f",oSRS->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0,&ogrerrorOl)); + papszGeoref = CSLSetNameValue( papszGeoref, "projection.origin_longitude", + ol_txt ); + CPLFree(ol_txt); + } + else if ((oSRS->GetAttrValue("PROJECTION") == NULL) && (oSRS->IsGeographic())) + { + papszGeoref = CSLSetNameValue( papszGeoref, "projection.name", "LL" ); + } + else + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unrecognized projection."); + return CE_Failure; + } + eq_radius = oSRS->GetSemiMajor(&ogrerrorEq); + inv_flattening = oSRS->GetInvFlattening(&ogrerrorInvf); + if ((ogrerrorEq == OGRERR_NONE) && (ogrerrorInvf == OGRERR_NONE)) + { + hkvEllipsoids = new HKVSpheroidList; + spheroid_name = hkvEllipsoids->GetSpheroidNameByEqRadiusAndInvFlattening(eq_radius,inv_flattening); + if (spheroid_name != NULL) + { + papszGeoref = CSLSetNameValue( papszGeoref, "spheroid.name", + spheroid_name ); + } + delete hkvEllipsoids; + } + else + { + /* default to previous behaviour if spheroid not found by */ + /* radius and inverse flattening */ + + if( strstr(pszNewProjection,"Bessel") != NULL ) + { + papszGeoref = CSLSetNameValue( papszGeoref, "spheroid.name", + "ev-bessel" ); + } + else + { + papszGeoref = CSLSetNameValue( papszGeoref, "spheroid.name", + "ev-wgs-84" ); + } + } + bGeorefChanged = TRUE; + delete oSRS; + return CE_None; +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int HKVDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *HKVDataset::GetGCPProjection() + +{ + return pszGCPProjection; +} + +/************************************************************************/ +/* GetGCP() */ +/************************************************************************/ + +const GDAL_GCP *HKVDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* ProcessGeorefGCP() */ +/************************************************************************/ + +void HKVDataset::ProcessGeorefGCP( char **papszGeoref, const char *pszBase, + double dfRasterX, double dfRasterY ) + +{ + char szFieldName[128]; + double dfLat, dfLong; + +/* -------------------------------------------------------------------- */ +/* Fetch the GCP from the string list. */ +/* -------------------------------------------------------------------- */ + sprintf( szFieldName, "%s.latitude", pszBase ); + if( CSLFetchNameValue(papszGeoref, szFieldName) == NULL ) + return; + else + dfLat = atof(CSLFetchNameValue(papszGeoref, szFieldName)); + + sprintf( szFieldName, "%s.longitude", pszBase ); + if( CSLFetchNameValue(papszGeoref, szFieldName) == NULL ) + return; + else + dfLong = atof(CSLFetchNameValue(papszGeoref, szFieldName)); + +/* -------------------------------------------------------------------- */ +/* Add the gcp to the internal list. */ +/* -------------------------------------------------------------------- */ + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + + CPLFree( pasGCPList[nGCPCount].pszId ); + + pasGCPList[nGCPCount].pszId = CPLStrdup( pszBase ); + + pasGCPList[nGCPCount].dfGCPX = dfLong; + pasGCPList[nGCPCount].dfGCPY = dfLat; + pasGCPList[nGCPCount].dfGCPZ = 0.0; + + pasGCPList[nGCPCount].dfGCPPixel = dfRasterX; + pasGCPList[nGCPCount].dfGCPLine = dfRasterY; + + nGCPCount++; +} + +/************************************************************************/ +/* ProcessGeoref() */ +/************************************************************************/ + +void HKVDataset::ProcessGeoref( const char * pszFilename ) + +{ + int i; + HKVSpheroidList *hkvEllipsoids = NULL; + +/* -------------------------------------------------------------------- */ +/* Load the georef file, and boil white space away from around */ +/* the equal sign. */ +/* -------------------------------------------------------------------- */ + CSLDestroy( papszGeoref ); + papszGeoref = CSLLoad( pszFilename ); + if( papszGeoref == NULL ) + return; + + hkvEllipsoids = new HKVSpheroidList; + + for( i = 0; papszGeoref[i] != NULL; i++ ) + { + int bAfterEqual = FALSE; + int iSrc, iDst; + char *pszLine = papszGeoref[i]; + + for( iSrc=0, iDst=0; pszLine[iSrc] != '\0'; iSrc++ ) + { + if( bAfterEqual || pszLine[iSrc] != ' ' ) + { + pszLine[iDst++] = pszLine[iSrc]; + } + + if( iDst > 0 && pszLine[iDst-1] == '=' ) + bAfterEqual = FALSE; + } + pszLine[iDst] = '\0'; + } + +/* -------------------------------------------------------------------- */ +/* Try to get GCPs, in lat/longs . */ +/* -------------------------------------------------------------------- */ + nGCPCount = 0; + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),5); + + if (MFF2version > 1.0) + { + ProcessGeorefGCP( papszGeoref, "top_left", + 0, 0 ); + ProcessGeorefGCP( papszGeoref, "top_right", + GetRasterXSize(), 0 ); + ProcessGeorefGCP( papszGeoref, "bottom_left", + 0, GetRasterYSize() ); + ProcessGeorefGCP( papszGeoref, "bottom_right", + GetRasterXSize(), GetRasterYSize() ); + ProcessGeorefGCP( papszGeoref, "centre", + GetRasterXSize()/2.0, GetRasterYSize()/2.0 ); + } + else + { + ProcessGeorefGCP( papszGeoref, "top_left", + 0.5, 0.5 ); + ProcessGeorefGCP( papszGeoref, "top_right", + GetRasterXSize()-0.5, 0.5 ); + ProcessGeorefGCP( papszGeoref, "bottom_left", + 0.5, GetRasterYSize()-0.5 ); + ProcessGeorefGCP( papszGeoref, "bottom_right", + GetRasterXSize()-0.5, GetRasterYSize()-0.5 ); + ProcessGeorefGCP( papszGeoref, "centre", + GetRasterXSize()/2.0, GetRasterYSize()/2.0 ); + } + +/* -------------------------------------------------------------------- */ +/* Do we have a recognised projection? */ +/* -------------------------------------------------------------------- */ + const char *pszProjName, *pszOriginLong, *pszSpheroidName; + double eq_radius, inv_flattening; + + pszProjName = CSLFetchNameValue(papszGeoref, + "projection.name"); + pszOriginLong = CSLFetchNameValue(papszGeoref, + "projection.origin_longitude"); + pszSpheroidName = CSLFetchNameValue(papszGeoref, + "spheroid.name"); + + + if ((pszSpheroidName != NULL) && (hkvEllipsoids->SpheroidInList(pszSpheroidName))) + { + eq_radius=hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName); + inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName); + } + else if (pszProjName != NULL) + { + CPLError(CE_Warning,CPLE_AppDefined,"Warning- unrecognized ellipsoid. Using wgs-84 parameters.\n"); + eq_radius=hkvEllipsoids->GetSpheroidEqRadius("wgs-84"); + inv_flattening=hkvEllipsoids->GetSpheroidInverseFlattening("wgs-84"); + } + + if( (pszProjName != NULL) && EQUAL(pszProjName,"utm") && (nGCPCount == 5) ) + { + /*int nZone = (int)((atof(pszOriginLong)+184.5) / 6.0); */ + int nZone; + + if (pszOriginLong == NULL) + { + /* If origin not specified, assume 0.0 */ + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- no projection origin longitude specified. Assuming 0.0."); + nZone = 31; + } + else + nZone = 31 + (int) floor(atof(pszOriginLong)/6.0); + + OGRSpatialReference oUTM; + OGRSpatialReference oLL; + OGRCoordinateTransformation *poTransform = NULL; + double dfUtmX[5], dfUtmY[5]; + int gcp_index; + + int bSuccess = TRUE; + + if( pasGCPList[4].dfGCPY < 0 ) + oUTM.SetUTM( nZone, 0 ); + else + oUTM.SetUTM( nZone, 1 ); + + if (pszOriginLong != NULL) + { + oUTM.SetProjParm(SRS_PP_CENTRAL_MERIDIAN,atof(pszOriginLong)); + oLL.SetProjParm(SRS_PP_LONGITUDE_OF_ORIGIN,atof(pszOriginLong)); + } + + if ((pszSpheroidName == NULL) || (EQUAL(pszSpheroidName,"wgs-84")) || + (EQUAL(pszSpheroidName,"wgs_84"))) + { + oUTM.SetWellKnownGeogCS( "WGS84" ); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + else + { + if (hkvEllipsoids->SpheroidInList(pszSpheroidName)) + { + oUTM.SetGeogCS( "unknown","unknown",pszSpheroidName, + hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName), + hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName) + ); + oLL.SetGeogCS( "unknown","unknown",pszSpheroidName, + hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName), + hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName) + ); + } + else + { + CPLError(CE_Warning,CPLE_AppDefined,"Warning- unrecognized ellipsoid. Using wgs-84 parameters.\n"); + oUTM.SetWellKnownGeogCS( "WGS84" ); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + } + + poTransform = OGRCreateCoordinateTransformation( &oLL, &oUTM ); + if( poTransform == NULL ) + bSuccess = FALSE; + + for(gcp_index=0;gcp_index<5;gcp_index++) + { + dfUtmX[gcp_index] = pasGCPList[gcp_index].dfGCPX; + dfUtmY[gcp_index] = pasGCPList[gcp_index].dfGCPY; + + if( bSuccess && !poTransform->Transform( 1, &(dfUtmX[gcp_index]), &(dfUtmY[gcp_index]) ) ) + bSuccess = FALSE; + + } + + if( bSuccess ) + { + int transform_ok = FALSE; + + /* update GCPS to proper projection */ + for(gcp_index=0;gcp_index<5;gcp_index++) + { + pasGCPList[gcp_index].dfGCPX = dfUtmX[gcp_index]; + pasGCPList[gcp_index].dfGCPY = dfUtmY[gcp_index]; + } + + CPLFree( pszGCPProjection ); + pszGCPProjection = NULL; + oUTM.exportToWkt( &pszGCPProjection ); + + transform_ok = GDALGCPsToGeoTransform(5,pasGCPList,adfGeoTransform,0); + + CPLFree( pszProjection ); + pszProjection = NULL; + if (transform_ok == FALSE) + { + /* transform may not be sufficient in all cases (slant range projection) */ + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + pszProjection = CPLStrdup(""); + } + else + oUTM.exportToWkt( &pszProjection ); + + } + + if( poTransform != NULL ) + delete poTransform; + } + else if ((pszProjName != NULL) && (nGCPCount == 5)) + { + OGRSpatialReference oLL; + int transform_ok = FALSE; + + + if (pszOriginLong != NULL) + { + oLL.SetProjParm(SRS_PP_LONGITUDE_OF_ORIGIN,atof(pszOriginLong)); + } + + if ((pszSpheroidName == NULL) || (EQUAL(pszSpheroidName,"wgs-84")) || + (EQUAL(pszSpheroidName,"wgs_84"))) + { + oLL.SetWellKnownGeogCS( "WGS84" ); + } + else + { + if (hkvEllipsoids->SpheroidInList(pszSpheroidName)) + { + oLL.SetGeogCS( "","",pszSpheroidName, + hkvEllipsoids->GetSpheroidEqRadius(pszSpheroidName), + hkvEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName) + ); + } + else + { + CPLError(CE_Warning,CPLE_AppDefined,"Warning- unrecognized ellipsoid. Using wgs-84 parameters.\n"); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + } + + transform_ok = GDALGCPsToGeoTransform(5,pasGCPList,adfGeoTransform,0); + + CPLFree( pszProjection ); + pszProjection = NULL; + + if (transform_ok == FALSE) + { + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + } + else + { + oLL.exportToWkt( &pszProjection ); + } + + CPLFree( pszGCPProjection ); + pszGCPProjection = NULL; + oLL.exportToWkt( &pszGCPProjection ); + + } + + delete hkvEllipsoids; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *HKVDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i, bNoDataSet = FALSE; + double dfNoDataValue = 0.0; + char **papszAttrib; + const char *pszFilename, *pszValue; + VSIStatBuf sStat; + +/* -------------------------------------------------------------------- */ +/* We assume the dataset is passed as a directory. Check for */ +/* an attrib and blob file as a minimum. */ +/* -------------------------------------------------------------------- */ + if( !poOpenInfo->bIsDirectory ) + return NULL; + + pszFilename = CPLFormFilename(poOpenInfo->pszFilename, "image_data", NULL); + if( VSIStat(pszFilename,&sStat) != 0 ) + pszFilename = CPLFormFilename(poOpenInfo->pszFilename, "blob", NULL ); + if( VSIStat(pszFilename,&sStat) != 0 ) + return NULL; + + pszFilename = CPLFormFilename(poOpenInfo->pszFilename, "attrib", NULL ); + if( VSIStat(pszFilename,&sStat) != 0 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Load the attrib file, and boil white space away from around */ +/* the equal sign. */ +/* -------------------------------------------------------------------- */ + papszAttrib = CSLLoad( pszFilename ); + if( papszAttrib == NULL ) + return NULL; + + for( i = 0; papszAttrib[i] != NULL; i++ ) + { + int bAfterEqual = FALSE; + int iSrc, iDst; + char *pszLine = papszAttrib[i]; + + for( iSrc=0, iDst=0; pszLine[iSrc] != '\0'; iSrc++ ) + { + if( bAfterEqual || pszLine[iSrc] != ' ' ) + { + pszLine[iDst++] = pszLine[iSrc]; + } + + if( iDst > 0 && pszLine[iDst-1] == '=' ) + bAfterEqual = FALSE; + } + pszLine[iDst] = '\0'; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + HKVDataset *poDS; + + poDS = new HKVDataset(); + + poDS->pszPath = CPLStrdup( poOpenInfo->pszFilename ); + poDS->papszAttrib = papszAttrib; + +/* -------------------------------------------------------------------- */ +/* Set some dataset wide information. */ +/* -------------------------------------------------------------------- */ + int bNative, bComplex; + int nRawBands = 0; + + if( CSLFetchNameValue( papszAttrib, "extent.cols" ) == NULL + || CSLFetchNameValue( papszAttrib, "extent.rows" ) == NULL ) + return NULL; + + poDS->RasterInitialize( + atoi(CSLFetchNameValue(papszAttrib,"extent.cols")), + atoi(CSLFetchNameValue(papszAttrib,"extent.rows")) ); + + pszValue = CSLFetchNameValue(papszAttrib,"pixel.order"); + if( pszValue == NULL ) + bNative = TRUE; + else + { +#ifdef CPL_MSB + bNative = (strstr(pszValue,"*msbf") != NULL); +#else + bNative = (strstr(pszValue,"*lsbf") != NULL); +#endif + } + + pszValue = CSLFetchNameValue(papszAttrib,"pixel.no_data"); + if( pszValue != NULL ) + { + bNoDataSet = TRUE; + dfNoDataValue = atof(pszValue); + } + + pszValue = CSLFetchNameValue(papszAttrib,"channel.enumeration"); + if( pszValue != NULL ) + nRawBands = atoi(pszValue); + else + nRawBands = 1; + + pszValue = CSLFetchNameValue(papszAttrib,"pixel.field"); + if( pszValue != NULL && strstr(pszValue,"*complex") != NULL ) + bComplex = TRUE; + else + bComplex = FALSE; + + /* Get the version number, if present (if not, assume old version. */ + /* Versions differ in their interpretation of corner coordinates. */ + + if (CSLFetchNameValue( papszAttrib, "version" ) != NULL) + poDS->SetVersion((float) + atof(CSLFetchNameValue(papszAttrib, "version"))); + else + poDS->SetVersion(1.0); + +/* -------------------------------------------------------------------- */ +/* Figure out the datatype */ +/* -------------------------------------------------------------------- */ + const char * pszEncoding; + int nSize = 1; + int nPseudoBands; + GDALDataType eType; + + pszEncoding = CSLFetchNameValue(papszAttrib,"pixel.encoding"); + if( pszEncoding == NULL ) + pszEncoding = "{ *unsigned }"; + + if( CSLFetchNameValue(papszAttrib,"pixel.size") != NULL ) + nSize = atoi(CSLFetchNameValue(papszAttrib,"pixel.size"))/8; + + if( bComplex ) + nPseudoBands = 2; + else + nPseudoBands = 1; + + if( nSize == 1 ) + eType = GDT_Byte; + else if( nSize == 2 && strstr(pszEncoding,"*unsigned") != NULL ) + eType = GDT_UInt16; + else if( nSize == 4 && bComplex ) + eType = GDT_CInt16; + else if( nSize == 2 ) + eType = GDT_Int16; + else if( nSize == 4 && strstr(pszEncoding,"*unsigned") != NULL ) + eType = GDT_UInt32; + else if( nSize == 8 && strstr(pszEncoding,"*two") != NULL && bComplex ) + eType = GDT_CInt32; + else if( nSize == 4 && strstr(pszEncoding,"*two") != NULL ) + eType = GDT_Int32; + else if( nSize == 8 && bComplex ) + eType = GDT_CFloat32; + else if( nSize == 4 ) + eType = GDT_Float32; + else if( nSize == 16 && bComplex ) + eType = GDT_CFloat64; + else if( nSize == 8 ) + eType = GDT_Float64; + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unsupported pixel data type in %s.\n" + "pixel.size=%d pixel.encoding=%s\n", + poDS->pszPath, nSize, pszEncoding ); + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Open the blob file. */ +/* -------------------------------------------------------------------- */ + pszFilename = CPLFormFilename(poDS->pszPath, "image_data", NULL ); + if( VSIStat(pszFilename,&sStat) != 0 ) + pszFilename = CPLFormFilename(poDS->pszPath, "blob", NULL ); + if( poOpenInfo->eAccess == GA_ReadOnly ) + { + poDS->fpBlob = VSIFOpenL( pszFilename, "rb" ); + if( poDS->fpBlob == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open file %s for read access.\n", + pszFilename ); + delete poDS; + return NULL; + } + } + else + { + poDS->fpBlob = VSIFOpenL( pszFilename, "rb+" ); + if( poDS->fpBlob == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open file %s for update access.\n", + pszFilename ); + delete poDS; + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Build the overview filename, as blob file = "_ovr". */ +/* -------------------------------------------------------------------- */ + char *pszOvrFilename = (char *) CPLMalloc(strlen(pszFilename)+5); + + sprintf( pszOvrFilename, "%s_ovr", pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Define the bands. */ +/* -------------------------------------------------------------------- */ + int nPixelOffset, nLineOffset, nOffset; + + nPixelOffset = nRawBands * nSize; + nLineOffset = nPixelOffset * poDS->GetRasterXSize(); + nOffset = 0; + + for( int iRawBand=0; iRawBand < nRawBands; iRawBand++ ) + { + HKVRasterBand *poBand; + + poBand = + new HKVRasterBand( poDS, poDS->GetRasterCount()+1, poDS->fpBlob, + nOffset, nPixelOffset, nLineOffset, + eType, bNative ); + poDS->SetBand( poDS->GetRasterCount()+1, poBand ); + nOffset += GDALGetDataTypeSize( eType ) / 8; + + if( bNoDataSet ) + poBand->StoreNoDataValue( dfNoDataValue ); + } + + poDS->eRasterType = eType; + +/* -------------------------------------------------------------------- */ +/* Process the georef file if there is one. */ +/* -------------------------------------------------------------------- */ + pszFilename = CPLFormFilename(poDS->pszPath, "georef", NULL ); + if( VSIStat(pszFilename,&sStat) == 0 ) + poDS->ProcessGeoref(pszFilename); + +/* -------------------------------------------------------------------- */ +/* Handle overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, pszOvrFilename, TRUE ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( pszOvrFilename ); + poDS->TryLoadXML(); + + CPLFree( pszOvrFilename ); + + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *HKVDataset::Create( const char * pszFilenameIn, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** /* papszParmList */ ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte && eType != GDT_Float32 + && eType != GDT_UInt16 && eType != GDT_Int16 + && eType != GDT_CInt16 && eType != GDT_CInt32 + && eType != GDT_CFloat32 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create HKV file with currently unsupported\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Establish the name of the directory we will be creating the */ +/* new HKV directory in. Verify that this is a directory. */ +/* -------------------------------------------------------------------- */ + char *pszBaseDir; + VSIStatBuf sStat; + + if( strlen(CPLGetPath(pszFilenameIn)) == 0 ) + pszBaseDir = CPLStrdup("."); + else + pszBaseDir = CPLStrdup(CPLGetPath(pszFilenameIn)); + + if( CPLStat( pszBaseDir, &sStat ) != 0 || !VSI_ISDIR( sStat.st_mode ) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create HKV dataset under %s,\n" + "but this is not a valid directory.\n", + pszBaseDir); + CPLFree( pszBaseDir ); + return NULL; + } + + if( VSIMkdir( pszFilenameIn, 0755 ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to create directory %s.\n", + pszFilenameIn ); + return NULL; + } + + CPLFree( pszBaseDir ); + +/* -------------------------------------------------------------------- */ +/* Create the header file. */ +/* -------------------------------------------------------------------- */ + CPLErr CEHeaderCreated; + + CEHeaderCreated = SaveHKVAttribFile( pszFilenameIn, nXSize, nYSize, + nBands, eType, FALSE, 0.0 ); + + if (CEHeaderCreated != CE_None ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create the blob file. */ +/* -------------------------------------------------------------------- */ + + FILE *fp; + const char *pszFilename; + + pszFilename = CPLFormFilename( pszFilenameIn, "image_data", NULL ); + fp = VSIFOpen( pszFilename, "wb" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Couldn't create %s.\n", pszFilename ); + return NULL; + } + + VSIFWrite( (void*)"", 1, 1, fp ); + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Open the dataset normally. */ +/* -------------------------------------------------------------------- */ + return (GDALDataset *) GDALOpen( pszFilenameIn, GA_Update ); +} + +/************************************************************************/ +/* Delete() */ +/* */ +/* An HKV Blob dataset consists of a bunch of files in a */ +/* directory. Try to delete all the files, then the */ +/* directory. */ +/************************************************************************/ + +CPLErr HKVDataset::Delete( const char * pszName ) + +{ + VSIStatBuf sStat; + char **papszFiles; + int i; + + if( CPLStat( pszName, &sStat ) != 0 + || !VSI_ISDIR(sStat.st_mode) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s does not appear to be an HKV Dataset, as it is not\n" + "a path to a directory.", + pszName ); + return CE_Failure; + } + + papszFiles = CPLReadDir( pszName ); + for( i = 0; i < CSLCount(papszFiles); i++ ) + { + const char *pszTarget; + + if( EQUAL(papszFiles[i],".") || EQUAL(papszFiles[i],"..") ) + continue; + + pszTarget = CPLFormFilename(pszName, papszFiles[i], NULL ); + if( VSIUnlink(pszTarget) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to delete file %s,\n" + "HKVDataset Delete(%s) failed.\n", + pszTarget, + pszName ); + CSLDestroy( papszFiles ); + return CE_Failure; + } + } + + CSLDestroy( papszFiles ); + + if( VSIRmdir( pszName ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to delete directory %s,\n" + "HKVDataset Delete() failed.\n", + pszName ); + return CE_Failure; + } + + return CE_None; +} + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +GDALDataset * +HKVDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + HKVDataset *poDS; + GDALDataType eType = poSrcDS->GetRasterBand(1)->GetRasterDataType(); + int iBand; + + if( !pfnProgress( 0.0, NULL, pProgressData ) ) + return NULL; + + /* check that other bands match type- sets type */ + /* to unknown if they differ. */ + for( iBand = 1; iBand < poSrcDS->GetRasterCount(); iBand++ ) + { + GDALRasterBand *poBand = poSrcDS->GetRasterBand( iBand+1 ); + eType = GDALDataTypeUnion( eType, poBand->GetRasterDataType() ); + } + + poDS = (HKVDataset *) Create( pszFilename, + poSrcDS->GetRasterXSize(), + poSrcDS->GetRasterYSize(), + poSrcDS->GetRasterCount(), + eType, papszOptions ); + + /* Check that Create worked- return Null if it didn't */ + if (poDS == NULL) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Copy the image data. */ +/* -------------------------------------------------------------------- */ + int nXSize = poDS->GetRasterXSize(); + int nYSize = poDS->GetRasterYSize(); + int nBlockXSize, nBlockYSize, nBlockTotal, nBlocksDone; + + poDS->GetRasterBand(1)->GetBlockSize( &nBlockXSize, &nBlockYSize ); + + nBlockTotal = ((nXSize + nBlockXSize - 1) / nBlockXSize) + * ((nYSize + nBlockYSize - 1) / nBlockYSize) + * poSrcDS->GetRasterCount(); + + nBlocksDone = 0; + for( iBand = 0; iBand < poSrcDS->GetRasterCount(); iBand++ ) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 ); + GDALRasterBand *poDstBand = poDS->GetRasterBand( iBand+1 ); + int iYOffset, iXOffset; + void *pData; + CPLErr eErr; + int pbSuccess; + double dfSrcNoDataValue =0.0; + + /* Get nodata value, if relevant */ + dfSrcNoDataValue = poSrcBand->GetNoDataValue( &pbSuccess ); + if ( pbSuccess ) + poDS->SetNoDataValue( dfSrcNoDataValue ); + + pData = CPLMalloc(nBlockXSize * nBlockYSize + * GDALGetDataTypeSize(eType) / 8); + + for( iYOffset = 0; iYOffset < nYSize; iYOffset += nBlockYSize ) + { + for( iXOffset = 0; iXOffset < nXSize; iXOffset += nBlockXSize ) + { + int nTBXSize, nTBYSize; + + if( !pfnProgress( (nBlocksDone++) / (float) nBlockTotal, + NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poHKVDriver = + (GDALDriver *) GDALGetDriverByName( "MFF2" ); + poHKVDriver->Delete( pszFilename ); + return NULL; + } + + nTBXSize = MIN(nBlockXSize,nXSize-iXOffset); + nTBYSize = MIN(nBlockYSize,nYSize-iYOffset); + + eErr = poSrcBand->RasterIO( GF_Read, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + if( eErr != CE_None ) + { + return NULL; + } + + eErr = poDstBand->RasterIO( GF_Write, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + + if( eErr != CE_None ) + { + return NULL; + } + } + } + + CPLFree( pData ); + } + +/* -------------------------------------------------------------------- */ +/* Copy georeferencing information, if enough is available. */ +/* Only copy geotransform-style info (won't work for slant range). */ +/* -------------------------------------------------------------------- */ + + double *tempGeoTransform=NULL; + + tempGeoTransform = (double *) CPLMalloc(6*sizeof(double)); + + if (( poSrcDS->GetGeoTransform( tempGeoTransform ) == CE_None) + && (tempGeoTransform[0] != 0.0 || tempGeoTransform[1] != 1.0 + || tempGeoTransform[2] != 0.0 || tempGeoTransform[3] != 0.0 + || tempGeoTransform[4] != 0.0 || ABS(tempGeoTransform[5]) != 1.0 )) + { + + poDS->SetGCPProjection(poSrcDS->GetProjectionRef()); + poDS->SetProjection(poSrcDS->GetProjectionRef()); + poDS->SetGeoTransform(tempGeoTransform); + + CPLFree(tempGeoTransform); + + /* georef file will be saved automatically when dataset is deleted */ + /* because SetProjection sets a flag to indicate it's necessary. */ + + } + else + { + CPLFree(tempGeoTransform); + } + + /* Make sure image data gets flushed */ + for( iBand = 0; iBand < poDS->GetRasterCount(); iBand++ ) + { + RawRasterBand *poDstBand = (RawRasterBand *) poDS->GetRasterBand( iBand+1 ); + poDstBand->FlushCache(); + } + + + if( !pfnProgress( 1.0, NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poHKVDriver = + (GDALDriver *) GDALGetDriverByName( "MFF2" ); + poHKVDriver->Delete( pszFilename ); + return NULL; + } + + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + + +/************************************************************************/ +/* GDALRegister_HKV() */ +/************************************************************************/ + +void GDALRegister_HKV() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "MFF2" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "MFF2" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Vexcel MFF2 (HKV) Raster" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_mff2.html" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Int32 UInt32 CInt16 CInt32 Float32 Float64 CFloat32 CFloat64" ); + + poDriver->pfnOpen = HKVDataset::Open; + poDriver->pfnCreate = HKVDataset::Create; + poDriver->pfnDelete = HKVDataset::Delete; + poDriver->pfnCreateCopy = HKVDataset::CreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/raw/idadataset.cpp b/Utilities/GDAL/frmts/raw/idadataset.cpp new file mode 100644 index 0000000000..9afc1c2af9 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/idadataset.cpp @@ -0,0 +1,979 @@ +/****************************************************************************** + * $Id: idadataset.cpp,v 1.9 2005/09/14 01:12:00 fwarmerdam Exp $ + * + * Project: IDA Raster Driver + * Purpose: Implemenents IDA driver/dataset/rasterband. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: idadataset.cpp,v $ + * Revision 1.9 2005/09/14 01:12:00 fwarmerdam + * Fixed creation data types and help link. + * + * Revision 1.8 2005/08/23 16:21:25 fwarmerdam + * Fixed help link, dont barf in open if fp null. + * + * Revision 1.7 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.6 2005/02/08 20:22:39 fwarmerdam + * Added SetProjection support. + * + * Revision 1.5 2005/01/15 16:11:12 fwarmerdam + * lots of work on create support + * + * Revision 1.4 2005/01/04 22:14:33 fwarmerdam + * Nailed down open checking fairly closely. + * + * Revision 1.3 2004/12/26 21:25:36 fwarmerdam + * avoid spurious opens + * + * Revision 1.2 2004/12/26 17:37:46 fwarmerdam + * fix unix/dos format + * + * Revision 1.1 2004/12/26 16:17:00 fwarmerdam + * New + * + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: idadataset.cpp,v 1.9 2005/09/14 01:12:00 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_IDA(void); +CPL_C_END + +// convert a Turbo Pascal real into a double +static double tp2c(GByte *r); + +// convert a double into a Turbo Pascal real +static void c2tp(double n, GByte *r); + +/************************************************************************/ +/* ==================================================================== */ +/* IDADataset */ +/* ==================================================================== */ +/************************************************************************/ + +class IDADataset : public RawDataset +{ + friend class IDARasterBand; + + int nImageType; + int nProjection; + char szTitle[81]; + double dfLatCenter; + double dfLongCenter; + double dfXCenter; + double dfYCenter; + double dfDX; + double dfDY; + double dfParallel1; + double dfParallel2; + int nLower; + int nUpper; + int nMissing; + double dfM; + double dfB; + int nDecimals; + + FILE *fpRaw; + + char *pszProjection; + double adfGeoTransform[6]; + + void ProcessGeoref(); + + GByte abyHeader[512]; + int bHeaderDirty; + + public: + IDADataset(); + ~IDADataset(); + + virtual void FlushCache(); + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** /* papszParmList */ ); + +}; + +/************************************************************************/ +/* ==================================================================== */ +/* IDARasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class IDARasterBand : public RawRasterBand +{ + friend class IDADataset; + + public: + IDARasterBand( IDADataset *poDSIn, FILE *fpRaw, int nXSize ); + virtual ~IDARasterBand(); + + virtual double GetOffset( int *pbSuccess = NULL ); + virtual CPLErr SetOffset( double dfNewValue ); + virtual double GetScale( int *pbSuccess = NULL ); + virtual CPLErr SetScale( double dfNewValue ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); +}; + +/************************************************************************/ +/* IDARasterBand */ +/************************************************************************/ + +IDARasterBand::IDARasterBand( IDADataset *poDSIn, + FILE *fpRaw, int nXSize ) + : RawRasterBand( poDSIn, 1, fpRaw, 512, 1, nXSize, + GDT_Byte, FALSE, FALSE ) + +{ +} + +/************************************************************************/ +/* ~IDARasterBand() */ +/************************************************************************/ + +IDARasterBand::~IDARasterBand() + +{ +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double IDARasterBand::GetNoDataValue( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + return ((IDADataset *) poDS)->nMissing; +} + +/************************************************************************/ +/* GetOffset() */ +/************************************************************************/ + +double IDARasterBand::GetOffset( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + return ((IDADataset *) poDS)->dfB; +} + +/************************************************************************/ +/* SetOffset() */ +/************************************************************************/ + +CPLErr IDARasterBand::SetOffset( double dfNewValue ) + +{ + IDADataset *poIDS = (IDADataset *) poDS; + + if( dfNewValue == poIDS->dfB ) + return CE_None; + + if( poIDS->nImageType != 200 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Setting explicit offset only support for image type 200."); + return CE_Failure; + } + + poIDS->dfB = dfNewValue; + c2tp( dfNewValue, poIDS->abyHeader + 178 ); + poIDS->bHeaderDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* GetScale() */ +/************************************************************************/ + +double IDARasterBand::GetScale( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + return ((IDADataset *) poDS)->dfM; +} + +/************************************************************************/ +/* SetScale() */ +/************************************************************************/ + +CPLErr IDARasterBand::SetScale( double dfNewValue ) + +{ + IDADataset *poIDS = (IDADataset *) poDS; + + if( dfNewValue == poIDS->dfM ) + return CE_None; + + if( poIDS->nImageType != 200 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Setting explicit scale only support for image type 200."); + return CE_Failure; + } + + poIDS->dfM = dfNewValue; + c2tp( dfNewValue, poIDS->abyHeader + 172 ); + poIDS->bHeaderDirty = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* ==================================================================== */ +/* IDADataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* IDADataset() */ +/************************************************************************/ + +IDADataset::IDADataset() +{ + fpRaw = NULL; + pszProjection = 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; + + bHeaderDirty = FALSE; +} + +/************************************************************************/ +/* ~IDADataset() */ +/************************************************************************/ + +IDADataset::~IDADataset() + +{ + FlushCache(); + + if( fpRaw != NULL ) + VSIFClose( fpRaw ); + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* ProcessGeoref() */ +/************************************************************************/ + +void IDADataset::ProcessGeoref() + +{ + OGRSpatialReference oSRS; + + if( nProjection == 3 ) + { + oSRS.SetWellKnownGeogCS( "WGS84" ); + } + else if( nProjection == 4 ) + { + oSRS.SetLCC( dfParallel1, dfParallel2, + dfLatCenter, dfLongCenter, + 0.0, 0.0 ); + oSRS.SetGeogCS( "Clarke 1866", "Clarke 1866", "Clarke 1866", + 6378206.4, 293.97869821389662 ); + } + else if( nProjection == 6 ) + { + oSRS.SetLAEA( dfLatCenter, dfLongCenter, 0.0, 0.0 ); + oSRS.SetGeogCS( "Sphere", "Sphere", "Sphere", + 6370997.0, 0.0 ); + } + else if( nProjection == 8 ) + { + oSRS.SetACEA( dfParallel1, dfParallel2, + dfLatCenter, dfLongCenter, + 0.0, 0.0 ); + oSRS.SetGeogCS( "Clarke 1866", "Clarke 1866", "Clarke 1866", + 6378206.4, 293.97869821389662 ); + } + else if( nProjection == 9 ) + { + oSRS.SetGH( dfLongCenter, 0.0, 0.0 ); + oSRS.SetGeogCS( "Sphere", "Sphere", "Sphere", + 6370997.0, 0.0 ); + } + + if( oSRS.GetRoot() != NULL ) + { + CPLFree( pszProjection ); + pszProjection = NULL; + + oSRS.exportToWkt( &pszProjection ); + } + + adfGeoTransform[0] = 0 - dfDX * dfXCenter; + adfGeoTransform[1] = dfDX; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = dfDY * dfYCenter; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = -dfDY; + + if( nProjection == 3 ) + { + adfGeoTransform[0] += dfLongCenter; + adfGeoTransform[3] += dfLatCenter; + } +} + +/************************************************************************/ +/* FlushCache() */ +/************************************************************************/ + +void IDADataset::FlushCache() + +{ + RawDataset::FlushCache(); + + if( bHeaderDirty ) + { + VSIFSeek( fpRaw, 0, SEEK_SET ); + VSIFWrite( abyHeader, 512, 1, fpRaw ); + bHeaderDirty = FALSE; + } +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr IDADataset::GetGeoTransform( double *padfGeoTransform ) + +{ + memcpy( padfGeoTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr IDADataset::SetGeoTransform( double *padfGeoTransform ) + +{ + if( padfGeoTransform[2] != 0.0 || padfGeoTransform[4] != 0.0 ) + return GDALPamDataset::SetGeoTransform( padfGeoTransform ); + + memcpy( adfGeoTransform, padfGeoTransform, sizeof(double) * 6 ); + bHeaderDirty = TRUE; + + dfDX = adfGeoTransform[1]; + dfDY = -adfGeoTransform[5]; + dfXCenter = -adfGeoTransform[0] / dfDX; + dfYCenter = adfGeoTransform[3] / dfDY; + + c2tp( dfDX, abyHeader + 144 ); + c2tp( dfDY, abyHeader + 150 ); + c2tp( dfXCenter, abyHeader + 132 ); + c2tp( dfYCenter, abyHeader + 138 ); + + return CE_None; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *IDADataset::GetProjectionRef() + +{ + if( pszProjection ) + return pszProjection; + else + return ""; +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr IDADataset::SetProjection( const char *pszWKTIn ) + +{ + OGRSpatialReference oSRS; + + oSRS.importFromWkt( (char **) &pszWKTIn ); + + if( !oSRS.IsGeographic() && !oSRS.IsProjected() ) + GDALPamDataset::SetProjection( pszWKTIn ); + +/* -------------------------------------------------------------------- */ +/* Clear projection parameters. */ +/* -------------------------------------------------------------------- */ + dfParallel1 = 0.0; + dfParallel2 = 0.0; + dfLatCenter = 0.0; + dfLongCenter = 0.0; + +/* -------------------------------------------------------------------- */ +/* Geographic. */ +/* -------------------------------------------------------------------- */ + if( oSRS.IsGeographic() ) + { + // If no change, just return. + if( nProjection == 3 ) + return CE_None; + + nProjection = 3; + } + +/* -------------------------------------------------------------------- */ +/* Verify we don't have a false easting or northing as these */ +/* will be ignored for the projections we do support. */ +/* -------------------------------------------------------------------- */ + if( oSRS.GetProjParm( SRS_PP_FALSE_EASTING ) != 0.0 + || oSRS.GetProjParm( SRS_PP_FALSE_NORTHING ) != 0.0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to set a projection on an IDA file with a non-zero\n" + "false easting and/or northing. This is not supported." ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Lambert Conformal Conic. Note that we don't support false */ +/* eastings or nothings. */ +/* -------------------------------------------------------------------- */ + const char *pszProjection = oSRS.GetAttrValue( "PROJECTION" ); + + if( pszProjection == NULL ) + { + /* do nothing - presumably geographic */; + } + else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ) + { + nProjection = 4; + dfParallel1 = oSRS.GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0); + dfParallel2 = oSRS.GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0); + dfLatCenter = oSRS.GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0); + dfLongCenter = oSRS.GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0); + } + else if( EQUAL(pszProjection,SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) ) + { + nProjection = 6; + dfLatCenter = oSRS.GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0); + dfLongCenter = oSRS.GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0); + } + else if( EQUAL(pszProjection,SRS_PT_ALBERS_CONIC_EQUAL_AREA) ) + { + nProjection = 8; + dfParallel1 = oSRS.GetNormProjParm(SRS_PP_STANDARD_PARALLEL_1,0.0); + dfParallel2 = oSRS.GetNormProjParm(SRS_PP_STANDARD_PARALLEL_2,0.0); + dfLatCenter = oSRS.GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0); + dfLongCenter = oSRS.GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0); + } + else if( EQUAL(pszProjection,SRS_PT_GOODE_HOMOLOSINE) ) + { + nProjection = 9; + dfLongCenter = oSRS.GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0); + } + else + { + return GDALPamDataset::SetProjection( pszWKTIn ); + } + +/* -------------------------------------------------------------------- */ +/* Update header and mark it as dirty. */ +/* -------------------------------------------------------------------- */ + bHeaderDirty = TRUE; + + abyHeader[23] = nProjection; + c2tp( dfLatCenter, abyHeader + 120 ); + c2tp( dfLongCenter, abyHeader + 126 ); + c2tp( dfParallel1, abyHeader + 156 ); + c2tp( dfParallel2, abyHeader + 162 ); + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *IDADataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Is this an IDA file? */ +/* -------------------------------------------------------------------- */ + int nXSize, nYSize; + GIntBig nExpectedFileSize, nActualFileSize; + + if( poOpenInfo->fp == NULL ) + return NULL; + + if( poOpenInfo->nHeaderBytes < 512 ) + return NULL; + + // projection legal? + if( poOpenInfo->pabyHeader[23] > 10 ) + return NULL; + + // imagetype legal? + if( (poOpenInfo->pabyHeader[22] > 14 + && poOpenInfo->pabyHeader[22] < 100) + || (poOpenInfo->pabyHeader[22] > 114 + && poOpenInfo->pabyHeader[22] != 200 ) ) + return NULL; + + nXSize = poOpenInfo->pabyHeader[30] + poOpenInfo->pabyHeader[31] * 256; + nYSize = poOpenInfo->pabyHeader[32] + poOpenInfo->pabyHeader[33] * 256; + + if( nXSize == 0 || nYSize == 0 ) + return NULL; + + // The file just be exactly the image size + header size in length. + nExpectedFileSize = nXSize * nYSize + 512; + + VSIFSeek( poOpenInfo->fp, 0, SEEK_END ); + nActualFileSize = VSIFTell( poOpenInfo->fp ); + VSIRewind( poOpenInfo->fp ); + + if( nActualFileSize != nExpectedFileSize ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create the dataset. */ +/* -------------------------------------------------------------------- */ + IDADataset *poDS = new IDADataset(); + + memcpy( poDS->abyHeader, poOpenInfo->pabyHeader, 512 ); + +/* -------------------------------------------------------------------- */ +/* Parse various values out of the header. */ +/* -------------------------------------------------------------------- */ + poDS->nImageType = poOpenInfo->pabyHeader[22]; + poDS->nProjection = poOpenInfo->pabyHeader[23]; + + poDS->nRasterYSize = poOpenInfo->pabyHeader[30] + + poOpenInfo->pabyHeader[31] * 256; + poDS->nRasterXSize = poOpenInfo->pabyHeader[32] + + poOpenInfo->pabyHeader[33] * 256; + + strncpy( poDS->szTitle, (const char *) poOpenInfo->pabyHeader+38, 80 ); + poDS->szTitle[80] = '\0'; + + int nLastTitleChar = strlen(poDS->szTitle)-1; + while( nLastTitleChar > -1 + && (poDS->szTitle[nLastTitleChar] == 10 + || poDS->szTitle[nLastTitleChar] == 13 + || poDS->szTitle[nLastTitleChar] == ' ') ) + poDS->szTitle[nLastTitleChar--] = '\0'; + + poDS->dfLatCenter = tp2c( poOpenInfo->pabyHeader + 120 ); + poDS->dfLongCenter = tp2c( poOpenInfo->pabyHeader + 126 ); + poDS->dfXCenter = tp2c( poOpenInfo->pabyHeader + 132 ); + poDS->dfYCenter = tp2c( poOpenInfo->pabyHeader + 138 ); + poDS->dfDX = tp2c( poOpenInfo->pabyHeader + 144 ); + poDS->dfDY = tp2c( poOpenInfo->pabyHeader + 150 ); + poDS->dfParallel1 = tp2c( poOpenInfo->pabyHeader + 156 ); + poDS->dfParallel2 = tp2c( poOpenInfo->pabyHeader + 162 ); + + poDS->ProcessGeoref(); + + poDS->SetMetadataItem( "TITLE", poDS->szTitle ); + +/* -------------------------------------------------------------------- */ +/* Handle various image types. */ +/* -------------------------------------------------------------------- */ + +/* +GENERIC = 0 +FEW S NDVI = 1 +EROS NDVI = 6 +ARTEMIS CUTOFF = 10 +ARTEMIS RECODE = 11 +ARTEMIS NDVI = 12 +ARTEMIS FEWS = 13 +ARTEMIS NEWNASA = 14 +GENERIC DIFF = 100 +FEW S NDVI DIFF = 101 +EROS NDVI DIFF = 106 +ARTEMIS CUTOFF DIFF = 110 +ARTEMIS RECODE DIFF = 111 +ARTEMIS NDVI DIFF = 112 +ARTEMIS FEWS DIFF = 113 +ARTEMIS NEWNASA DIFF = 114 +CALCULATED =200 +*/ + + poDS->nMissing = 0; + + switch( poDS->nImageType ) + { + case 1: + poDS->SetMetadataItem( "IMAGETYPE", "1, FEWS NDVI" ); + poDS->dfM = 1/256.0; + poDS->dfB = -82/256.0; + break; + + case 6: + poDS->SetMetadataItem( "IMAGETYPE", "6, EROS NDVI" ); + poDS->dfM = 1/100.0; + poDS->dfB = -100/100.0; + break; + + case 10: + poDS->SetMetadataItem( "IMAGETYPE", "10, ARTEMIS CUTOFF" ); + poDS->dfM = 1.0; + poDS->dfB = 0.0; + poDS->nMissing = 254; + break; + + case 11: + poDS->SetMetadataItem( "IMAGETYPE", "11, ARTEMIS RECODE" ); + poDS->dfM = 4.0; + poDS->dfB = 0.0; + poDS->nMissing = 254; + break; + + case 12: /* ANDVI */ + poDS->SetMetadataItem( "IMAGETYPE", "12, ARTEMIS NDVI" ); + poDS->dfM = 4/500.0; + poDS->dfB = -3/500.0 - 1.0; + poDS->nMissing = 254; + break; + + case 13: /* AFEWS */ + poDS->SetMetadataItem( "IMAGETYPE", "13, ARTEMIS FEWS" ); + poDS->dfM = 1/256.0; + poDS->dfB = -82/256.0; + poDS->nMissing = 254; + break; + + case 14: /* NEWNASA */ + poDS->SetMetadataItem( "IMAGETYPE", "13, ARTEMIS NEWNASA" ); + poDS->dfM = 0.75/250.0; + poDS->dfB = 0.0; + poDS->nMissing = 254; + break; + + case 101: /* NDVI_DIFF (FEW S) */ + poDS->dfM = 1/128.0; + poDS->dfB = -1.0; + poDS->nMissing = 0; + break; + + case 106: /* EROS_DIFF */ + poDS->dfM = 1/50.0; + poDS->dfB = -128/50.0; + poDS->nMissing = 0; + break; + + case 110: /* CUTOFF_DIFF */ + poDS->dfM = 2.0; + poDS->dfB = -128*2; + poDS->nMissing = 254; + break; + + case 111: /* RECODE_DIFF */ + poDS->dfM = 8; + poDS->dfB = -128*8; + poDS->nMissing = 254; + break; + + case 112: /* ANDVI_DIFF */ + poDS->dfM = 8/1000.0; + poDS->dfB = (-128*8)/1000.0; + poDS->nMissing = 254; + break; + + case 113: /* AFEWS_DIFF */ + poDS->dfM = 1/128.0; + poDS->dfB = -1; + poDS->nMissing = 254; + break; + + case 114: /* NEWNASA_DIFF */ + poDS->dfM = 0.75/125.0; + poDS->dfB = -128*poDS->dfM; + poDS->nMissing = 254; + break; + + case 200: + /* we use the values from the header */ + poDS->dfM = tp2c( poOpenInfo->pabyHeader + 171 ); + poDS->dfB = tp2c( poOpenInfo->pabyHeader + 177 ); + poDS->nMissing = poOpenInfo->pabyHeader[170]; + break; + + default: + poDS->dfM = 1.0; + poDS->dfB = 0.0; + break; + } + +/* -------------------------------------------------------------------- */ +/* Create the band. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_ReadOnly ) + { + poDS->fpRaw = poOpenInfo->fp; + poOpenInfo->fp = NULL; + } + else + { + poDS->fpRaw = VSIFOpen( poOpenInfo->pszFilename, "rb+" ); + poDS->eAccess = GA_Update; + if( poDS->fpRaw == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open %s for write access.", + poOpenInfo->pszFilename ); + return NULL; + } + } + + poDS->SetBand( 1, new IDARasterBand( poDS, poDS->fpRaw, + poDS->nRasterXSize ) ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* tp2c() */ +/* */ +/* convert a Turbo Pascal real into a double */ +/************************************************************************/ + +static double tp2c(GByte *r) +{ + double mant; + int sign, exp, i; + + // handle 0 case + if (r[0] == 0) + return 0.0; + + // extract sign: bit 7 of byte 5 + sign = r[5] & 0x80 ? -1 : 1; + + // extract mantissa from first bit of byte 1 to bit 7 of byte 5 + mant = 0; + for (i = 1; i < 5; i++) + mant = (r[i] + mant) / 256; + mant = (mant + (r[5] & 0x7F)) / 128 + 1; + + // extract exponent + exp = r[0] - 129; + + // compute the damned number + return sign * ldexp(mant, exp); +} + +/************************************************************************/ +/* c2tp() */ +/* */ +/* convert a double into a Turbo Pascal real */ +/************************************************************************/ + +static void c2tp(double x, GByte *r) +{ + double mant, temp; + int negative, exp, i; + + // handle 0 case + if (x == 0.0) + { + for (i = 0; i < 6; r[i++] = 0); + return; + } + + // compute mantissa, sign and exponent + mant = frexp(x, &exp) * 2 - 1; + exp--; + negative = 0; + if (mant < 0) + { + mant = -mant; + negative = 1; + } + // stuff mantissa into Turbo Pascal real + mant = modf(mant * 128, &temp); + r[5] = (unsigned char) temp; + for (i = 4; i >= 1; i--) + { + mant = modf(mant * 256, &temp); + r[i] = (unsigned char) temp; + } + // add sign + if (negative) + r[5] |= 0x80; + + // put exponent + r[0] = exp + 129; +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *IDADataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** /* papszParmList */ ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte || nBands != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Only 1 band, Byte datasets supported for IDA format." ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszFilename, "wb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Prepare formatted header. */ +/* -------------------------------------------------------------------- */ + GByte abyHeader[512]; + + memset( abyHeader, 0, sizeof(abyHeader) ); + + abyHeader[22] = 200; /* image type - CALCULATED */ + abyHeader[23] = 0; /* projection - NONE */ + abyHeader[30] = nYSize % 256; + abyHeader[31] = nYSize / 256; + abyHeader[32] = nXSize % 256; + abyHeader[33] = nXSize / 256; + + abyHeader[170] = 255; /* missing = 255 */ + c2tp( 1.0, abyHeader + 171 ); /* slope = 1.0 */ + c2tp( 0.0, abyHeader + 177 ); /* offset = 0 */ + abyHeader[168] = 0; // lower limit + abyHeader[169] = 254; // upper limit + + // pixel size = 1.0 + c2tp( 1.0, abyHeader + 144 ); + c2tp( 1.0, abyHeader + 150 ); + + if( VSIFWrite( abyHeader, 1, 512, fp ) != 512 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "IO error writing %s.\n%s", + VSIStrerror( errno ) ); + VSIFClose( fp ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Now we need to extend the file to just the right number of */ +/* bytes for the data we have to ensure it will open again */ +/* properly. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeek( fp, nXSize * nYSize - 1, SEEK_CUR ) != 0 + || VSIFWrite( abyHeader, 1, 1, fp ) != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "IO error writing %s.\n%s", + VSIStrerror( errno ) ); + VSIFClose( fp ); + return NULL; + } + + VSIFClose( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* GDALRegister_IDA() */ +/************************************************************************/ + +void GDALRegister_IDA() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "IDA" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "IDA" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Image Data and Analysis" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#IDA" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, "Byte" ); + + poDriver->pfnOpen = IDADataset::Open; + poDriver->pfnCreate = IDADataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/isis2dataset.cpp b/Utilities/GDAL/frmts/raw/isis2dataset.cpp new file mode 100644 index 0000000000..3a6051daee --- /dev/null +++ b/Utilities/GDAL/frmts/raw/isis2dataset.cpp @@ -0,0 +1,1029 @@ +/****************************************************************************** + * $Id: isis2dataset.cpp,v 1.3 2006/04/13 16:39:35 fwarmerdam Exp $ + * + * Project: ISIS Version 2 Driver + * Purpose: Implementation of ISIS2Dataset + * Author: Trent Hare (thare@usgs.gov), + * Robert Soricone (rsoricone@usgs.gov) + * + * NOTE: Original code authored by Trent and Robert and placed in the public + * domain as per US government policy. I have (within my rights) appropriated + * it and placed it under the following license. This is not intended to + * diminish Trent and Roberts contribution. + ****************************************************************************** + * Copyright (c) 2006, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: isis2dataset.cpp,v $ + * Revision 1.3 2006/04/13 16:39:35 fwarmerdam + * added more notes on copyright + * + * Revision 1.2 2006/04/04 04:34:12 fwarmerdam + * Fixed copyright date. + * + * Revision 1.1 2006/04/04 04:33:29 fwarmerdam + * New + * + */ + +#define NULL1 0 +#define NULL2 -32768 +//#define NULL3 -0.3402822655089E+39 /*0xFF7FFFFB*/ + +#define NULL3 0xFF7FFFFB //in hex + +#include "rawdataset.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: isis2dataset.cpp,v 1.3 2006/04/13 16:39:35 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_ISIS2(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* NASAKeywordHandler */ +/* ==================================================================== */ +/************************************************************************/ + +class NASAKeywordHandler +{ + char **papszKeywordList; + + CPLString osHeaderText; + const char *pszHeaderNext; + + void SkipWhite(); + int ReadWord( CPLString &osWord ); + int ReadPair( CPLString &osName, CPLString &osValue ); + int ReadGroup( const char *pszPathPrefix ); + +public: + NASAKeywordHandler(); + ~NASAKeywordHandler(); + + int Ingest( FILE *fp, int nOffset ); + + const char *GetKeyword( const char *pszPath, const char *pszDefault ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* ISISDataset version2 */ +/* ==================================================================== */ +/************************************************************************/ + +class ISIS2Dataset : public RawDataset +{ + FILE *fpImage; // image data file. + + NASAKeywordHandler oKeywords; + + int bGotTransform; + double adfGeoTransform[6]; + + char *pszProjection; + + int parse_label(const char *file, char *keyword, char *value); + int strstrip(char instr[], char outstr[], int position); + + CPLString oTempResult; + + const char *GetKeyword( const char *pszPath, + const char *pszDefault = ""); + const char *GetKeywordSub( const char *pszPath, + int iSubscript, + const char *pszDefault = ""); + +public: + ISIS2Dataset(); + ~ISIS2Dataset(); + + virtual CPLErr GetGeoTransform( double * padfTransform ); + virtual const char *GetProjectionRef(void); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); +}; + +/************************************************************************/ +/* ISIS2Dataset() */ +/************************************************************************/ + +ISIS2Dataset::ISIS2Dataset() +{ + fpImage = NULL; + pszProjection = CPLStrdup(""); + bGotTransform = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~ISIS2Dataset() */ +/************************************************************************/ + +ISIS2Dataset::~ISIS2Dataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFCloseL( fpImage ); + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *ISIS2Dataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr ISIS2Dataset::GetGeoTransform( double * padfTransform ) + +{ + if( bGotTransform ) + { + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; + } + else + { + return GDALDataset::GetGeoTransform( padfTransform ); + } +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *ISIS2Dataset::Open( GDALOpenInfo * poOpenInfo ) +{ +/* -------------------------------------------------------------------- */ +/* Does this look like a CUBE dataset? */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->pabyHeader == NULL + || strstr((const char *)poOpenInfo->pabyHeader,"^QUBE") == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Open the file using the large file API. */ +/* -------------------------------------------------------------------- */ + FILE *fpQube = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + + if( fpQube == NULL ) + return NULL; + + ISIS2Dataset *poDS; + + poDS = new ISIS2Dataset(); + poDS->fpImage = fpQube; + + if( ! poDS->oKeywords.Ingest( fpQube, 0 ) ) + { + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the label (ie. .lab) file. */ +/* -------------------------------------------------------------------- */ + // QUBE can be inline or detached and point to an image name + // ^QUBE = 76 + // ^QUBE = ("ui31s015.img",6441<BYTES>) - has another label on the image + // ^QUBE = "ui31s015.img" - which implies no label or skip value + + const char *pszQube = poDS->GetKeyword( "^QUBE" ); + int nQube = atoi(pszQube); + + if( pszQube[0] == '"' ) + { + CPLAssert( FALSE ); // TODO + } + else if( pszQube[0] == '(' ) + { + CPLAssert( FALSE ); // TODO + } + +/* -------------------------------------------------------------------- */ +/* Check if file an ISIS2 header file? Read a few lines of text */ +/* searching for something starting with nrows or ncols. */ +/* -------------------------------------------------------------------- */ + GDALDataType eDataType = GDT_Byte; + OGRSpatialReference oSRS; + + int nRows = -1; + int nCols = -1; + int nBands = 1; + int nSkipBytes = 0; + int itype; + int s_ix, s_iy, s_iz; // check SUFFIX_ITEMS params. + int record_bytes; + double dfULXMap=0.5; + double dfULYMap = 0.5; + double dfXDim = 1.0; + double dfYDim = 1.0; + double dfNoData = 0.0; + int bNoDataSet = FALSE; + char chByteOrder = 'M'; //default to MSB + char szLayout[10] = "BSQ"; //default to band seq. + char target_name[60]; //planet name + //projection parameters + float xulcenter = 0.0; + float yulcenter = 0.0; + char map_proj_name[60]; + int bProjectionSet = TRUE; + char proj_target_name[80]; + char datum_name[60]; + char sphere_name[60]; + char bIsGeographic = TRUE; + double semi_major = 0.0; + double semi_minor = 0.0; + double iflattening = 0.0; + float center_lat = 0.0; + float center_lon = 0.0; + float first_std_parallel = 0.0; + float second_std_parallel = 0.0; + FILE *fp; + + /* -------------------------------------------------------------------- */ + /* Checks to see if this is valid ISIS2 cube */ + /* SUFFIX_ITEM tag in .cub file should be (0,0,0); no side-planes */ + /* -------------------------------------------------------------------- */ + s_ix = atoi(poDS->GetKeywordSub( "QUBE.SUFFIX_ITEMS", 1 )); + s_iy = atoi(poDS->GetKeywordSub( "QUBE.SUFFIX_ITEMS", 2 )); + s_iz = atoi(poDS->GetKeywordSub( "QUBE.SUFFIX_ITEMS", 3 )); + + if( s_ix != 0 || s_iy != 0 || s_iz != 0 ) { + printf( "*** ISIS 2 cube file has invalid SUFFIX_ITEMS parameters:\n"); + printf( "*** gdal isis2 driver requires (0, 0, 0), thus no sideplanes or backplanes"); + printf( "found: (%i, %i, %i)\n\n", s_ix, s_iy, s_iz ); + printf( "exit status 1\n\n" ); + exit(1); + } + /**************** end SUFFIX_ITEM check ***********************/ + + + /*********** Grab layout type (BSQ, BIP, BIL) ************/ + // AXIS_NAME = (SAMPLE,LINE,BAND) + /***********************************************************/ +#ifdef notdef + i = poDS->parse_label(pszCUBFilename, "AXIS_NAME", value); + if (i == FALSE) { + printf("\nAXIS_NAME not found. Abort\n\n"); + exit(1); + } + if (EQUAL(value,"(SAMPLE,LINE,BAND)") ) + strcpy(szLayout,"BSQ"); + else if (EQUAL(value,"(BAND,LINE,SAMPLE)") ) + strcpy(szLayout,"BIP"); + else if (EQUAL(value,"(SAMPLE,BAND,LINE)") ) + strcpy(szLayout,"BSQ"); + else { + printf( "%s layout not supported. Abort\n\n", value); + exit(1); + } + + /*********** Grab samples lines band ************/ + i = poDS->parse_label(pszCUBFilename, "CORE_ITEMS", value); + if (i == FALSE) { + printf("\nCORE_ITEMS not found. Abort\n\n"); + exit(1); + } + i = poDS->strstrip(value,value_strip,1); + nCols = atoi(value_strip); + i = poDS->strstrip(value,value_strip,2); + nRows = atoi(value_strip); + i = poDS->strstrip(value,value_strip,3); + nBands = atoi(value_strip); + + /*********** Grab Qube record bytes **********/ + i = poDS->parse_label(pszCUBFilename, "RECORD_BYTES", value); + if (i == FALSE) + { + printf("\nRECORD_BYTES not found. Abort\n\n"); + exit(1); + } else { + record_bytes = atoi(value); + } + if (nQube > 0) + nSkipBytes = (nQube - 1) * record_bytes; + else + nSkipBytes = 0; + + /******** Grab format type - isis2 only supports 8,16,32 *******/ + i = poDS->parse_label(pszCUBFilename, "CORE_ITEM_BYTES", value); + if (i == FALSE) { + printf("\nCORE_ITEM_BYTES not found. Abort\n\n"); + exit(1); + } + itype = atoi(value); + switch(itype) { + case 1 : + eDataType = GDT_Byte; + dfNoData = NULL1; + bNoDataSet = TRUE; + break; + case 2 : + eDataType = GDT_Int16; + dfNoData = NULL2; + bNoDataSet = TRUE; + break; + case 4 : + eDataType = GDT_Float32; + dfNoData = NULL3; + bNoDataSet = TRUE; + break; + default : + printf("\nItype of %d is not supported in ISIS 2. Exiting\n\n",itype); + exit(1); + } + + /*********** Grab samples lines band ************/ + i = poDS->parse_label(pszCUBFilename, "CORE_ITEM_TYPE", value); + if (i == FALSE) { + printf("\nCORE_ITEM_TYPE not found. Abort\n\n"); + exit(1); + } + if ( (EQUAL(value,"PC_INTEGER")) || + (EQUAL(value,"PC_UNSIGNED_INTEGER")) || + (EQUAL(value,"PC_REAL")) ) { + chByteOrder = 'I'; + } + + /*********** Grab Cellsize ************/ + i = poDS->parse_label(pszCUBFilename, "MAP_SCALE", value); + if (i) { + dfXDim = (float) atof(value) * 1000.0; /* convert from km to m */ + dfYDim = (float) atof(value) * 1000.0 * -1; + } + + /*********** Grab LINE_PROJECTION_OFFSET ************/ + i = poDS->parse_label(pszCUBFilename, "LINE_PROJECTION_OFFSET", value); + if (i) { + yulcenter = (float) atof(value); + yulcenter = ((yulcenter) * dfYDim); + dfULYMap = yulcenter - (dfYDim/2); + } + + /*********** Grab SAMPLE_PROJECTION_OFFSET ************/ + i = poDS->parse_label(pszCUBFilename, "SAMPLE_PROJECTION_OFFSET", value); + if (i) { + xulcenter = (float) atof(value); + xulcenter = ((yulcenter) * dfXDim); + dfULXMap = xulcenter - (dfXDim/2); + } + + /*********** Grab TARGET_NAME ************/ + /**** This is the planets name i.e. MARS ***/ + i = poDS->parse_label(pszCUBFilename, "TARGET_NAME", target_name); + if (i) { + //printf("ISIS 2 Target Name: %s\n", target_name); + } + + /*********** Grab MAP_PROJECTION_TYPE ************/ + i = poDS->parse_label(pszCUBFilename, "MAP_PROJECTION_TYPE", map_proj_name); + if (i) { + //printf("ISIS 2 projection: %s\n", map_proj_name); + } + + /*********** Grab SEMI-MAJOR ************/ + i = poDS->parse_label(pszCUBFilename, "A_AXIS_RADIUS", value); + if (i) { + semi_major = (double) atof(value); + printf("SemiMajor: %f\n", semi_major); + } + + /*********** Grab semi-minor ************/ + i = poDS->parse_label(pszCUBFilename, "C_AXIS_RADIUS", value); + if (i) { + semi_major = (double) atof(value); + printf("SemiMinor: %f\n", semi_major); + } + + /*********** Grab CENTER_LAT ************/ + i = poDS->parse_label(pszCUBFilename, "CENTER_LATITUDE", value); + if (i) { + center_lat = (float) atof(value); + printf("center_lat: %f\n", center_lat); + } + + /*********** Grab CENTER_LON ************/ + i = poDS->parse_label(pszCUBFilename, "CENTER_LONGITUDE", value); + if (i) { + center_lon = (float) atof(value); + printf("center_lon: %f\n", center_lon); + } + + /*********** Grab 1st std parallel ************/ + i = poDS->parse_label(pszCUBFilename, "FIRST_STANDARD_PARALLEL", value); + if (i) { + first_std_parallel = (float) atof(value); + printf("first std par: %f\n", center_lon); + } + + /*********** Grab 2nd std parallel ************/ + i = poDS->parse_label(pszCUBFilename, "SECOND_STANDARD_PARALLEL", value); + if (i) { + second_std_parallel = (float) atof(value); + printf("second std par: %f\n", second_std_parallel); + } + + /*** grab PROJECTION_LATITUDE_TYPE = "PLANETOCENTRIC" ****/ + // Need to further study how ocentric/ographic will effect the gdal library. + // So far we will use this fact to define a sphere or ellipse for some projections + // Frank - may need to talk this over + i = poDS->parse_label(pszCUBFilename, "PROJECTION_LATITUDE_TYPE", value); + if (i) { + if (EQUAL( value, "\"PLANETOCENTRIC\"" )) + bIsGeographic = FALSE; + } + + //Set oSRS projection and parameters + if ((EQUAL( map_proj_name, "\"EQUIRECTANGULAR_CYLINDRICAL\"" )) || + (EQUAL( map_proj_name, "\"SIMPLE_CYLINDRICAL\"" )) ) { +#ifdef DEBUG + printf("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetEquirectangular ( center_lat, center_lon, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"ORTHOGRAPHIC\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetOrthographic ( center_lat, center_lon, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"SINUSOIDAL\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetSinusoidal ( center_lon, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"MERCATOR\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetMercator ( center_lat, center_lon, 1, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"POLAR_STEREOGRAPHIC\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetPS ( center_lat, center_lon, 1, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"TRANSVERSE_MERCATOR\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetTM ( center_lat, center_lon, 1, 0, 0 ); + } else if (EQUAL( map_proj_name, "\"LAMBERT_CONFORMAL_CONIC\"" )) { +#ifdef DEBUG + printf ("using projection %s\n\n", map_proj_name); +#endif + oSRS.OGRSpatialReference::SetLCC ( first_std_parallel, second_std_parallel, center_lat, center_lon, 0, 0 ); + } else { + printf("*** no projection define or supported! Are you sure this is a map projected cube?\n\n" ); + bProjectionSet = FALSE; + } + + if (bProjectionSet) { + //Create projection name, i.e. MARS_MERCATOR + strcpy(proj_target_name, map_proj_name); + strcat(proj_target_name, "_"); + strcat(proj_target_name, target_name); + + //The datum name will be the same basic name aas the planet + strcpy(datum_name, "D_"); + strcat(datum_name, target_name); + + strcpy(sphere_name, target_name); + //strcat(sphere_name, "_IAU_IAG"); //Might not be IAU defined so don't add + + //calculate inverse flattening from major and minor axis: 1/f = a/(a-b) + iflattening = semi_major / (semi_major - semi_minor); + + //The use of a Sphere, polar radius or ellipse here is based on how ISIS 2 does it internally + //Notice that most ISIS 2 projections are spherical + if ( (EQUAL( map_proj_name, "\"EQUIRECTANGULAR_CYLINDRICAL\"" )) || + (EQUAL( map_proj_name, "\"SIMPLE_CYLINDRICAL\"" )) || + (EQUAL( map_proj_name, "\"ORTHOGRAPHIC\"" )) || + (EQUAL( map_proj_name, "\"SINUSOIDAL\"" )) ) { //flattening = 1.0 for sphere + oSRS.SetGeogCS( proj_target_name, datum_name, sphere_name, + semi_major, 1.0, "Reference_Meridian", 0.0, "degree" ); + //Here isis2 uses the polar radius to define m/p, so we should use the polar radius for body + } else if (EQUAL( map_proj_name, "\"POLAR_STEREOGRAPHIC\"" )) { + //flattening = 1.0 for sphere using minor axis + oSRS.SetGeogCS( proj_target_name, datum_name, sphere_name, + semi_minor, 1.0, "Reference_Meridian", 0.0, "degree" ); + } else { //ellipse => Mercator, Transverse Mercator, Lambert Conformal + if (bIsGeographic) { + oSRS.SetGeogCS( proj_target_name, datum_name, sphere_name, + semi_major, iflattening, "Reference_Meridian", 0.0, "degree" ); + } else { //we have Ocentric so use a sphere! I hope... So flattening is 1.0 + oSRS.SetGeogCS( proj_target_name, datum_name, sphere_name, + semi_major, 1.0, "Reference_Meridian", 0.0, "degree" ); + } + } + } + +/* END ISIS2 Label Read */ +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + +/* -------------------------------------------------------------------- */ +/* Is the CUB detached - if so, reset name to binary file? */ +/* -------------------------------------------------------------------- */ + // Frank - is this correct? + //The extension already added on so don't add another. But is this needed? + char *pszPath = CPLStrdup( CPLGetPath( poOpenInfo->pszFilename ) ); + char *pszName = CPLStrdup( CPLGetBasename( poOpenInfo->pszFilename ) ); + if (bIsDetached) + pszCUBFilename = CPLFormCIFilename( pszPath, detachedCub, "" ); + +/* -------------------------------------------------------------------- */ +/* Did we get the required keywords? If not we return with */ +/* this never having been considered to be a match. This isn't */ +/* an error! */ +/* -------------------------------------------------------------------- */ + if( nRows == -1 || nCols == -1 ) + { + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nCols; + poDS->nRasterYSize = nRows; + +/* -------------------------------------------------------------------- */ +/* Open target binary file. */ +/* -------------------------------------------------------------------- */ + + //printf("psztarget: %s\n", pszFilename); + + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "r+b" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open %s with write permission.\n%s", + VSIStrerror( errno ) ); + delete poDS; + return NULL; + } + + poDS->eAccess = poOpenInfo->eAccess; + +/* -------------------------------------------------------------------- */ +/* Compute the line offset. */ +/* -------------------------------------------------------------------- */ + int nItemSize = GDALGetDataTypeSize(eDataType)/8; + int nLineOffset, nPixelOffset, nBandOffset; + + if( EQUAL(szLayout,"BIP") ) + { + nPixelOffset = nItemSize * nBands; + nLineOffset = nPixelOffset * nCols; + nBandOffset = nItemSize; + } + else if( EQUAL(szLayout,"BSQ") ) + { + nPixelOffset = nItemSize; + nLineOffset = nPixelOffset * nCols; + nBandOffset = nLineOffset * nRows; + } + else /* assume BIL */ + { + nPixelOffset = nItemSize; + nLineOffset = nItemSize * nBands * nCols; + nBandOffset = nItemSize * nCols; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = nBands;; + for( i = 0; i < poDS->nBands; i++ ) + { + RawRasterBand *poBand; + + poBand = + new RawRasterBand( poDS, i+1, poDS->fpImage, + nSkipBytes + nBandOffset * i, + nPixelOffset, nLineOffset, eDataType, +#ifdef CPL_LSB + chByteOrder == 'I' || chByteOrder == 'L', +#else + chByteOrder == 'M', +#endif + TRUE ); + + if( bNoDataSet ) + poBand->StoreNoDataValue( dfNoData ); + + poDS->SetBand( i+1, poBand ); + } + +/* -------------------------------------------------------------------- */ +/* Check for a .prj file. For isis2 I would like to keep this in */ +/* -------------------------------------------------------------------- */ + + pszPath = CPLStrdup( CPLGetPath( poOpenInfo->pszFilename ) ); + pszName = CPLStrdup( CPLGetBasename(poOpenInfo->pszFilename) ); + const char *pszPrjFile = CPLFormCIFilename( pszPath, pszName, "prj" ); + CPLFree( pszPath ); + CPLFree( pszName ); + + fp = VSIFOpen( pszPrjFile, "r" ); + if( fp != NULL ) + { + char **papszLines; + OGRSpatialReference oSRS; + + VSIFClose( fp ); + + papszLines = CSLLoad( pszPrjFile ); + + if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE ) + { + CPLFree( poDS->pszProjection ); + oSRS.exportToWkt( &(poDS->pszProjection) ); + } + + CSLDestroy( papszLines ); + } + + + if( dfULYMap != 0.5 || dfULYMap != 0.5 || dfXDim != 1.0 || dfYDim != 1.0 ) + { + poDS->bGotTransform = TRUE; + poDS->adfGeoTransform[0] = dfULXMap; + poDS->adfGeoTransform[1] = dfXDim; + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = dfULYMap; + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = dfYDim; + } + + if( !poDS->bGotTransform ) + poDS->bGotTransform = + GDALReadWorldFile( poOpenInfo->pszFilename, "cbw", + poDS->adfGeoTransform ); + + if( !poDS->bGotTransform ) + poDS->bGotTransform = + GDALReadWorldFile( poOpenInfo->pszFilename, "wld", + poDS->adfGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); +#endif + + return( poDS ); +} + +/************************************************************************/ +/* GetKeyword() */ +/************************************************************************/ + +const char *ISIS2Dataset::GetKeyword( const char *pszPath, + const char *pszDefault ) + +{ + return oKeywords.GetKeyword( pszPath, pszDefault ); +} + +/************************************************************************/ +/* GetKeywordSub() */ +/************************************************************************/ + +const char *ISIS2Dataset::GetKeywordSub( const char *pszPath, + int iSubscript, + const char *pszDefault ) + +{ + const char *pszResult = oKeywords.GetKeyword( pszPath, NULL ); + + if( pszResult == NULL ) + return pszDefault; + + if( pszResult[0] != '(' ) + return pszDefault; + + char **papszTokens = CSLTokenizeString2( pszResult, "(,)", + CSLT_HONOURSTRINGS ); + + if( iSubscript <= CSLCount(papszTokens) ) + { + oTempResult = papszTokens[iSubscript-1]; + CSLDestroy( papszTokens ); + return oTempResult.c_str(); + } + else + { + CSLDestroy( papszTokens ); + return pszDefault; + } +} + + +/************************************************************************/ +/* ==================================================================== */ +/* NASAKeywordHandler */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* NASAKeywordHandler() */ +/************************************************************************/ + +NASAKeywordHandler::NASAKeywordHandler() + +{ + papszKeywordList = NULL; +} + +/************************************************************************/ +/* ~NASAKeywordHandler() */ +/************************************************************************/ + +NASAKeywordHandler::~NASAKeywordHandler() + +{ + CSLDestroy( papszKeywordList ); + papszKeywordList = NULL; +} + +/************************************************************************/ +/* Ingest() */ +/************************************************************************/ + +int NASAKeywordHandler::Ingest( FILE *fp, int nOffset ) + +{ +/* -------------------------------------------------------------------- */ +/* Read in buffer till we find END all on it's own line. */ +/* -------------------------------------------------------------------- */ + if( VSIFSeekL( fp, nOffset, SEEK_SET ) != 0 ) + return FALSE; + + for( ; TRUE; ) + { + const char *pszCheck; + char szChunk[513]; + + int nBytesRead = VSIFReadL( szChunk, 1, 512, fp ); + + szChunk[nBytesRead] = '\0'; + osHeaderText += szChunk; + + if( nBytesRead < 512 ) + break; + + if( osHeaderText.size() > 520 ) + pszCheck = osHeaderText.c_str() + (osHeaderText.size() - 520); + else + pszCheck = szChunk; + + if( strstr(pszCheck,"\r\nEND\r\n") != NULL + || strstr(pszCheck,"\nEND\n") != NULL ) + break; + } + + pszHeaderNext = osHeaderText.c_str(); + +/* -------------------------------------------------------------------- */ +/* Process name/value pairs, keeping track of a "path stack". */ +/* -------------------------------------------------------------------- */ + return ReadGroup( "" ); +} + +/************************************************************************/ +/* ReadGroup() */ +/************************************************************************/ + +int NASAKeywordHandler::ReadGroup( const char *pszPathPrefix ) + +{ + CPLString osName, osValue; + + for( ; TRUE; ) + { + if( !ReadPair( osName, osValue ) ) + return FALSE; + + if( osName == "OBJECT" || osName == "GROUP" ) + { + if( !ReadGroup( (CPLString(pszPathPrefix) + osValue + ".").c_str() ) ) + return FALSE; + } + else if( EQUALN(osName.c_str(),"END",3) ) + { + return TRUE; + } + else + { + osName = pszPathPrefix + osName; + printf( "%s=%s\n", osName.c_str(), osValue.c_str() ); + papszKeywordList = CSLSetNameValue( papszKeywordList, + osName, osValue ); + } + } +} + +/************************************************************************/ +/* ReadPair() */ +/* */ +/* Read a name/value pair from the input stream. Strip off */ +/* white space, ignore comments, split on '='. */ +/************************************************************************/ + +int NASAKeywordHandler::ReadPair( CPLString &osName, CPLString &osValue ) + +{ + osName = ""; + osValue = ""; + + if( !ReadWord( osName ) ) + return FALSE; + + SkipWhite(); + if( *pszHeaderNext != '=' ) + return FALSE; + + pszHeaderNext++; + + SkipWhite(); + + osValue = ""; + + if( *pszHeaderNext == '(' ) + { + osValue = ""; + + // TODO: Fix to capture, removing white space, honours strings. + while( *pszHeaderNext != ')' ) + { + if( *pszHeaderNext == '\0' ) + return FALSE; + + *pszHeaderNext++; + } + pszHeaderNext++; + + return TRUE; + } + else + return ReadWord( osValue ); +} + +/************************************************************************/ +/* ReadWord() */ +/************************************************************************/ + +int NASAKeywordHandler::ReadWord( CPLString &osWord ) + +{ + osWord = ""; + + SkipWhite(); + + if( pszHeaderNext == '\0' ) + return FALSE; + + while( *pszHeaderNext != '\0' + && !isspace(*pszHeaderNext) ) + { + if( *pszHeaderNext == '"' ) + { + osWord += *(pszHeaderNext++); + while( *pszHeaderNext != '"' ) + { + if( *pszHeaderNext == '\0' ) + return FALSE; + + osWord += *(pszHeaderNext++); + } + osWord += *(pszHeaderNext++); + } + else + { + osWord += *pszHeaderNext; + pszHeaderNext++; + } + } + + return TRUE; +} + +/************************************************************************/ +/* SkipWhite() */ +/************************************************************************/ + +void NASAKeywordHandler::SkipWhite() + +{ + for( ; TRUE; ) + { + // Skip white space (newline, space, tab, etc ) + if( isspace( *pszHeaderNext ) ) + { + pszHeaderNext++; + continue; + } + + // Skip C style comments + if( *pszHeaderNext == '/' && pszHeaderNext[1] == '*' ) + { + pszHeaderNext += 2; + + while( *pszHeaderNext != '\0' + && (*pszHeaderNext != '*' + || pszHeaderNext[1] != '/' ) ) + { + pszHeaderNext++; + } + + pszHeaderNext += 2; + continue; + } + + // not white space, return. + return; + } +} + +/************************************************************************/ +/* GetKeyword() */ +/************************************************************************/ + +const char *NASAKeywordHandler::GetKeyword( const char *pszPath, + const char *pszDefault ) + +{ + const char *pszResult; + + pszResult = CSLFetchNameValue( papszKeywordList, pszPath ); + if( pszResult == NULL ) + return pszDefault; + else + return pszResult; +} + +/************************************************************************/ +/* GDALRegister_ISIS2() */ +/************************************************************************/ + +void GDALRegister_ISIS2() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "ISIS2" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "ISIS2" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "USGS Astrogeology ISIS cube (Version 2)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#ISIS2" ); + + poDriver->pfnOpen = ISIS2Dataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/landataset.cpp b/Utilities/GDAL/frmts/raw/landataset.cpp new file mode 100644 index 0000000000..c0ceb71857 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/landataset.cpp @@ -0,0 +1,650 @@ +/****************************************************************************** + * $Id: landataset.cpp,v 1.10 2005/12/14 20:03:57 fwarmerdam Exp $ + * + * Project: eCognition + * Purpose: Implementation of Erdas .LAN / .GIS format. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2004, 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: landataset.cpp,v $ + * Revision 1.10 2005/12/14 20:03:57 fwarmerdam + * Corrected byte swapping decision for 16bit images per report from Maciek. + * + * Revision 1.9 2005/09/27 18:13:04 fwarmerdam + * Only return 16 colors for 4bit files. + * + * Revision 1.8 2005/09/27 17:40:05 fwarmerdam + * Make sure we notify RawRasterBand we are using large file api. + * + * Revision 1.7 2005/09/27 17:37:20 fwarmerdam + * Derived 4bit band from GDALPamRasterBand, and added colortable support. + * Also use large file API consistently for file access. + * + * Revision 1.6 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.5 2004/05/28 18:15:58 warmerda + * added .TRL colortable support + * + * Revision 1.4 2004/05/28 16:06:27 warmerda + * added pre7.4 handling and world file support + * + * Revision 1.3 2004/05/26 20:25:05 warmerda + * Added 4bit support. + * + * Revision 1.2 2004/05/26 18:19:15 warmerda + * Implement + * + * Revision 1.1 2004/05/26 17:45:16 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: landataset.cpp,v 1.10 2005/12/14 20:03:57 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_LAN(void); +CPL_C_END + +/** + +Erdas Header format: "HEAD74" + +Offset Size Type Description +------ ---- ---- ----------- +0 6 char magic cookie / version (ie. HEAD74). +6 2 Int16 Pixel type, 0=8bit, 1=4bit, 2=16bit +8 2 Int16 Number of Bands. +10 6 char Unknown. +16 4 Int32 Width +20 4 Int32 Height +24 4 Int32 X Start (offset in original file?) +28 4 Int32 Y Start (offset in original file?) +32 56 char Unknown. +88 2 Int16 0=LAT, 1=UTM, 2=StatePlane, 3- are projections? +90 2 Int16 Classes in coverage. +92 14 char Unknown. +106 2 Int16 Area Unit (0=none, 1=Acre, 2=Hectare, 3=Other) +108 4 Float32 Pixel area. +112 4 Float32 Upper Left corner X (center of pixel?) +116 4 Float32 Upper Left corner Y (center of pixel?) +120 4 Float32 Width of a pixel. +124 4 Float32 Height of a pixel. + +Erdas Header format: "HEADER" + +Offset Size Type Description +------ ---- ---- ----------- +0 6 char magic cookie / version (ie. HEAD74). +6 2 Int16 Pixel type, 0=8bit, 1=4bit, 2=16bit +8 2 Int16 Number of Bands. +10 6 char Unknown. +16 4 Float32 Width +20 4 Float32 Height +24 4 Int32 X Start (offset in original file?) +28 4 Int32 Y Start (offset in original file?) +32 56 char Unknown. +88 2 Int16 0=LAT, 1=UTM, 2=StatePlane, 3- are projections? +90 2 Int16 Classes in coverage. +92 14 char Unknown. +106 2 Int16 Area Unit (0=none, 1=Acre, 2=Hectare, 3=Other) +108 4 Float32 Pixel area. +112 4 Float32 Upper Left corner X (center of pixel?) +116 4 Float32 Upper Left corner Y (center of pixel?) +120 4 Float32 Width of a pixel. +124 4 Float32 Height of a pixel. + +All binary fields are in the same byte order but it may be big endian or +little endian depending on what platform the file was written on. Usually +this can be checked against the number of bands though this test won't work +if there are more than 255 bands. + +**/ + +#define ERD_HEADER_SIZE 128 + +/************************************************************************/ +/* ==================================================================== */ +/* LAN4BitRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class LANDataset; + +class LAN4BitRasterBand : public GDALPamRasterBand +{ + GDALColorTable *poCT; + GDALColorInterp eInterp; + + public: + LAN4BitRasterBand( LANDataset *, int ); + ~LAN4BitRasterBand(); + + virtual GDALColorTable *GetColorTable(); + virtual GDALColorInterp GetColorInterpretation(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* LANDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class LANDataset : public RawDataset +{ + public: + FILE *fpImage; // image data file. + + char pachHeader[ERD_HEADER_SIZE]; + + char *pszProjection; + + double adfGeoTransform[6]; + + public: + LANDataset(); + ~LANDataset(); + + virtual CPLErr GetGeoTransform( double * padfTransform ); + virtual const char *GetProjectionRef(); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* LAN4BitRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* LAN4BitRasterBand() */ +/************************************************************************/ + +LAN4BitRasterBand::LAN4BitRasterBand( LANDataset *poDS, int nBandIn ) + +{ + this->poDS = poDS; + this->nBand = nBandIn; + this->eDataType = GDT_Byte; + + nBlockXSize = poDS->GetRasterXSize();; + nBlockYSize = 1; + + poCT = NULL; + eInterp = GCI_Undefined; +} + +/************************************************************************/ +/* ~LAN4BitRasterBand() */ +/************************************************************************/ + +LAN4BitRasterBand::~LAN4BitRasterBand() + +{ + if( poCT ) + delete poCT; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr LAN4BitRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + LANDataset *poLAN_DS = (LANDataset *) poDS; + CPLAssert( nBlockXOff == 0 ); + +/* -------------------------------------------------------------------- */ +/* Seek to profile. */ +/* -------------------------------------------------------------------- */ + int nOffset; + + nOffset = + ERD_HEADER_SIZE + + (nBlockYOff * nRasterXSize * poLAN_DS->GetRasterCount()) / 2 + + ((nBand - 1) * nRasterXSize) / 2; + + if( VSIFSeekL( poLAN_DS->fpImage, nOffset, SEEK_SET ) != 0 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "LAN Seek failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Read the profile. */ +/* -------------------------------------------------------------------- */ + if( VSIFReadL( pImage, 1, nRasterXSize/2, poLAN_DS->fpImage ) != + (size_t) nRasterXSize / 2 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "LAN Read failed:%s", VSIStrerror( errno ) ); + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Convert 4bit to 8bit. */ +/* -------------------------------------------------------------------- */ + int i; + + for( i = nRasterXSize-1; i >= 0; i-- ) + { + if( (i & 0x01) != 0 ) + ((GByte *) pImage)[i] = ((GByte *) pImage)[i/2] & 0x0f; + else + ((GByte *) pImage)[i] = (((GByte *) pImage)[i/2] & 0xf0)/16; + } + + return CE_None; +} + +/************************************************************************/ +/* SetColorTable() */ +/************************************************************************/ + +CPLErr LAN4BitRasterBand::SetColorTable( GDALColorTable *poNewCT ) + +{ + if( poCT ) + delete poCT; + if( poNewCT == NULL ) + poCT = NULL; + else + poCT = poNewCT->Clone(); + + return CE_None; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *LAN4BitRasterBand::GetColorTable() + +{ + if( poCT != NULL ) + return poCT; + else + return GDALPamRasterBand::GetColorTable(); +} + +/************************************************************************/ +/* SetColorInterpretation() */ +/************************************************************************/ + +CPLErr LAN4BitRasterBand::SetColorInterpretation( GDALColorInterp eNewInterp ) + +{ + eInterp = eNewInterp; + + return CE_None; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp LAN4BitRasterBand::GetColorInterpretation() + +{ + return eInterp; +} + +/************************************************************************/ +/* ==================================================================== */ +/* LANDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* LANDataset() */ +/************************************************************************/ + +LANDataset::LANDataset() +{ + fpImage = NULL; + pszProjection = NULL; +} + +/************************************************************************/ +/* ~LANDataset() */ +/************************************************************************/ + +LANDataset::~LANDataset() + +{ + FlushCache(); + + if( fpImage != NULL ) + VSIFCloseL( fpImage ); + + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *LANDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the header (.pcb) file. */ +/* Does this appear to be a pcb file? */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < ERD_HEADER_SIZE || poOpenInfo->fp == NULL ) + return NULL; + + if( !EQUALN((const char *)poOpenInfo->pabyHeader,"HEADER",6) + && !EQUALN((const char *)poOpenInfo->pabyHeader,"HEAD74",6) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + LANDataset *poDS; + + poDS = new LANDataset(); + +/* -------------------------------------------------------------------- */ +/* Adopt the openinfo file pointer for use with this file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_ReadOnly ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); + if( poDS->fpImage == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Do we need to byte swap the headers to local machine order? */ +/* -------------------------------------------------------------------- */ + int bBigEndian = poOpenInfo->pabyHeader[8] == 0; + int bNeedSwap; + + memcpy( poDS->pachHeader, poOpenInfo->pabyHeader, ERD_HEADER_SIZE ); + +#ifdef CPL_LSB + bNeedSwap = bBigEndian; +#else + bNeedSwap = !bBigEndian; +#endif + + if( bNeedSwap ) + { + CPL_SWAP16PTR( poDS->pachHeader + 6 ); + CPL_SWAP16PTR( poDS->pachHeader + 8 ); + + CPL_SWAP32PTR( poDS->pachHeader + 16 ); + CPL_SWAP32PTR( poDS->pachHeader + 20 ); + CPL_SWAP32PTR( poDS->pachHeader + 24 ); + CPL_SWAP32PTR( poDS->pachHeader + 28 ); + + CPL_SWAP16PTR( poDS->pachHeader + 88 ); + CPL_SWAP16PTR( poDS->pachHeader + 90 ); + + CPL_SWAP16PTR( poDS->pachHeader + 106 ); + CPL_SWAP32PTR( poDS->pachHeader + 108 ); + CPL_SWAP32PTR( poDS->pachHeader + 112 ); + CPL_SWAP32PTR( poDS->pachHeader + 116 ); + CPL_SWAP32PTR( poDS->pachHeader + 120 ); + CPL_SWAP32PTR( poDS->pachHeader + 124 ); + } + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + int nBandCount, nPixelOffset; + GDALDataType eDataType; + + if( EQUALN(poDS->pachHeader,"HEADER",7) ) + { + poDS->nRasterXSize = (int) *((float *) (poDS->pachHeader + 16)); + poDS->nRasterYSize = (int) *((float *) (poDS->pachHeader + 20)); + } + else + { + poDS->nRasterXSize = *((GInt32 *) (poDS->pachHeader + 16)); + poDS->nRasterYSize = *((GInt32 *) (poDS->pachHeader + 20)); + } + + if( *((GInt16 *) (poDS->pachHeader + 6)) == 0 ) + { + eDataType = GDT_Byte; + nPixelOffset = 1; + } + else if( *((GInt16 *) (poDS->pachHeader + 6)) == 1 ) /* 4bit! */ + { + eDataType = GDT_Byte; + nPixelOffset = -1; + } + else if( *((GInt16 *) (poDS->pachHeader + 6)) == 2 ) + { + nPixelOffset = 2; + eDataType = GDT_Int16; + } + else + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unsupported pixel type (%d).", + *((GInt16 *) (poDS->pachHeader + 6)) ); + + delete poDS; + return NULL; + } + + nBandCount = *((GInt16 *) (poDS->pachHeader + 8)); + +/* -------------------------------------------------------------------- */ +/* Create band information object. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 1; iBand <= nBandCount; iBand++ ) + { + if( nPixelOffset == -1 ) /* 4 bit case */ + poDS->SetBand( iBand, + new LAN4BitRasterBand( poDS, iBand ) ); + else + poDS->SetBand( + iBand, + new RawRasterBand( poDS, iBand, poDS->fpImage, + ERD_HEADER_SIZE + (iBand-1) + * nPixelOffset * poDS->nRasterXSize, + nPixelOffset, + poDS->nRasterXSize*nPixelOffset*nBandCount, + eDataType, !bNeedSwap, TRUE )); + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + +/* -------------------------------------------------------------------- */ +/* Try to interprete georeferencing. */ +/* -------------------------------------------------------------------- */ + poDS->adfGeoTransform[0] = *((float *) (poDS->pachHeader + 112)); + poDS->adfGeoTransform[1] = *((float *) (poDS->pachHeader + 120)); + poDS->adfGeoTransform[2] = 0.0; + poDS->adfGeoTransform[3] = *((float *) (poDS->pachHeader + 116)); + poDS->adfGeoTransform[4] = 0.0; + poDS->adfGeoTransform[5] = - *((float *) (poDS->pachHeader + 124)); + + // adjust for center of pixel vs. top left corner of pixel. + poDS->adfGeoTransform[0] -= poDS->adfGeoTransform[1] * 0.5; + poDS->adfGeoTransform[3] -= poDS->adfGeoTransform[5] * 0.5; + +/* -------------------------------------------------------------------- */ +/* If we didn't get any georeferencing, try for a worldfile. */ +/* -------------------------------------------------------------------- */ + if( poDS->adfGeoTransform[1] == 0.0 + || poDS->adfGeoTransform[5] == 0.0 ) + { + if( !GDALReadWorldFile( poOpenInfo->pszFilename, NULL, + poDS->adfGeoTransform ) ) + GDALReadWorldFile( poOpenInfo->pszFilename, ".wld", + poDS->adfGeoTransform ); + } + +/* -------------------------------------------------------------------- */ +/* Try to come up with something for the coordinate system. */ +/* -------------------------------------------------------------------- */ + int nCoordSys = *((GInt16 *) (poDS->pachHeader + 88)); + + if( nCoordSys == 0 ) + { + poDS->pszProjection = CPLStrdup("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"); + + } + else if( nCoordSys == 1 ) + { + poDS->pszProjection = + CPLStrdup("LOCAL_CS[\"UTM - Zone Unknown\",UNIT[\"Meter\",1]]"); + } + else if( nCoordSys == 2 ) + { + poDS->pszProjection = CPLStrdup("LOCAL_CS[\"State Plane - Zone Unknown\",UNIT[\"US survey foot\",0.3048006096012192]]"); + } + else + { + poDS->pszProjection = + CPLStrdup("LOCAL_CS[\"Unknown\",UNIT[\"Meter\",1]]"); + } + +/* -------------------------------------------------------------------- */ +/* Check for a trailer file with a colormap in it. */ +/* -------------------------------------------------------------------- */ + char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); + char *pszBasename = CPLStrdup(CPLGetBasename(poOpenInfo->pszFilename)); + const char *pszTRLFilename = + CPLFormCIFilename( pszPath, pszBasename, "trl" ); + FILE *fpTRL; + + fpTRL = VSIFOpenL( pszTRLFilename, "rb" ); + if( fpTRL != NULL ) + { + char szTRLData[896]; + int iColor; + GDALColorTable *poCT; + + VSIFReadL( szTRLData, 1, 896, fpTRL ); + VSIFCloseL( fpTRL ); + + poCT = new GDALColorTable(); + for( iColor = 0; iColor < 256; iColor++ ) + { + GDALColorEntry sEntry; + + sEntry.c2 = ((GByte *) szTRLData)[iColor+128]; + sEntry.c1 = ((GByte *) szTRLData)[iColor+128+256]; + sEntry.c3 = ((GByte *) szTRLData)[iColor+128+512]; + sEntry.c4 = 255; + poCT->SetColorEntry( iColor, &sEntry ); + + // only 16 colors in 4bit files. + if( nPixelOffset == -1 && iColor == 15 ) + break; + } + + poDS->GetRasterBand(1)->SetColorTable( poCT ); + poDS->GetRasterBand(1)->SetColorInterpretation( GCI_PaletteIndex ); + + delete poCT; + } + + CPLFree( pszPath ); + CPLFree( pszBasename ); + + return( poDS ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr LANDataset::GetGeoTransform( double * padfTransform ) + +{ + if( adfGeoTransform[1] == 0.0 || adfGeoTransform[5] == 0.0 ) + return CE_Failure; + else + { + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + return CE_None; + } +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *LANDataset::GetProjectionRef() + +{ + if( pszProjection == NULL ) + return ""; + else + return pszProjection; +} + +/************************************************************************/ +/* GDALRegister_LAN() */ +/************************************************************************/ + +void GDALRegister_LAN() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "LAN" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "LAN" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Erdas .LAN/.GIS" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#LAN" ); + + poDriver->pfnOpen = LANDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/makefile.vc b/Utilities/GDAL/frmts/raw/makefile.vc new file mode 100644 index 0000000000..128cce2feb --- /dev/null +++ b/Utilities/GDAL/frmts/raw/makefile.vc @@ -0,0 +1,18 @@ + +OBJ = rawdataset.obj ehdrdataset.obj pauxdataset.obj doq1dataset.obj\ + hkvdataset.obj mffdataset.obj pnmdataset.obj \ + fujibasdataset.obj doq2dataset.obj envidataset.obj \ + gscdataset.obj fastdataset.obj atlsci_spheroid.obj \ + btdataset.obj landataset.obj cpgdataset.obj idadataset.obj \ + ndfdataset.obj dipxdataset.obj isis2dataset.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/raw/mffdataset.cpp b/Utilities/GDAL/frmts/raw/mffdataset.cpp new file mode 100644 index 0000000000..1fc3ce6bf9 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/mffdataset.cpp @@ -0,0 +1,1680 @@ +/****************************************************************************** + * $Id: mffdataset.cpp,v 1.29 2006/01/05 16:20:34 gwalter Exp $ + * + * Project: GView + * Purpose: Implementation of Atlantis MFF Support + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 2000, 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: mffdataset.cpp,v $ + * Revision 1.29 2006/01/05 16:20:34 gwalter + * Atlantis->Vexcel in long name. + * + * Revision 1.28 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.27 2003/04/02 19:05:59 dron + * Large file support. + * + * Revision 1.26 2003/03/18 19:03:44 gwalter + * Add flushing, fix coordinate interpretation. + * + * Revision 1.25 2003/03/13 18:34:02 gwalter + * Fix data type determination in CreateCopy. + * + * Revision 1.24 2003/03/12 16:02:28 gwalter + * Fix spheroid support. + * + * Revision 1.22 2003/03/03 20:10:06 gwalter + * Updated MFF and HKV (MFF2) georeferencing support. + * + * Revision 1.21 2002/11/23 18:54:17 warmerda + * added CREATIONDATATYPES metadata for drivers + * + * Revision 1.20 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.19 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.18 2001/11/11 23:51:00 warmerda + * added required class keyword to friend declarations + * + * Revision 1.17 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.16 2001/07/11 18:08:14 warmerda + * Fixed pixel interpretation again. TOP_LEFT is really 0.0,0.0 but + * BOTTOM_RIGHT is the top left corner of the bottom right pixel! + * + * Revision 1.15 2001/07/11 18:00:57 warmerda + * Fixed off-by-half-pixel issues with MFF GCPs. + * + * Revision 1.14 2000/10/11 16:06:51 warmerda + * added read support for GCPn and NUM_GCPs keywords + * + * Revision 1.13 2000/09/25 21:20:13 warmerda + * avoid initialization warnings + * + * Revision 1.12 2000/08/24 14:26:09 warmerda + * improved handling of read-only file sets + * + * Revision 1.11 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.10 2000/07/26 21:05:21 warmerda + * added support for reading tiled MFF files + * + * Revision 1.9 2000/07/12 19:21:34 warmerda + * fixed cleanup of GCPs + * + * Revision 1.8 2000/06/05 17:24:06 warmerda + * added real complex support + * + * Revision 1.7 2000/05/18 22:06:03 warmerda + * added gcp and metadata support + * + * Revision 1.6 2000/05/15 14:18:27 warmerda + * added COMPLEX_INTERPRETATION metadata + * + * Revision 1.5 2000/04/21 21:59:26 warmerda + * added overview support + * + * Revision 1.4 2000/03/24 20:00:46 warmerda + * Don't require IMAGE_FILE_FORMAT. + * + * Revision 1.3 2000/03/13 14:34:42 warmerda + * avoid const problem on write + * + * Revision 1.2 2000/03/06 21:51:32 warmerda + * fixed docs + * + * Revision 1.1 2000/03/06 19:23:20 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" +#include <ctype.h> +#include "ogr_spatialref.h" +#include "atlsci_spheroid.h" + +CPL_CVSID("$Id: mffdataset.cpp,v 1.29 2006/01/05 16:20:34 gwalter Exp $"); + +CPL_C_START +void GDALRegister_MFF(void); +CPL_C_END + +typedef enum { + MFFPRJ_NONE, + MFFPRJ_LL, + MFFPRJ_UTM, + MFFPRJ_UNRECOGNIZED +} ; + +static int GetMFFProjectionType(const char * pszNewProjection); + +/************************************************************************/ +/* ==================================================================== */ +/* MFFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class MFFDataset : public RawDataset +{ + FILE *fpImage; // image data file. + + int nGCPCount; + GDAL_GCP *pasGCPList; + + char *pszProjection; + char *pszGCPProjection; + double adfGeoTransform[6]; + + void ScanForGCPs(); + void ScanForProjectionInfo(); + + + public: + MFFDataset(); + ~MFFDataset(); + + char **papszHdrLines; + + FILE **pafpBandFiles; + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + virtual const char *GetProjectionRef(); + virtual CPLErr GetGeoTransform( double * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); + static GDALDataset *CreateCopy( const char * pszFilename, + GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, + void * pProgressData ); + +}; + +/************************************************************************/ +/* ==================================================================== */ +/* MFFTiledBand */ +/* ==================================================================== */ +/************************************************************************/ + +class MFFTiledBand : public GDALRasterBand +{ + friend class MFFDataset; + + FILE *fpRaw; + int bNative; + + public: + + MFFTiledBand( MFFDataset *, int, FILE *, int, int, + GDALDataType, int ); + ~MFFTiledBand(); + + virtual CPLErr IReadBlock( int, int, void * ); +}; + + +/************************************************************************/ +/* MFFTiledBand() */ +/************************************************************************/ + +MFFTiledBand::MFFTiledBand( MFFDataset *poDS, int nBand, FILE *fp, + int nTileXSize, int nTileYSize, + GDALDataType eDataType, int bNative ) + +{ + this->poDS = poDS; + this->nBand = nBand; + + this->eDataType = eDataType; + + this->bNative = bNative; + + this->nBlockXSize = nTileXSize; + this->nBlockYSize = nTileYSize; + + this->fpRaw = fp; +} + +/************************************************************************/ +/* ~MFFTiledBand() */ +/************************************************************************/ + +MFFTiledBand::~MFFTiledBand() + +{ + VSIFCloseL( fpRaw ); +} + + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr MFFTiledBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + long nOffset; + int nTilesPerRow; + int nWordSize, nBlockSize; + + nTilesPerRow = (nRasterXSize + nBlockXSize - 1) / nBlockXSize; + nWordSize = GDALGetDataTypeSize( eDataType ) / 8; + nBlockSize = nWordSize * nBlockXSize * nBlockYSize; + + nOffset = nBlockSize * (nBlockXOff + nBlockYOff*nTilesPerRow); + + if( VSIFSeekL( fpRaw, nOffset, SEEK_SET ) == -1 + || VSIFReadL( pImage, 1, nBlockSize, fpRaw ) < 1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Read of tile %d/%d failed with fseek or fread error.", + nBlockXOff, nBlockYOff ); + return CE_Failure; + } + + if( !bNative && nWordSize > 1 ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + GDALSwapWords( pImage, nWordSize/2, nBlockXSize*nBlockYSize, + nWordSize ); + GDALSwapWords( ((GByte *) pImage)+nWordSize/2, + nWordSize/2, nBlockXSize*nBlockYSize, nWordSize ); + } + else + GDALSwapWords( pImage, nWordSize, + nBlockXSize * nBlockYSize, nWordSize ); + } + + return CE_None; +} + +/************************************************************************/ +/* MFF Spheroids */ +/************************************************************************/ + +class MFFSpheroidList : public SpheroidList +{ + +public: + + MFFSpheroidList(); + ~MFFSpheroidList(); + +}; + +MFFSpheroidList :: MFFSpheroidList() +{ + num_spheroids = 18; + + epsilonR = 0.1; + epsilonI = 0.000001; + + spheroids[0].SetValuesByRadii("SPHERE",6371007.0,6371007.0); + spheroids[1].SetValuesByRadii("EVEREST",6377304.0,6356103.0); + spheroids[2].SetValuesByRadii("BESSEL",6377397.0,6356082.0); + spheroids[3].SetValuesByRadii("AIRY",6377563.0,6356300.0); + spheroids[4].SetValuesByRadii("CLARKE_1858",6378294.0,6356621.0); + spheroids[5].SetValuesByRadii("CLARKE_1866",6378206.4,6356583.8); + spheroids[6].SetValuesByRadii("CLARKE_1880",6378249.0,6356517.0); + spheroids[7].SetValuesByRadii("HAYFORD",6378388.0,6356915.0); + spheroids[8].SetValuesByRadii("KRASOVSKI",6378245.0,6356863.0); + spheroids[9].SetValuesByRadii("HOUGH",6378270.0,6356794.0); + spheroids[10].SetValuesByRadii("FISHER_60",6378166.0,6356784.0); + spheroids[11].SetValuesByRadii("KAULA",6378165.0,6356345.0); + spheroids[12].SetValuesByRadii("IUGG_67",6378160.0,6356775.0); + spheroids[13].SetValuesByRadii("FISHER_68",6378150.0,6356330.0); + spheroids[14].SetValuesByRadii("WGS_72",6378135.0,6356751.0); + spheroids[15].SetValuesByRadii("IUGG_75",6378140.0,6356755.0); + spheroids[16].SetValuesByRadii("WGS_84",6378137.0,6356752.0); + spheroids[17].SetValuesByRadii("HUGHES",6378273.0,6356889.4); +} + +MFFSpheroidList::~MFFSpheroidList() + +{ +} + +/************************************************************************/ +/* ==================================================================== */ +/* MFFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* MFFDataset() */ +/************************************************************************/ + +MFFDataset::MFFDataset() +{ + papszHdrLines = NULL; + pafpBandFiles = NULL; + nGCPCount = 0; + pasGCPList = NULL; + + pszProjection = CPLStrdup(""); + pszGCPProjection = CPLStrdup(""); + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~MFFDataset() */ +/************************************************************************/ + +MFFDataset::~MFFDataset() + +{ + FlushCache(); + CSLDestroy( papszHdrLines ); + if( pafpBandFiles != NULL ) + { + for( int i = 0; i < GetRasterCount(); i++ ) + { + if( pafpBandFiles[i] != NULL ) + VSIFCloseL( pafpBandFiles[i] ); + } + CPLFree( pafpBandFiles ); + } + + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int MFFDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *MFFDataset::GetGCPProjection() + +{ + if( nGCPCount > 0 ) + return pszGCPProjection; + else + return ""; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *MFFDataset::GetProjectionRef() + +{ + return ( pszProjection ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr MFFDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return( CE_None ); +} + +/************************************************************************/ +/* GetGCP() */ +/************************************************************************/ + +const GDAL_GCP *MFFDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* ScanForGCPs() */ +/************************************************************************/ + +void MFFDataset::ScanForGCPs() + +{ + int nCorner; + int NUM_GCPS = 0; + + if( CSLFetchNameValue(papszHdrLines, "NUM_GCPS") != NULL ) + NUM_GCPS = atoi(CSLFetchNameValue(papszHdrLines, "NUM_GCPS")); + + nGCPCount = 0; + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),5+NUM_GCPS); + + for( nCorner = 0; nCorner < 5; nCorner++ ) + { + const char * pszBase=NULL; + double dfRasterX=0.0, dfRasterY=0.0; + char szLatName[40], szLongName[40]; + + if( nCorner == 0 ) + { + dfRasterX = 0.5; + dfRasterY = 0.5; + pszBase = "TOP_LEFT_CORNER"; + } + else if( nCorner == 1 ) + { + dfRasterX = GetRasterXSize()-0.5; + dfRasterY = 0.5; + pszBase = "TOP_RIGHT_CORNER"; + } + else if( nCorner == 2 ) + { + dfRasterX = GetRasterXSize()-0.5; + dfRasterY = GetRasterYSize()-0.5; + pszBase = "BOTTOM_RIGHT_CORNER"; + } + else if( nCorner == 3 ) + { + dfRasterX = 0.5; + dfRasterY = GetRasterYSize()-0.5; + pszBase = "BOTTOM_LEFT_CORNER"; + } + else if( nCorner == 4 ) + { + dfRasterX = GetRasterXSize()/2.0; + dfRasterY = GetRasterYSize()/2.0; + pszBase = "CENTRE"; + } + + sprintf( szLatName, "%s_LATITUDE", pszBase ); + sprintf( szLongName, "%s_LONGITUDE", pszBase ); + + if( CSLFetchNameValue(papszHdrLines, szLatName) != NULL + && CSLFetchNameValue(papszHdrLines, szLongName) != NULL ) + { + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + + CPLFree( pasGCPList[nGCPCount].pszId ); + + pasGCPList[nGCPCount].pszId = CPLStrdup( pszBase ); + + pasGCPList[nGCPCount].dfGCPX = + atof(CSLFetchNameValue(papszHdrLines, szLongName)); + pasGCPList[nGCPCount].dfGCPY = + atof(CSLFetchNameValue(papszHdrLines, szLatName)); + pasGCPList[nGCPCount].dfGCPZ = 0.0; + + pasGCPList[nGCPCount].dfGCPPixel = dfRasterX; + pasGCPList[nGCPCount].dfGCPLine = dfRasterY; + + nGCPCount++; + } + + } + +/* -------------------------------------------------------------------- */ +/* Collect standalone GCPs. They look like: */ +/* */ +/* GCPn = row, col, lat, long */ +/* GCP1 = 1, 1, 45.0, -75.0 */ +/* -------------------------------------------------------------------- */ + int i; + + for( i = 0; i < NUM_GCPS; i++ ) + { + char szName[25]; + char **papszTokens; + + sprintf( szName, "GCP%d", i+1 ); + if( CSLFetchNameValue( papszHdrLines, szName ) == NULL ) + continue; + + papszTokens = CSLTokenizeStringComplex( + CSLFetchNameValue( papszHdrLines, szName ), + ",", FALSE, FALSE ); + if( CSLCount(papszTokens) == 4 ) + { + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + + CPLFree( pasGCPList[nGCPCount].pszId ); + pasGCPList[nGCPCount].pszId = CPLStrdup( szName ); + + pasGCPList[nGCPCount].dfGCPX = atof(papszTokens[3]); + pasGCPList[nGCPCount].dfGCPY = atof(papszTokens[2]); + pasGCPList[nGCPCount].dfGCPZ = 0.0; + pasGCPList[nGCPCount].dfGCPPixel = atof(papszTokens[1])+0.5; + pasGCPList[nGCPCount].dfGCPLine = atof(papszTokens[0])+0.5; + + nGCPCount++; + } + } +} + +/************************************************************************/ +/* ScanForProjectionInfo */ +/************************************************************************/ + +void MFFDataset::ScanForProjectionInfo() +{ + const char *pszProjName, *pszOriginLong, *pszSpheroidName; + const char *pszSpheroidEqRadius, *pszSpheroidPolarRadius; + double eq_radius, polar_radius; + OGRSpatialReference oProj; + OGRSpatialReference oLL; + MFFSpheroidList *mffEllipsoids; + + pszProjName = CSLFetchNameValue(papszHdrLines, + "PROJECTION_NAME"); + pszOriginLong = CSLFetchNameValue(papszHdrLines, + "PROJECTION_ORIGIN_LONGITUDE"); + pszSpheroidName = CSLFetchNameValue(papszHdrLines, + "SPHEROID_NAME"); + + if (pszProjName == NULL) + { + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + pszProjection=CPLStrdup(""); + pszGCPProjection=CPLStrdup(""); + return; + } + else if ((!EQUAL(pszProjName,"utm")) && (!EQUAL(pszProjName,"ll"))) + { + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- only utm and lat/long projections are currently supported."); + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + pszProjection=CPLStrdup(""); + pszGCPProjection=CPLStrdup(""); + return; + } + mffEllipsoids = new MFFSpheroidList; + + if( EQUAL(pszProjName,"utm") ) + { + int nZone; + + if (pszOriginLong == NULL) + { + /* If origin not specified, assume 0.0 */ + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- no projection origin longitude specified. Assuming 0.0."); + nZone = 31; + } + else + nZone = 31 + (int) floor(atof(pszOriginLong)/6.0); + + + if( pasGCPList[4].dfGCPY < 0 ) + oProj.SetUTM( nZone, 0 ); + else + oProj.SetUTM( nZone, 1 ); + + if (pszOriginLong != NULL) + oProj.SetProjParm(SRS_PP_CENTRAL_MERIDIAN,atof(pszOriginLong)); + + } + + if (pszOriginLong != NULL) + oLL.SetProjParm(SRS_PP_LONGITUDE_OF_ORIGIN,atof(pszOriginLong)); + + if ((pszSpheroidName == NULL)) + { + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- unspecified ellipsoid. Using wgs-84 parameters.\n"); + + oProj.SetWellKnownGeogCS( "WGS84" ); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + else + { + if (mffEllipsoids->SpheroidInList(pszSpheroidName)) + { + oProj.SetGeogCS( "unknown","unknown",pszSpheroidName, + mffEllipsoids->GetSpheroidEqRadius(pszSpheroidName), + mffEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName) + ); + oLL.SetGeogCS( "unknown","unknown",pszSpheroidName, + mffEllipsoids->GetSpheroidEqRadius(pszSpheroidName), + mffEllipsoids->GetSpheroidInverseFlattening(pszSpheroidName) + ); + } + else if (EQUAL(pszSpheroidName,"USER_DEFINED")) + { + pszSpheroidEqRadius = CSLFetchNameValue(papszHdrLines, + "SPHEROID_EQUATORIAL_RADIUS"); + pszSpheroidPolarRadius = CSLFetchNameValue(papszHdrLines, + "SPHEROID_POLAR_RADIUS"); + if ((pszSpheroidEqRadius != NULL) && (pszSpheroidPolarRadius != NULL)) + { + eq_radius = atof( pszSpheroidEqRadius ); + polar_radius = atof( pszSpheroidPolarRadius ); + oProj.SetGeogCS( "unknown","unknown","unknown", + eq_radius, eq_radius/(eq_radius - polar_radius)); + oLL.SetGeogCS( "unknown","unknown","unknown", + eq_radius, eq_radius/(eq_radius - polar_radius)); + } + else + { + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- radii not specified for user-defined ellipsoid. Using wgs-84 parameters. \n"); + oProj.SetWellKnownGeogCS( "WGS84" ); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + } + else + { + CPLError(CE_Warning,CPLE_AppDefined, + "Warning- unrecognized ellipsoid. Using wgs-84 parameters.\n"); + oProj.SetWellKnownGeogCS( "WGS84" ); + oLL.SetWellKnownGeogCS( "WGS84" ); + } + } + + /* If a geotransform is sufficient to represent the GCP's (ie. each */ + /* estimated gcp is within 0.25*pixel size of the actual value- this */ + /* is the test applied by GDALGCPsToGeoTransform), store the */ + /* geotransform. */ + int transform_ok = FALSE; + + if (EQUAL(pszProjName,"LL")) + { + transform_ok = GDALGCPsToGeoTransform(nGCPCount,pasGCPList,adfGeoTransform,0); + } + else + { + OGRCoordinateTransformation *poTransform = NULL; + double *dfPrjX, *dfPrjY; + int gcp_index; + int bSuccess = TRUE; + + dfPrjX = (double *) CPLMalloc(nGCPCount*sizeof(double)); + dfPrjY = (double *) CPLMalloc(nGCPCount*sizeof(double)); + + + poTransform = OGRCreateCoordinateTransformation( &oLL, &oProj ); + if( poTransform == NULL ) + bSuccess = FALSE; + + for(gcp_index=0;gcp_index<nGCPCount;gcp_index++) + { + dfPrjX[gcp_index] = pasGCPList[gcp_index].dfGCPX; + dfPrjY[gcp_index] = pasGCPList[gcp_index].dfGCPY; + + if( bSuccess && !poTransform->Transform( 1, &(dfPrjX[gcp_index]), &(dfPrjY[gcp_index]) ) ) + bSuccess = FALSE; + + } + + if( bSuccess ) + { + + for(gcp_index=0;gcp_index<nGCPCount;gcp_index++) + { + pasGCPList[gcp_index].dfGCPX = dfPrjX[gcp_index]; + pasGCPList[gcp_index].dfGCPY = dfPrjY[gcp_index]; + + } + transform_ok = GDALGCPsToGeoTransform(nGCPCount,pasGCPList,adfGeoTransform,0); + + } + CPLFree(dfPrjX); + CPLFree(dfPrjY); + + } + + CPLFree( pszProjection ); + CPLFree( pszGCPProjection ); + pszProjection = NULL; + pszGCPProjection = NULL; + oProj.exportToWkt( &pszProjection ); + oProj.exportToWkt( &pszGCPProjection ); + + if (transform_ok == FALSE) + { + /* transform is sufficient in some cases (slant range, standalone gcps) */ + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + CPLFree( pszProjection ); + pszProjection = CPLStrdup(""); + } + + delete mffEllipsoids; + +} + + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *MFFDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i, bNative = TRUE; + char **papszHdrLines; + +/* -------------------------------------------------------------------- */ +/* We assume the user is pointing to the header file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 17 || poOpenInfo->fp == NULL ) + return NULL; + + if( !EQUAL(CPLGetExtension(poOpenInfo->pszFilename),"hdr") ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Load the .hdr file, and compress white space out around the */ +/* equal sign. */ +/* -------------------------------------------------------------------- */ + papszHdrLines = CSLLoad( poOpenInfo->pszFilename ); + if( papszHdrLines == NULL ) + return NULL; + + for( i = 0; papszHdrLines[i] != NULL; i++ ) + { + int bAfterEqual = FALSE; + int iSrc, iDst; + char *pszLine = papszHdrLines[i]; + + for( iSrc=0, iDst=0; pszLine[iSrc] != '\0'; iSrc++ ) + { + if( bAfterEqual || pszLine[iSrc] != ' ' ) + { + pszLine[iDst++] = pszLine[iSrc]; + } + + if( iDst > 0 && pszLine[iDst-1] == '=' ) + bAfterEqual = FALSE; + } + pszLine[iDst] = '\0'; + } + +/* -------------------------------------------------------------------- */ +/* Verify it is an MFF file. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue( papszHdrLines, "IMAGE_FILE_FORMAT" ) != NULL + && !EQUAL(CSLFetchNameValue(papszHdrLines,"IMAGE_FILE_FORMAT"),"MFF") ) + { + CSLDestroy( papszHdrLines ); + return NULL; + } + + if( (CSLFetchNameValue( papszHdrLines, "IMAGE_LINES" ) == NULL + || CSLFetchNameValue(papszHdrLines,"LINE_SAMPLES") == NULL) + && (CSLFetchNameValue( papszHdrLines, "no_rows" ) == NULL + || CSLFetchNameValue(papszHdrLines,"no_columns") == NULL) ) + { + CSLDestroy( papszHdrLines ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + MFFDataset *poDS; + + poDS = new MFFDataset(); + + poDS->papszHdrLines = papszHdrLines; + +/* -------------------------------------------------------------------- */ +/* Set some dataset wide information. */ +/* -------------------------------------------------------------------- */ + if( CSLFetchNameValue(papszHdrLines,"no_rows") != NULL + && CSLFetchNameValue(papszHdrLines,"no_columns") != NULL ) + { + poDS->RasterInitialize( + atoi(CSLFetchNameValue(papszHdrLines,"no_columns")), + atoi(CSLFetchNameValue(papszHdrLines,"no_rows")) ); + } + else + { + poDS->RasterInitialize( + atoi(CSLFetchNameValue(papszHdrLines,"LINE_SAMPLES")), + atoi(CSLFetchNameValue(papszHdrLines,"IMAGE_LINES")) ); + } + + if( CSLFetchNameValue( papszHdrLines, "BYTE_ORDER" ) != NULL ) + { +#ifdef CPL_MSB + bNative = EQUAL(CSLFetchNameValue(papszHdrLines,"BYTE_ORDER"),"MSB"); +#else + bNative = EQUAL(CSLFetchNameValue(papszHdrLines,"BYTE_ORDER"),"LSB"); +#endif + } + +/* -------------------------------------------------------------------- */ +/* Get some information specific to APP tiled files. */ +/* -------------------------------------------------------------------- */ + int bTiled, nTileXSize=0, nTileYSize=0; + const char *pszRefinedType = NULL; + + pszRefinedType = CSLFetchNameValue(papszHdrLines, "type" ); + + bTiled = CSLFetchNameValue(papszHdrLines,"no_rows") != NULL; + if( bTiled ) + { + if( CSLFetchNameValue(papszHdrLines,"tile_size_rows") ) + nTileYSize = + atoi(CSLFetchNameValue(papszHdrLines,"tile_size_rows")); + if( CSLFetchNameValue(papszHdrLines,"tile_size_columns") ) + nTileXSize = + atoi(CSLFetchNameValue(papszHdrLines,"tile_size_columns")); + } + +/* -------------------------------------------------------------------- */ +/* Read the directory to find matching band files. */ +/* -------------------------------------------------------------------- */ + char **papszDirFiles; + char *pszTargetBase, *pszTargetPath; + int nRawBand, nSkipped=0; + + pszTargetPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); + pszTargetBase = CPLStrdup(CPLGetBasename( poOpenInfo->pszFilename )); + papszDirFiles = CPLReadDir( CPLGetPath( poOpenInfo->pszFilename ) ); + if( papszDirFiles == NULL ) + return NULL; + + for( nRawBand = 0; TRUE; nRawBand++ ) + { + const char *pszExtension; + int nBand; + GDALDataType eDataType; + + /* Find the next raw band file. */ + for( i = 0; papszDirFiles[i] != NULL; i++ ) + { + if( !EQUAL(CPLGetBasename(papszDirFiles[i]),pszTargetBase) ) + continue; + + pszExtension = CPLGetExtension(papszDirFiles[i]); + if( isdigit(pszExtension[1]) + && atoi(pszExtension+1) == nRawBand + && strchr("bBcCiIjJrRxXzZ",pszExtension[0]) != NULL ) + break; + } + + if( papszDirFiles[i] == NULL ) + break; + + /* open the file for required level of access */ + FILE *fpRaw; + const char *pszRawFilename = CPLFormFilename(pszTargetPath, + papszDirFiles[i], NULL ); + + if( poOpenInfo->eAccess == GA_Update ) + fpRaw = VSIFOpenL( pszRawFilename, "rb+" ); + else + fpRaw = VSIFOpenL( pszRawFilename, "rb" ); + + if( fpRaw == NULL ) + { + CPLError( CE_Warning, CPLE_OpenFailed, + "Unable to open %s ... skipping.\n", + pszRawFilename ); + nSkipped++; + continue; + } + + pszExtension = CPLGetExtension(papszDirFiles[i]); + if( pszRefinedType != NULL ) + { + if( EQUAL(pszRefinedType,"C*4") ) + eDataType = GDT_CFloat32; + else if( EQUAL(pszRefinedType,"C*8") ) + eDataType = GDT_CFloat64; + else if( EQUAL(pszRefinedType,"R*4") ) + eDataType = GDT_Float32; + else if( EQUAL(pszRefinedType,"R*8") ) + eDataType = GDT_Float64; + else if( EQUAL(pszRefinedType,"I*1") ) + eDataType = GDT_Byte; + else if( EQUAL(pszRefinedType,"I*2") ) + eDataType = GDT_Int16; + else if( EQUAL(pszRefinedType,"I*4") ) + eDataType = GDT_Int32; + else if( EQUAL(pszRefinedType,"U*2") ) + eDataType = GDT_UInt16; + else if( EQUAL(pszRefinedType,"U*4") ) + eDataType = GDT_UInt32; + else if( EQUAL(pszRefinedType,"J*1") ) + continue; /* we don't support 1 byte complex */ + else if( EQUAL(pszRefinedType,"J*2") ) + eDataType = GDT_CInt16; + else if( EQUAL(pszRefinedType,"K*4") ) + eDataType = GDT_CInt32; + else + continue; + } + else if( EQUALN(pszExtension,"b",1) ) + { + eDataType = GDT_Byte; + } + else if( EQUALN(pszExtension,"i",1) ) + { + eDataType = GDT_UInt16; + } + else if( EQUALN(pszExtension,"j",1) ) + { + eDataType = GDT_CInt16; + } + else if( EQUALN(pszExtension,"r",1) ) + { + eDataType = GDT_Float32; + } + else if( EQUALN(pszExtension,"x",1) ) + { + eDataType = GDT_CFloat32; + } + else + continue; + + nBand = poDS->GetRasterCount() + 1; + + int nPixelOffset = GDALGetDataTypeSize(eDataType)/8; + GDALRasterBand *poBand = NULL; + + if( bTiled ) + { + poBand = + new MFFTiledBand( poDS, nBand, fpRaw, nTileXSize, nTileYSize, + eDataType, bNative ); + } + else + { + poBand = + new RawRasterBand( poDS, nBand, fpRaw, 0, nPixelOffset, + nPixelOffset * poDS->GetRasterXSize(), + eDataType, bNative, TRUE ); + } + + poDS->SetBand( nBand, poBand ); + } + + CPLFree(pszTargetPath); + CPLFree(pszTargetBase); + CSLDestroy(papszDirFiles); + +/* -------------------------------------------------------------------- */ +/* Check if we have bands. */ +/* -------------------------------------------------------------------- */ + if( poDS->GetRasterCount() == 0 ) + { + if( nSkipped > 0 && poOpenInfo->eAccess ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open %d files that were apparently bands.\n" + "Perhaps this dataset is readonly?\n", + nSkipped ); + delete poDS; + return NULL; + } + else + { + CPLError( CE_Failure, CPLE_OpenFailed, + "MFF header file read successfully, but no bands\n" + "were successfully found and opened." ); + delete poDS; + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + +/* -------------------------------------------------------------------- */ +/* Set all information from the .hdr that isn't well know to be */ +/* metadata. */ +/* -------------------------------------------------------------------- */ + for( i = 0; papszHdrLines[i] != NULL; i++ ) + { + const char *pszValue; + char *pszName; + + pszValue = CPLParseNameValue(papszHdrLines[i], &pszName); + if( pszName == NULL || pszValue == NULL ) + continue; + + if( !EQUAL(pszName,"END") + && !EQUAL(pszName,"FILE_TYPE") + && !EQUAL(pszName,"BYTE_ORDER") + && !EQUAL(pszName,"no_columns") + && !EQUAL(pszName,"no_rows") + && !EQUAL(pszName,"type") + && !EQUAL(pszName,"tile_size_rows") + && !EQUAL(pszName,"tile_size_columns") + && !EQUAL(pszName,"IMAGE_FILE_FORMAT") + && !EQUAL(pszName,"IMAGE_LINES") + && !EQUAL(pszName,"LINE_SAMPLES") ) + { + poDS->SetMetadataItem( pszName, pszValue ); + } + + CPLFree( pszName ); + } + +/* -------------------------------------------------------------------- */ +/* Any GCPs in header file? */ +/* -------------------------------------------------------------------- */ + poDS->ScanForGCPs(); + poDS->ScanForProjectionInfo(); + + return( poDS ); +} + +int GetMFFProjectionType(const char *pszNewProjection) +{ + OGRSpatialReference *oSRS; + char *modifiableProjection = NULL; + + if( !EQUALN(pszNewProjection,"GEOGCS",6) + && !EQUALN(pszNewProjection,"PROJCS",6) + && !EQUAL(pszNewProjection,"") ) + { + return MFFPRJ_UNRECOGNIZED; + } + else if (EQUAL(pszNewProjection,"")) + { + return MFFPRJ_NONE; + } + else + { + /* importFromWkt updates the pointer, so don't use pszNewProjection directly */ + modifiableProjection=CPLStrdup(pszNewProjection); + + oSRS = new OGRSpatialReference; + oSRS->importFromWkt(&modifiableProjection); + + if ((oSRS->GetAttrValue("PROJECTION") != NULL) && + (EQUAL(oSRS->GetAttrValue("PROJECTION"),SRS_PT_TRANSVERSE_MERCATOR))) + { + return MFFPRJ_UTM; + } + else if ((oSRS->GetAttrValue("PROJECTION") == NULL) && (oSRS->IsGeographic())) + { + return MFFPRJ_LL; + } + else + { + return MFFPRJ_UNRECOGNIZED; + } + } +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *MFFDataset::Create( const char * pszFilenameIn, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszParmList ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 + && eType != GDT_CInt16 && eType != GDT_CFloat32 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create MFF file with currently unsupported\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Establish the base filename (path+filename, less extension). */ +/* -------------------------------------------------------------------- */ + char *pszBaseFilename; + int i; + + pszBaseFilename = (char *) CPLMalloc(strlen(pszFilenameIn)+5); + strcpy( pszBaseFilename, pszFilenameIn ); + + for( i = strlen(pszBaseFilename)-1; i > 0; i-- ) + { + if( pszBaseFilename[i] == '.' ) + { + pszBaseFilename[i] = '\0'; + break; + } + + if( pszBaseFilename[i] == '/' || pszBaseFilename[i] == '\\' ) + break; + } + +/* -------------------------------------------------------------------- */ +/* Create the header file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + const char *pszFilename; + + pszFilename = CPLFormFilename( NULL, pszBaseFilename, "hdr" ); + + fp = VSIFOpen( pszFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Couldn't create %s.\n", pszFilename ); + return NULL; + } + + fprintf( fp, "IMAGE_FILE_FORMAT = MFF\n" ); + fprintf( fp, "FILE_TYPE = IMAGE\n" ); + fprintf( fp, "IMAGE_LINES = %d\n", nYSize ); + fprintf( fp, "LINE_SAMPLES = %d\n", nXSize ); +#ifdef CPL_MSB + fprintf( fp, "BYTE_ORDER = MSB\n" ); +#else + fprintf( fp, "BYTE_ORDER = LSB\n" ); +#endif + + if (CSLFetchNameValue(papszParmList,"NO_END") == NULL) + fprintf( fp, "END\n" ); + + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Create the data files, but don't bother writing any data to them.*/ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < nBands; iBand++ ) + { + char szExtension[4]; + + if( eType == GDT_Byte ) + sprintf( szExtension, "b%02d", iBand ); + else if( eType == GDT_UInt16 ) + sprintf( szExtension, "i%02d", iBand ); + else if( eType == GDT_Float32 ) + sprintf( szExtension, "r%02d", iBand ); + else if( eType == GDT_CInt16 ) + sprintf( szExtension, "j%02d", iBand ); + else if( eType == GDT_CFloat32 ) + sprintf( szExtension, "x%02d", iBand ); + + pszFilename = CPLFormFilename( NULL, pszBaseFilename, szExtension ); + fp = VSIFOpen( pszFilename, "wb" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Couldn't create %s.\n", pszFilename ); + return NULL; + } + + VSIFWrite( (void *) "", 1, 1, fp ); + VSIFClose( fp ); + } + +/* -------------------------------------------------------------------- */ +/* Open the dataset normally. */ +/* -------------------------------------------------------------------- */ + GDALDataset *poDS; + + strcat( pszBaseFilename, ".hdr" ); + poDS = (GDALDataset *) GDALOpen( pszBaseFilename, GA_Update ); + CPLFree( pszBaseFilename ); + + return poDS; +} + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +GDALDataset * +MFFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, + int bStrict, char ** papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + MFFDataset *poDS; + GDALDataType eType = poSrcDS->GetRasterBand(1)->GetRasterDataType(); + int iBand; + char **newpapszOptions=NULL; + + if( !pfnProgress( 0.0, NULL, pProgressData ) ) + return NULL; + + /* check that other bands match type- sets type */ + /* to unknown if they differ. */ + for( iBand = 1; iBand < poSrcDS->GetRasterCount(); iBand++ ) + { + GDALRasterBand *poBand = poSrcDS->GetRasterBand( iBand+1 ); + eType = GDALDataTypeUnion( eType, poBand->GetRasterDataType() ); + } + + newpapszOptions=CSLDuplicate(papszOptions); + newpapszOptions=CSLSetNameValue(newpapszOptions,"NO_END","TRUE"); + + poDS = (MFFDataset *) Create( pszFilename, + poSrcDS->GetRasterXSize(), + poSrcDS->GetRasterYSize(), + poSrcDS->GetRasterCount(), + eType, newpapszOptions ); + + CSLDestroy(newpapszOptions); + + + /* Check that Create worked- return Null if it didn't */ + if (poDS == NULL) + return NULL; + + +/* -------------------------------------------------------------------- */ +/* Copy the image data. */ +/* -------------------------------------------------------------------- */ + int nXSize = poDS->GetRasterXSize(); + int nYSize = poDS->GetRasterYSize(); + int nBlockXSize, nBlockYSize, nBlockTotal, nBlocksDone; + + poDS->GetRasterBand(1)->GetBlockSize( &nBlockXSize, &nBlockYSize ); + + nBlockTotal = ((nXSize + nBlockXSize - 1) / nBlockXSize) + * ((nYSize + nBlockYSize - 1) / nBlockYSize) + * poSrcDS->GetRasterCount(); + + nBlocksDone = 0; + for( iBand = 0; iBand < poSrcDS->GetRasterCount(); iBand++ ) + { + GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand+1 ); + GDALRasterBand *poDstBand = poDS->GetRasterBand( iBand+1 ); + int iYOffset, iXOffset; + void *pData; + CPLErr eErr; + + + pData = CPLMalloc(nBlockXSize * nBlockYSize + * GDALGetDataTypeSize(eType) / 8); + + for( iYOffset = 0; iYOffset < nYSize; iYOffset += nBlockYSize ) + { + for( iXOffset = 0; iXOffset < nXSize; iXOffset += nBlockXSize ) + { + int nTBXSize, nTBYSize; + + if( !pfnProgress( (nBlocksDone++) / (float) nBlockTotal, + NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poMFFDriver = + (GDALDriver *) GDALGetDriverByName( "MFF" ); + poMFFDriver->Delete( pszFilename ); + return NULL; + } + + nTBXSize = MIN(nBlockXSize,nXSize-iXOffset); + nTBYSize = MIN(nBlockYSize,nYSize-iYOffset); + + eErr = poSrcBand->RasterIO( GF_Read, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + if( eErr != CE_None ) + { + return NULL; + } + + eErr = poDstBand->RasterIO( GF_Write, + iXOffset, iYOffset, + nTBXSize, nTBYSize, + pData, nTBXSize, nTBYSize, + eType, 0, 0 ); + + if( eErr != CE_None ) + { + return NULL; + } + } + } + + CPLFree( pData ); + } + +/* -------------------------------------------------------------------- */ +/* Copy georeferencing information, if enough is available. */ +/* -------------------------------------------------------------------- */ + + +/* -------------------------------------------------------------------- */ +/* Establish the base filename (path+filename, less extension). */ +/* -------------------------------------------------------------------- */ + char *pszBaseFilename; + int i; + FILE *fp; + const char *pszFilenameGEO; + + pszBaseFilename = (char *) CPLMalloc(strlen(pszFilename)+5); + strcpy( pszBaseFilename, pszFilename ); + + for( i = strlen(pszBaseFilename)-1; i > 0; i-- ) + { + if( pszBaseFilename[i] == '.' ) + { + pszBaseFilename[i] = '\0'; + break; + } + + if( pszBaseFilename[i] == '/' || pszBaseFilename[i] == '\\' ) + break; + } + + pszFilenameGEO = CPLFormFilename( NULL, pszBaseFilename, "hdr" ); + + fp = VSIFOpen( pszFilenameGEO, "at" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Couldn't open %s for appending.\n", pszFilenameGEO ); + return NULL; + } + + + /* MFF requires corner and center gcps */ + double *padfTiepoints; + int src_prj; + int georef_created = FALSE; + + padfTiepoints = (double *) CPLMalloc(2*sizeof(double)*5); + + src_prj = GetMFFProjectionType(poSrcDS->GetProjectionRef()); + + if ((src_prj != MFFPRJ_NONE) && (src_prj != MFFPRJ_UNRECOGNIZED)) + { + double *tempGeoTransform = NULL; + + tempGeoTransform = (double *) CPLMalloc(6*sizeof(double)); + + if (( poSrcDS->GetGeoTransform( tempGeoTransform ) == CE_None) + && (tempGeoTransform[0] != 0.0 || tempGeoTransform[1] != 1.0 + || tempGeoTransform[2] != 0.0 || tempGeoTransform[3] != 0.0 + || tempGeoTransform[4] != 0.0 || ABS(tempGeoTransform[5]) != 1.0 )) + { + OGRSpatialReference oUTMorLL; + OGRSpatialReference oLL; + OGRCoordinateTransformation *poTransform = NULL; + char *srcProjection=NULL; + char *newGCPProjection=NULL; + + padfTiepoints[0]=tempGeoTransform[0] + tempGeoTransform[1]*0.5 +\ + tempGeoTransform[2]*0.5; + + padfTiepoints[1]=tempGeoTransform[3] + tempGeoTransform[4]*0.5 +\ + tempGeoTransform[5]*0.5; + + padfTiepoints[2]=tempGeoTransform[0] + tempGeoTransform[2]*0.5 +\ + tempGeoTransform[1]*(poSrcDS->GetRasterXSize()-0.5); + + padfTiepoints[3]=tempGeoTransform[3] + tempGeoTransform[5]*0.5 +\ + tempGeoTransform[4]*(poSrcDS->GetRasterXSize()-0.5); + + padfTiepoints[4]=tempGeoTransform[0] + tempGeoTransform[1]*0.5 +\ + tempGeoTransform[2]*(poSrcDS->GetRasterYSize()-0.5); + + padfTiepoints[5]=tempGeoTransform[3] + tempGeoTransform[4]*0.5 +\ + tempGeoTransform[5]*(poSrcDS->GetRasterYSize()-0.5); + + padfTiepoints[6]=tempGeoTransform[0] +\ + tempGeoTransform[1]*(poSrcDS->GetRasterXSize()-0.5) +\ + tempGeoTransform[2]*(poSrcDS->GetRasterYSize()-0.5); + + padfTiepoints[7]=tempGeoTransform[3]+\ + tempGeoTransform[4]*(poSrcDS->GetRasterXSize()-0.5)+\ + tempGeoTransform[5]*(poSrcDS->GetRasterYSize()-0.5); + + padfTiepoints[8]=tempGeoTransform[0]+\ + tempGeoTransform[1]*(poSrcDS->GetRasterXSize())/2.0+\ + tempGeoTransform[2]*(poSrcDS->GetRasterYSize())/2.0; + + padfTiepoints[9]=tempGeoTransform[3]+\ + tempGeoTransform[4]*(poSrcDS->GetRasterXSize())/2.0+\ + tempGeoTransform[5]*(poSrcDS->GetRasterYSize())/2.0; + + srcProjection = CPLStrdup(poSrcDS->GetProjectionRef()); + oUTMorLL.importFromWkt(&srcProjection); + (oUTMorLL.GetAttrNode("GEOGCS"))->exportToWkt(&newGCPProjection); + oLL.importFromWkt(&newGCPProjection); + if EQUALN(poSrcDS->GetProjectionRef(),"PROJCS",6) + { + // projected coordinate system- need to translate gcps */ + int bSuccess=TRUE; + int index; + + poTransform = OGRCreateCoordinateTransformation( &oUTMorLL, &oLL ); + if( poTransform == NULL ) + bSuccess = FALSE; + + for (index=0;index<5;index++) + { + if( !bSuccess || !poTransform->Transform( 1, &(padfTiepoints[index*2]), &(padfTiepoints[index*2+1]) ) ) + bSuccess = FALSE; + } + if (bSuccess == TRUE) + georef_created = TRUE; + } + else + { + georef_created = TRUE; + } + } + CPLFree(tempGeoTransform); + } + + if (georef_created == TRUE) + { + char *szValue; + + szValue = (char *) CPLMalloc(255); + /* -------------------------------------------------------------------- */ + /* top left */ + /* -------------------------------------------------------------------- */ + sprintf( szValue, "TOP_LEFT_CORNER_LATITUDE = %.10f\n", padfTiepoints[1] ); + fprintf( fp, szValue ); + sprintf( szValue, "TOP_LEFT_CORNER_LONGITUDE = %.10f\n", padfTiepoints[0] ); + fprintf( fp, szValue ); + /* -------------------------------------------------------------------- */ + /* top_right */ + /* -------------------------------------------------------------------- */ + sprintf( szValue, "TOP_RIGHT_CORNER_LATITUDE = %.10f\n", padfTiepoints[3] ); + fprintf( fp, szValue ); + sprintf( szValue, "TOP_RIGHT_CORNER_LONGITUDE = %.10f\n", padfTiepoints[2] ); + fprintf( fp, szValue ); + /* -------------------------------------------------------------------- */ + /* bottom_left */ + /* -------------------------------------------------------------------- */ + sprintf( szValue, "BOTTOM_LEFT_CORNER_LATITUDE = %.10f\n", padfTiepoints[5] ); + fprintf( fp, szValue ); + sprintf( szValue, "BOTTOM_LEFT_CORNER_LONGITUDE = %.10f\n", padfTiepoints[4] ); + fprintf( fp, szValue ); + /* -------------------------------------------------------------------- */ + /* bottom_right */ + /* -------------------------------------------------------------------- */ + sprintf( szValue, "BOTTOM_RIGHT_CORNER_LATITUDE = %.10f\n", padfTiepoints[7] ); + fprintf( fp, szValue ); + sprintf( szValue, "BOTTOM_RIGHT_CORNER_LONGITUDE = %.10f\n", padfTiepoints[6] ); + fprintf( fp, szValue ); + /* -------------------------------------------------------------------- */ + /* Center */ + /* -------------------------------------------------------------------- */ + sprintf( szValue, "CENTRE_LATITUDE = %.10f\n", padfTiepoints[9] ); + fprintf( fp, szValue ); + sprintf( szValue, "CENTRE_LONGITUDE = %.10f\n", padfTiepoints[8] ); + fprintf( fp, szValue ); + + + CPLFree(szValue); + /* ------------------------------------------------------------------- */ + /* Ellipsoid/projection */ + /* --------------------------------------------------------------------*/ + + + OGRSpatialReference *oSRS; + MFFSpheroidList *mffEllipsoids; + double eq_radius, inv_flattening; + OGRErr ogrerrorEq=OGRERR_NONE; + OGRErr ogrerrorInvf=OGRERR_NONE; + OGRErr ogrerrorOl=OGRERR_NONE; + char *modifiableProjection = NULL; + char *pszNewProjection; + char *spheroid_name = NULL; + + pszNewProjection = CPLStrdup( poSrcDS->GetProjectionRef() ); + + if( !EQUALN(pszNewProjection,"GEOGCS",6) + && !EQUALN(pszNewProjection,"PROJCS",6) + && !EQUAL(pszNewProjection,"") ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Only OGC WKT Projections supported for writing to MFF.\n" + "%s not supported.", + pszNewProjection ); + } + else if (!EQUAL(pszNewProjection,"")) + { + + + /* importFromWkt updates the pointer, so don't use pszNewProjection directly */ + modifiableProjection=CPLStrdup(pszNewProjection); + + oSRS = new OGRSpatialReference; + oSRS->importFromWkt(&modifiableProjection); + + if ((oSRS->GetAttrValue("PROJECTION") != NULL) && + (EQUAL(oSRS->GetAttrValue("PROJECTION"),SRS_PT_TRANSVERSE_MERCATOR))) + { + char *ol_txt; + + ol_txt=(char *) CPLMalloc(255); + fprintf(fp,"PROJECTION_NAME = UTM\n"); + sprintf(ol_txt,"PROJECTION_ORIGIN_LONGITUDE = %f\n", + oSRS->GetProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0,&ogrerrorOl)); + fprintf(fp,ol_txt); + CPLFree(ol_txt); + } + else if ((oSRS->GetAttrValue("PROJECTION") == NULL) && (oSRS->IsGeographic())) + { + fprintf(fp,"PROJECTION_NAME = LL\n"); + } + else + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unrecognized projection- no georeferencing information transferred."); + fprintf(fp,"PROJECTION_NAME = LL\n"); + } + eq_radius = oSRS->GetSemiMajor(&ogrerrorEq); + inv_flattening = oSRS->GetInvFlattening(&ogrerrorInvf); + if ((ogrerrorEq == OGRERR_NONE) && (ogrerrorInvf == OGRERR_NONE)) + { + char *ol_txt; + + ol_txt=(char *) CPLMalloc(255); + mffEllipsoids = new MFFSpheroidList; + spheroid_name = mffEllipsoids->GetSpheroidNameByEqRadiusAndInvFlattening(eq_radius,inv_flattening); + if (spheroid_name != NULL) + { + sprintf(ol_txt,"SPHEROID_NAME = %s\n",spheroid_name ); + fprintf(fp,ol_txt); + } + else + { + sprintf(ol_txt, + "SPHEROID_NAME = USER_DEFINED\nSPHEROID_EQUATORIAL_RADIUS = %.10f\nSPHEROID_POLAR_RADIUS = %.10f\n", + eq_radius,eq_radius*(1-1.0/inv_flattening) ); + fprintf(fp,ol_txt); + } + delete mffEllipsoids; + CPLFree(ol_txt); + CPLFree(spheroid_name); + } + } + CPLFree(pszNewProjection); + } + + CPLFree( padfTiepoints ); + fprintf( fp, "END\n" ); + VSIFClose( fp ); + + /* End of georeferencing stuff */ + + /* Make sure image data gets flushed */ + for( iBand = 0; iBand < poDS->GetRasterCount(); iBand++ ) + { + RawRasterBand *poDstBand = (RawRasterBand *) poDS->GetRasterBand( iBand+1 ); + poDstBand->FlushCache(); + } + + + if( !pfnProgress( 1.0, NULL, pProgressData ) ) + { + CPLError( CE_Failure, CPLE_UserInterrupt, + "User terminated" ); + delete poDS; + + GDALDriver *poMFFDriver = + (GDALDriver *) GDALGetDriverByName( "MFF" ); + poMFFDriver->Delete( pszFilename ); + return NULL; + } + + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} + + +/************************************************************************/ +/* GDALRegister_MFF() */ +/************************************************************************/ + +void GDALRegister_MFF() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "MFF" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "MFF" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Vexcel MFF Raster" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#MFF" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "hdr" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte UInt16 Float32 CInt16 CFloat32" ); + + poDriver->pfnOpen = MFFDataset::Open; + poDriver->pfnCreate = MFFDataset::Create; + poDriver->pfnCreateCopy = MFFDataset::CreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/ndfdataset.cpp b/Utilities/GDAL/frmts/raw/ndfdataset.cpp new file mode 100644 index 0000000000..d78e42074e --- /dev/null +++ b/Utilities/GDAL/frmts/raw/ndfdataset.cpp @@ -0,0 +1,376 @@ +/****************************************************************************** + * $Id: ndfdataset.cpp,v 1.4 2005/05/05 13:55:42 fwarmerdam Exp $ + * + * Project: NDF Driver + * Purpose: Implementation of NLAPS Data Format read support. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2005, 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: ndfdataset.cpp,v $ + * Revision 1.4 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.3 2005/03/05 17:27:00 fwarmerdam + * updated to support NDF1 and rotated datasets + * + * Revision 1.2 2005/03/05 17:07:30 fwarmerdam + * Fixed up an off-by-half-a-pixel error in geotransform. + * + * Revision 1.1 2005/01/06 20:27:22 fwarmerdam + * New + * + */ + +#include "rawdataset.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: ndfdataset.cpp,v 1.4 2005/05/05 13:55:42 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* NDFDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class NDFDataset : public RawDataset +{ + double adfGeoTransform[6]; + + char *pszProjection; + + char **papszHeader; + const char *Get( const char *pszKey, const char *pszDefault); + + int ReadHeader( FILE * ); + + public: + NDFDataset(); + ~NDFDataset(); + + virtual CPLErr GetGeoTransform( double * padfTransform ); + virtual const char *GetProjectionRef(void); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* NDFDataset() */ +/************************************************************************/ + +NDFDataset::NDFDataset() +{ + pszProjection = CPLStrdup(""); + + papszHeader = 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; +} + +/************************************************************************/ +/* ~NDFDataset() */ +/************************************************************************/ + +NDFDataset::~NDFDataset() + +{ + FlushCache(); + CPLFree( pszProjection ); + CSLDestroy( papszHeader ); + + for( int i = 0; i < GetRasterCount(); i++ ) + { + VSIFCloseL( ((RawRasterBand *) GetRasterBand(i+1))->GetFP() ); + } +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *NDFDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr NDFDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; +} + +/************************************************************************/ +/* Get() */ +/* */ +/* Fetch a value from the header by keyword. */ +/************************************************************************/ + +const char *NDFDataset::Get( const char *pszKey, const char *pszDefault ) + +{ + const char *pszResult = CSLFetchNameValue( papszHeader, pszKey ); + + if( pszResult == NULL ) + return pszDefault; + else + return pszResult; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *NDFDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* The user must select the header file (ie. .H1). */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->fp == NULL ) + return NULL; + + if( poOpenInfo->nHeaderBytes < 50 ) + return NULL; + + if( !EQUALN((const char *)poOpenInfo->pabyHeader,"NDF_REVISION=2",14) + && !EQUALN((const char *)poOpenInfo->pabyHeader,"NDF_REVISION=0",14) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Read and process the header into a local name/value */ +/* stringlist. We just take off the trailing semicolon. The */ +/* keyword is already seperated from the value by an equal */ +/* sign. */ +/* -------------------------------------------------------------------- */ + const char *pszLine; + const int nHeaderMax = 1000; + int nHeaderLines = 0; + char **papszHeader = (char **) CPLMalloc(sizeof(char *) * (nHeaderMax+1)); + + VSIRewind( poOpenInfo->fp ); + while( nHeaderLines < nHeaderMax + && (pszLine = CPLReadLine( poOpenInfo->fp )) != NULL + && !EQUAL(pszLine,"END_OF_HDR;") ) + { + char *pszFixed; + + if( strstr(pszLine,"=") == NULL ) + break; + + pszFixed = CPLStrdup( pszLine ); + if( pszFixed[strlen(pszFixed)-1] == ';' ) + pszFixed[strlen(pszFixed)-1] = '\0'; + + papszHeader[nHeaderLines++] = pszFixed; + papszHeader[nHeaderLines] = NULL; + } + + if( CSLFetchNameValue( papszHeader, "PIXELS_PER_LINE" ) == NULL + || CSLFetchNameValue( papszHeader, "LINES_PER_DATA_FILE" ) == NULL + || CSLFetchNameValue( papszHeader, "BITS_PER_PIXEL" ) == NULL + || CSLFetchNameValue( papszHeader, "PIXEL_FORMAT" ) == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Dataset appears to be NDF but is missing a required field."); + CSLDestroy( papszHeader ); + return NULL; + } + + if( !EQUAL(CSLFetchNameValue( papszHeader, "PIXEL_FORMAT"), + "BYTE" ) + || !EQUAL(CSLFetchNameValue( papszHeader, "BITS_PER_PIXEL"),"8") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Currently NDF driver supports only 8bit BYTE format." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + NDFDataset *poDS; + + poDS = new NDFDataset(); + poDS->papszHeader = papszHeader; + + poDS->nRasterXSize = atoi(poDS->Get("PIXELS_PER_LINE","")); + poDS->nRasterYSize = atoi(poDS->Get("LINES_PER_DATA_FILE","")); + +/* -------------------------------------------------------------------- */ +/* Create a raw raster band for each file. */ +/* -------------------------------------------------------------------- */ + int iBand; + int nBands = atoi(CSLFetchNameValue(papszHeader, + "NUMBER_OF_BANDS_IN_VOLUME")); + + for( iBand = 0; iBand < nBands; iBand++ ) + { + char szKey[100]; + const char *pszFilename; + + sprintf( szKey, "BAND%d_FILENAME", iBand+1 ); + pszFilename = poDS->Get(szKey,NULL); + + // NDF1 file do not include the band filenames. + if( pszFilename == NULL ) + { + char szBandExtension[15]; + sprintf( szBandExtension, "I%d", iBand+1 ); + pszFilename = CPLResetExtension( poOpenInfo->pszFilename, + szBandExtension ); + } + + FILE *fpRaw = VSIFOpenL( pszFilename, "rb" ); + if( fpRaw == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to open band file: %s", + pszFilename ); + delete poDS; + return NULL; + } + + RawRasterBand *poBand = + new RawRasterBand( poDS, iBand+1, fpRaw, 0, 1, poDS->nRasterXSize, + GDT_Byte, TRUE, TRUE ); + + sprintf( szKey, "BAND%d_NAME", iBand+1 ); + poBand->SetDescription( poDS->Get(szKey, "") ); + + sprintf( szKey, "BAND%d_WAVELENGTHS", iBand+1 ); + poBand->SetMetadataItem( "WAVELENGTHS", poDS->Get(szKey,"") ); + + sprintf( szKey, "BAND%d_RADIOMETRIC_GAINS/BIAS", iBand+1 ); + poBand->SetMetadataItem( "RADIOMETRIC_GAINS_BIAS", + poDS->Get(szKey,"") ); + + poDS->SetBand( iBand+1, poBand ); + } + +/* -------------------------------------------------------------------- */ +/* Minimal georef support ... should add full USGS style */ +/* support at some point. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS; + + if( EQUAL(poDS->Get( "USGS_PROJECTION_NUMBER", "" ),"1") ) + { + oSRS.SetUTM( atoi(poDS->Get("USGS_MAP_ZONE","0")) ); + oSRS.SetWellKnownGeogCS( "WGS84" ); + } + + if( oSRS.GetRoot() != NULL ) + { + CPLFree( poDS->pszProjection ); + poDS->pszProjection = NULL; + oSRS.exportToWkt( &(poDS->pszProjection) ); + } + +/* -------------------------------------------------------------------- */ +/* Get geotransform. */ +/* -------------------------------------------------------------------- */ + char **papszUL = CSLTokenizeString2( + poDS->Get("UPPER_LEFT_CORNER",""), ",", 0 ); + char **papszUR = CSLTokenizeString2( + poDS->Get("UPPER_RIGHT_CORNER",""), ",", 0 ); + char **papszLL = CSLTokenizeString2( + poDS->Get("LOWER_LEFT_CORNER",""), ",", 0 ); + + if( CSLCount(papszUL) == 4 + && CSLCount(papszUR) == 4 + && CSLCount(papszLL) == 4 ) + { + poDS->adfGeoTransform[0] = atof(papszUL[2]); + poDS->adfGeoTransform[1] = + (atof(papszUR[2]) - atof(papszUL[2])) / (poDS->nRasterXSize-1); + poDS->adfGeoTransform[2] = + (atof(papszUR[3]) - atof(papszUL[3])) / (poDS->nRasterXSize-1); + + poDS->adfGeoTransform[3] = atof(papszUL[3]); + poDS->adfGeoTransform[4] = + (atof(papszLL[2]) - atof(papszUL[2])) / (poDS->nRasterYSize-1); + poDS->adfGeoTransform[5] = + (atof(papszLL[3]) - atof(papszUL[3])) / (poDS->nRasterYSize-1); + + // Move origin up-left half a pixel. + poDS->adfGeoTransform[0] -= poDS->adfGeoTransform[1] * 0.5; + poDS->adfGeoTransform[0] -= poDS->adfGeoTransform[4] * 0.5; + poDS->adfGeoTransform[3] -= poDS->adfGeoTransform[2] * 0.5; + poDS->adfGeoTransform[3] -= poDS->adfGeoTransform[5] * 0.5; + } + + CSLDestroy( papszUL ); + CSLDestroy( papszLL ); + CSLDestroy( papszUR ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_NDF() */ +/************************************************************************/ + +void GDALRegister_NDF() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "NDF" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "NDF" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "NLAPS Data Format" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#NDF" ); + + poDriver->pfnOpen = NDFDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/pauxdataset.cpp b/Utilities/GDAL/frmts/raw/pauxdataset.cpp new file mode 100644 index 0000000000..815ac0c19a --- /dev/null +++ b/Utilities/GDAL/frmts/raw/pauxdataset.cpp @@ -0,0 +1,1114 @@ +/****************************************************************************** + * $Id: pauxdataset.cpp,v 1.32 2006/03/03 18:37:46 fwarmerdam Exp $ + * + * Project: PCI .aux Driver + * Purpose: Implementation of PAuxDataset + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: pauxdataset.cpp,v $ + * Revision 1.32 2006/03/03 18:37:46 fwarmerdam + * PCI2WKT changed to use OGRSpatialReference::ImportFromPCI(). + * + * Revision 1.31 2005/10/06 16:32:37 fwarmerdam + * Bug 947: Don't issue an error if there is no RawDefinition in .aux, + * just ignore it. + * + * Revision 1.30 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.29 2004/04/23 22:23:59 warmerda + * Fixed memory leak of pszAuxFilename. + * + * Revision 1.28 2004/03/24 09:02:07 dron + * Use CPL* functions for large integers parsing/printing. + * + * Revision 1.27 2004/03/23 15:03:25 dron + * Fixed problems with large (>4GB) multiband datasets. + * + * Revision 1.26 2004/01/18 14:10:56 dron + * Don't crash on broken auxilary files. + * + * Revision 1.25 2003/07/08 21:10:19 warmerda + * avoid warnings + * + * Revision 1.24 2003/06/26 19:05:03 warmerda + * fixed leak of pszTarget + * + * Revision 1.23 2003/02/03 05:10:18 warmerda + * fix expectation that GDALOpenInfo.fp is set, not necessarily for large files + * + * Revision 1.22 2002/11/23 18:54:17 warmerda + * added CREATIONDATATYPES metadata for drivers + * + * Revision 1.21 2002/10/07 19:27:02 warmerda + * Fixed small memory leak in ::Open(). + * + * Revision 1.20 2002/09/11 14:18:17 warmerda + * added channel description support + * + * Revision 1.19 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.18 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.17 2002/02/01 20:20:40 warmerda + * Added delete support. + * + * Revision 1.16 2001/12/12 18:15:46 warmerda + * preliminary update for large raw file support + */ + +#include "rawdataset.h" +#include "cpl_string.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: pauxdataset.cpp,v 1.32 2006/03/03 18:37:46 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_PAux(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* PAuxDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class PAuxRasterBand; + +class PAuxDataset : public RawDataset +{ + friend class PAuxRasterBand; + + FILE *fpImage; // image data file. + + int nGCPCount; + GDAL_GCP *pasGCPList; + char *pszGCPProjection; + + void ScanForGCPs(); + char *PCI2WKT( const char *pszGeosys, const char *pszProjParms ); + + char *pszProjection; + + public: + PAuxDataset(); + ~PAuxDataset(); + + char *pszAuxFilename; + char **papszAuxLines; + int bAuxUpdated; + + virtual const char *GetProjectionRef(); + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszParmList ); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* PAuxRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class PAuxRasterBand : public RawRasterBand +{ + GDALColorTable *poCT; + + public: + + PAuxRasterBand( GDALDataset *poDS, int nBand, FILE * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder ); + + ~PAuxRasterBand(); + + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual CPLErr SetNoDataValue( double ); + + virtual GDALColorTable *GetColorTable(); + virtual GDALColorInterp GetColorInterpretation(); + + virtual void SetDescription( const char *pszNewDescription ); +}; + +/************************************************************************/ +/* PAuxRasterBand() */ +/************************************************************************/ + +PAuxRasterBand::PAuxRasterBand( GDALDataset *poDS, int nBand, + FILE * fpRaw, vsi_l_offset nImgOffset, + int nPixelOffset, int nLineOffset, + GDALDataType eDataType, int bNativeOrder ) + : RawRasterBand( poDS, nBand, fpRaw, + nImgOffset, nPixelOffset, nLineOffset, + eDataType, bNativeOrder, TRUE ) + +{ + PAuxDataset *poPDS = (PAuxDataset *) poDS; + + poCT = NULL; + +/* -------------------------------------------------------------------- */ +/* Does this channel have a description? */ +/* -------------------------------------------------------------------- */ + char szTarget[128]; + + sprintf( szTarget, "ChanDesc-%d", nBand ); + if( CSLFetchNameValue( poPDS->papszAuxLines, szTarget ) != NULL ) + GDALRasterBand::SetDescription( + CSLFetchNameValue( poPDS->papszAuxLines, szTarget ) ); + +/* -------------------------------------------------------------------- */ +/* See if we have colors. Currently we must have color zero, */ +/* but this shouldn't really be a limitation. */ +/* -------------------------------------------------------------------- */ + sprintf( szTarget, "METADATA_IMG_%d_Class_%d_Color", nBand, 0 ); + if( CSLFetchNameValue( poPDS->papszAuxLines, szTarget ) != NULL ) + { + const char *pszLine; + int i; + + poCT = new GDALColorTable(); + + for( i = 0; i < 256; i++ ) + { + int nRed, nGreen, nBlue; + + sprintf( szTarget, "METADATA_IMG_%d_Class_%d_Color", nBand, i ); + pszLine = CSLFetchNameValue( poPDS->papszAuxLines, szTarget ); + while( pszLine && *pszLine == ' ' ) + pszLine++; + + if( pszLine != NULL + && EQUALN(pszLine, "(RGB:",5) + && sscanf( pszLine+5, "%d %d %d", + &nRed, &nGreen, &nBlue ) == 3 ) + { + GDALColorEntry oColor; + + oColor.c1 = (short) nRed; + oColor.c2 = (short) nGreen; + oColor.c3 = (short) nBlue; + oColor.c4 = 255; + + poCT->SetColorEntry( i, &oColor ); + } + } + } +} + +/************************************************************************/ +/* ~PAuxRasterBand() */ +/************************************************************************/ + +PAuxRasterBand::~PAuxRasterBand() + +{ + if( poCT != NULL ) + delete poCT; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double PAuxRasterBand::GetNoDataValue( int *pbSuccess ) + +{ + PAuxDataset *poPDS = (PAuxDataset *) poDS; + char szTarget[128]; + const char *pszLine; + + sprintf( szTarget, "METADATA_IMG_%d_NO_DATA_VALUE", nBand ); + + pszLine = CSLFetchNameValue( poPDS->papszAuxLines, szTarget ); + + if( pbSuccess != NULL ) + *pbSuccess = (pszLine != NULL); + + if( pszLine == NULL ) + return -1e8; + else + return atof(pszLine); +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr PAuxRasterBand::SetNoDataValue( double dfNewValue ) + +{ + PAuxDataset *poPDS = (PAuxDataset *) poDS; + char szTarget[128]; + char szValue[128]; + + if( GetAccess() == GA_ReadOnly ) + { + CPLError( CE_Failure, CPLE_NoWriteAccess, + "Can't update readonly dataset." ); + return CE_Failure; + } + + sprintf( szTarget, "METADATA_IMG_%d_NO_DATA_VALUE", nBand ); + sprintf( szValue, "%24.12f", dfNewValue ); + poPDS->papszAuxLines = + CSLSetNameValue( poPDS->papszAuxLines, szTarget, szValue ); + + poPDS->bAuxUpdated = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* SetDescription() */ +/* */ +/* We override the set description so we can mark the auxfile */ +/* info as changed. */ +/************************************************************************/ + +void PAuxRasterBand::SetDescription( const char *pszNewDescription ) + +{ + PAuxDataset *poPDS = (PAuxDataset *) poDS; + + if( GetAccess() == GA_Update ) + { + char szTarget[128]; + + sprintf( szTarget, "ChanDesc-%d", nBand ); + poPDS->papszAuxLines = + CSLSetNameValue( poPDS->papszAuxLines, + szTarget, pszNewDescription ); + + poPDS->bAuxUpdated = TRUE; + } + + GDALRasterBand::SetDescription( pszNewDescription ); +} + + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *PAuxRasterBand::GetColorTable() + +{ + return poCT; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp PAuxRasterBand::GetColorInterpretation() + +{ + if( poCT == NULL ) + return GCI_Undefined; + else + return GCI_PaletteIndex; +} + +/************************************************************************/ +/* ==================================================================== */ +/* PAuxDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* PAuxDataset() */ +/************************************************************************/ + +PAuxDataset::PAuxDataset() +{ + papszAuxLines = NULL; + fpImage = NULL; + bAuxUpdated = FALSE; + pszAuxFilename = NULL; + nGCPCount = 0; + pasGCPList = NULL; + + pszProjection = NULL; + pszGCPProjection = NULL; +} + +/************************************************************************/ +/* ~PAuxDataset() */ +/************************************************************************/ + +PAuxDataset::~PAuxDataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFCloseL( fpImage ); + + if( bAuxUpdated ) + { + CSLSetNameValueSeparator( papszAuxLines, ": " ); + CSLSave( papszAuxLines, pszAuxFilename ); + } + + CPLFree( pszProjection ); + + CPLFree( pszGCPProjection ); + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + + CPLFree( pszAuxFilename ); + CSLDestroy( papszAuxLines ); +} + +/************************************************************************/ +/* PCI2WKT() */ +/* */ +/* Convert PCI coordinate system to WKT. For now this is very */ +/* incomplete, but can be filled out in the future. */ +/************************************************************************/ + +char *PAuxDataset::PCI2WKT( const char *pszGeosys, + const char *pszProjParms ) + +{ + OGRSpatialReference oSRS; + + while( *pszGeosys == ' ' ) + pszGeosys++; + +/* -------------------------------------------------------------------- */ +/* Parse projection parameters array. */ +/* -------------------------------------------------------------------- */ + double adfProjParms[16]; + + memset( adfProjParms, 0, sizeof(adfProjParms) ); + + if( pszProjParms != NULL ) + { + char **papszTokens; + int i; + + papszTokens = CSLTokenizeString( pszProjParms ); + + for( i=0; papszTokens != NULL && papszTokens[i] != NULL && i < 16; i++) + adfProjParms[i] = atof(papszTokens[i]); + + CSLDestroy( papszTokens ); + } + +/* -------------------------------------------------------------------- */ +/* Convert to SRS. */ +/* -------------------------------------------------------------------- */ + if( oSRS.importFromPCI( pszGeosys, NULL, adfProjParms ) == OGRERR_NONE ) + { + char *pszResult = NULL; + + oSRS.exportToWkt( &pszResult ); + + return pszResult; + } + else + return NULL; +} + +/************************************************************************/ +/* ScanForGCPs() */ +/************************************************************************/ + +void PAuxDataset::ScanForGCPs() + +{ +#define MAX_GCP 256 + + nGCPCount = 0; + pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),MAX_GCP); + +/* -------------------------------------------------------------------- */ +/* Get the GCP coordinate system. */ +/* -------------------------------------------------------------------- */ + const char *pszMapUnits, *pszProjParms; + + pszMapUnits = CSLFetchNameValue( papszAuxLines, "GCP_1_MapUnits" ); + pszProjParms = CSLFetchNameValue( papszAuxLines, "GCP_1_ProjParms" ); + + if( pszMapUnits != NULL ) + pszGCPProjection = PCI2WKT( pszMapUnits, pszProjParms ); + +/* -------------------------------------------------------------------- */ +/* Collect standalone GCPs. They look like: */ +/* */ +/* GCP_1_n = row, col, x, y [,z [,"id"[, "desc"]]] */ +/* -------------------------------------------------------------------- */ + int i; + + for( i = 0; nGCPCount < MAX_GCP; i++ ) + { + char szName[50]; + char **papszTokens; + + sprintf( szName, "GCP_1_%d", i+1 ); + if( CSLFetchNameValue( papszAuxLines, szName ) == NULL ) + break; + + papszTokens = CSLTokenizeStringComplex( + CSLFetchNameValue( papszAuxLines, szName ), + " ", TRUE, FALSE ); + + if( CSLCount(papszTokens) >= 4 ) + { + GDALInitGCPs( 1, pasGCPList + nGCPCount ); + + pasGCPList[nGCPCount].dfGCPX = atof(papszTokens[2]); + pasGCPList[nGCPCount].dfGCPY = atof(papszTokens[3]); + pasGCPList[nGCPCount].dfGCPPixel = atof(papszTokens[0]); + pasGCPList[nGCPCount].dfGCPLine = atof(papszTokens[1]); + + if( CSLCount(papszTokens) > 4 ) + pasGCPList[nGCPCount].dfGCPZ = atof(papszTokens[4]); + + CPLFree( pasGCPList[nGCPCount].pszId ); + if( CSLCount(papszTokens) > 5 ) + { + pasGCPList[nGCPCount].pszId = papszTokens[5]; + } + else + { + sprintf( szName, "GCP_%d", i+1 ); + pasGCPList[nGCPCount].pszId = CPLStrdup( szName ); + } + + if( CSLCount(papszTokens) > 6 ) + { + CPLFree( pasGCPList[nGCPCount].pszInfo ); + pasGCPList[nGCPCount].pszInfo = papszTokens[6]; + } + + nGCPCount++; + } + } +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int PAuxDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *PAuxDataset::GetGCPProjection() + +{ + if( nGCPCount > 0 && pszGCPProjection != NULL ) + return pszGCPProjection; + else + return ""; +} + +/************************************************************************/ +/* GetGCP() */ +/************************************************************************/ + +const GDAL_GCP *PAuxDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *PAuxDataset::GetProjectionRef() + +{ + if( pszProjection ) + return pszProjection; + else + return GDALPamDataset::GetProjectionRef(); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr PAuxDataset::GetGeoTransform( double * padfGeoTransform ) + +{ + if( CSLFetchNameValue(papszAuxLines, "UpLeftX") != NULL + && CSLFetchNameValue(papszAuxLines, "UpLeftY") != NULL + && CSLFetchNameValue(papszAuxLines, "LoRightX") != NULL + && CSLFetchNameValue(papszAuxLines, "LoRightY") != NULL ) + { + double dfUpLeftX, dfUpLeftY, dfLoRightX, dfLoRightY; + + dfUpLeftX = atof(CSLFetchNameValue(papszAuxLines, "UpLeftX" )); + dfUpLeftY = atof(CSLFetchNameValue(papszAuxLines, "UpLeftY" )); + dfLoRightX = atof(CSLFetchNameValue(papszAuxLines, "LoRightX" )); + dfLoRightY = atof(CSLFetchNameValue(papszAuxLines, "LoRightY" )); + + padfGeoTransform[0] = dfUpLeftX; + padfGeoTransform[1] = (dfLoRightX - dfUpLeftX) / GetRasterXSize(); + padfGeoTransform[2] = 0.0; + padfGeoTransform[3] = dfUpLeftY; + padfGeoTransform[4] = 0.0; + padfGeoTransform[5] = (dfLoRightY - dfUpLeftY) / GetRasterYSize(); + + return CE_None; + } + else + { + return CE_Failure; + } +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr PAuxDataset::SetGeoTransform( double * padfGeoTransform ) + +{ + char szUpLeftX[128]; + char szUpLeftY[128]; + char szLoRightX[128]; + char szLoRightY[128]; + + if( ABS(padfGeoTransform[0]) < 181 + && ABS(padfGeoTransform[1]) < 1 ) + { + sprintf( szUpLeftX, "%.12f", padfGeoTransform[0] ); + sprintf( szUpLeftY, "%.12f", padfGeoTransform[3] ); + sprintf( szLoRightX, "%.12f", + padfGeoTransform[0] + padfGeoTransform[1] * GetRasterXSize() ); + sprintf( szLoRightY, "%.12f", + padfGeoTransform[3] + padfGeoTransform[5] * GetRasterYSize() ); + } + else + { + sprintf( szUpLeftX, "%.3f", padfGeoTransform[0] ); + sprintf( szUpLeftY, "%.3f", padfGeoTransform[3] ); + sprintf( szLoRightX, "%.3f", + padfGeoTransform[0] + padfGeoTransform[1] * GetRasterXSize() ); + sprintf( szLoRightY, "%.3f", + padfGeoTransform[3] + padfGeoTransform[5] * GetRasterYSize() ); + } + + papszAuxLines = CSLSetNameValue( papszAuxLines, + "UpLeftX", szUpLeftX ); + papszAuxLines = CSLSetNameValue( papszAuxLines, + "UpLeftY", szUpLeftY ); + papszAuxLines = CSLSetNameValue( papszAuxLines, + "LoRightX", szLoRightX ); + papszAuxLines = CSLSetNameValue( papszAuxLines, + "LoRightY", szLoRightY ); + + bAuxUpdated = TRUE; + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *PAuxDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i; + char *pszAuxFilename; + char **papszTokens; + char *pszTarget; + + if( poOpenInfo->nHeaderBytes < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* If this is an .aux file, fetch out and form the name of the */ +/* file it references. */ +/* -------------------------------------------------------------------- */ + + pszTarget = CPLStrdup( poOpenInfo->pszFilename ); + + if( EQUAL(CPLGetExtension( poOpenInfo->pszFilename ),"aux") + && EQUALN((const char *) poOpenInfo->pabyHeader,"AuxilaryTarget: ",16)) + { + char szAuxTarget[1024]; + char *pszPath; + const char *pszSrc = (const char *) poOpenInfo->pabyHeader+16; + + for( i = 0; + pszSrc[i] != 10 && pszSrc[i] != 13 && pszSrc[i] != '\0' + && i < (int) sizeof(szAuxTarget)-1; + i++ ) + { + szAuxTarget[i] = pszSrc[i]; + } + szAuxTarget[i] = '\0'; + + CPLFree( pszTarget ); + + pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); + pszTarget = CPLStrdup(CPLFormFilename(pszPath, szAuxTarget, NULL)); + } + +/* -------------------------------------------------------------------- */ +/* Now we need to tear apart the filename to form a .aux */ +/* filename. */ +/* -------------------------------------------------------------------- */ + pszAuxFilename = CPLStrdup(CPLResetExtension(pszTarget,"aux")); + +/* -------------------------------------------------------------------- */ +/* Do we have a .aux file? */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszAuxFilename, "r" ); + if( fp == NULL ) + { + strcpy( pszAuxFilename + strlen(pszAuxFilename)-4, ".aux" ); + fp = VSIFOpen( pszAuxFilename, "r" ); + } + + if( fp == NULL ) + { + CPLFree( pszTarget ); + CPLFree( pszAuxFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Is this file a PCI .aux file? Check the first line for the */ +/* telltale AuxilaryTarget keyword. */ +/* */ +/* At this point we should be verifying that it refers to our */ +/* binary file, but that is a pretty involved test. */ +/* -------------------------------------------------------------------- */ + const char * pszLine; + + pszLine = CPLReadLine( fp ); + + VSIFClose( fp ); + + if( pszLine == NULL || !EQUALN(pszLine,"AuxilaryTarget",14) ) + { + CPLFree( pszAuxFilename ); + CPLFree( pszTarget ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + PAuxDataset *poDS; + + poDS = new PAuxDataset(); + +/* -------------------------------------------------------------------- */ +/* Load the .aux file into a string list suitable to be */ +/* searched with CSLFetchNameValue(). */ +/* -------------------------------------------------------------------- */ + poDS->papszAuxLines = CSLLoad( pszAuxFilename ); + poDS->pszAuxFilename = pszAuxFilename; + +/* -------------------------------------------------------------------- */ +/* Find the RawDefinition line to establish overall parameters. */ +/* -------------------------------------------------------------------- */ + pszLine = CSLFetchNameValue(poDS->papszAuxLines, "RawDefinition"); + + // It seems PCI now writes out .aux files without RawDefinition in + // some cases. See bug 947. + if( pszLine == NULL ) + { + delete poDS; + return NULL; + } + + papszTokens = CSLTokenizeString(pszLine); + + if( CSLCount(papszTokens) < 3 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "RawDefinition missing or corrupt in %s.", + poOpenInfo->pszFilename ); + + return NULL; + } + + poDS->nRasterXSize = atoi(papszTokens[0]); + poDS->nRasterYSize = atoi(papszTokens[1]); + poDS->nBands = atoi(papszTokens[2]); + poDS->eAccess = poOpenInfo->eAccess; + + CSLDestroy( papszTokens ); + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->eAccess == GA_Update ) + { + poDS->fpImage = VSIFOpenL( pszTarget, "rb+" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "File %s is missing or read-only, check permissions.", + pszTarget ); + + delete poDS; + return NULL; + } + } + else + { + poDS->fpImage = VSIFOpenL( pszTarget, "rb" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "File %s is missing or unreadable.", + pszTarget ); + + delete poDS; + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Collect raw definitions of each channel and create */ +/* corresponding bands. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < poDS->nBands; i++ ) + { + char szDefnName[32]; + GDALDataType eType; + int bNative = TRUE; + + sprintf( szDefnName, "ChanDefinition-%d", i+1 ); + + pszLine = CSLFetchNameValue(poDS->papszAuxLines, szDefnName); + papszTokens = CSLTokenizeString(pszLine); + if( CSLCount(papszTokens) < 4 ) + { + // Skip the band with broken description + poDS->nBands--; + continue; + } + + if( EQUAL(papszTokens[0],"16U") ) + eType = GDT_UInt16; + else if( EQUAL(papszTokens[0],"16S") ) + eType = GDT_Int16; + else if( EQUAL(papszTokens[0],"32R") ) + eType = GDT_Float32; + else + eType = GDT_Byte; + + if( CSLCount(papszTokens) > 4 ) + { +#ifdef CPL_LSB + bNative = EQUAL(papszTokens[4],"Swapped"); +#else + bNative = EQUAL(papszTokens[4],"Unswapped"); +#endif + } + + poDS->SetBand( i+1, + new PAuxRasterBand( poDS, i+1, poDS->fpImage, + CPLScanUIntBig(papszTokens[1], + strlen(papszTokens[1])), + atoi(papszTokens[2]), + atoi(papszTokens[3]), eType, bNative ) ); + + CSLDestroy( papszTokens ); + } + +/* -------------------------------------------------------------------- */ +/* Get the projection. */ +/* -------------------------------------------------------------------- */ + const char *pszMapUnits, *pszProjParms; + + pszMapUnits = CSLFetchNameValue( poDS->papszAuxLines, "MapUnits" ); + pszProjParms = CSLFetchNameValue( poDS->papszAuxLines, "ProjParms" ); + + if( pszMapUnits != NULL ) + poDS->pszProjection = poDS->PCI2WKT( pszMapUnits, pszProjParms ); + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, pszTarget ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( pszTarget ); + poDS->TryLoadXML(); + + poDS->ScanForGCPs(); + + CPLFree( pszTarget ); + + poDS->bAuxUpdated = FALSE; + + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *PAuxDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** /* papszParmList */ ) + +{ + char *pszAuxFilename; + +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 + && eType != GDT_Int16 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create PCI .Aux labelled dataset with an illegal\n" + "data type (%s).\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpen( pszFilename, "w" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Just write out a couple of bytes to establish the binary */ +/* file, and then close it. */ +/* -------------------------------------------------------------------- */ + VSIFWrite( (void *) "\0\0", 2, 1, fp ); + VSIFClose( fp ); + +/* -------------------------------------------------------------------- */ +/* Create the aux filename. */ +/* -------------------------------------------------------------------- */ + pszAuxFilename = (char *) CPLMalloc(strlen(pszFilename)+5); + strcpy( pszAuxFilename, pszFilename );; + + for( int i = strlen(pszAuxFilename)-1; i > 0; i-- ) + { + if( pszAuxFilename[i] == '.' ) + { + pszAuxFilename[i] = '\0'; + break; + } + } + + strcat( pszAuxFilename, ".aux" ); + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + fp = VSIFOpen( pszAuxFilename, "wt" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszAuxFilename ); + return NULL; + } + CPLFree( pszAuxFilename ); + +/* -------------------------------------------------------------------- */ +/* We need to write out the original filename but without any */ +/* path components in the AuxilaryTarget line. Do so now. */ +/* -------------------------------------------------------------------- */ + int iStart; + + iStart = strlen(pszFilename)-1; + while( iStart > 0 && pszFilename[iStart-1] != '/' + && pszFilename[iStart-1] != '\\' ) + iStart--; + + VSIFPrintf( fp, "AuxilaryTarget: %s\n", pszFilename + iStart ); + +/* -------------------------------------------------------------------- */ +/* Write out the raw definition for the dataset as a whole. */ +/* -------------------------------------------------------------------- */ + VSIFPrintf( fp, "RawDefinition: %d %d %d\n", + nXSize, nYSize, nBands ); + +/* -------------------------------------------------------------------- */ +/* Write out a definition for each band. We always write band */ +/* sequential files for now as these are pretty efficiently */ +/* handled by GDAL. */ +/* -------------------------------------------------------------------- */ + vsi_l_offset nImgOffset = 0; + + for( int iBand = 0; iBand < nBands; iBand++ ) + { + const char *pszTypeName; + char szImgOffset[64]; + int nPixelOffset, nLineOffset, nChars; + + nPixelOffset = GDALGetDataTypeSize(eType)/8; + nLineOffset = nXSize * nPixelOffset; + + if( eType == GDT_Float32 ) + pszTypeName = "32R"; + else if( eType == GDT_Int16 ) + pszTypeName = "16S"; + else if( eType == GDT_UInt16 ) + pszTypeName = "16U"; + else + pszTypeName = "8U"; + + nChars = CPLPrintUIntBig( szImgOffset, nImgOffset, 63 ); + szImgOffset[nChars] = '\0'; + + VSIFPrintf( fp, "ChanDefinition-%d: %s %s %d %d %s\n", iBand+1, + pszTypeName, strpbrk(szImgOffset, "-.0123456789"), + nPixelOffset, nLineOffset, +#ifdef CPL_LSB + "Swapped" +#else + "Unswapped" +#endif + ); + + nImgOffset += (vsi_l_offset)nYSize * nLineOffset; + } + +/* -------------------------------------------------------------------- */ +/* Cleanup */ +/* -------------------------------------------------------------------- */ + VSIFClose( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* PAuxDelete() */ +/************************************************************************/ + +CPLErr PAuxDelete( const char * pszBasename ) + +{ + FILE *fp; + const char *pszLine; + + fp = VSIFOpen( CPLResetExtension( pszBasename, "aux" ), "r" ); + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s does not appear to be a PAux dataset, there is no .aux file.", + pszBasename ); + return CE_Failure; + } + + pszLine = CPLReadLine( fp ); + VSIFClose( fp ); + + if( pszLine == NULL || !EQUALN(pszLine,"AuxilaryTarget",14) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s does not appear to be a PAux dataset,\n" + "the .aux file does not start with AuxilaryTarget", + pszBasename ); + return CE_Failure; + } + + if( VSIUnlink( pszBasename ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "OS unlinking file %s.", pszBasename ); + return CE_Failure; + } + + VSIUnlink( CPLResetExtension( pszBasename, "aux" ) ); + + return CE_None; +} + +/************************************************************************/ +/* GDALRegister_PAux() */ +/************************************************************************/ + +void GDALRegister_PAux() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "PAux" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "PAux" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "PCI .aux Labelled" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#PAux" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte Int16 UInt16 Float32" ); + + poDriver->pfnOpen = PAuxDataset::Open; + poDriver->pfnCreate = PAuxDataset::Create; + poDriver->pfnDelete = PAuxDelete; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/raw/pnmdataset.cpp b/Utilities/GDAL/frmts/raw/pnmdataset.cpp new file mode 100644 index 0000000000..431a0311a1 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/pnmdataset.cpp @@ -0,0 +1,445 @@ +/****************************************************************************** + * $Id: pnmdataset.cpp,v 1.17 2005/05/05 13:55:42 fwarmerdam Exp $ + * + * Project: PNM Driver + * Purpose: Portable anymap file format imlementation + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2001, 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: pnmdataset.cpp,v $ + * Revision 1.17 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.16 2004/02/04 21:47:31 warmerda + * use VSIFClose() to close openinfo file, not VSIFCloseL() + * + * Revision 1.15 2003/10/24 14:22:49 warmerda + * Added worldfile read support (but not write/export). + * + * Revision 1.14 2003/03/27 11:34:25 dron + * Fixes for large file support. + * + * Revision 1.13 2003/03/25 13:52:18 dron + * CREATIONOPTIONLIST added, fixed problem with MIMETYPE. + * + * Revision 1.12 2003/02/13 22:00:26 dron + * Added creation option MAXVAL. + * + * + * Revision 1.10 2003/02/06 20:27:09 dron + * More PNM standard complience in header reading. + * + * Revision 1.9 2003/02/03 11:14:24 dron + * Added support for reading and writing 16-bit images. + * + * Revision 1.8 2002/11/23 18:54:17 warmerda + * added CREATIONDATATYPES metadata for drivers + * + * Revision 1.7 2002/09/19 21:10:02 warmerda + * Fixed GetDriverByName call. + * + * Revision 1.6 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.5 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.4 2002/04/16 17:52:35 warmerda + * Initialize variables. + * + * Revision 1.3 2001/07/18 19:04:10 warmerda + * Removed debug printf. + * + * Revision 1.2 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.1 2001/01/03 18:53:36 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_string.h" +#include <ctype.h> + +CPL_CVSID("$Id: pnmdataset.cpp,v 1.17 2005/05/05 13:55:42 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_PNM(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* PNMDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class PNMDataset : public RawDataset +{ + FILE *fpImage; // image data file. + + int bGeoTransformValid; + double adfGeoTransform[6]; + + public: + PNMDataset(); + ~PNMDataset(); + + virtual CPLErr GetGeoTransform( double * ); + + static GDALDataset *Open( GDALOpenInfo * ); + static GDALDataset *Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, char ** papszOptions ); +}; + +/************************************************************************/ +/* PNMDataset() */ +/************************************************************************/ + +PNMDataset::PNMDataset() +{ + fpImage = NULL; + bGeoTransformValid = FALSE; + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; +} + +/************************************************************************/ +/* ~PNMDataset() */ +/************************************************************************/ + +PNMDataset::~PNMDataset() + +{ + FlushCache(); + if( fpImage != NULL ) + VSIFCloseL( fpImage ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr PNMDataset::GetGeoTransform( double * padfTransform ) + +{ + + if( bGeoTransformValid ) + { + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + return CE_None; + } + else + return CE_Failure; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *PNMDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify that this is a _raw_ ppm or pgm file. Note, we don't */ +/* support ascii files, or pbm (1bit) files. */ +/* -------------------------------------------------------------------- */ + if( poOpenInfo->nHeaderBytes < 10 || poOpenInfo->fp == NULL ) + return NULL; + + if( poOpenInfo->pabyHeader[0] != 'P' && + (poOpenInfo->pabyHeader[2] != ' ' || // XXX: Magick number + poOpenInfo->pabyHeader[2] != '\t' || // may be followed + poOpenInfo->pabyHeader[2] != '\n' || // any of the blank + poOpenInfo->pabyHeader[2] != '\r') ) // characters + return NULL; + + if( poOpenInfo->pabyHeader[1] != '5' + && poOpenInfo->pabyHeader[1] != '6' ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Parse out the tokens from the header. */ +/* -------------------------------------------------------------------- */ + const char *pszSrc = (const char *) poOpenInfo->pabyHeader; + char szToken[512]; + int iIn, iOut, iToken = 0, nWidth =-1, nHeight=-1, nMaxValue=-1; + + iIn = 2; + while( iIn < poOpenInfo->nHeaderBytes && iToken < 3 ) + { + iOut = 0; + szToken[0] = '\0'; + while( iIn < poOpenInfo->nHeaderBytes ) + { + if( pszSrc[iIn] == '#' ) + { + while( pszSrc[iIn] != 10 && pszSrc[iIn] != 13 + && iIn < poOpenInfo->nHeaderBytes - 1 ) + iIn++; + } + + if( iOut != 0 && isspace(pszSrc[iIn]) ) + { + szToken[iOut] = '\0'; + + if( iToken == 0 ) + nWidth = atoi(szToken); + else if( iToken == 1 ) + nHeight = atoi(szToken); + else if( iToken == 2 ) + nMaxValue = atoi(szToken); + + iToken++; + iIn++; + break; + } + + else if( !isspace(pszSrc[iIn]) ) + { + szToken[iOut++] = pszSrc[iIn]; + } + + iIn++; + } + } + + CPLDebug( "PNM", "PNM header contains: width=%d, height=%d, maxval=%d", + nWidth, nHeight, nMaxValue ); + + if( iToken != 3 || nWidth < 1 || nHeight < 1 || nMaxValue < 1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + PNMDataset *poDS; + + poDS = new PNMDataset(); + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = nWidth; + poDS->nRasterYSize = nHeight; + +/* -------------------------------------------------------------------- */ +/* Assume ownership of the file handled from the GDALOpenInfo. */ +/* -------------------------------------------------------------------- */ + VSIFClose( poOpenInfo->fp ); + poOpenInfo->fp = NULL; + + if( poOpenInfo->eAccess == GA_Update ) + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); + else + poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); + + if( poDS->fpImage == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to re-open %s within PNM driver.\n", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + int bMSBFirst = TRUE, iPixelSize; + GDALDataType eDataType; + +#ifdef CPL_LSB + bMSBFirst = FALSE; +#endif + + if ( nMaxValue < 256 ) + eDataType = GDT_Byte; + else + eDataType = GDT_UInt16; + + iPixelSize = GDALGetDataTypeSize( eDataType ) / 8; + + if( poOpenInfo->pabyHeader[1] == '5' ) + { + poDS->SetBand( + 1, new RawRasterBand( poDS, 1, poDS->fpImage, iIn, iPixelSize, + nWidth*iPixelSize, eDataType, bMSBFirst, TRUE )); + } + else + { + poDS->SetBand( + 1, new RawRasterBand( poDS, 1, poDS->fpImage, iIn, 3*iPixelSize, + nWidth*3*iPixelSize, eDataType, bMSBFirst, TRUE )); + poDS->SetBand( + 2, new RawRasterBand( poDS, 2, poDS->fpImage, iIn+iPixelSize, + 3*iPixelSize, nWidth*3*iPixelSize, + eDataType, bMSBFirst, TRUE )); + poDS->SetBand( + 3, new RawRasterBand( poDS, 3, poDS->fpImage, iIn+2*iPixelSize, + 3*iPixelSize, nWidth*3*iPixelSize, + eDataType, bMSBFirst, TRUE )); + } + +/* -------------------------------------------------------------------- */ +/* Check for overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + poDS->bGeoTransformValid = + GDALReadWorldFile( poOpenInfo->pszFilename, ".wld", + poDS->adfGeoTransform ); + return( poDS ); +} + +/************************************************************************/ +/* Create() */ +/************************************************************************/ + +GDALDataset *PNMDataset::Create( const char * pszFilename, + int nXSize, int nYSize, int nBands, + GDALDataType eType, + char ** papszOptions ) + +{ +/* -------------------------------------------------------------------- */ +/* Verify input options. */ +/* -------------------------------------------------------------------- */ + if( eType != GDT_Byte && eType != GDT_UInt16 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create PNM dataset with an illegal\n" + "data type (%s), only Byte and UInt16 supported.\n", + GDALGetDataTypeName(eType) ); + + return NULL; + } + + if( nBands != 1 && nBands != 3 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create PNM dataset with an illegal number\n" + "of bands (%d). Must be 1 (greyscale) or 3 (RGB).\n", + nBands ); + + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Try to create the file. */ +/* -------------------------------------------------------------------- */ + FILE *fp; + + fp = VSIFOpenL( pszFilename, "wb" ); + + if( fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed.\n", + pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Write out the header. */ +/* -------------------------------------------------------------------- */ + char szHeader[500]; + const char *pszMaxValue = NULL; + int nMaxValue = 0; + + pszMaxValue = CSLFetchNameValue( papszOptions, "MAXVAL" ); + if ( pszMaxValue ) + { + nMaxValue = atoi( pszMaxValue ); + if ( eType == GDT_Byte && (nMaxValue > 255 || nMaxValue < 0) ) + nMaxValue = 255; + else if ( nMaxValue > 65535 || nMaxValue < 0 ) + nMaxValue = 65535; + } + else + { + if ( eType == GDT_Byte ) + nMaxValue = 255; + else + nMaxValue = 65535; + } + + + memset( szHeader, 0, sizeof(szHeader) ); + + if( nBands == 3 ) + sprintf( szHeader, "P6\n%d %d\n%d\n", nXSize, nYSize, nMaxValue ); + else + sprintf( szHeader, "P5\n%d %d\n%d\n", nXSize, nYSize, nMaxValue ); + + VSIFWriteL( (void *) szHeader, strlen(szHeader) + 2, 1, fp ); + VSIFCloseL( fp ); + + return (GDALDataset *) GDALOpen( pszFilename, GA_Update ); +} + +/************************************************************************/ +/* GDALRegister_PNM() */ +/************************************************************************/ + +void GDALRegister_PNM() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "PNM" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "PNM" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Portable Pixmap Format (netpbm)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#PNM" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "pnm" ); + poDriver->SetMetadataItem( GDAL_DMD_MIMETYPE, + "image/x-portable-anymap" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, + "Byte UInt16" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='MAXVAL' type='unsigned int' description='Maximum color value'/>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = PNMDataset::Open; + poDriver->pfnCreate = PNMDataset::Create; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/raw/rawdataset.cpp b/Utilities/GDAL/frmts/raw/rawdataset.cpp new file mode 100644 index 0000000000..0b11393cf4 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/rawdataset.cpp @@ -0,0 +1,1097 @@ +/****************************************************************************** + * $Id: rawdataset.cpp,v 1.27 2005/05/23 06:53:45 fwarmerdam Exp $ + * + * Project: Generic Raw Binary Driver + * Purpose: Implementation of RawDataset and RawRasterBand classes. + * Author: Frank Warmerdam, warmerda@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: rawdataset.cpp,v $ + * Revision 1.27 2005/05/23 06:53:45 fwarmerdam + * Avoid IsBlockCached() + * + * Revision 1.26 2004/11/02 20:21:38 fwarmerdam + * added support for category names + * + * Revision 1.25 2004/06/02 20:57:55 warmerda + * centralize initialization + * + * Revision 1.24 2004/06/02 20:54:42 warmerda + * Ensure poCT and eInterp are initialize in the *other* constructor. + * + * Revision 1.23 2004/05/28 18:16:22 warmerda + * Added support for hold colortable and interp on RawRasterBand + * + * Revision 1.22 2004/04/06 19:25:31 dron + * Use GDALRasterBand::IsBlockCached() instead of GDALRasterBlock::IsCached(). + * + * Revision 1.21 2003/07/27 11:08:19 dron + * Added some heuristic to switch between cached and direct IRasterIO() + * implementations. + * + * Revision 1.20 2003/07/16 19:29:09 warmerda + * use overviews in IRasterIO() on reads when appropriate + * + * Revision 1.19 2003/07/08 21:10:19 warmerda + * avoid warnings + * + * Revision 1.18 2003/05/18 11:05:07 dron + * Fixed problem in IRasterIO(). + * + * Revision 1.17 2003/05/02 16:00:17 dron + * Implemented RawRasterBand::IRasterIO() method. Introduced `dirty' flag. + * + * Revision 1.16 2003/03/18 05:59:41 warmerda + * Added FlushCache() implementation that uses fflush() to force + * everything out. + * + * Revision 1.15 2002/11/23 18:54:47 warmerda + * added setnodatavalue + * + * Revision 1.14 2002/02/07 15:14:59 warmerda + * ensure that no more bytes are read or written than necessary + * + * Revision 1.13 2001/12/14 19:18:38 ldjohn + * Typecast offset parameter to Seek for large file support. + * + * Revision 1.12 2001/12/12 18:41:33 warmerda + * don't pass vsi_l_offset values in debug calls + * + * Revision 1.11 2001/12/12 18:15:46 warmerda + * preliminary update for large raw file support + * + * Revision 1.10 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.9 2001/03/26 18:31:55 warmerda + * Fixed nodata handling in first constructor. + * + * Revision 1.8 2001/03/23 03:25:32 warmerda + * Added nodata support + * + * Revision 1.7 2001/01/03 18:54:25 warmerda + * improved seek error message + * + * Revision 1.6 2000/08/16 15:51:17 warmerda + * allow floating (datasetless) raw bands + * + * Revision 1.5 2000/08/09 16:26:27 warmerda + * improved error checking + * + * Revision 1.4 2000/06/05 17:24:06 warmerda + * added real complex support + * + * Revision 1.3 2000/03/31 13:36:40 warmerda + * RawRasterBand no longer depends on RawDataset + * + * Revision 1.2 1999/08/13 02:36:57 warmerda + * added write support + * + * Revision 1.1 1999/07/23 19:34:34 warmerda + * New + * + */ + +#include "rawdataset.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: rawdataset.cpp,v 1.27 2005/05/23 06:53:45 fwarmerdam Exp $"); + +/************************************************************************/ +/* RawRasterBand() */ +/************************************************************************/ + +RawRasterBand::RawRasterBand( GDALDataset *poDS, int nBand, + FILE * fpRaw, vsi_l_offset nImgOffset, + int nPixelOffset, int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int bIsVSIL ) + +{ + Initialize(); + + this->poDS = poDS; + this->nBand = nBand; + this->eDataType = eDataType; + this->bIsVSIL = bIsVSIL; + + this->fpRaw = fpRaw; + this->nImgOffset = nImgOffset; + this->nPixelOffset = nPixelOffset; + this->nLineOffset = nLineOffset; + this->bNativeOrder = bNativeOrder; + + CPLDebug( "GDALRaw", + "RawRasterBand(%p,%d,%p,\n" + " Off=%d,PixOff=%d,LineOff=%d,%s,%d)\n", + poDS, nBand, fpRaw, + (unsigned int) nImgOffset, nPixelOffset, nLineOffset, + GDALGetDataTypeName(eDataType), bNativeOrder ); + +/* -------------------------------------------------------------------- */ +/* Treat one scanline as the block size. */ +/* -------------------------------------------------------------------- */ + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = 1; + +/* -------------------------------------------------------------------- */ +/* Allocate working scanline. */ +/* -------------------------------------------------------------------- */ + nLoadedScanline = -1; + nLineSize = nPixelOffset * nBlockXSize; + pLineBuffer = CPLMalloc( nLineSize ); +} + +/************************************************************************/ +/* RawRasterBand() */ +/************************************************************************/ + +RawRasterBand::RawRasterBand( FILE * fpRaw, vsi_l_offset nImgOffset, + int nPixelOffset, int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int nXSize, int nYSize, int bIsVSIL ) + +{ + Initialize(); + + this->poDS = NULL; + this->nBand = 1; + this->eDataType = eDataType; + this->bIsVSIL = bIsVSIL; + + this->fpRaw = fpRaw; + this->nImgOffset = nImgOffset; + this->nPixelOffset = nPixelOffset; + this->nLineOffset = nLineOffset; + this->bNativeOrder = bNativeOrder; + + + CPLDebug( "GDALRaw", + "RawRasterBand(floating,Off=%d,PixOff=%d,LineOff=%d,%s,%d)\n", + (unsigned int) nImgOffset, nPixelOffset, nLineOffset, + GDALGetDataTypeName(eDataType), bNativeOrder ); + +/* -------------------------------------------------------------------- */ +/* Treat one scanline as the block size. */ +/* -------------------------------------------------------------------- */ + nBlockXSize = nXSize; + nBlockYSize = 1; + nRasterXSize = nXSize; + nRasterYSize = nYSize; + +/* -------------------------------------------------------------------- */ +/* Allocate working scanline. */ +/* -------------------------------------------------------------------- */ + nLoadedScanline = -1; + nLineSize = nPixelOffset * nBlockXSize; + pLineBuffer = CPLMalloc( nLineSize ); +} + +/************************************************************************/ +/* Initialize() */ +/************************************************************************/ + +void RawRasterBand::Initialize() + +{ + dfNoDataValue = 0.0; + bNoDataSet = FALSE; + + poCT = NULL; + eInterp = GCI_Undefined; + + papszCategoryNames = NULL; + + bDirty = FALSE; +} + + +/************************************************************************/ +/* ~RawRasterBand() */ +/************************************************************************/ + +RawRasterBand::~RawRasterBand() + +{ + CSLDestroy( papszCategoryNames ); + + FlushCache(); + + CPLFree( pLineBuffer ); +} + +/************************************************************************/ +/* FlushCache() */ +/* */ +/* We override this so we have the opportunity to call */ +/* fflush(). We don't want to do this all the time in the */ +/* write block function as it is kind of expensive. */ +/************************************************************************/ + +CPLErr RawRasterBand::FlushCache() + +{ + CPLErr eErr; + + eErr = GDALRasterBand::FlushCache(); + if( eErr != CE_None ) + return eErr; + + // If we have unflushed raw, flush it to disk now. + if ( bDirty ) + { + if( bIsVSIL ) + VSIFFlushL( fpRaw ); + else + VSIFFlush( fpRaw ); + + bDirty = FALSE; + } + + return CE_None; +} + +/************************************************************************/ +/* AccessLine() */ +/************************************************************************/ + +CPLErr RawRasterBand::AccessLine( int iLine ) + +{ + if( nLoadedScanline == iLine ) + return CE_None; + +/* -------------------------------------------------------------------- */ +/* Seek to the right line. */ +/* -------------------------------------------------------------------- */ + if( Seek(nImgOffset + (vsi_l_offset)iLine * nLineOffset, SEEK_SET) == -1 ) + { + // for now I just set to zero under the assumption we might + // be trying to read from a file past the data that has + // actually been written out. Eventually we should differentiate + // between newly created datasets, and existing datasets. Existing + // datasets should generate an error in this case. + memset( pLineBuffer, 0, nPixelOffset * nBlockXSize ); + nLoadedScanline = iLine; + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Read the line. Take care not to request any more bytes than */ +/* are needed, and not to lose a partially successful scanline */ +/* read. */ +/* -------------------------------------------------------------------- */ + int nBytesToRead, nBytesActuallyRead; + + nBytesToRead = nPixelOffset * (nBlockXSize - 1) + + GDALGetDataTypeSize(GetRasterDataType()) / 8; + + nBytesActuallyRead = Read( pLineBuffer, 1, nBytesToRead ); + if( nBytesActuallyRead < nBlockXSize ) + { + // for now I just set to zero under the assumption we might + // be trying to read from a file past the data that has + // actually been written out. Eventually we should differentiate + // between newly created datasets, and existing datasets. Existing + // datasets should generate an error in this case. + memset( ((GByte *) pLineBuffer) + nBytesActuallyRead, + 0, nBytesToRead - nBytesActuallyRead ); + } + +/* -------------------------------------------------------------------- */ +/* Byte swap the interesting data, if required. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pLineBuffer, nWordSize, nBlockXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pLineBuffer)+nWordSize, + nWordSize, nBlockXSize, nPixelOffset ); + } + else + GDALSwapWords( pLineBuffer, GDALGetDataTypeSize(eDataType)/8, + nBlockXSize, nPixelOffset ); + } + + nLoadedScanline = iLine; + + return CE_None; +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr RawRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + CPLErr eErr = CE_None; + + CPLAssert( nBlockXOff == 0 ); + + AccessLine( nBlockYOff ); + +/* -------------------------------------------------------------------- */ +/* Copy data from disk buffer to user block buffer. */ +/* -------------------------------------------------------------------- */ + GDALCopyWords( pLineBuffer, eDataType, nPixelOffset, + pImage, eDataType, GDALGetDataTypeSize(eDataType)/8, + nBlockXSize ); + + return eErr; +} + +/************************************************************************/ +/* IWriteBlock() */ +/************************************************************************/ + +CPLErr RawRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + CPLErr eErr = CE_None; + + CPLAssert( nBlockXOff == 0 ); + +/* -------------------------------------------------------------------- */ +/* If the data for this band is completely contiguous we don't */ +/* have to worry about pre-reading from disk. */ +/* -------------------------------------------------------------------- */ + if( nPixelOffset > GDALGetDataTypeSize(eDataType) / 8 ) + eErr = AccessLine( nBlockYOff ); + +/* -------------------------------------------------------------------- */ +/* Copy data from user buffer into disk buffer. */ +/* -------------------------------------------------------------------- */ + GDALCopyWords( pImage, eDataType, GDALGetDataTypeSize(eDataType)/8, + pLineBuffer, eDataType, nPixelOffset, + nBlockXSize ); + +/* -------------------------------------------------------------------- */ +/* Byte swap (if necessary) back into disk order before writing. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pLineBuffer, nWordSize, nBlockXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pLineBuffer)+nWordSize, + nWordSize, nBlockXSize, nPixelOffset ); + } + else + GDALSwapWords( pLineBuffer, GDALGetDataTypeSize(eDataType)/8, + nBlockXSize, nPixelOffset ); + } + +/* -------------------------------------------------------------------- */ +/* Seek to correct location. */ +/* -------------------------------------------------------------------- */ + if( Seek( nImgOffset + (vsi_l_offset) nBlockYOff * nLineOffset, + SEEK_SET ) == -1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to seek to scanline %d @ %d to write to file.\n", + nBlockYOff, (int) (nImgOffset + nBlockYOff * nLineOffset) ); + + eErr = CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Write data buffer. */ +/* -------------------------------------------------------------------- */ + int nBytesToWrite; + + nBytesToWrite = nPixelOffset * (nBlockXSize - 1) + + GDALGetDataTypeSize(GetRasterDataType()) / 8; + + if( eErr == CE_None + && Write( pLineBuffer, 1, nBytesToWrite ) < (size_t) nBytesToWrite ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to write scanline %d to file.\n", + nBlockYOff ); + + eErr = CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap (if necessary) back into machine order so the */ +/* buffer is still usable for reading purposes. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + GDALSwapWords( pLineBuffer, GDALGetDataTypeSize(eDataType)/8, + nBlockXSize, nPixelOffset ); + } + + bDirty = TRUE; + return eErr; +} + +/************************************************************************/ +/* AccessBlock() */ +/************************************************************************/ + +CPLErr RawRasterBand::AccessBlock( vsi_l_offset nBlockOff, int nBlockSize, + void * pData ) +{ + int nBytesActuallyRead; + +/* -------------------------------------------------------------------- */ +/* Seek to the right block. */ +/* -------------------------------------------------------------------- */ + if( Seek( nBlockOff, SEEK_SET ) == -1 ) + { + memset( pData, 0, nBlockSize ); + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Read the block. */ +/* -------------------------------------------------------------------- */ + nBytesActuallyRead = Read( pData, 1, nBlockSize ); + if( nBytesActuallyRead < nBlockSize ) + { + + memset( ((GByte *) pData) + nBytesActuallyRead, + 0, nBlockSize - nBytesActuallyRead ); + return CE_None; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap the interesting data, if required. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pData, nWordSize, nBlockSize / nPixelOffset, + nPixelOffset ); + GDALSwapWords( ((GByte *) pData) + nWordSize, + nWordSize, nBlockSize / nPixelOffset, nPixelOffset ); + } + else + GDALSwapWords( pData, GDALGetDataTypeSize(eDataType) / 8, + nBlockSize / nPixelOffset, nPixelOffset ); + } + + return CE_None; +} + +/************************************************************************/ +/* IsLineLoaded() */ +/* */ +/* Check whether at least one scanline from the specified block of */ +/* lines is cached. */ +/************************************************************************/ + +int RawRasterBand::IsLineLoaded( int nLineOff, int nLines ) +{ + int iLine; + + for ( iLine = nLineOff; iLine < nLineOff + nLines; iLine++ ) + { + GDALRasterBlock *poBlock = TryGetLockedBlockRef( 0, iLine ); + if( poBlock != NULL ) + { + poBlock->DropLock(); + return TRUE; + } + } + + return FALSE; +} + +/************************************************************************/ +/* IRasterIO() */ +/************************************************************************/ + +CPLErr RawRasterBand::IRasterIO( GDALRWFlag eRWFlag, + int nXOff, int nYOff, int nXSize, int nYSize, + void * pData, int nBufXSize, int nBufYSize, + GDALDataType eBufType, + int nPixelSpace, int nLineSpace ) + +{ + int nBandDataSize = GDALGetDataTypeSize(eDataType) / 8; + int nBufDataSize = GDALGetDataTypeSize( eBufType ) / 8; + int nBytesToRW = nPixelOffset * nXSize; + +/* -------------------------------------------------------------------- */ +/* Use direct IO without caching if: */ +/* */ +/* GDAL_ONE_BIG_READ is enabled */ +/* */ +/* or */ +/* */ +/* the length of a scanline on disk is more than 50000 bytes, and the */ +/* width of the requested chunk is less than 40% of the whole scanline */ +/* and none of the requested scanlines are already in the cache. */ +/* -------------------------------------------------------------------- */ + if ( !CSLTestBoolean( CPLGetConfigOption( "GDAL_ONE_BIG_READ", "NO") ) ) + { + if ( nLineSize < 50000 + || nBytesToRW > nLineSize / 5 * 2 + || IsLineLoaded( nYOff, nYSize ) ) + { + + return GDALRasterBand::IRasterIO( eRWFlag, nXOff, nYOff, + nXSize, nYSize, + pData, nBufXSize, nBufYSize, + eBufType, + nPixelSpace, nLineSpace ); + } + } + +/* ==================================================================== */ +/* Read data. */ +/* ==================================================================== */ + if ( eRWFlag == GF_Read ) + { +/* -------------------------------------------------------------------- */ +/* Do we have overviews that would be appropriate to satisfy */ +/* this request? */ +/* -------------------------------------------------------------------- */ + if( (nBufXSize < nXSize || nBufYSize < nYSize) + && GetOverviewCount() > 0 ) + { + if( OverviewRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, + eBufType, nPixelSpace, nLineSpace ) == CE_None ) + return CE_None; + } + +/* ==================================================================== */ +/* 1. Simplest case when we should get contiguous block */ +/* of uninterleaved pixels. */ +/* ==================================================================== */ + if ( nXSize == GetXSize() + && nXSize == nBufXSize + && nYSize == nBufYSize + && eBufType == eDataType + && nPixelOffset == nBandDataSize + && nPixelSpace == nBufDataSize + && nLineSpace == nPixelSpace * nXSize ) + { + if ( AccessBlock( nImgOffset + + (vsi_l_offset)nYOff * nLineOffset + nXOff, + nXSize * nYSize * nBandDataSize, pData ) != CE_None ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to read %d bytes at %d.", + nXSize * nYSize * nBandDataSize, + nImgOffset + + (vsi_l_offset)nYOff * nLineOffset + nXOff ); + } + } + +/* ==================================================================== */ +/* 2. Case when we need deinterleave and/or subsample data. */ +/* ==================================================================== */ + else + { + GByte *pabyData; + double dfSrcXInc, dfSrcYInc; + int iLine; + + dfSrcXInc = (double)nXSize / nBufXSize; + dfSrcYInc = (double)nYSize / nBufYSize; + + + pabyData = (GByte *) CPLMalloc( nBytesToRW ); + + for ( iLine = 0; iLine < nBufYSize; iLine++ ) + { + if ( AccessBlock( nImgOffset + + ((vsi_l_offset)nYOff + + (int)(iLine * dfSrcYInc)) * nLineOffset + + nXOff * nPixelOffset, + nBytesToRW, pabyData ) != CE_None ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to read %d bytes at %d.", + nBytesToRW, + nImgOffset + + ((vsi_l_offset)nYOff + + (int)(iLine * dfSrcYInc)) * nLineOffset + + nXOff * nPixelOffset ); + } + +/* -------------------------------------------------------------------- */ +/* Copy data from disk buffer to user block buffer and subsample, */ +/* if needed. */ +/* -------------------------------------------------------------------- */ + if ( nXSize == nBufXSize && nYSize == nBufYSize ) + { + GDALCopyWords( pabyData, eDataType, nPixelOffset, + (GByte *)pData + iLine * nLineSpace, + eBufType, nPixelSpace, nXSize ); + } + else + { + int iPixel; + + for ( iPixel = 0; iPixel < nBufXSize; iPixel++ ) + { + GDALCopyWords( pabyData + + (int)(iPixel * dfSrcXInc) * nPixelOffset, + eDataType, 0, + (GByte *)pData + iLine * nLineSpace + + iPixel * nBufDataSize, + eBufType, nPixelSpace, 1 ); + } + } + } + + CPLFree( pabyData ); + } + } + +/* ==================================================================== */ +/* Write data. */ +/* ==================================================================== */ + else + { + int nBytesActuallyWritten; + +/* ==================================================================== */ +/* 1. Simplest case when we should write contiguous block */ +/* of uninterleaved pixels. */ +/* ==================================================================== */ + if ( nXSize == GetXSize() + && nXSize == nBufXSize + && nYSize == nBufYSize + && eBufType == eDataType + && nPixelOffset == nBandDataSize + && nPixelSpace == nBufDataSize + && nLineSpace == nPixelSpace * nXSize ) + { +/* -------------------------------------------------------------------- */ +/* Byte swap the data buffer, if required. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pData, nWordSize, nXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pData) + nWordSize, + nWordSize, nXSize, nPixelOffset ); + } + else + GDALSwapWords( pData, nBandDataSize, nXSize, nPixelOffset ); + } + +/* -------------------------------------------------------------------- */ +/* Seek to the right block. */ +/* -------------------------------------------------------------------- */ + if( Seek( nImgOffset + (vsi_l_offset)nYOff * nLineOffset + nXOff, + SEEK_SET) == -1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to seek to %d to write data.\n", + nImgOffset + (vsi_l_offset)nYOff * nLineOffset + nXOff ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Write the block. */ +/* -------------------------------------------------------------------- */ + nBytesToRW = nXSize * nYSize * nBandDataSize; + + nBytesActuallyWritten = Write( pData, 1, nBytesToRW ); + if( nBytesActuallyWritten < nBytesToRW ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to write %d bytes to file. %d bytes written", + nBytesToRW, nBytesActuallyWritten ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap (if necessary) back into machine order so the */ +/* buffer is still usable for reading purposes. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pData, nWordSize, nXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pData) + nWordSize, + nWordSize, nXSize, nPixelOffset ); + } + else + GDALSwapWords( pData, nBandDataSize, nXSize, nPixelOffset ); + } + } + +/* ==================================================================== */ +/* 2. Case when we need deinterleave and/or subsample data. */ +/* ==================================================================== */ + else + { + GByte *pabyData; + double dfSrcXInc, dfSrcYInc; + vsi_l_offset nBlockOff; + int iLine; + + dfSrcXInc = (double)nXSize / nBufXSize; + dfSrcYInc = (double)nYSize / nBufYSize; + + pabyData = (GByte *) CPLMalloc( nBytesToRW ); + + for ( iLine = 0; iLine < nBufYSize; iLine++ ) + { + nBlockOff = nImgOffset + + ((vsi_l_offset)nYOff + (int)(iLine*dfSrcYInc))*nLineOffset + + nXOff * nPixelOffset; + +/* -------------------------------------------------------------------- */ +/* If the data for this band is completely contiguous we don't */ +/* have to worry about pre-reading from disk. */ +/* -------------------------------------------------------------------- */ + if( nPixelOffset > nBandDataSize ) + AccessBlock( nBlockOff, nBytesToRW, pabyData ); + +/* -------------------------------------------------------------------- */ +/* Copy data from user block buffer to disk buffer and subsample, */ +/* if needed. */ +/* -------------------------------------------------------------------- */ + if ( nXSize == nBufXSize && nYSize == nBufYSize ) + { + GDALCopyWords( (GByte *)pData + iLine * nLineSpace, + eBufType, nPixelSpace, + pabyData, eDataType, nPixelOffset, nXSize ); + } + else + { + int iPixel; + + for ( iPixel = 0; iPixel < nBufXSize; iPixel++ ) + { + GDALCopyWords( (GByte *)pData+iLine*nLineSpace + + iPixel * nBufDataSize, + eBufType, nPixelSpace, + pabyData + + (int)(iPixel * dfSrcXInc) * nPixelOffset, + eDataType, 0, 1 ); + } + } + +/* -------------------------------------------------------------------- */ +/* Byte swap the data buffer, if required. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pabyData, nWordSize, nXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pabyData) + nWordSize, + nWordSize, nXSize, nPixelOffset ); + } + else + GDALSwapWords( pabyData, nBandDataSize, nXSize, + nPixelOffset ); + } + +/* -------------------------------------------------------------------- */ +/* Seek to the right line in block. */ +/* -------------------------------------------------------------------- */ + if( Seek( nBlockOff, SEEK_SET) == -1 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to seek to %d to read.\n", nBlockOff ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Write the line of block. */ +/* -------------------------------------------------------------------- */ + nBytesActuallyWritten = Write( pabyData, 1, nBytesToRW ); + if( nBytesActuallyWritten < nBytesToRW ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failed to write %d bytes to file. %d bytes written", + nBytesToRW, nBytesActuallyWritten ); + + return CE_Failure; + } + +/* -------------------------------------------------------------------- */ +/* Byte swap (if necessary) back into machine order so the */ +/* buffer is still usable for reading purposes. */ +/* -------------------------------------------------------------------- */ + if( !bNativeOrder && eDataType != GDT_Byte ) + { + if( GDALDataTypeIsComplex( eDataType ) ) + { + int nWordSize; + + nWordSize = GDALGetDataTypeSize(eDataType)/16; + GDALSwapWords( pabyData, nWordSize, nXSize, nPixelOffset ); + GDALSwapWords( ((GByte *) pabyData) + nWordSize, + nWordSize, nXSize, nPixelOffset ); + } + else + GDALSwapWords( pabyData, nBandDataSize, nXSize, + nPixelOffset ); + } + + } + + bDirty = TRUE; + CPLFree( pabyData ); + } + } + + return CE_None; +} + +/************************************************************************/ +/* Seek() */ +/************************************************************************/ + +int RawRasterBand::Seek( vsi_l_offset nOffset, int nSeekMode ) + +{ + if( bIsVSIL ) + return VSIFSeekL( fpRaw, nOffset, nSeekMode ); + else + return VSIFSeek( fpRaw, (long) nOffset, nSeekMode ); +} + +/************************************************************************/ +/* Read() */ +/************************************************************************/ + +size_t RawRasterBand::Read( void *pBuffer, size_t nSize, size_t nCount ) + +{ + if( bIsVSIL ) + return VSIFReadL( pBuffer, nSize, nCount, fpRaw ); + else + return VSIFRead( pBuffer, nSize, nCount, fpRaw ); +} + +/************************************************************************/ +/* Write() */ +/************************************************************************/ + +size_t RawRasterBand::Write( void *pBuffer, size_t nSize, size_t nCount ) + +{ + if( bIsVSIL ) + return VSIFWriteL( pBuffer, nSize, nCount, fpRaw ); + else + return VSIFWrite( pBuffer, nSize, nCount, fpRaw ); +} + +/************************************************************************/ +/* StoreNoDataValue() */ +/* */ +/* This is a helper function for datasets to associate a no */ +/* data value with this band, it isn't intended to be called by */ +/* applications. */ +/************************************************************************/ + +void RawRasterBand::StoreNoDataValue( double dfValue ) + +{ + bNoDataSet = TRUE; + dfNoDataValue = dfValue; +} + +/************************************************************************/ +/* SetNoDataValue() */ +/************************************************************************/ + +CPLErr RawRasterBand::SetNoDataValue( double dfValue ) + +{ + bNoDataSet = TRUE; + dfNoDataValue = dfValue; + return CE_None; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double RawRasterBand::GetNoDataValue( int * pbSuccess ) + +{ + if( pbSuccess ) + *pbSuccess = bNoDataSet; + + return dfNoDataValue; +} + +/************************************************************************/ +/* GetCategoryNames() */ +/************************************************************************/ + +char **RawRasterBand::GetCategoryNames() + +{ + return papszCategoryNames; +} + +/************************************************************************/ +/* SetCategoryNames() */ +/************************************************************************/ + +CPLErr RawRasterBand::SetCategoryNames( char ** papszNewNames ) + +{ + CSLDestroy( papszCategoryNames ); + papszCategoryNames = CSLDuplicate( papszNewNames ); + + return CE_None; +} + +/************************************************************************/ +/* SetColorTable() */ +/************************************************************************/ + +CPLErr RawRasterBand::SetColorTable( GDALColorTable *poNewCT ) + +{ + if( poCT ) + delete poCT; + if( poNewCT == NULL ) + poCT = NULL; + else + poCT = poNewCT->Clone(); + + return CE_None; +} + +/************************************************************************/ +/* GetColorTable() */ +/************************************************************************/ + +GDALColorTable *RawRasterBand::GetColorTable() + +{ + return poCT; +} + +/************************************************************************/ +/* SetColorInterpretation() */ +/************************************************************************/ + +CPLErr RawRasterBand::SetColorInterpretation( GDALColorInterp eNewInterp ) + +{ + eInterp = eNewInterp; + + return CE_None; +} + +/************************************************************************/ +/* GetColorInterpretation() */ +/************************************************************************/ + +GDALColorInterp RawRasterBand::GetColorInterpretation() + +{ + return eInterp; +} + +/************************************************************************/ +/* ==================================================================== */ +/* RawDataset */ +/* ==================================================================== */ +/************************************************************************/ + + +/************************************************************************/ +/* RawDataset() */ +/************************************************************************/ + +RawDataset::RawDataset() + +{ +} + +/************************************************************************/ +/* ~RawDataset() */ +/************************************************************************/ + +RawDataset::~RawDataset() + +{ +} + +/************************************************************************/ +/* IRasterIO() */ +/* */ +/* Multi-band raster io handler. */ +/************************************************************************/ + +CPLErr RawDataset::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( nBandCount > 1 ) + return GDALDataset::BlockBasedRasterIO( + eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, nPixelSpace, nLineSpace, nBandSpace ); + else*/ + return + GDALDataset::IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize, + pData, nBufXSize, nBufYSize, eBufType, + nBandCount, panBandMap, + nPixelSpace, nLineSpace, nBandSpace ); +} + + diff --git a/Utilities/GDAL/frmts/raw/rawdataset.h b/Utilities/GDAL/frmts/raw/rawdataset.h new file mode 100644 index 0000000000..217eb40cf3 --- /dev/null +++ b/Utilities/GDAL/frmts/raw/rawdataset.h @@ -0,0 +1,202 @@ +/****************************************************************************** + * $Id$ + * + * Project: Raw Translator + * Purpose: Implementation of RawDataset class. Intented to be subclassed + * by other raw formats. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: rawdataset.h,v $ + * Revision 1.18 2006/04/10 16:28:33 fwarmerdam + * Fixed contact info. + * + * Revision 1.17 2005/05/05 13:55:42 fwarmerdam + * PAM Enable + * + * Revision 1.16 2004/11/02 20:21:38 fwarmerdam + * added support for category names + * + * Revision 1.15 2004/07/31 04:53:21 warmerda + * added various query methods + * + * Revision 1.14 2004/06/02 20:57:55 warmerda + * centralize initialization + * + * Revision 1.13 2004/05/28 18:16:22 warmerda + * Added support for hold colortable and interp on RawRasterBand + * + * Revision 1.12 2003/07/27 11:04:40 dron + * Added RawRasterBand::IsLineLoaded() method. + * + * Revision 1.11 2003/05/02 16:00:17 dron + * Implemented RawRasterBand::IRasterIO() method. Introduced `dirty' flag. + * + * Revision 1.10 2003/03/18 06:00:26 warmerda + * Added FlushCache() method on rawrasterband. + * + * Revision 1.9 2002/11/23 18:54:47 warmerda + * added setnodatavalue + * + * Revision 1.8 2002/03/21 16:22:03 warmerda + * fixed friend declarations + * + * Revision 1.7 2001/12/12 18:15:46 warmerda + * preliminary update for large raw file support + * + * Revision 1.6 2001/03/23 03:25:32 warmerda + * Added nodata support + * + * Revision 1.5 2000/08/16 15:51:17 warmerda + * allow floating (datasetless) raw bands + * + * Revision 1.4 2000/07/20 13:38:56 warmerda + * make classes public with CPL_DLL + * + * Revision 1.3 2000/03/31 13:36:41 warmerda + * RawRasterBand no longer depends on RawDataset + * + * Revision 1.2 1999/08/13 02:36:57 warmerda + * added write support + * + * Revision 1.1 1999/07/23 19:34:34 warmerda + * New + * + */ + +#include "gdal_pam.h" + +/************************************************************************/ +/* ==================================================================== */ +/* RawDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class RawRasterBand; + +class CPL_DLL RawDataset : public GDALPamDataset +{ + friend class RawRasterBand; + + protected: + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int *, int, int, int ); + public: + RawDataset(); + ~RawDataset(); + +}; + +/************************************************************************/ +/* ==================================================================== */ +/* RawRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class CPL_DLL RawRasterBand : public GDALPamRasterBand +{ + friend class RawDataset; + + FILE *fpRaw; + int bIsVSIL; + + vsi_l_offset nImgOffset; + int nPixelOffset; + int nLineOffset; + int nLineSize; + int bNativeOrder; + + int bNoDataSet; + double dfNoDataValue; + + int nLoadedScanline; + void *pLineBuffer; + int bDirty; + + GDALColorTable *poCT; + GDALColorInterp eInterp; + + char **papszCategoryNames; + + int Seek( vsi_l_offset, int ); + size_t Read( void *, size_t, size_t ); + size_t Write( void *, size_t, size_t ); + + CPLErr AccessBlock( vsi_l_offset nBlockOff, int nBlockSize, + void * pData ); + int IsLineLoaded( int nLineOff, int nLines ); + virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, + void *, int, int, GDALDataType, + int, int ); + + void Initialize(); + + public: + + RawRasterBand( GDALDataset *poDS, int nBand, FILE * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int bIsVSIL = FALSE ); + + RawRasterBand( FILE * fpRaw, + vsi_l_offset nImgOffset, int nPixelOffset, + int nLineOffset, + GDALDataType eDataType, int bNativeOrder, + int nXSize, int nYSize, int bIsVSIL = FALSE ); + + ~RawRasterBand(); + + // should override RasterIO eventually. + + virtual CPLErr IReadBlock( int, int, void * ); + virtual CPLErr IWriteBlock( int, int, void * ); + + virtual GDALColorTable *GetColorTable(); + virtual GDALColorInterp GetColorInterpretation(); + virtual CPLErr SetColorTable( GDALColorTable * ); + virtual CPLErr SetColorInterpretation( GDALColorInterp ); + + virtual CPLErr SetNoDataValue( double ); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + + virtual char **GetCategoryNames(); + virtual CPLErr SetCategoryNames( char ** ); + + virtual CPLErr FlushCache(); + + CPLErr AccessLine( int iLine ); + // this is deprecated. + void StoreNoDataValue( double ); + + // Query methods for internal data. + vsi_l_offset GetImgOffset() { return nImgOffset; } + int GetPixelOffset() { return nPixelOffset; } + int GetLineOffset() { return nLineOffset; } + int GetNativeOrder() { return bNativeOrder; } + int GetIsVSIL() { return bIsVSIL; } + FILE *GetFP() { return fpRaw; } +}; + diff --git a/Utilities/GDAL/frmts/sdts/.cvsignore b/Utilities/GDAL/frmts/sdts/.cvsignore new file mode 100644 index 0000000000..5c383114d0 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/.cvsignore @@ -0,0 +1,8 @@ +8211dump +sdts2ascii +sdts2shp +html +sdts_1_1 +man +*.tar.gz +*.zip diff --git a/Utilities/GDAL/frmts/sdts/Doxyfile b/Utilities/GDAL/frmts/sdts/Doxyfile new file mode 100644 index 0000000000..d4831605fe --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/Doxyfile @@ -0,0 +1,255 @@ +# This file describes the settings to be used by doxygen for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of word surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = SDTS_AL + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each page. A value of NO (the default) enables the index and the +# value YES disables it. + +DISABLE_INDEX = NO + +# If the EXTRACT_ALL tag is set to YES all classes and functions will be +# included in the documentation, even if no documentation was available. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members inside documented classes or files. + +HIDE_UNDOC_MEMBERS = YES + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output + +GENERATE_HTML = YES + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the FULL_PATH_NAMES tag is set to YES Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used + +FULL_PATH_NAMES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . ../iso8211 ../../port + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +FILE_PATTERNS = *.h *.cpp *.dox + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = . ../iso8211 + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. + +INPUT_FILTER = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. + +MACRO_EXPANSION = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). In the former case 1 is used as the +# definition. + +PREDEFINED = + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED tag. + +EXPAND_ONLY_PREDEF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES tag can be used to specify one or more tagfiles. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/local/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO + +# The CGI_NAME tag should be the name of the CGI script that +# starts the search engine (doxysearch) with the correct parameters. +# A script with this name will be generated by doxygen. + +CGI_NAME = search.cgi + +# The CGI_URL tag should be the absolute URL to the directory where the +# cgi binaries are located. See the documentation of your http daemon for +# details. + +CGI_URL = + +# The DOC_URL tag should be the absolute URL to the directory where the +# documentation is located. If left blank the absolute path to the +# documentation, with file:// prepended to it, will be used. + +DOC_URL = + +# The DOC_ABSPATH tag should be the absolute path to the directory where the +# documentation is located. If left blank the directory on the local machine +# will be used. + +DOC_ABSPATH = + +# The BIN_ABSPATH tag must point to the directory where the doxysearch binary +# is installed. + +BIN_ABSPATH = /usr/local/bin/ + +# The EXT_DOC_PATHS tag can be used to specify one or more paths to +# documentation generated for other projects. This allows doxysearch to search +# the documentation for these projects as well. + +EXT_DOC_PATHS = diff --git a/Utilities/GDAL/frmts/sdts/GNUmakefile b/Utilities/GDAL/frmts/sdts/GNUmakefile new file mode 100644 index 0000000000..92c3338876 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/GNUmakefile @@ -0,0 +1,71 @@ +VERSION = 1_3 +DISTDIR = sdts_$(VERSION) +WEB_DIR = /u/www/projects/sdts + +SHPDIR = ../shapelib +ISO8211DIR = ../iso8211 + +include ../../GDALmake.opt + +OBJ = sdtsiref.o sdtscatd.o sdtslinereader.o sdtslib.o \ + sdtspointreader.o sdtsattrreader.o sdtstransfer.o \ + sdtspolygonreader.o sdtsxref.o sdtsrasterreader.o \ + sdtsindexedreader.o + +CPPFLAGS := -I$(ISO8211DIR) $(GDAL_INCLUDE) $(CPPFLAGS) + +SDTSLIB = libsdts_al.a +LIBS := $(SDTSLIB) $(ISO8211DIR)/libiso8211.a $(GDAL_LIB) $(LIBS) + + + +default: $(SDTSLIB) sdtsdataset.o + +all: $(SDTSLIB) sdts2shp + +clean: clean-dist + rm -rf *.o sdts2shp html man $(SDTSLIB) + +clean-dist: + rm -rf $(DISTDIR) $(DISTDIR).zip $(DISTDIR).tar.gz + +$(SDTSLIB): $(OBJ) + ar r $(SDTSLIB) $? + +sdts2shp: sdts2shp.cpp $(SDTSLIB) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -I$(SHPDIR) sdts2shp.cpp \ + $(SHPDIR)/shpopen.o $(SHPDIR)/dbfopen.o \ + $(LIBS) -o sdts2shp + +install-obj: $(O_OBJ) ../o/sdtsdataset.o + +docs: + rm -rf html + mkdir html + doxygen + rm html/index.html + cp html/sdts_al_main.html html/index.html + +dist: docs + rm -rf $(DISTDIR) + mkdir $(DISTDIR) + mkdir $(DISTDIR)/html + cp html/* $(DISTDIR)/html + autoconf + cp *.cpp *.h configure Makefile.in $(DISTDIR) + cp makefile.vc.dist $(DISTDIR)/Makefile.vc + rm $(DISTDIR)/sdtsdataset.cpp + cp $(ISO8211DIR)/{*.cpp,*.h} $(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.*,cpl_path.cpp} $(DISTDIR) + cp ../../port/cpl_config.h.in $(DISTDIR)/cpl_config.h + cp $(SHPDIR)/{shpopen.c,dbfopen.c,shapefil.h} $(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 /u/ftp/pub/outgoing diff --git a/Utilities/GDAL/frmts/sdts/Makefile.in b/Utilities/GDAL/frmts/sdts/Makefile.in new file mode 100644 index 0000000000..3868db67fc --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/Makefile.in @@ -0,0 +1,133 @@ + +OBJ = sdtsiref.o sdtscatd.o sdtslinereader.o sdtslib.o \ + sdtspointreader.o sdtsattrreader.o sdtstransfer.o \ + sdtspolygonreader.o sdtsxref.o sdtsrasterreader.o \ + sdtsindexedreader.o \ + \ + ddfmodule.o ddfutils.o ddffielddefn.o ddfrecord.o ddffield.o \ + ddfsubfielddefn.o \ + \ + shpopen.o dbfopen.o \ + \ + cpl_error.o cpl_vsisimple.o cpl_string.o cpl_conv.o cpl_path.o + +CXXFLAGS = @CXXFLAGS@ @CXX_WFLAGS@ +LIBS = @LIBS@ -lm +CXX = @CXX@ + + +default: sdts2shp 8211view + +libsdts_al.a: $(OBJ) + ar r libsdts_al.a $(OBJ) + + +# +# SDTS library +# +sdtsiref.o: sdtsiref.cpp + $(CXX) -c $(CXXFLAGS) sdtsiref.cpp + +sdtscatd.o: sdtscatd.cpp + $(CXX) -c $(CXXFLAGS) sdtscatd.cpp + +sdtslinereader.o: sdtslinereader.cpp + $(CXX) -c $(CXXFLAGS) sdtslinereader.cpp + +sdtslib.o: sdtslib.cpp + $(CXX) -c $(CXXFLAGS) sdtslib.cpp + +sdtspointreader.o: sdtspointreader.cpp + $(CXX) -c $(CXXFLAGS) sdtspointreader.cpp + +sdtsattrreader.o: sdtsattrreader.cpp + $(CXX) -c $(CXXFLAGS) sdtsattrreader.cpp + +sdtstransfer.o: sdtstransfer.cpp + $(CXX) -c $(CXXFLAGS) sdtstransfer.cpp + +sdtspolygonreader.o: sdtspolygonreader.cpp + $(CXX) -c $(CXXFLAGS) sdtspolygonreader.cpp + +sdtsxref.o: sdtsxref.cpp + $(CXX) -c $(CXXFLAGS) sdtsxref.cpp + +sdtsrasterreader.o: sdtsrasterreader.cpp + $(CXX) -c $(CXXFLAGS) sdtsrasterreader.cpp + +sdtsindexedreader.o: sdtsindexedreader.cpp + $(CXX) -c $(CXXFLAGS) sdtsindexedreader.cpp + +# +# from iso8211 library +# + +ddfmodule.o: ddfmodule.cpp + $(CXX) -c $(CXXFLAGS) ddfmodule.cpp + +ddfutils.o: ddfutils.cpp + $(CXX) -c $(CXXFLAGS) ddfutils.cpp + +ddffielddefn.o: ddffielddefn.cpp + $(CXX) -c $(CXXFLAGS) ddffielddefn.cpp + +ddfrecord.o: ddfrecord.cpp + $(CXX) -c $(CXXFLAGS) ddfrecord.cpp + +ddffield.o: ddffield.cpp + $(CXX) -c $(CXXFLAGS) ddffield.cpp + +ddfsubfielddefn.o: ddfsubfielddefn.cpp + $(CXX) -c $(CXXFLAGS) ddfsubfielddefn.cpp + +# +# Common Portability Library +# + +cpl_error.o: cpl_error.cpp + $(CXX) -c $(CXXFLAGS) cpl_error.cpp + +cpl_string.o: cpl_string.cpp + $(CXX) -c $(CXXFLAGS) cpl_string.cpp + +cpl_conv.o: cpl_conv.cpp + $(CXX) -c $(CXXFLAGS) cpl_conv.cpp + +cpl_vsisimple.o: cpl_vsisimple.cpp + $(CXX) -c $(CXXFLAGS) cpl_vsisimple.cpp + +cpl_path.o: cpl_path.cpp + $(CXX) -c $(CXXFLAGS) cpl_path.cpp + +# +# Shapefile access +# +shpopen.o: shpopen.c + $(CXX) -c $(CXXFLAGS) shpopen.c + +dbfopen.o: dbfopen.c + $(CXX) -c $(CXXFLAGS) dbfopen.c + +# +# Mainlines +# + +sdts2shp.o: sdts2shp.cpp + $(CXX) -c $(CXXFLAGS) sdts2shp.cpp + +8211view.o: 8211view.cpp + $(CXX) -c $(CXXFLAGS) 8211view.cpp + +8211dump.o: 8211dump.cpp + $(CXX) -c $(CXXFLAGS) 8211dump.cpp + +sdts2shp: sdts2shp.o libsdts_al.a + $(CXX) $(CXXFLAGS) sdts2shp.o libsdts_al.a $(LIBS) -o sdts2shp + +8211view: 8211view.o libsdts_al.a + $(CXX) $(CXXFLAGS) 8211view.o libsdts_al.a $(LIBS) -o 8211view + +8211dump: 8211dump.o libsdts_al.a + $(CXX) $(CXXFLAGS) 8211dump.o libsdts_al.a $(LIBS) -o 8211dump + + diff --git a/Utilities/GDAL/frmts/sdts/aclocal.m4 b/Utilities/GDAL/frmts/sdts/aclocal.m4 new file mode 100644 index 0000000000..d4d18f50c9 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/aclocal.m4 @@ -0,0 +1,15 @@ +AC_DEFUN(AC_COMPILER_WFLAGS, +[ + # Remove -g from compile flags, we will add via CFG variable if + # we need it. + CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-g //"` + CFLAGS=`echo "$CFLAGS " | sed "s/-g //"` + + # check for GNU compiler, and use -Wall + if test "$GXX" = "yes"; then + CXX_WFLAGS="-Wall" + AC_DEFINE(USE_GNUCC) + fi + AC_SUBST(CXX_WFLAGS,$CXX_WFLAGS) + AC_SUBST(C_WFLAGS,$C_WFLAGS) +]) diff --git a/Utilities/GDAL/frmts/sdts/configure.in b/Utilities/GDAL/frmts/sdts/configure.in new file mode 100644 index 0000000000..b3a8a31f25 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/configure.in @@ -0,0 +1,18 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(Makefile.in) +AC_CONFIG_HEADER(cpl_config.h) + +dnl Checks for programs. +AC_PROG_CXX + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(fcntl.h unistd.h) + +dnl Checks for library functions. +AC_C_BIGENDIAN +AC_FUNC_VPRINTF + +AC_COMPILER_WFLAGS + +AC_OUTPUT(Makefile) diff --git a/Utilities/GDAL/frmts/sdts/makefile.vc b/Utilities/GDAL/frmts/sdts/makefile.vc new file mode 100644 index 0000000000..7df89b434e --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/makefile.vc @@ -0,0 +1,34 @@ + +BOBJ = sdtsiref.obj sdtscatd.obj sdtslinereader.obj sdtslib.obj \ + sdtspointreader.obj sdtsattrreader.obj sdtstransfer.obj \ + sdtspolygonreader.obj sdtsxref.obj sdtsrasterreader.obj \ + sdtsindexedreader.obj +OBJ = sdtsdataset.obj $(BOBJ) + +EXTRAFLAGS = -I..\iso8211 + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +base: $(BOBJ) + +clean: + -del *.obj + -del *.exe + -del *.lib + +sdts2shp.exe: sdts2shp.cpp $(BOBJ) + $(CC) $(CFLAGS) /I..\shapelib sdts2shp.cpp $(BOBJ) \ + ..\iso8211\ddfmodule.cpp \ + ..\iso8211\ddfutils.cpp \ + ..\iso8211\ddffielddefn.cpp \ + ..\iso8211\ddfrecord.cpp \ + ..\iso8211\ddffield.cpp \ + ..\iso8211\ddfsubfielddefn.cpp \ + ..\shapelib\shpopen.c ..\shapelib\dbfopen.c \ + $(GDAL_ROOT)\port\cpl.lib $(LIBS) + diff --git a/Utilities/GDAL/frmts/sdts/makefile.vc.dist b/Utilities/GDAL/frmts/sdts/makefile.vc.dist new file mode 100644 index 0000000000..2e714253ec --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/makefile.vc.dist @@ -0,0 +1,47 @@ +CFLAGS = /W3 +CXXFLAGS = /W3 + +LIBNAME = sdts_al.lib + +OBJ = sdtsiref.obj sdtscatd.obj sdtslinereader.obj sdtslib.obj \ + sdtspointreader.obj sdtsattrreader.obj sdtstransfer.obj \ + sdtspolygonreader.obj sdtsxref.obj sdtsrasterreader.obj \ + sdtsindexedreader.obj \ + \ + ddfmodule.obj ddfutils.obj ddffielddefn.obj ddfrecord.obj \ + ddffield.obj ddfsubfielddefn.obj \ + \ + shpopen.obj dbfopen.obj \ + \ + cpl_error.obj cpl_vsisimple.obj cpl_string.obj cpl_conv.obj \ + cpl_path.obj + + +default: $(LIBNAME) sdts2shp.exe 8211view.exe 8211dump.exe + +clean: + del *.obj $(LIBNAME) + +.c.obj: + $(CC) $(CFLAGS) /c $*.c + +.cpp.obj: + $(CXX) $(CXXFLAGS) /c $*.cpp + +$(LIBNAME): $(OBJ) + if exist $(LIBNAME) del $(LIBNAME) + lib /out:$(LIBNAME) $(OBJ) + +# +# Mainlines +# +sdts2shp.exe: sdts2shp.cpp $(LIBNAME) + $(CXX) sdts2shp.cpp $(LIBNAME) + +8211view.exe: 8211view.cpp $(LIBNAME) + $(CXX) 8211view.cpp $(LIBNAME) + +8211dump.exe: 8211dump.cpp $(LIBNAME) + $(CXX) 8211dump.cpp $(LIBNAME) + + diff --git a/Utilities/GDAL/frmts/sdts/sdts2shp.cpp b/Utilities/GDAL/frmts/sdts/sdts2shp.cpp new file mode 100644 index 0000000000..740eb1273e --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdts2shp.cpp @@ -0,0 +1,901 @@ +/* **************************************************************************** + * $Id: sdts2shp.cpp,v 1.16 2006/04/10 16:34:18 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Mainline for converting to ArcView Shapefiles. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdts2shp.cpp,v $ + * Revision 1.16 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.15 2003/10/06 14:35:21 warmerda + * added support for secondary attribute tables. + * + * Revision 1.14 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.13 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.12 2000/08/24 18:49:04 warmerda + * More error checking. + * + * Revision 1.11 2000/08/24 18:44:40 warmerda + * Made a little less case sensitive. + * + * Revision 1.10 1999/11/04 22:52:52 warmerda + * added dynamic ATID support + * + * Revision 1.9 1999/09/22 13:34:51 warmerda + * use new SDTSPolygonReader::AssembleRings() method + * + * Revision 1.8 1999/09/03 19:04:13 warmerda + * made comment blocks doxygen compatible + * + * Revision 1.7 1999/09/03 14:16:36 warmerda + * Fixed other memory leaks. + * + * Revision 1.6 1999/09/03 14:13:15 warmerda + * fix memory leaks + * + * Revision 1.5 1999/09/03 13:34:12 warmerda + * cleanup properly + * + * Revision 1.4 1999/09/03 13:01:16 warmerda + * rewrote attribute writing to simplify + * + * Revision 1.3 1999/09/02 12:00:28 warmerda + * write related attributes for points, and lines + * + * Revision 1.2 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.1 1999/05/07 13:44:57 warmerda + * New + * + */ + +#include "sdts_al.h" +#include "shapefil.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: sdts2shp.cpp,v 1.16 2006/04/10 16:34:18 fwarmerdam Exp $"); + +static int bVerbose = FALSE; + +static void WriteLineShapefile( const char *, SDTSTransfer *, + const char * ); +static void WritePointShapefile( const char *, SDTSTransfer *, + const char * ); +static void WriteAttributeDBF( const char *, SDTSTransfer *, + const char * ); +static void WritePolygonShapefile( const char *, SDTSTransfer *, + const char * ); + +static void +AddPrimaryAttrToDBFSchema( DBFHandle hDBF, SDTSTransfer * poTransfer, + char ** papszModuleList ); +static void +WritePrimaryAttrToDBF( DBFHandle hDBF, int nRecord, + SDTSTransfer *, SDTSFeature * poFeature ); +static void +WriteAttrRecordToDBF( DBFHandle hDBF, int nRecord, + SDTSTransfer *, DDFField * poAttributes ); + +/* **********************************************************************/ +/* Usage() */ +/* **********************************************************************/ + +static void Usage() + +{ + printf( "Usage: sdts2shp CATD_filename [-o shapefile_name]\n" + " [-m module_name] [-v]\n" + "\n" + "Modules include `LE01', `PC01', `NP01' and `ARDF'\n" ); + + exit( 1 ); +} + +/* **********************************************************************/ +/* main() */ +/* **********************************************************************/ + +int main( int nArgc, char ** papszArgv ) + +{ +{ + int i; + const char *pszCATDFilename = NULL; + const char *pszMODN = "LE01"; + char *pszShapefile = "sdts_out.shp"; + SDTSTransfer oTransfer; + + +/* -------------------------------------------------------------------- */ +/* Interpret commandline switches. */ +/* -------------------------------------------------------------------- */ + if( nArgc < 2 ) + Usage(); + + pszCATDFilename = papszArgv[1]; + + for( i = 2; i < nArgc; i++ ) + { + if( EQUAL(papszArgv[i],"-m") && i+1 < nArgc ) + pszMODN = papszArgv[++i]; + else if( EQUAL(papszArgv[i],"-o") && i+1 < nArgc ) + pszShapefile = papszArgv[++i]; + else if( EQUAL(papszArgv[i],"-v") ) + bVerbose = TRUE; + else + { + printf( "Incomplete, or unsupported option `%s'\n\n", + papszArgv[i] ); + Usage(); + } + } + +/* -------------------------------------------------------------------- */ +/* Massage shapefile name to have no extension. */ +/* -------------------------------------------------------------------- */ + pszShapefile = strdup( pszShapefile ); + for( i = strlen(pszShapefile)-1; i >= 0; i-- ) + { + if( pszShapefile[i] == '.' ) + { + pszShapefile[i] = '\0'; + break; + } + else if( pszShapefile[i] == '/' || pszShapefile[i] == '\\' ) + break; + } + +/* -------------------------------------------------------------------- */ +/* Open the transfer. */ +/* -------------------------------------------------------------------- */ + if( !oTransfer.Open( pszCATDFilename ) ) + { + fprintf( stderr, + "Failed to read CATD file `%s'\n", + pszCATDFilename ); + exit( 100 ); + } + +/* -------------------------------------------------------------------- */ +/* Dump available layer in verbose mode. */ +/* -------------------------------------------------------------------- */ + if( bVerbose ) + { + printf( "Layers:\n" ); + for( i = 0; i < oTransfer.GetLayerCount(); i++ ) + { + int iCATDEntry = oTransfer.GetLayerCATDEntry(i); + + printf( " %s: `%s'\n", + oTransfer.GetCATD()->GetEntryModule(iCATDEntry), + oTransfer.GetCATD()->GetEntryTypeDesc(iCATDEntry) ); + } + printf( "\n" ); + } + +/* -------------------------------------------------------------------- */ +/* Check that module exists. */ +/* -------------------------------------------------------------------- */ + if( oTransfer.FindLayer( pszMODN ) == -1 ) + { + fprintf( stderr, "Unable to identify module: %s\n", pszMODN ); + exit( 1 ); + } + +/* -------------------------------------------------------------------- */ +/* If the module is an LE module, write it to an Arc file. */ +/* -------------------------------------------------------------------- */ + if( pszMODN[0] == 'L' || pszMODN[0] == 'l' ) + { + WriteLineShapefile( pszShapefile, &oTransfer, pszMODN ); + } + +/* -------------------------------------------------------------------- */ +/* If the module is an attribute primary one, dump to DBF. */ +/* -------------------------------------------------------------------- */ + else if( pszMODN[0] == 'A' || pszMODN[0] == 'a' + || pszMODN[0] == 'B' || pszMODN[0] == 'b' ) + { + WriteAttributeDBF( pszShapefile, &oTransfer, pszMODN ); + } + +/* -------------------------------------------------------------------- */ +/* If the module is a point one, dump to Shapefile. */ +/* -------------------------------------------------------------------- */ + else if( pszMODN[0] == 'N' || pszMODN[0] == 'N' ) + { + WritePointShapefile( pszShapefile, &oTransfer, pszMODN ); + } + +/* -------------------------------------------------------------------- */ +/* If the module is a polygon one, dump to Shapefile. */ +/* -------------------------------------------------------------------- */ + else if( pszMODN[0] == 'P' || pszMODN[0] == 'p' ) + { + WritePolygonShapefile( pszShapefile, &oTransfer, pszMODN ); + } + + else + { + fprintf( stderr, "Unrecognised module name: %s\n", pszMODN ); + } + + CPLFree( pszShapefile ); +} +#ifdef DBMALLOC + malloc_dump(1); +#endif +} + +/* **********************************************************************/ +/* WriteLineShapefile() */ +/* **********************************************************************/ + +static void WriteLineShapefile( const char * pszShapefile, + SDTSTransfer * poTransfer, + const char * pszMODN ) + +{ + SDTSLineReader *poLineReader; + +/* -------------------------------------------------------------------- */ +/* Fetch a reference to the indexed Pointgon reader. */ +/* -------------------------------------------------------------------- */ + poLineReader = (SDTSLineReader *) + poTransfer->GetLayerIndexedReader( poTransfer->FindLayer( pszMODN ) ); + + if( poLineReader == NULL ) + { + fprintf( stderr, "Failed to open %s.\n", + poTransfer->GetCATD()->GetModuleFilePath( pszMODN ) ); + return; + } + + poLineReader->Rewind(); + +/* -------------------------------------------------------------------- */ +/* Create the Shapefile. */ +/* -------------------------------------------------------------------- */ + SHPHandle hSHP; + + hSHP = SHPCreate( pszShapefile, SHPT_ARC ); + if( hSHP == NULL ) + { + fprintf( stderr, "Unable to create shapefile `%s'\n", + pszShapefile ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Create the database file, and our basic set of attributes. */ +/* -------------------------------------------------------------------- */ + DBFHandle hDBF; + int nLeftPolyField, nRightPolyField; + int nStartNodeField, nEndNodeField, nSDTSRecordField; + char szDBFFilename[1024]; + + sprintf( szDBFFilename, "%s.dbf", pszShapefile ); + + hDBF = DBFCreate( szDBFFilename ); + if( hDBF == NULL ) + { + fprintf( stderr, "Unable to create shapefile .dbf for `%s'\n", + pszShapefile ); + return; + } + + nSDTSRecordField = DBFAddField( hDBF, "SDTSRecId", FTInteger, 8, 0 ); + nLeftPolyField = DBFAddField( hDBF, "LeftPoly", FTString, 12, 0 ); + nRightPolyField = DBFAddField( hDBF, "RightPoly", FTString, 12, 0 ); + nStartNodeField = DBFAddField( hDBF, "StartNode", FTString, 12, 0 ); + nEndNodeField = DBFAddField( hDBF, "EndNode", FTString, 12, 0 ); + + char **papszModRefs = poLineReader->ScanModuleReferences(); + AddPrimaryAttrToDBFSchema( hDBF, poTransfer, papszModRefs ); + CSLDestroy( papszModRefs ); + +/* ==================================================================== */ +/* Process all the line features in the module. */ +/* ==================================================================== */ + SDTSRawLine *poRawLine; + + while( (poRawLine = poLineReader->GetNextLine()) != NULL ) + { + int iShape; + +/* -------------------------------------------------------------------- */ +/* Write out a shape with the vertices. */ +/* -------------------------------------------------------------------- */ + SHPObject *psShape; + + psShape = SHPCreateSimpleObject( SHPT_ARC, poRawLine->nVertices, + poRawLine->padfX, poRawLine->padfY, + poRawLine->padfZ ); + + iShape = SHPWriteObject( hSHP, -1, psShape ); + + SHPDestroyObject( psShape ); + +/* -------------------------------------------------------------------- */ +/* Write out the attributes. */ +/* -------------------------------------------------------------------- */ + char szID[13]; + + DBFWriteIntegerAttribute( hDBF, iShape, nSDTSRecordField, + poRawLine->oModId.nRecord ); + + sprintf( szID, "%s:%ld", + poRawLine->oLeftPoly.szModule, + poRawLine->oLeftPoly.nRecord ); + DBFWriteStringAttribute( hDBF, iShape, nLeftPolyField, szID ); + + sprintf( szID, "%s:%ld", + poRawLine->oRightPoly.szModule, + poRawLine->oRightPoly.nRecord ); + DBFWriteStringAttribute( hDBF, iShape, nRightPolyField, szID ); + + sprintf( szID, "%s:%ld", + poRawLine->oStartNode.szModule, + poRawLine->oStartNode.nRecord ); + DBFWriteStringAttribute( hDBF, iShape, nStartNodeField, szID ); + + sprintf( szID, "%s:%ld", + poRawLine->oEndNode.szModule, + poRawLine->oEndNode.nRecord ); + DBFWriteStringAttribute( hDBF, iShape, nEndNodeField, szID ); + + WritePrimaryAttrToDBF( hDBF, iShape, poTransfer, poRawLine ); + + if( !poLineReader->IsIndexed() ) + delete poRawLine; + } + +/* -------------------------------------------------------------------- */ +/* Close, and cleanup. */ +/* -------------------------------------------------------------------- */ + DBFClose( hDBF ); + SHPClose( hSHP ); +} + +/* **********************************************************************/ +/* WritePointShapefile() */ +/* **********************************************************************/ + +static void WritePointShapefile( const char * pszShapefile, + SDTSTransfer * poTransfer, + const char * pszMODN ) + +{ + SDTSPointReader *poPointReader; + +/* -------------------------------------------------------------------- */ +/* Fetch a reference to the indexed Pointgon reader. */ +/* -------------------------------------------------------------------- */ + poPointReader = (SDTSPointReader *) + poTransfer->GetLayerIndexedReader( poTransfer->FindLayer( pszMODN ) ); + + if( poPointReader == NULL ) + { + fprintf( stderr, "Failed to open %s.\n", + poTransfer->GetCATD()->GetModuleFilePath( pszMODN ) ); + return; + } + + poPointReader->Rewind(); + +/* -------------------------------------------------------------------- */ +/* Create the Shapefile. */ +/* -------------------------------------------------------------------- */ + SHPHandle hSHP; + + hSHP = SHPCreate( pszShapefile, SHPT_POINT ); + if( hSHP == NULL ) + { + fprintf( stderr, "Unable to create shapefile `%s'\n", + pszShapefile ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Create the database file, and our basic set of attributes. */ +/* -------------------------------------------------------------------- */ + DBFHandle hDBF; + int nAreaField, nSDTSRecordField; + char szDBFFilename[1024]; + + sprintf( szDBFFilename, "%s.dbf", pszShapefile ); + + hDBF = DBFCreate( szDBFFilename ); + if( hDBF == NULL ) + { + fprintf( stderr, "Unable to create shapefile .dbf for `%s'\n", + pszShapefile ); + return; + } + + nSDTSRecordField = DBFAddField( hDBF, "SDTSRecId", FTInteger, 8, 0 ); + nAreaField = DBFAddField( hDBF, "AreaId", FTString, 12, 0 ); + + char **papszModRefs = poPointReader->ScanModuleReferences(); + AddPrimaryAttrToDBFSchema( hDBF, poTransfer, papszModRefs ); + CSLDestroy( papszModRefs ); + +/* ==================================================================== */ +/* Process all the line features in the module. */ +/* ==================================================================== */ + SDTSRawPoint *poRawPoint; + + while( (poRawPoint = poPointReader->GetNextPoint()) != NULL ) + { + int iShape; + +/* -------------------------------------------------------------------- */ +/* Write out a shape with the vertices. */ +/* -------------------------------------------------------------------- */ + SHPObject *psShape; + + psShape = SHPCreateSimpleObject( SHPT_POINT, 1, + &(poRawPoint->dfX), + &(poRawPoint->dfY), + &(poRawPoint->dfZ) ); + + iShape = SHPWriteObject( hSHP, -1, psShape ); + + SHPDestroyObject( psShape ); + +/* -------------------------------------------------------------------- */ +/* Write out the attributes. */ +/* -------------------------------------------------------------------- */ + char szID[13]; + + DBFWriteIntegerAttribute( hDBF, iShape, nSDTSRecordField, + poRawPoint->oModId.nRecord ); + + sprintf( szID, "%s:%ld", + poRawPoint->oAreaId.szModule, + poRawPoint->oAreaId.nRecord ); + DBFWriteStringAttribute( hDBF, iShape, nAreaField, szID ); + + WritePrimaryAttrToDBF( hDBF, iShape, poTransfer, poRawPoint ); + + if( !poPointReader->IsIndexed() ) + delete poRawPoint; + } + +/* -------------------------------------------------------------------- */ +/* Close, and cleanup. */ +/* -------------------------------------------------------------------- */ + DBFClose( hDBF ); + SHPClose( hSHP ); +} + +/* **********************************************************************/ +/* WriteAttributeDBF() */ +/* **********************************************************************/ + +static void WriteAttributeDBF( const char * pszShapefile, + SDTSTransfer * poTransfer, + const char * pszMODN ) + +{ + SDTSAttrReader *poAttrReader; + +/* -------------------------------------------------------------------- */ +/* Fetch a reference to the indexed Pointgon reader. */ +/* -------------------------------------------------------------------- */ + poAttrReader = (SDTSAttrReader *) + poTransfer->GetLayerIndexedReader( poTransfer->FindLayer( pszMODN ) ); + + if( poAttrReader == NULL ) + { + fprintf( stderr, "Failed to open %s.\n", + poTransfer->GetCATD()->GetModuleFilePath( pszMODN ) ); + return; + } + + poAttrReader->Rewind(); + +/* -------------------------------------------------------------------- */ +/* Create the database file, and our basic set of attributes. */ +/* -------------------------------------------------------------------- */ + DBFHandle hDBF; + char szDBFFilename[1024]; + + sprintf( szDBFFilename, "%s.dbf", pszShapefile ); + + hDBF = DBFCreate( szDBFFilename ); + if( hDBF == NULL ) + { + fprintf( stderr, "Unable to create shapefile .dbf for `%s'\n", + pszShapefile ); + return; + } + + DBFAddField( hDBF, "SDTSRecId", FTInteger, 8, 0 ); + +/* -------------------------------------------------------------------- */ +/* Prepare the schema. */ +/* -------------------------------------------------------------------- */ + char **papszMODNList = CSLAddString( NULL, pszMODN ); + + AddPrimaryAttrToDBFSchema( hDBF, poTransfer, papszMODNList ); + + CSLDestroy( papszMODNList ); + +/* ==================================================================== */ +/* Process all the records in the module. */ +/* ==================================================================== */ + SDTSAttrRecord *poRecord; + int iRecord = 0; + + while((poRecord = (SDTSAttrRecord*)poAttrReader->GetNextFeature()) != NULL) + { + DBFWriteIntegerAttribute( hDBF, iRecord, 0, + poRecord->oModId.nRecord ); + + WriteAttrRecordToDBF( hDBF, iRecord, poTransfer, poRecord->poATTR ); + + if( !poAttrReader->IsIndexed() ) + delete poRecord; + + iRecord++; + } + +/* -------------------------------------------------------------------- */ +/* Close, and cleanup. */ +/* -------------------------------------------------------------------- */ + DBFClose( hDBF ); +} + +/* **********************************************************************/ +/* WritePolygonShapefile() */ +/* **********************************************************************/ + +static void WritePolygonShapefile( const char * pszShapefile, + SDTSTransfer * poTransfer, + const char * pszMODN ) + +{ + SDTSPolygonReader *poPolyReader; + +/* -------------------------------------------------------------------- */ +/* Fetch a reference to the indexed polygon reader. */ +/* -------------------------------------------------------------------- */ + poPolyReader = (SDTSPolygonReader *) + poTransfer->GetLayerIndexedReader( poTransfer->FindLayer( pszMODN ) ); + + if( poPolyReader == NULL ) + { + fprintf( stderr, "Failed to open %s.\n", + poTransfer->GetCATD()->GetModuleFilePath( pszMODN ) ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Assemble polygon geometries from all the line layers. */ +/* -------------------------------------------------------------------- */ + poPolyReader->AssembleRings( poTransfer ); + +/* -------------------------------------------------------------------- */ +/* Create the Shapefile. */ +/* -------------------------------------------------------------------- */ + SHPHandle hSHP; + + hSHP = SHPCreate( pszShapefile, SHPT_POLYGON ); + if( hSHP == NULL ) + { + fprintf( stderr, "Unable to create shapefile `%s'\n", + pszShapefile ); + return; + } + +/* -------------------------------------------------------------------- */ +/* Create the database file, and our basic set of attributes. */ +/* -------------------------------------------------------------------- */ + DBFHandle hDBF; + int nSDTSRecordField; + char szDBFFilename[1024]; + + sprintf( szDBFFilename, "%s.dbf", pszShapefile ); + + hDBF = DBFCreate( szDBFFilename ); + if( hDBF == NULL ) + { + fprintf( stderr, "Unable to create shapefile .dbf for `%s'\n", + pszShapefile ); + return; + } + + nSDTSRecordField = DBFAddField( hDBF, "SDTSRecId", FTInteger, 8, 0 ); + + char **papszModRefs = poPolyReader->ScanModuleReferences(); + AddPrimaryAttrToDBFSchema( hDBF, poTransfer, papszModRefs ); + CSLDestroy( papszModRefs ); + +/* ==================================================================== */ +/* Process all the polygon features in the module. */ +/* ==================================================================== */ + SDTSRawPolygon *poRawPoly; + + poPolyReader->Rewind(); + while( (poRawPoly = (SDTSRawPolygon *) poPolyReader->GetNextFeature()) + != NULL ) + { + int iShape; + +/* -------------------------------------------------------------------- */ +/* Write out a shape with the vertices. */ +/* -------------------------------------------------------------------- */ + SHPObject *psShape; + + psShape = SHPCreateObject( SHPT_POLYGON, -1, poRawPoly->nRings, + poRawPoly->panRingStart, NULL, + poRawPoly->nVertices, + poRawPoly->padfX, + poRawPoly->padfY, + poRawPoly->padfZ, + NULL ); + + iShape = SHPWriteObject( hSHP, -1, psShape ); + + SHPDestroyObject( psShape ); + +/* -------------------------------------------------------------------- */ +/* Write out the attributes. */ +/* -------------------------------------------------------------------- */ + DBFWriteIntegerAttribute( hDBF, iShape, nSDTSRecordField, + poRawPoly->oModId.nRecord ); + WritePrimaryAttrToDBF( hDBF, iShape, poTransfer, poRawPoly ); + + if( !poPolyReader->IsIndexed() ) + delete poRawPoly; + } + +/* -------------------------------------------------------------------- */ +/* Close, and cleanup. */ +/* -------------------------------------------------------------------- */ + DBFClose( hDBF ); + SHPClose( hSHP ); +} + +/* **********************************************************************/ +/* AddPrimaryAttrToDBF() */ +/* */ +/* Add the fields from all the given primary attribute modules */ +/* to the schema of the passed DBF file. */ +/* **********************************************************************/ + +static void +AddPrimaryAttrToDBFSchema( DBFHandle hDBF, SDTSTransfer *poTransfer, + char ** papszModuleList ) + +{ + for( int iModule = 0; + papszModuleList != NULL && papszModuleList[iModule] != NULL; + iModule++ ) + { + SDTSAttrReader *poAttrReader; + +/* -------------------------------------------------------------------- */ +/* Get a reader on the desired module. */ +/* -------------------------------------------------------------------- */ + poAttrReader = (SDTSAttrReader *) + poTransfer->GetLayerIndexedReader( + poTransfer->FindLayer( papszModuleList[iModule] ) ); + + if( poAttrReader == NULL ) + { + printf( "Unable to open attribute module %s, skipping.\n" , + papszModuleList[iModule] ); + continue; + } + + poAttrReader->Rewind(); + +/* -------------------------------------------------------------------- */ +/* Read the first record so we can clone schema information off */ +/* of it. */ +/* -------------------------------------------------------------------- */ + SDTSAttrRecord *poAttrFeature; + + poAttrFeature = (SDTSAttrRecord *) poAttrReader->GetNextFeature(); + if( poAttrFeature == NULL ) + { + fprintf( stderr, + "Didn't find any meaningful attribute records in %s.\n", + papszModuleList[iModule] ); + + continue; + } + +/* -------------------------------------------------------------------- */ +/* Clone schema off the first record. Eventually we need to */ +/* get the information out of the DDR record, but it isn't */ +/* clear to me how to accomplish that with the SDTS++ API. */ +/* */ +/* The following approach may fail (dramatically) if some */ +/* records do not include all subfields. Furthermore, no */ +/* effort is made to make DBF field names unique. The SDTS */ +/* attributes often have names much beyond the 14 character dbf */ +/* limit which may result in non-unique attributes. */ +/* -------------------------------------------------------------------- */ + DDFFieldDefn *poFDefn = poAttrFeature->poATTR->GetFieldDefn(); + int iSF; + DDFField *poSR = poAttrFeature->poATTR; + + for( iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ ) + { + DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF ); + int nWidth = poSFDefn->GetWidth(); + + switch( poSFDefn->GetType() ) + { + case DDFString: + if( nWidth == 0 ) + { + int nMaxBytes; + + const char * pachData = poSR->GetSubfieldData(poSFDefn, + &nMaxBytes); + + nWidth = strlen(poSFDefn->ExtractStringData(pachData, + nMaxBytes, NULL )); + } + + DBFAddField( hDBF, poSFDefn->GetName(), FTString, nWidth, 0 ); + break; + + case DDFInt: + if( nWidth == 0 ) + nWidth = 9; + + DBFAddField( hDBF, poSFDefn->GetName(), FTInteger, nWidth, 0 ); + break; + + case DDFFloat: + DBFAddField( hDBF, poSFDefn->GetName(), FTDouble, 18, 6 ); + break; + + default: + fprintf( stderr, + "Dropping attribute `%s' of module `%s'. " + "Type unsupported\n", + poSFDefn->GetName(), + papszModuleList[iModule] ); + break; + } + } + + if( !poAttrReader->IsIndexed() ) + delete poAttrFeature; + + } /* next module */ +} + +/* **********************************************************************/ +/* WritePrimaryAttrToDBF() */ +/* **********************************************************************/ + +static void +WritePrimaryAttrToDBF( DBFHandle hDBF, int iRecord, + SDTSTransfer * poTransfer, SDTSFeature * poFeature ) + +{ +/* ==================================================================== */ +/* Loop over all the attribute records linked to this feature. */ +/* ==================================================================== */ + int iAttrRecord; + + for( iAttrRecord = 0; iAttrRecord < poFeature->nAttributes; iAttrRecord++) + { + DDFField *poSR; + + poSR = poTransfer->GetAttr( poFeature->paoATID+iAttrRecord ); + + WriteAttrRecordToDBF( hDBF, iRecord, poTransfer, poSR ); + } +} + +/* **********************************************************************/ +/* WriteAttrRecordToDBF() */ +/* **********************************************************************/ + +static void +WriteAttrRecordToDBF( DBFHandle hDBF, int iRecord, + SDTSTransfer * poTransfer, DDFField * poSR ) + +{ +/* -------------------------------------------------------------------- */ +/* Process each subfield in the record. */ +/* -------------------------------------------------------------------- */ + DDFFieldDefn *poFDefn = poSR->GetFieldDefn(); + + for( int iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ ) + { + DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF ); + int iField; + int nMaxBytes; + const char * pachData = poSR->GetSubfieldData(poSFDefn, + &nMaxBytes); + +/* -------------------------------------------------------------------- */ +/* Identify the related DBF field, if any. */ +/* -------------------------------------------------------------------- */ + for( iField = 0; iField < hDBF->nFields; iField++ ) + { + if( EQUALN(poSFDefn->GetName(), + hDBF->pszHeader+iField*32,10) ) + break; + } + + if( iField == hDBF->nFields ) + iField = -1; + +/* -------------------------------------------------------------------- */ +/* Handle each of the types. */ +/* -------------------------------------------------------------------- */ + switch( poSFDefn->GetType() ) + { + case DDFString: + const char *pszValue; + + pszValue = poSFDefn->ExtractStringData(pachData, nMaxBytes, + NULL); + + if( iField != -1 ) + DBFWriteStringAttribute(hDBF, iRecord, iField, pszValue ); + break; + + case DDFFloat: + double dfValue; + + dfValue = poSFDefn->ExtractFloatData(pachData, nMaxBytes, + NULL); + + if( iField != -1 ) + DBFWriteDoubleAttribute( hDBF, iRecord, iField, dfValue ); + break; + + case DDFInt: + int nValue; + + nValue = poSFDefn->ExtractIntData(pachData, nMaxBytes, NULL); + + if( iField != -1 ) + DBFWriteIntegerAttribute( hDBF, iRecord, iField, nValue ); + break; + + default: + break; + } + } /* next subfield */ +} diff --git a/Utilities/GDAL/frmts/sdts/sdts_al.h b/Utilities/GDAL/frmts/sdts/sdts_al.h new file mode 100644 index 0000000000..e7d7f6fe24 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdts_al.h @@ -0,0 +1,756 @@ +/****************************************************************************** + * $Id$ + * + * Project: SDTS Translator + * Purpose: Include file for entire SDTS Abstraction Layer functions. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdts_al.h,v $ + * Revision 1.26 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.25 2001/09/10 19:27:36 warmerda + * added GetMinMax() and raster data types + * + * Revision 1.24 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.23 2000/02/03 19:44:51 warmerda + * added method for getting bounds of transfer + * + * Revision 1.22 1999/11/12 13:12:35 warmerda + * make adfTransform public + * + * Revision 1.21 1999/11/04 22:52:53 warmerda + * added dynamic ATID support + * + * Revision 1.20 1999/10/01 14:49:42 warmerda + * added Getmodule() + * + * Revision 1.19 1999/09/22 13:35:31 warmerda + * added SDTSPolygonReader::AssembleRings() + * + * Revision 1.18 1999/09/21 17:25:45 warmerda + * Added DDSH fields to raster reader. + * Moved SADR reading onto SDTS_IREF. + * + * Revision 1.17 1999/09/21 02:23:25 warmerda + * added logic to put outer ring first, and set ring direction + * + * Revision 1.16 1999/09/03 19:03:45 warmerda + * fixed up help + * + * Revision 1.15 1999/09/03 13:34:45 warmerda + * added duplicate flag on GetNextRecord + * + * Revision 1.14 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.13 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.12 1999/08/16 20:59:28 warmerda + * added szOBRP support for SDTSModId + * + * Revision 1.11 1999/08/16 19:24:45 warmerda + * upped ATID limits, added polyreader method + * + * Revision 1.10 1999/08/16 15:45:46 warmerda + * added IsSecondary() + * + * Revision 1.9 1999/08/10 02:52:13 warmerda + * introduce use of SDTSApplyModIdList to capture multi-attributes + * + * Revision 1.8 1999/07/30 19:15:56 warmerda + * added module reference counting + * + * Revision 1.7 1999/06/03 21:13:02 warmerda + * Added transform for rasters. + * + * Revision 1.6 1999/06/03 14:04:10 warmerda + * Added SDTS_XREF and SDTSRasterReader + * + * Revision 1.5 1999/05/11 14:05:59 warmerda + * added SDTSTransfer and SDTSPolygonreader + * + * Revision 1.4 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.3 1999/04/21 04:38:32 warmerda + * Added new classes including SDTSPoint + * + * Revision 1.2 1999/03/23 15:58:01 warmerda + * some const fixes, and attr record fixes + * + * Revision 1.1 1999/03/23 13:56:14 warmerda + * New + * + */ + +#ifndef SDTS_AL_H_INCLUDED +#define STDS_AL_H_INCLUDED + +#include "cpl_conv.h" +#include "iso8211.h" + +class SDTS_IREF; +class SDTSModId; +class SDTSTransfer; + +#define SDTS_SIZEOF_SADR 8 + +char **SDTSScanModuleReferences( DDFModule *, const char * ); + +/************************************************************************/ +/* SDTS_IREF */ +/************************************************************************/ + +/** + Class holding SDTS IREF (internal reference) information, internal + coordinate system format, scaling and resolution. This object isn't + normally needed by applications. +*/ +class SDTS_IREF +{ + int nDefaultSADRFormat; + + public: + SDTS_IREF(); + ~SDTS_IREF(); + + int Read( const char *pszFilename ); + + char *pszXAxisName; /* XLBL */ + char *pszYAxisName; /* YLBL */ + + double dfXScale; /* SFAX */ + double dfYScale; /* SFAY */ + + double dfXOffset; /* XORG */ + double dfYOffset; /* YORG */ + + double dfXRes; /* XHRS */ + double dfYRes; /* YHRS */ + + char *pszCoordinateFormat; /* HFMT */ + + int GetSADRCount( DDFField * ); + int GetSADR( DDFField *, int, double *, double *, double * ); +}; + +/************************************************************************/ +/* SDTS_XREF */ +/************************************************************************/ + +/** + Class for reading the XREF (external reference) module containing the + data projection definition. +*/ + +class SDTS_XREF +{ + public: + SDTS_XREF(); + ~SDTS_XREF(); + + int Read( const char *pszFilename ); + + /** Projection system name, from the RSNM field. One of GEO, SPCS, UTM, + UPS, OTHR, UNSP. */ + char *pszSystemName; + + + /** Horizontal datum name, from the HDAT field. One of NAS, NAX, WGA, + WGB, WGC, WGE. */ + char *pszDatum; + + /** Zone number for UTM and SPCS projections, from the ZONE field. */ + int nZone; +}; + +/************************************************************************/ +/* SDTS_CATD */ +/************************************************************************/ +class SDTS_CATDEntry; + +/** + List of feature layer types. See SDTSTransfer::GetLayerType(). + */ + +typedef enum { + SLTUnknown, + SLTPoint, + SLTLine, + SLTAttr, + SLTPoly, + SLTRaster +} SDTSLayerType; + +/** + Class for accessing the CATD (Catalog Directory) file containing a list of + all other files (modules) in the transfer. +*/ +class SDTS_CATD +{ + char *pszPrefixPath; + + int nEntries; + SDTS_CATDEntry **papoEntries; + + public: + SDTS_CATD(); + ~SDTS_CATD(); + + int Read( const char * pszFilename ); + + const char *GetModuleFilePath( const char * pszModule ); + + int GetEntryCount() { return nEntries; } + const char * GetEntryModule(int); + const char * GetEntryTypeDesc(int); + const char * GetEntryFilePath(int); + SDTSLayerType GetEntryType(int); +}; + +/************************************************************************/ +/* SDTSModId */ +/************************************************************************/ + +/** + Object representing a unique module/record identifier within an SDTS + transfer. +*/ +class SDTSModId +{ + public: + SDTSModId() { szModule[0] = '\0'; + nRecord = -1; + szOBRP[0] = '\0'; } + + int Set( DDFField * ); + + const char *GetName(); + + /** The module name, such as PC01, containing the indicated record. */ + char szModule[8]; + + /** The record within the module referred to. This is -1 for unused + SDTSModIds. */ + long nRecord; + + /** The "role" of this record within the module. This is normally empty + for references, but set in the oModId member of a feature. */ + char szOBRP[8]; +}; + +/************************************************************************/ +/* SDTSFeature */ +/************************************************************************/ + +/** + Base class for various SDTS features classes, providing a generic + module identifier, and list of attribute references. +*/ +class SDTSFeature +{ +public: + + SDTSFeature(); + virtual ~SDTSFeature(); + + /** Unique identifier for this record/feature within transfer. */ + SDTSModId oModId; + + /** Number of attribute links (aoATID[]) on this feature. */ + int nAttributes; + + /** List of nAttributes attribute record identifiers related to this + feature. */ + SDTSModId *paoATID; + + void ApplyATID( DDFField * ); + + + /** Dump reable description of feature to indicated stream. */ + virtual void Dump( FILE * ) = 0; +}; + +/************************************************************************/ +/* SDTSIndexedReader */ +/************************************************************************/ + +/** + Base class for all the SDTSFeature type readers. Provides feature + caching semantics and fetching based on a record number. + */ + +class SDTSIndexedReader +{ + int nIndexSize; + SDTSFeature **papoFeatures; + + int iCurrentFeature; + +protected: + DDFModule oDDFModule; + +public: + SDTSIndexedReader(); + virtual ~SDTSIndexedReader(); + + virtual SDTSFeature *GetNextRawFeature() = 0; + + SDTSFeature *GetNextFeature(); + + virtual void Rewind(); + + void FillIndex(); + void ClearIndex(); + int IsIndexed(); + + SDTSFeature *GetIndexedFeatureRef( int ); + char ** ScanModuleReferences( const char * = "ATID" ); + + DDFModule *GetModule() { return &oDDFModule; } +}; + + +/************************************************************************/ +/* SDTSRawLine */ +/************************************************************************/ + +/** SDTS line feature, as read from LE* modules by SDTSLineReader. */ + +class SDTSRawLine : public SDTSFeature +{ + public: + SDTSRawLine(); + virtual ~SDTSRawLine(); + + int Read( SDTS_IREF *, DDFRecord * ); + + /** Number of vertices in the padfX, padfY and padfZ arrays. */ + int nVertices; + + /** List of nVertices X coordinates. */ + double *padfX; + /** List of nVertices Y coordinates. */ + double *padfY; + /** List of nVertices Z coordinates - currently always zero. */ + double *padfZ; + + /** Identifier of polygon to left of this line. This is the SDTS PIDL + subfield. */ + SDTSModId oLeftPoly; + + /** Identifier of polygon to right of this line. This is the SDTS PIDR + subfield. */ + SDTSModId oRightPoly; + + /** Identifier for the start node of this line. This is the SDTS SNID + subfield. */ + SDTSModId oStartNode; /* SNID */ + + /** Identifier for the end node of this line. This is the SDTS ENID + subfield. */ + SDTSModId oEndNode; /* ENID */ + + void Dump( FILE * ); +}; + +/************************************************************************/ +/* SDTSLineReader */ +/* */ +/* Class for reading any of the files lines. */ +/************************************************************************/ + +/** + Reader for SDTS line modules. + + Returns SDTSRawLine features. Normally readers are instantiated with + the SDTSTransfer::GetIndexedReader() method. + + */ + +class SDTSLineReader : public SDTSIndexedReader +{ + SDTS_IREF *poIREF; + + public: + SDTSLineReader( SDTS_IREF * ); + ~SDTSLineReader(); + + int Open( const char * ); + SDTSRawLine *GetNextLine( void ); + void Close(); + + SDTSFeature *GetNextRawFeature( void ) { return GetNextLine(); } + + void AttachToPolygons( SDTSTransfer * ); +}; + +/************************************************************************/ +/* SDTSAttrRecord */ +/************************************************************************/ + +/** + SDTS attribute record feature, as read from A* modules by + SDTSAttrReader. + + Note that even though SDTSAttrRecord is derived from SDTSFeature, there + are never any attribute records associated with attribute records using + the aoATID[] mechanism. SDTSFeature::nAttributes will always be zero. + */ + +class SDTSAttrRecord : public SDTSFeature +{ + public: + SDTSAttrRecord(); + virtual ~SDTSAttrRecord(); + + /** The entire DDFRecord read from the file. */ + DDFRecord *poWholeRecord; + + /** The ATTR DDFField with the user attribute. Each subfield is a + attribute value. */ + + DDFField *poATTR; + + virtual void Dump( FILE * ); +}; + +/************************************************************************/ +/* SDTSAttrReader */ +/************************************************************************/ + +/** + Class for reading SDTSAttrRecord features from a primary or secondary + attribute module. + */ + +class SDTSAttrReader : public SDTSIndexedReader +{ + SDTS_IREF *poIREF; + + int bIsSecondary; + + public: + SDTSAttrReader( SDTS_IREF * ); + virtual ~SDTSAttrReader(); + + int Open( const char * ); + DDFField *GetNextRecord( SDTSModId * = NULL, + DDFRecord ** = NULL, + int bDuplicate = FALSE ); + SDTSAttrRecord *GetNextAttrRecord(); + void Close(); + + /** + Returns TRUE if this is a Attribute Secondary layer rather than + an Attribute Primary layer. + */ + int IsSecondary() { return bIsSecondary; } + + SDTSFeature *GetNextRawFeature( void ) { return GetNextAttrRecord(); } +}; + +/************************************************************************/ +/* SDTSRawPoint */ +/************************************************************************/ + +/** + Object containing a point feature (type NA, NO or NP). + */ +class SDTSRawPoint : public SDTSFeature +{ + public: + SDTSRawPoint(); + virtual ~SDTSRawPoint(); + + int Read( SDTS_IREF *, DDFRecord * ); + + /** X coordinate of point. */ + double dfX; + /** Y coordinate of point. */ + double dfY; + /** Z coordinate of point. */ + double dfZ; + + /** Optional identifier of area marked by this point (ie. PC01:27). */ + SDTSModId oAreaId; /* ARID */ + + virtual void Dump( FILE * ); +}; + +/************************************************************************/ +/* SDTSPointReader */ +/************************************************************************/ + +/** + Class for reading SDTSRawPoint features from a point module (type NA, NO + or NP). + */ + +class SDTSPointReader : public SDTSIndexedReader +{ + SDTS_IREF *poIREF; + + public: + SDTSPointReader( SDTS_IREF * ); + virtual ~SDTSPointReader(); + + int Open( const char * ); + SDTSRawPoint *GetNextPoint( void ); + void Close(); + + SDTSFeature *GetNextRawFeature( void ) { return GetNextPoint(); } +}; + +/************************************************************************/ +/* SDTSRawPolygon */ +/************************************************************************/ + +/** + Class for holding information about a polygon feature. + + When directly read from a polygon module, the polygon has no concept + of it's geometry. Just it's ID, and references to attribute records. + However, if the SDTSLineReader::AttachToPolygons() method is called on + the module containing the lines forming the polygon boundaries, then the + nEdges/papoEdges information on the SDTSRawPolygon will be filled in. + + Once this is complete the AssembleRings() method can be used to fill in the + nRings/nVertices/panRingStart/padfX/padfY/padfZ information defining the + ring geometry. + + Note that the rings may not appear in any particular order, nor with any + meaningful direction (clockwise or counterclockwise). + */ + +class SDTSRawPolygon : public SDTSFeature +{ + void AddEdgeToRing( int, double *, double *, double *, int, int ); + + public: + SDTSRawPolygon(); + virtual ~SDTSRawPolygon(); + + int Read( DDFRecord * ); + + int nEdges; + SDTSRawLine **papoEdges; + + void AddEdge( SDTSRawLine * ); + + /** This method will assemble the edges associated with a polygon into + rings, returning FALSE if problems are encountered during assembly. */ + int AssembleRings(); + + /** Number of rings in assembled polygon. */ + int nRings; + /** Total number of vertices in all rings of assembled polygon. */ + int nVertices; + /** Offsets into padfX/padfY/padfZ for the beginning of each ring in the + polygon. This array is nRings long. */ + int *panRingStart; + + /** List of nVertices X coordinates for the polygon (split over multiple + rings via panRingStart. */ + double *padfX; + /** List of nVertices Y coordinates for the polygon (split over multiple + rings via panRingStart. */ + double *padfY; + /** List of nVertices Z coordinates for the polygon (split over multiple + rings via panRingStart. The values are almost always zero. */ + double *padfZ; + + virtual void Dump( FILE * ); +}; + +/************************************************************************/ +/* SDTSPolygonReader */ +/************************************************************************/ + +/** Class for reading SDTSRawPolygon features from a polygon (PC*) module. */ + +class SDTSPolygonReader : public SDTSIndexedReader +{ + int bRingsAssembled; + + public: + SDTSPolygonReader(); + virtual ~SDTSPolygonReader(); + + int Open( const char * ); + SDTSRawPolygon *GetNextPolygon( void ); + void Close(); + + SDTSFeature *GetNextRawFeature( void ) { return GetNextPolygon(); } + + void AssembleRings( SDTSTransfer * ); +}; + +/************************************************************************/ +/* SDTSRasterReader */ +/************************************************************************/ + +/** + Class for reading raster data from a raster layer. + + This class is somewhat unique amoung the reader classes in that it isn't + derived from SDTSIndexedFeature, and it doesn't return "features". Instead + it is used to read raster blocks, in the natural block size of the dataset. + */ + +class SDTSRasterReader +{ + DDFModule oDDFModule; + + char szModule[20]; + + int nXSize; + int nYSize; + int nXBlockSize; + int nYBlockSize; + + int nXStart; /* SOCI */ + int nYStart; /* SORI */ + + double adfTransform[6]; + + public: + char szINTR[4]; /* CE is center, TL is top left */ + char szFMT[32]; + char szUNITS[64]; + char szLabel[64]; + + SDTSRasterReader(); + ~SDTSRasterReader(); + + int Open( SDTS_CATD * poCATD, SDTS_IREF *, + const char * pszModule ); + void Close(); + + int GetRasterType(); /* 1 = int16, see GDAL types */ +#define SDTS_RT_INT16 1 +#define SDTS_RT_FLOAT32 6 + + int GetTransform( double * ); + + int GetMinMax( double * pdfMin, double * pdfMax, + double dfNoData ); + + /** + Fetch the raster width. + + @return the width in pixels. + */ + int GetXSize() { return nXSize; } + /** + Fetch the raster height. + + @return the height in pixels. + */ + int GetYSize() { return nYSize; } + + /** Fetch the width of a source block (usually same as raster width). */ + int GetBlockXSize() { return nXBlockSize; } + /** Fetch the height of a source block (usually one). */ + int GetBlockYSize() { return nYBlockSize; } + + int GetBlock( int nXOffset, int nYOffset, void * pData ); +}; + +/************************************************************************/ +/* SDTSTransfer */ +/************************************************************************/ + +/** + Master class representing an entire SDTS transfer. + + This class is used to open the transfer, to get a list of available + feature layers, and to instantiate readers for those layers. + + */ + +class SDTSTransfer +{ + public: + SDTSTransfer(); + ~SDTSTransfer(); + + int Open( const char * ); + void Close(); + + int FindLayer( const char * ); + int GetLayerCount() { return nLayers; } + SDTSLayerType GetLayerType( int ); + int GetLayerCATDEntry( int ); + + SDTSLineReader *GetLayerLineReader( int ); + SDTSPointReader *GetLayerPointReader( int ); + SDTSPolygonReader *GetLayerPolygonReader( int ); + SDTSAttrReader *GetLayerAttrReader( int ); + SDTSRasterReader *GetLayerRasterReader( int ); + DDFModule *GetLayerModuleReader( int ); + + SDTSIndexedReader *GetLayerIndexedReader( int ); + + /** + Fetch the catalog object for this transfer. + + @return pointer to the internally managed SDTS_CATD for the transfer. + */ + SDTS_CATD *GetCATD() { return &oCATD ; } + + SDTS_IREF *GetIREF() { return &oIREF; } + + /** + Fetch the external reference object for this transfer. + + @return pointer to the internally managed SDTS_XREF for the transfer. + */ + SDTS_XREF *GetXREF() { return &oXREF; } + + SDTSFeature *GetIndexedFeatureRef( SDTSModId *, + SDTSLayerType *peType = NULL); + + DDFField *GetAttr( SDTSModId * ); + + int GetBounds( double *pdfMinX, double *pdfMinY, + double *pdfMaxX, double *pdfMaxY ); + + private: + + SDTS_CATD oCATD; + SDTS_IREF oIREF; + SDTS_XREF oXREF; + + int nLayers; + int *panLayerCATDEntry; + SDTSIndexedReader **papoLayerReader; +}; + +#endif /* ndef SDTS_AL_H_INCLUDED */ diff --git a/Utilities/GDAL/frmts/sdts/sdts_main.dox b/Utilities/GDAL/frmts/sdts/sdts_main.dox new file mode 100644 index 0000000000..98d2728a43 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdts_main.dox @@ -0,0 +1,226 @@ +/*! \page sdts_al_main + +<center> +<title>SDTS Abstraction Library</title> +</center> + +<h2>Introduction</h2> + +SDTS_AL, the SDTS Abstraction Library, is intended to be an relatively +easy to use library for reading vector from SDTS TVP (Topological Vector +Profile) files, primary DLG data from the USGS. It also include support +for reading raster data such as USGS DEMs in SDTS format. It consists +of open source, easy to compile and integrate C++ code.<p> + +<!---------------------------------------------------------------------------> + +<h2>SDTS Background</h2> + +The USGS SDTS Page at +<a href="http://mcmcweb.er.usgs.gov/sdts/">http://mcmcweb.er.usgs.gov/sdts</a> +is the definative source of information on the SDTS format. The SDTS +format is based on the +<a href="http://starship.skyport.net/crew/tibs/iso8211/faq.html">ISO 8211</a> +encoding scheme for the underlying files, and the SDTS Abstraction Library +uses +<a href="http://gdal.velocet.ca/projects/iso8211/index.html">ISO8211Lib</a> +library to decode them. All references to DDF* classes are from ISO8211Lib.<p> + +An SDTS Transfer is a grouping of ISO8211 encoded files (ending in the +.DDF extension), normally with part of the basename in common. For instance +a USGS DLG SDTS transfer might consists of many files matching the +SC01????.DDF pattern. The key file in an SDTS transfer is the catalog +file, such as SC01CATD.DDF.<p> + +<!---------------------------------------------------------------------------> + +<h2>Development Information</h2> + +The <a href="class_sdtstransfer-include.html">sdts_al.h</a> +include file contains the definitions for all public +SDTS classes, enumerations and other services.<p> + +The SDTSTransfer class is used to access a transfer as a whole. The +SDTSTransfer::Open() method is passed the name of the catalog file, +such as SC01CATD.DDF, to open.<p> + +The SDTSTransfer analyses the catalog, and some other aspects of the +transfer, and builds a list of feature layers. This list can be +accessed using the SDTSTransfer::GetLayerCount(), SDTSTransfer::GetLayerType(), +and SDTSTransfer::GetLayerIndexedReader() methods. A typical TVP (Topological +Vector Profile) transfer might include three point layers (of type +SLTPoint), a line layer (of type SLTLine), a polygon layer (of type SLTPoly) +as well as some additional attribute layers (of type SLTAttr). the +SDTSTransfer::GetLayerIndexedReader() method can be used to instantiate a +reader object for reading a particular layer. (NOTE: raster layers are +handled differently).<p> + +Each type of SDTSIndexedReader (SDTSPointReader, SDTSLineReader, +SDTSPolygonReader, and SDTSAttrReader) returns specific subclasses of +SDTSIndexedFeature from the SDTSIndexedReader::GetNextFeature() method. +These classes are SDTSRawPoint, SDTSRawLine, SDTSRawPolygon and +SDTSAttrRecord. These classes can be investigated for details on the +data available for each.<p> + +See the <a href="sdts_al_tut.html">SDTS_AL Tutorial</a> for more information +on how to use this library.<p> + +<!---------------------------------------------------------------------------> + +<h2>Building the Source on Unix</h2> + +<ol> + +<li> First, fetch the source. The most recent source should be accessable +at an url such as +<a href="ftp://gdal.velocet.ca/pub/outgoing/sdts_1_3.tar.gz"> +ftp://gdal.velocet.ca/pub/outgoing/sdts_1_3.tar.gz</a>.<p> + + +<li> Unpack the source.<p> +<pre> +% gzip -d sdts_1_3.tar.gz +% tar xzvf sdts_1_3.tar.gz +</pre> + +<li> Type ``configure'' to establish configuration +options. <p> + +<li> Type make to build sdts_al.a, and the sample +mainline sdts2shp.<p> + +</ol> + +See the <a href="sdts_al_tut.html">SDTS_AL Tutorial</a> for more information +on how to use this library.<p> + +<!---------------------------------------------------------------------------> + +<h2>Building the Source on Windows</h2> + +<ol> + +<li> First, fetch the source. The most recent source should be accessable +at an url such as +<a href="ftp://gdal.velocet.ca/pub/outgoing/sdts_1_3.zip"> +ftp://gdal.velocet.ca/pub/outgoing/sdts_1_3.zip</a>.<p> + + +<li> Unpack the source.<p> + +<pre> +C:\SDTS> unzip sdts_1_3.zip +</pre> + +<li> Build using makefile.vc with VC++. You will need the VC++ runtime +environment variables (LIB/INCLUDE) set properly. This will build the +library (sdts_al.lib), and the executables sdts2shp.exe, 8211view.exe and +8211dump.exe.<p> + +<pre> +C:\SDTS> nmake /f makefile.vc +</pre> + +</ol> + +See the <a href="sdts_al_tut.html">SDTS_AL Tutorial</a> for more information +on how to use this library.<p> + +<!---------------------------------------------------------------------------> + +<h2>The sdts2shp Sample Program</h2> + +The sdts2shp program distributed with this toolkit is primary intended to +serve as an example of how to use the SDTS access library. However, it can +be useful to translate SDTS datasets into ESRI Shapefile format. + +<pre> +Usage: sdts2shp CATD_filename [-o shapefile_name] + [-m module_name] [-v] + +Modules include `LE01', `PC01', `NP01' and `ARDF' +</pre> + +A typical session in which we inspect the contents of a transfer, and then +extract polygon and line layers might look like this:<p> + +<pre> +warmerda[134]% sdts2shp data/SC01CATD.DDF -v +Layers: + ASCF: `Attribute Primary ' + AHDR: `Attribute Primary ' + NP01: `Point-Node ' + NA01: `Point-Node ' + NO01: `Point-Node ' + LE01: `Line ' + PC01: `Polygon ' + +warmerda[135]% sdts2shp data/SC01CATD.DDF -m PC01 -o pc01.shp +warmerda[136]% sdts2shp data/SC01CATD.DDF -m LE01 -o le01.shp +</pre> + +A <a href="sdts2shp.zip">prebuilt executable</a> is available for +Windows.<p> + +<!---------------------------------------------------------------------------> + +<h2>Licensing</h2> + +This library is offered as <a href="http://www.opensource.org">Open Source</a>. +In particular, it is offered under the X Consortium license which doesn't +attempt to impose any copyleft, or credit requirements on users of the code.<p> + +The precise license text is:<p> + +<em> + Copyright (c) 1999, Frank Warmerdam +<p> + 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: +<p> + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. +<p> + 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. +<p> +</em> + +<!---------------------------------------------------------------------------> + +<h2>Author and Acknowledgements</h2> + +The primary author of SDTS_AL is <a href="http://pobox.com/~warmerdam"> +Frank Warmerdam</a>, and I can be reached at +<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>. I am eager to +receive bug reports, and also open to praise or suggestions.<p> + +I would like to thank:<p> + +<ul> +<li> <a href="http://www.safe.com/">Safe Software</a> +who funded development of this library, and agreed for it to be Open Source.<p> + +<li> Mark Colletti, a primary author of +<a href="http://mcmcweb.er.usgs.gov/sdts/sdtsxx/index.html">SDTS++</a> from +which I derived most of what I know about SDTS and ISO8211 and who was very +supportive, answering a variety of questions.<p> + +</ul> + +I would also like to dedicate this library to the memory of Sol Katz. +Sol released a variety of SDTS translators, at substantial +personal effort, to the GIS community along with the many other generous +contributions he made to the community. His example has been an inspiration +to me, and I hope similar efforts on my part will contribute to his memory.<p> + +*/ diff --git a/Utilities/GDAL/frmts/sdts/sdts_tut.dox b/Utilities/GDAL/frmts/sdts/sdts_tut.dox new file mode 100644 index 0000000000..a929e04088 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdts_tut.dox @@ -0,0 +1,469 @@ +/*! \page SDTS_AL_TUT + +<center> +<title>SDTS Abstraction Library Tutorial</title> +</center> + +This page is a walk through of the polygon layer portion of the +<a href="sdts2shp.cpp.html">sdts2shp.cpp</a> example application. It is should +give sufficient information to utilize the SDTS_AL library to read SDTS +files.<p> + +<h2>Opening the Transfer</h2> + +The following statements will open an SDTS transfer. The filename +passed to SDTSTransfer::Open() should be the name of the catalog file, +such as <tt>palo_alto/SC01CATD.DDF</tt>. The Open() method returns FALSE +if it fails for any reason. In addition to the message we print out ourselves, +the SDTSTransfer::Open() method will also emit it's own error message using +CPLError(). See the cpl_error.h page for more information on how to +capture and control CPLError() style error reporting.<p> + +<pre> +#include "stds_al.h" + +... + + SDTSTransfer oTransfer; + + if( !oTransfer.Open( pszCATDFilename ) ) + { + fprintf( stderr, + "Failed to read CATD file `%s'\n", + pszCATDFilename ); + exit( 100 ); + } +</pre> + +<h2>Getting a Layer List</h2> + +Once an SDTSTransfer has been opened, it is possible to establish what +layers are available. The sdts2shp example problem includes a -v argument +to dump a list of available layers. It isn't normally necessary to use the +SDTS_CATD (catalog) from an application to access SDTS files; however, in +this example we use it to fetch a module name, and description for each +of the available layers.<p> + +In particular, the SDTSTransfer::GetLayerCount() method returns the +number of feature layers in the transfer and the +SDTSTransfer::GetLayerCATDEntry() is used to translate layer indexes into +SDTS_CATD compatible CATD indexes.<p> + +<pre> + printf( "Layers:\n" ); + for( i = 0; i < oTransfer.GetLayerCount(); i++ ) + { + int iCATDEntry = oTransfer.GetLayerCATDEntry(i); + + printf( " %s: `%s'\n", + oTransfer.GetCATD()->GetEntryModule(iCATDEntry), + oTransfer.GetCATD()->GetEntryTypeDesc(iCATDEntry) ); + } + printf( "\n" ); +</pre> + +The following would be a typical layer list. Note that there are many +other modules (files) registered with the catalog, but only these ones +are considered to be feature layers by the SDTSTransfer object. The +rest are supporting information, much of it, like data quality, is ignored +by the SDTS_AL library.<p> + +<pre> +warmerda@cs46980-c[113]% sdts2shp data/SC01CATD.DDF -v +Layers: + ASCF: `Attribute Primary ' + AHDR: `Attribute Primary ' + NP01: `Point-Node ' + NA01: `Point-Node ' + NO01: `Point-Node ' + LE01: `Line ' + PC01: `Polygon ' +</pre> + +<h2>Getting a Reader</h2> + +In order to read polygon features, it is necessary to instantiate a polygon +reader on the desired layer. The sdts2shp.cpp program allow the user to +select a module name (such as PC01, stored in pszMODN) to write to shape +format. Other application might just search for, and operate on all known +layers of a desired type.<p> + +The SDTSTransfer::GetLayerIndexedReader() method instantiates a reader of +the desired type. In this case we know we are instantiating a +SDTSPolygonReader so we can safely cast the returned SDTSIndexedReader +pointer to the more specific type SDTSPolygonReader.<p> + +<pre> + SDTSPolygonReader *poPolyReader; + + poPolyReader = (SDTSPolygonReader *) + poTransfer->GetLayerIndexedReader( poTransfer->FindLayer( pszMODN ) ); + + if( poPolyReader == NULL ) + { + fprintf( stderr, "Failed to open %s.\n", + poTransfer->GetCATD()->GetModuleFilePath( pszMODN ) ); + return; + } +</pre> + +Note that readers returned by SDTSTransfer::GetLayerIndexedReader() are +managed by the SDTSTransfer, and should not be deleted by the application.<p> + +<h2>Collecting Polygon Geometry</h2> + +The SDTS TVP format does not directly associate a polygons geometry (the +points forming it's boundary) with the polygon feature. Instead it is +stored in separate line layers, and the lines contain references to the +right, and left polygons that the lines border.<p> + +The SDTS_AL library provides a convenient method for forming the polygon +geometry. Basically just call the SDTSPolygonReader::AssemblePolygons() +method. This method will scan all SLTLine layers in the transfer, indexing +them and attaching their line work to the polygons. Then it assembles the +line work into rings. It also ensures that the outer ring comes first, that +the outer ring is counter-clockwise and that the inner ring(s) are +clockwise. + +<pre> + poPolyReader->AssembleRings( poTransfer ); +</pre> + +Upon completion the SDTSPolygonReader will have been "indexed". That means +that all the polygon information will have been read from disk, and the +polygon objects will now have information stored with them indicating the +list of edges that form their border.<p> + +<h2>Identifying Attributes</h2> + +In order to create the schema for the output shapefile dataset, it is +necessary to identify the attributes associated with the polygons. There +are two types of attributes which can occur. The first are hardcoded +attributes specific to the feature type, and the second are generic +user attributes stored in a separate primary attribute layer.<p> + +In the case of SDTSRawPolygon, there is only one attribute of interest, +and that is the record number of the polygon. This is actually stored within +the oModId data member of the SDTSIndexedFeature base class, as will be seen +in later examples when we write it to disk. For now we create a DBF +field for the record number. This record number is a unique identifier of +the polygon within this module/layer.<p> + +<pre> + nSDTSRecordField = DBFAddField( hDBF, "SDTSRecId", FTInteger, 8, 0 ); +</pre> + +Identification of user attributes is more complicated. Any feature in a +layer can have associates with 0, 1, 2 or potentially more attribute records +in other primary attribute layers. In order to establish a schema for the +layer it is necessary to build up a list of all attribute layers (tables) +to which references appear. The SDTSIndexedReader::ScanModuleReferences() +method can be used to scan a whole module for references to attribute modules +via the ATID field. The return result is a list of referenced modules in the +form of a string list. In a typical case this is one or two modules, such +as "ASCF".<p> + +<pre> + char **papszModRefs = poPolyReader->ScanModuleReferences(); +</pre> + +In sdts2shp.cpp, a subroutine (AddPrimaryAttrToDBFSchema()) is defined +to add all the fields of all references attribute layers to the DBF file. +For each module in the list the following steps are executed.<p> + +<h3>Fetch an Attribute Module Reader</h3> + +The following code is similar to our code for create a polygon layer +reader. It creates a reader on one of the attribute layers referenced. +We explicitly rewind it since it may have been previously opened and +read by another part of the application.<p> + +<pre> + SDTSAttrReader *poAttrReader; + + poAttrReader = (SDTSAttrReader *) + poTransfer->GetLayerIndexedReader( + poTransfer->FindLayer( papszModuleList[iModule] ) ); + + if( poAttrReader == NULL ) + { + printf( "Unable to open attribute module %s, skipping.\n" , + papszModuleList[iModule] ); + continue; + } + + poAttrReader->Rewind(); +</pre> + +<h3>Get a Prototype Record</h3> + +In order to get access to field definitions, and in order to establish +some sort of reasonable default lengths for field without fixed lengths +the sdts2shp program fetches a prototype record from the attribute module. + +<pre> + SDTSAttrRecord *poAttrFeature; + + poAttrFeature = (SDTSAttrRecord *) poAttrReader->GetNextFeature(); + if( poAttrFeature == NULL ) + { + fprintf( stderr, + "Didn't find any meaningful attribute records in %s.\n", + papszModuleList[iModule] ); + + continue; + } +</pre> + +When no longer needed, the attribute record may need to be explicitly +deleted if it is not part of an indexed cached.<p> + +<pre> + if( !poAttrReader->IsIndexed() ) + delete poAttrFeature; +</pre> + +<h3>Extract Field Definitions</h3> + + +The Shapefile DBF fields are defined based on the information available for +each of the subfields of the attribute records ATTR DDFField (the poATTR +data member). The following code loops over each of the subfields, +getting a pointer to the DDBSubfieldDefn containing information about that +subfield.<p> + +<pre> + DDFFieldDefn *poFDefn = poAttrFeature->poATTR->GetFieldDefn(); + int iSF; + DDFField *poSR = poAttrFeature->poATTR; + + for( iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ ) + { + DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF ); +</pre> + +Then each of the significant ISO8211 field types is translated to an +appropriate DBF field type. In cases where the nWidth field is zero, +indicating that the field is variable width, we use the length of the +field in the prototype record. Ideally we would scan the whole file to find +the longest value for each field, but that would be a significant amount of +work. <p> + +<pre> + int nWidth = poSFDefn->GetWidth(); + + switch( poSFDefn->GetType() ) + { + case DDFString: + if( nWidth == 0 ) + { + int nMaxBytes; + + const char * pachData = poSR->GetSubfieldData(poSFDefn, + &nMaxBytes); + + nWidth = strlen(poSFDefn->ExtractStringData(pachData, + nMaxBytes, NULL )); + } + + DBFAddField( hDBF, poSFDefn->GetName(), FTString, nWidth, 0 ); + break; + + case DDFInt: + if( nWidth == 0 ) + nWidth = 9; + + DBFAddField( hDBF, poSFDefn->GetName(), FTInteger, nWidth, 0 ); + break; + + case DDFFloat: + DBFAddField( hDBF, poSFDefn->GetName(), FTDouble, 18, 6 ); + break; + + default: + fprintf( stderr, + "Dropping attribute `%s' of module `%s'. " + "Type unsupported\n", + poSFDefn->GetName(), + papszModuleList[iModule] ); + break; + } + } +</pre> + +<h2>Reading Polygon Features</h2> + +With definition of the attribute schema out of the way, we return to the +main event, reading polygons from the polygon layer. We have already +instantiated the SDTSPolygonReader (poPolyReader), and now we loop reading +features from it. Note that we Rewind() the reader to ensure we are +starting at the beginning. After we are done process the polygon we +delete it, if and only if the layer does not have an index cache.<p> + +<pre> + SDTSRawPolygon *poRawPoly; + + poPolyReader->Rewind(); + while( (poRawPoly = (SDTSRawPolygon *) poPolyReader->GetNextFeature()) + != NULL ) + { + ... process and write polygon ... + + if( !poPolyReader->IsIndexed() ) + delete poRawPoly; + } +</pre> + +<h2>Translate Geometry</h2> + +In an earlier step we used the SDTSPolygonReader::AssembleRings() method to +build ring geometry on the polygons from the linework in the line layers.<p> + +Coincidently (well, ok, maybe it isn't a coincidence) it so happens that the +ring organization exactly matches what is needed for the shapefile api. +The following call creates a polygon from the ring information in the +SDTSRawPolygon. See the SDTSRawPolygon reference help for a fuller +definition of the nRings, panRingStart, nVertices, and vertex fields.<p> + +<pre> + psShape = SHPCreateObject( SHPT_POLYGON, -1, poRawPoly->nRings, + poRawPoly->panRingStart, NULL, + poRawPoly->nVertices, + poRawPoly->padfX, + poRawPoly->padfY, + poRawPoly->padfZ, + NULL ); +</pre> + +<h2>Write Record Number</h2> + +The following call is used to write out the record number of the polygon, +fetched from the SDTSIndexedFeature::oModId data member. The szModule value +in this data field will always match the module name for the whole layer. +While not shown here, there is also an szOBRP field on oModId which have +different values depending on whether the polygon is a universe or regular +polygon.<p> + +<pre> + DBFWriteIntegerAttribute( hDBF, iShape, nSDTSRecordField, + poRawPoly->oModId.nRecord ); +</pre> + +<h2>Fetch Associated User Records</h2> + +In keeping with the setting up of the schema, accessing the user records +is somewhat complicated. In sdts2shp, the primary attribute records associated +with any feature (including SDTSRawPolygons) can be fetched with the +WriteAttrRecordToDBF() function defined as follows.<p> + +In particular, the poFeature->nAttributes member indicates how many +associated attribute records there are. The poFeature->aoATID[] array +contains the SDTSModId's for each record. This SDTSModId can be passed +to SDTSTransfer::GetAttr() to fetch the DDFField pointer for the user +attributes. The WriteAttrRecordToDBF() method is specific to sdts2shp +and will be define later.<p> + +<pre> + int iAttrRecord; + + for( iAttrRecord = 0; iAttrRecord < poFeature->nAttributes; iAttrRecord++) + { + DDFField *poSR; + + poSR = poTransfer->GetAttr( poFeature->aoATID+iAttrRecord ); + + WriteAttrRecordToDBF( hDBF, iRecord, poTransfer, poSR ); + } +</pre> + +<h2>Write User Attributes</h2> + +In a manner analygous to the definition of the fields from the prototype +attribute record, the following code loops over the subfields, and fetches +the data for each. The data extraction via poSR->GetSubfieldData() is +a bit involved, and more information can be found on the DDFField reference +page.<p> + +<pre> +/* -------------------------------------------------------------------- */ +/* Process each subfield in the record. */ +/* -------------------------------------------------------------------- */ + DDFFieldDefn *poFDefn = poSR->GetFieldDefn(); + + for( int iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ ) + { + DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF ); + int iField; + int nMaxBytes; + const char * pachData = poSR->GetSubfieldData(poSFDefn, + &nMaxBytes); + +/* -------------------------------------------------------------------- */ +/* Identify the related DBF field, if any. */ +/* -------------------------------------------------------------------- */ + for( iField = 0; iField < hDBF->nFields; iField++ ) + { + if( EQUALN(poSFDefn->GetName(), + hDBF->pszHeader+iField*32,10) ) + break; + } + + if( iField == hDBF->nFields ) + iField = -1; + +/* -------------------------------------------------------------------- */ +/* Handle each of the types. */ +/* -------------------------------------------------------------------- */ + switch( poSFDefn->GetType() ) + { + case DDFString: + const char *pszValue; + + pszValue = poSFDefn->ExtractStringData(pachData, nMaxBytes, + NULL); + + if( iField != -1 ) + DBFWriteStringAttribute(hDBF, iRecord, iField, pszValue ); + break; + + case DDFFloat: + double dfValue; + + dfValue = poSFDefn->ExtractFloatData(pachData, nMaxBytes, + NULL); + + if( iField != -1 ) + DBFWriteDoubleAttribute( hDBF, iRecord, iField, dfValue ); + break; + + case DDFInt: + int nValue; + + nValue = poSFDefn->ExtractIntData(pachData, nMaxBytes, NULL); + + if( iField != -1 ) + DBFWriteIntegerAttribute( hDBF, iRecord, iField, nValue ); + break; + + default: + break; + } + } /* next subfield */ +</pre> + +<h2>Cleanup</h2> + +In the case of sdts2shp, the SDTSTransfer is created on the stack. When it +falls out of scope it is destroyed, and all the indexed readers, and their +indexed features caches are also cleaned up.<p> + +*/ + +/*! +\page sdts2shp.cpp +<center> +<title>SDTS To Shape Example Application</title> +</center> + +\include sdts2shp.cpp +*/ diff --git a/Utilities/GDAL/frmts/sdts/sdtsattrreader.cpp b/Utilities/GDAL/frmts/sdts/sdtsattrreader.cpp new file mode 100644 index 0000000000..d9fc13cd67 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsattrreader.cpp @@ -0,0 +1,262 @@ +/****************************************************************************** + * $Id: sdtsattrreader.cpp,v 1.12 2006/04/10 16:34:18 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSAttrReader class. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsattrreader.cpp,v $ + * Revision 1.12 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.11 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.10 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.9 1999/09/03 14:13:48 warmerda + * ensure DDFRecords are duplicated when needed + * + * Revision 1.8 1999/09/03 13:34:45 warmerda + * added duplicate flag on GetNextRecord + * + * Revision 1.7 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.6 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.5 1999/08/16 15:45:46 warmerda + * added IsSecondary() + * + * Revision 1.4 1999/08/16 13:58:30 warmerda + * added support for secondary attribute modules + * + * Revision 1.3 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.2 1999/03/23 15:59:40 warmerda + * implemented and working + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtsattrreader.cpp,v 1.12 2006/04/10 16:34:18 fwarmerdam Exp $"); + + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSAttrRecord */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSAttrRecord() */ +/************************************************************************/ + +SDTSAttrRecord::SDTSAttrRecord() + +{ + poWholeRecord = NULL; + poATTR = NULL; +} + +/************************************************************************/ +/* ~SDTSAttrRecord() */ +/************************************************************************/ + +SDTSAttrRecord::~SDTSAttrRecord() + +{ + if( poWholeRecord != NULL ) + delete poWholeRecord; +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void SDTSAttrRecord::Dump( FILE * fp ) + +{ + if( poATTR != NULL ) + poATTR->Dump( fp ); +} + + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSAttrReader */ +/* */ +/* This is the class used to read a primary attribute module. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSAttrReader() */ +/************************************************************************/ + +SDTSAttrReader::SDTSAttrReader( SDTS_IREF * poIREFIn ) + +{ + poIREF = poIREFIn; +} + +/************************************************************************/ +/* ~SDTSAttrReader() */ +/************************************************************************/ + +SDTSAttrReader::~SDTSAttrReader() +{ + Close(); +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSAttrReader::Close() + +{ + ClearIndex(); + oDDFModule.Close(); +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open the requested attr file, and prepare to start reading */ +/* data records. */ +/************************************************************************/ + +int SDTSAttrReader::Open( const char *pszFilename ) + +{ + int bSuccess; + + bSuccess = oDDFModule.Open( pszFilename ); + + if( bSuccess ) + bIsSecondary = (oDDFModule.FindFieldDefn("ATTS") != NULL); + + return bSuccess; +} + +/************************************************************************/ +/* GetNextRecord() */ +/************************************************************************/ + +DDFField *SDTSAttrReader::GetNextRecord( SDTSModId * poModId, + DDFRecord ** ppoRecord, + int bDuplicate ) + +{ + DDFRecord *poRecord; + DDFField *poATTP; + +/* -------------------------------------------------------------------- */ +/* Fetch a record. */ +/* -------------------------------------------------------------------- */ + if( ppoRecord != NULL ) + *ppoRecord = NULL; + + if( oDDFModule.GetFP() == NULL ) + return NULL; + + poRecord = oDDFModule.ReadRecord(); + + if( poRecord == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Make a copy of the record for persistent use if requested by */ +/* the caller. */ +/* -------------------------------------------------------------------- */ + if( bDuplicate ) + poRecord = poRecord->Clone(); + +/* -------------------------------------------------------------------- */ +/* Find the ATTP field. */ +/* -------------------------------------------------------------------- */ + poATTP = poRecord->FindField( "ATTP", 0 ); + if( poATTP == NULL ) + { + poATTP = poRecord->FindField( "ATTS", 0 ); + } + + if( poATTP == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Update the module ID if required. */ +/* -------------------------------------------------------------------- */ + if( poModId != NULL ) + { + DDFField *poATPR = poRecord->FindField( "ATPR" ); + + if( poATPR == NULL ) + poATPR = poRecord->FindField( "ATSC" ); + + if( poATPR != NULL ) + poModId->Set( poATPR ); + } + +/* -------------------------------------------------------------------- */ +/* return proper answer. */ +/* -------------------------------------------------------------------- */ + if( ppoRecord != NULL ) + *ppoRecord = poRecord; + + return poATTP; +} + +/************************************************************************/ +/* GetNextAttrRecord() */ +/************************************************************************/ + +SDTSAttrRecord *SDTSAttrReader::GetNextAttrRecord() + +{ + DDFRecord *poRawRecord; + DDFField *poATTRField; + SDTSModId oModId; + SDTSAttrRecord *poAttrRecord; + + poATTRField = GetNextRecord( &oModId, &poRawRecord, TRUE ); + + if( poATTRField == NULL ) + return NULL; + + poAttrRecord = new SDTSAttrRecord(); + + poAttrRecord->poWholeRecord = poRawRecord; + poAttrRecord->poATTR = poATTRField; + memcpy( &(poAttrRecord->oModId), &oModId, sizeof(SDTSModId) ); + + return poAttrRecord; +} + diff --git a/Utilities/GDAL/frmts/sdts/sdtscatd.cpp b/Utilities/GDAL/frmts/sdts/sdtscatd.cpp new file mode 100644 index 0000000000..1f7c4bc23a --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtscatd.cpp @@ -0,0 +1,374 @@ +/****************************************************************************** + * $Id: sdtscatd.cpp,v 1.16 2006/04/10 16:34:18 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTS_CATD and SDTS_CATDEntry classes for + * reading CATD files. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtscatd.cpp,v $ + * Revision 1.16 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.15 2006/02/24 15:57:11 fwarmerdam + * Added CATD open check to make sure this is a CATD file before reading + * any records. Mainly intended to avoid problems with ADRG files. + * + * Revision 1.14 2003/02/06 03:18:34 warmerda + * fixed memory leak of pszFullPath + * + * Revision 1.13 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.12 2001/02/24 01:54:52 warmerda + * use CPLFormCIFilename so case mixups in CATD filenames will be fixed up + * + * Revision 1.11 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.10 1999/12/23 14:17:58 warmerda + * Don't treat Lineage modules as being the same as Line modules. + * + * Revision 1.9 1999/11/30 21:44:33 warmerda + * Test for "Line" not "Line ". TYPE is not always padded, for instance + * coming out of Arc/Info's SDTSEXPORT command. + * + * Revision 1.8 1999/08/16 13:58:30 warmerda + * added support for secondary attribute modules + * + * Revision 1.7 1999/08/11 20:49:38 warmerda + * Initialize pszPrefixPath in case Open() isn't called. + * + * Revision 1.6 1999/06/03 14:03:01 warmerda + * Added raster layer support + * + * Revision 1.5 1999/05/11 14:08:26 warmerda + * added SLTPoly + * + * Revision 1.4 1999/05/11 12:55:17 warmerda + * added concept of entry types for vector layer identification + * + * Revision 1.3 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.2 1999/03/23 16:01:16 warmerda + * added storage of type and fetch methods + * + * Revision 1.1 1999/03/23 13:56:13 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtscatd.cpp,v 1.16 2006/04/10 16:34:18 fwarmerdam Exp $"); + + +/************************************************************************/ +/* ==================================================================== */ +/* SDTS_CATDEntry */ +/* */ +/* This class is for internal use of the SDTS_CATD class only, */ +/* and represents one entry in the directory ... a reference */ +/* to another module file. */ +/* ==================================================================== */ +/************************************************************************/ + +class SDTS_CATDEntry + +{ + public: + char * pszModule; + char * pszType; + char * pszFile; + char * pszExternalFlag; + + char * pszFullPath; +}; + +/************************************************************************/ +/* ==================================================================== */ +/* SDTS_CATD */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTS_CATD() */ +/************************************************************************/ + +SDTS_CATD::SDTS_CATD() + +{ + nEntries = 0; + papoEntries = NULL; + pszPrefixPath = NULL; +} + +/************************************************************************/ +/* ~SDTS_CATD() */ +/************************************************************************/ + +SDTS_CATD::~SDTS_CATD() +{ + int i; + + for( i = 0; i < nEntries; i++ ) + { + CPLFree( papoEntries[i]->pszModule ); + CPLFree( papoEntries[i]->pszType ); + CPLFree( papoEntries[i]->pszFile ); + CPLFree( papoEntries[i]->pszExternalFlag ); + CPLFree( papoEntries[i]->pszFullPath ); + delete papoEntries[i]; + } + + CPLFree( papoEntries ); + CPLFree( pszPrefixPath ); +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read the named file to initialize this structure. */ +/************************************************************************/ + +int SDTS_CATD::Read( const char * pszFilename ) + +{ + DDFModule oCATDFile; + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Open the file. */ +/* -------------------------------------------------------------------- */ + if( !oCATDFile.Open( pszFilename ) ) + return FALSE; + + CPLErrorReset(); // clear any ADRG "unrecognised data_struct_code" errors + +/* -------------------------------------------------------------------- */ +/* Does this file have a CATD field? If not, it isn't an SDTS */ +/* record and we won't even try reading the first record for */ +/* fear it will we a huge honking ADRG data record or something. */ +/* -------------------------------------------------------------------- */ + if( oCATDFile.FindFieldDefn( "CATD" ) == NULL ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Strip off the filename, and keep the path prefix. */ +/* -------------------------------------------------------------------- */ + int i; + + pszPrefixPath = CPLStrdup( pszFilename ); + for( i = strlen(pszPrefixPath)-1; i > 0; i-- ) + { + if( pszPrefixPath[i] == '\\' || pszPrefixPath[i] == '/' ) + { + pszPrefixPath[i] = '\0'; + break; + } + } + + if( i <= 0 ) + { + strcpy( pszPrefixPath, "." ); + } + +/* ==================================================================== */ +/* Loop reading CATD records, and adding to our list of entries */ +/* for each. */ +/* ==================================================================== */ + while( (poRecord = oCATDFile.ReadRecord()) != NULL ) + { +/* -------------------------------------------------------------------- */ +/* Verify that we have a proper CATD record. */ +/* -------------------------------------------------------------------- */ + if( poRecord->GetStringSubfield( "CATD", 0, "MODN", 0 ) == NULL ) + continue; + +/* -------------------------------------------------------------------- */ +/* Create a new entry, and get the module and file name. */ +/* -------------------------------------------------------------------- */ + SDTS_CATDEntry *poEntry = new SDTS_CATDEntry; + + poEntry->pszModule = + CPLStrdup(poRecord->GetStringSubfield( "CATD", 0, "NAME", 0 )); + poEntry->pszFile = + CPLStrdup(poRecord->GetStringSubfield( "CATD", 0, "FILE", 0 )); + poEntry->pszExternalFlag = + CPLStrdup(poRecord->GetStringSubfield( "CATD", 0, "EXTR", 0 )); + poEntry->pszType = + CPLStrdup(poRecord->GetStringSubfield( "CATD", 0, "TYPE", 0 )); + +/* -------------------------------------------------------------------- */ +/* Create a full path to the file. */ +/* -------------------------------------------------------------------- */ + poEntry->pszFullPath = + CPLStrdup(CPLFormCIFilename( pszPrefixPath, poEntry->pszFile, + NULL )); + +/* -------------------------------------------------------------------- */ +/* Add the entry to the list. */ +/* -------------------------------------------------------------------- */ + papoEntries = (SDTS_CATDEntry **) + CPLRealloc(papoEntries, sizeof(void*) * ++nEntries ); + papoEntries[nEntries-1] = poEntry; + } + + return nEntries > 0; +} + + +/************************************************************************/ +/* GetModuleFilePath() */ +/************************************************************************/ + +const char * SDTS_CATD::GetModuleFilePath( const char * pszModule ) + +{ + int i; + + for( i = 0; i < nEntries; i++ ) + { + if( EQUAL(papoEntries[i]->pszModule,pszModule) ) + return papoEntries[i]->pszFullPath; + } + + return NULL; +} + +/************************************************************************/ +/* GetEntryModule() */ +/************************************************************************/ + +const char * SDTS_CATD::GetEntryModule( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nEntries ) + return NULL; + else + return papoEntries[iEntry]->pszModule; +} + +/************************************************************************/ +/* GetEntryTypeDesc() */ +/************************************************************************/ + +/** + * Fetch the type description of a module in the catalog. + * + * @param iEntry The module index within the CATD catalog. A number from + * zero to GetEntryCount()-1. + * + * @return A pointer to an internal string with the type description for + * this module. This is from the CATD file (subfield TYPE of field CATD), + * and will be something like "Attribute Primary ". + */ + +const char * SDTS_CATD::GetEntryTypeDesc( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nEntries ) + return NULL; + else + return papoEntries[iEntry]->pszType; +} + +/************************************************************************/ +/* GetEntryType() */ +/************************************************************************/ + +/** + * Fetch the enumerated type of a module in the catalog. + * + * @param iEntry The module index within the CATD catalog. A number from + * zero to GetEntryCount()-1. + * + * @return A value from the SDTSLayerType enumeration indicating the type of + * the module, and indicating the corresponding type of reader.<p> + * + * <ul> + * <li> SLTPoint: Read with SDTSPointReader, underlying type of + * <tt>Point-Node</tt>. + * <li> SLTLine: Read with SDTSLineReader, underlying type of + * <tt>Line</tt>. + * <li> SLTAttr: Read with SDTSAttrReader, underlying type of + * <tt>Attribute Primary</tt> or <tt>Attribute Secondary</tt>. + * <li> SLTPolygon: Read with SDTSPolygonReader, underlying type of + * <tt>Polygon</tt>. + * </ul> + */ + +SDTSLayerType SDTS_CATD::GetEntryType( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nEntries ) + return SLTUnknown; + + else if( EQUALN(papoEntries[iEntry]->pszType,"Attribute Primary",17) ) + return SLTAttr; + + else if( EQUALN(papoEntries[iEntry]->pszType,"Attribute Secondary",17) ) + return SLTAttr; + + else if( EQUAL(papoEntries[iEntry]->pszType,"Line") + || EQUALN(papoEntries[iEntry]->pszType,"Line ",5) ) + return SLTLine; + + else if( EQUALN(papoEntries[iEntry]->pszType,"Point-Node",10) ) + return SLTPoint; + + else if( EQUALN(papoEntries[iEntry]->pszType,"Polygon",7) ) + return SLTPoly; + + else if( EQUALN(papoEntries[iEntry]->pszType,"Cell",4) ) + return SLTRaster; + + else + return SLTUnknown; +} + +/************************************************************************/ +/* GetEntryFilePath() */ +/************************************************************************/ + +/** + * Fetch the full filename of the requested module. + * + * @param iEntry The module index within the CATD catalog. A number from + * zero to GetEntryCount()-1. + * + * @return A pointer to an internal string containing the filename. This + * string should not be altered, or freed by the application. + */ + +const char * SDTS_CATD::GetEntryFilePath( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nEntries ) + return NULL; + else + return papoEntries[iEntry]->pszFullPath; +} diff --git a/Utilities/GDAL/frmts/sdts/sdtsdataset.cpp b/Utilities/GDAL/frmts/sdts/sdtsdataset.cpp new file mode 100644 index 0000000000..4a02b8b7a5 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsdataset.cpp @@ -0,0 +1,413 @@ +/****************************************************************************** + * $Id: sdtsdataset.cpp,v 1.17 2006/04/10 16:34:18 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: GDALDataset driver for SDTS Raster translator. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsdataset.cpp,v $ + * Revision 1.17 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.16 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.15 2003/02/06 03:18:49 warmerda + * use Fixup() on SRS to set linear units + * + * Revision 1.14 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.13 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.12 2002/04/12 20:20:29 warmerda + * make vector sdts transfers just a warning + * + * Revision 1.11 2001/11/11 23:51:00 warmerda + * added required class keyword to friend declarations + * + * Revision 1.10 2001/09/10 19:27:36 warmerda + * added GetMinMax() and raster data types + * + * Revision 1.9 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.8 2001/07/09 18:14:45 warmerda + * upgraded projection support to use WKT + * + * Revision 1.7 2001/07/05 13:12:40 warmerda + * added UnitType support + * + * Revision 1.6 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.5 2000/08/22 17:58:04 warmerda + * added floating point, and nodata support + * + * Revision 1.4 2000/08/15 19:28:26 warmerda + * added help topic + * + * Revision 1.3 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.2 1999/06/03 21:14:01 warmerda + * added GetGeoTransform() and GetProjectionRef() support + * + * Revision 1.1 1999/06/03 13:46:07 warmerda + * New + * + */ + +#include "sdts_al.h" +#include "gdal_pam.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: sdtsdataset.cpp,v 1.17 2006/04/10 16:34:18 fwarmerdam Exp $"); + +/** + \file sdtsdataset.cpp + + exclude +*/ + +CPL_C_START +void GDALRegister_SDTS(void); +CPL_C_END + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class SDTSRasterBand; + +class SDTSDataset : public GDALPamDataset +{ + friend class SDTSRasterBand; + + SDTSTransfer *poTransfer; + SDTSRasterReader *poRL; + + char *pszProjection; + + public: + virtual ~SDTSDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + + virtual const char *GetProjectionRef(void); + virtual CPLErr GetGeoTransform( double * ); +}; + +class SDTSRasterBand : public GDALPamRasterBand +{ + friend class SDTSDataset; + + SDTSRasterReader *poRL; + + public: + + SDTSRasterBand( SDTSDataset *, int, SDTSRasterReader * ); + + virtual CPLErr IReadBlock( int, int, void * ); + + virtual double GetNoDataValue( int *pbSuccess ); + virtual const char *GetUnitType(); +}; + + +/************************************************************************/ +/* ~SDTSDataset() */ +/************************************************************************/ + +SDTSDataset::~SDTSDataset() + +{ + FlushCache(); + + if( poTransfer != NULL ) + delete poTransfer; + + if( poRL != NULL ) + delete poRL; + + if( pszProjection != NULL ) + CPLFree( pszProjection ); +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *SDTSDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + int i; + +/* -------------------------------------------------------------------- */ +/* Before trying SDTSOpen() we first verify that the first */ +/* record is in fact a SDTS file descriptor record. */ +/* -------------------------------------------------------------------- */ + char *pachLeader = (char *) poOpenInfo->pabyHeader; + + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 24 ) + return NULL; + + if( pachLeader[5] != '1' && pachLeader[5] != '2' && pachLeader[5] != '3' ) + return NULL; + + if( pachLeader[6] != 'L' ) + return NULL; + + if( pachLeader[8] != '1' && pachLeader[8] != ' ' ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Try opening the dataset. */ +/* -------------------------------------------------------------------- */ + SDTSTransfer *poTransfer = new SDTSTransfer; + + if( !poTransfer->Open( poOpenInfo->pszFilename ) ) + { + delete poTransfer; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Find the first raster layer. If there are none, abort */ +/* returning an error. */ +/* -------------------------------------------------------------------- */ + SDTSRasterReader *poRL = NULL; + + for( i = 0; i < poTransfer->GetLayerCount(); i++ ) + { + if( poTransfer->GetLayerType( i ) == SLTRaster ) + { + poRL = poTransfer->GetLayerRasterReader( i ); + break; + } + } + + if( poRL == NULL ) + { + delete poTransfer; + + CPLError( CE_Warning, CPLE_AppDefined, + "%s is an SDTS transfer, but has no raster cell layers.\n" + "Perhaps it is a vector transfer?\n", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Initialize a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + SDTSDataset *poDS = new SDTSDataset(); + + poDS->poTransfer = poTransfer; + poDS->poRL = poRL; + +/* -------------------------------------------------------------------- */ +/* Capture some information from the file that is of interest. */ +/* -------------------------------------------------------------------- */ + poDS->nRasterXSize = poRL->GetXSize(); + poDS->nRasterYSize = poRL->GetYSize(); + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->nBands = 1; + poDS->papoBands = (GDALRasterBand **) + VSICalloc(sizeof(GDALRasterBand *),poDS->nBands); + + for( i = 0; i < poDS->nBands; i++ ) + poDS->SetBand( i+1, new SDTSRasterBand( poDS, i+1, poRL ) ); + +/* -------------------------------------------------------------------- */ +/* Try to establish the projection string. For now we only */ +/* support UTM and GEO. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS; + SDTS_XREF *poXREF = poTransfer->GetXREF(); + + if( EQUAL(poXREF->pszSystemName,"UTM") ) + { + oSRS.SetUTM( poXREF->nZone ); + } + else if( EQUAL(poXREF->pszSystemName,"GEO") ) + { + /* we set datum later */ + } + else + oSRS.SetLocalCS( poXREF->pszSystemName ); + + if( oSRS.IsLocal() ) + /* don't try to set datum. */; + else if( EQUAL(poXREF->pszDatum,"NAS") ) + oSRS.SetWellKnownGeogCS( "NAD27" ); + else if( EQUAL(poXREF->pszDatum, "NAX") ) + oSRS.SetWellKnownGeogCS( "NAD83" ); + else if( EQUAL(poXREF->pszDatum, "WGC") ) + oSRS.SetWellKnownGeogCS( "WGS72" ); + else if( EQUAL(poXREF->pszDatum, "WGE") ) + oSRS.SetWellKnownGeogCS( "WGS84" ); + else + oSRS.SetWellKnownGeogCS( "WGS84" ); + + oSRS.Fixup(); + + poDS->pszProjection = NULL; + if( oSRS.exportToWkt( &poDS->pszProjection ) != OGRERR_NONE ) + poDS->pszProjection = CPLStrdup(""); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr SDTSDataset::GetGeoTransform( double * padfTransform ) + +{ + if( poRL->GetTransform( padfTransform ) ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *SDTSDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSRasterBand() */ +/************************************************************************/ + +SDTSRasterBand::SDTSRasterBand( SDTSDataset *poDS, int nBand, + SDTSRasterReader * poRL ) + +{ + this->poDS = poDS; + this->nBand = nBand; + this->poRL = poRL; + + if( poRL->GetRasterType() == SDTS_RT_INT16 ) + eDataType = GDT_Int16; + else + eDataType = GDT_Float32; + + nBlockXSize = poRL->GetBlockXSize(); + nBlockYSize = poRL->GetBlockYSize(); +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr SDTSRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + if( poRL->GetBlock( nBlockXOff, nBlockYOff, pImage ) ) + return CE_None; + else + return CE_Failure; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double SDTSRasterBand::GetNoDataValue( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + + return -32766.0; +} + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ + +const char *SDTSRasterBand::GetUnitType() + +{ + if( EQUAL(poRL->szUNITS,"FEET") ) + return "ft"; + else if( EQUALN(poRL->szUNITS,"MET",3) ) + return "m"; + else + return poRL->szUNITS; +} + +/************************************************************************/ +/* GDALRegister_SDTS() */ +/************************************************************************/ + +void GDALRegister_SDTS() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "SDTS" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "SDTS" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "SDTS Raster" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_various.html#SDTS" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "ddf" ); + + poDriver->pfnOpen = SDTSDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} + diff --git a/Utilities/GDAL/frmts/sdts/sdtsindexedreader.cpp b/Utilities/GDAL/frmts/sdts/sdtsindexedreader.cpp new file mode 100644 index 0000000000..f4adabf477 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsindexedreader.cpp @@ -0,0 +1,291 @@ +/****************************************************************************** + * $Id: sdtsindexedreader.cpp,v 1.6 2006/04/10 16:34:18 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implmementation of SDTSIndexedReader class. This base class for + * various reader classes provides indexed caching of features for + * quick fetching when assembling composite features for other + * readers. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsindexedreader.cpp,v $ + * Revision 1.6 2006/04/10 16:34:18 fwarmerdam + * updated contact info + * + * Revision 1.5 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.4 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.3 1999/09/07 00:42:42 warmerda + * Grow index based on iRecordId rather than previous index max in + * FillIndex(). + * + * Revision 1.2 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.1 1999/09/02 03:39:40 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtsindexedreader.cpp,v 1.6 2006/04/10 16:34:18 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTSIndexedReader() */ +/************************************************************************/ + +SDTSIndexedReader::SDTSIndexedReader() + +{ + nIndexSize = 0; + papoFeatures = NULL; + iCurrentFeature = 0; +} + +/************************************************************************/ +/* ~SDTSIndexedReader() */ +/************************************************************************/ + +SDTSIndexedReader::~SDTSIndexedReader() + +{ + ClearIndex(); +} + +/************************************************************************/ +/* IsIndexed() */ +/************************************************************************/ + +/** + Returns TRUE if the module is indexed, otherwise it returns FALSE. + + If the module is indexed all the feature have already been read into + memory, and searches based on the record number can be performed + efficiently. + */ + +int SDTSIndexedReader::IsIndexed() + +{ + return nIndexSize != 0; +} + +/************************************************************************/ +/* ClearIndex() */ +/************************************************************************/ + +/** + Free all features in the index (if filled). + + After this the reader is considered to not be indexed, and IsIndexed() + will return FALSE untill the index is forcably filled again. + */ + +void SDTSIndexedReader::ClearIndex() + +{ + for( int i = 0; i < nIndexSize; i++ ) + { + if( papoFeatures[i] != NULL ) + delete papoFeatures[i]; + } + + CPLFree( papoFeatures ); + + papoFeatures = NULL; + nIndexSize = 0; +} + +/************************************************************************/ +/* GetNextFeature() */ +/************************************************************************/ + +/** + Fetch the next available feature from this reader. + + The returned SDTSFeature * is to an internal indexed object if the + IsIndexed() method returns TRUE, otherwise the returned feature becomes the + responsibility of the caller to destroy with delete. + + Note that the Rewind() method can be used to start over at the beginning of + the modules feature list. + + @return next feature, or NULL if no more are left. Please review above + ownership/delete semantics. + + */ + +SDTSFeature *SDTSIndexedReader::GetNextFeature() + +{ + if( nIndexSize == 0 ) + return GetNextRawFeature(); + else + { + while( iCurrentFeature < nIndexSize ) + { + if( papoFeatures[iCurrentFeature] != NULL ) + return papoFeatures[iCurrentFeature++]; + else + iCurrentFeature++; + } + + return NULL; + } +} + +/************************************************************************/ +/* GetIndexedFeatureRef() */ +/************************************************************************/ + +/** + Fetch a feature based on it's record number. + + This method will forceably fill the feature cache, reading all the + features in the file into memory, if they haven't already been loaded. + The ClearIndex() method can be used to flush this cache when no longer + needed. + + @param iRecordId the record to fetch, normally based on the nRecord + field of an SDTSModId. + + @return a pointer to an internal feature (not to be deleted) or NULL + if there is no matching feature. +*/ + +SDTSFeature *SDTSIndexedReader::GetIndexedFeatureRef( int iRecordId ) + +{ + if( nIndexSize == 0 ) + FillIndex(); + + if( iRecordId < 0 || iRecordId >= nIndexSize ) + return NULL; + else + return papoFeatures[iRecordId]; +} + +/************************************************************************/ +/* FillIndex() */ +/************************************************************************/ + +/** + Read all features into a memory indexed cached. + + The ClearIndex() method can be used to free all indexed features. + FillIndex() does nothing, if an index has already been built. +*/ + +void SDTSIndexedReader::FillIndex() + +{ + SDTSFeature *poFeature; + + if( nIndexSize != 0 ) + return; + + Rewind(); + + while( (poFeature = GetNextRawFeature()) != NULL ) + { + int iRecordId = poFeature->oModId.nRecord; + + CPLAssert( iRecordId < 1000000 ); + if( iRecordId >= 1000000 ) + { + delete poFeature; + continue; + } + + if( iRecordId >= nIndexSize ) + { + int nNewSize = (int) (iRecordId * 1.25 + 100); + + papoFeatures = (SDTSFeature **) + CPLRealloc( papoFeatures, sizeof(void*) * nNewSize); + + for( int i = nIndexSize; i < nNewSize; i++ ) + papoFeatures[i] = NULL; + + nIndexSize = nNewSize; + } + + CPLAssert( papoFeatures[iRecordId] == NULL ); + papoFeatures[iRecordId] = poFeature; + } +} + +/************************************************************************/ +/* ScanModuleReferences() */ +/************************************************************************/ + +/** + Scan an entire SDTS module for record references with the given field + name. + + The fields are required to have a MODN subfield from which the + module is extracted. + + This method is normally used to find all the attribute modules referred + to by a point, line or polygon module to build a unified schema. + + This method will have the side effect of rewinding unindexed readers + because the scanning operation requires reading all records in the module + from disk. + + @param pszFName the field name to search for. By default "ATID" is + used. + + @return a NULL terminated list of module names. Free with CSLDestroy(). +*/ + +char ** SDTSIndexedReader::ScanModuleReferences( const char * pszFName ) + +{ + return SDTSScanModuleReferences( &oDDFModule, pszFName ); +} + +/************************************************************************/ +/* Rewind() */ +/************************************************************************/ + +/** + Rewind so that the next feature returned by GetNextFeature() will be the + first in the module. + +*/ + +void SDTSIndexedReader::Rewind() + +{ + if( nIndexSize != 0 ) + iCurrentFeature = 0; + else + oDDFModule.Rewind(); +} diff --git a/Utilities/GDAL/frmts/sdts/sdtsiref.cpp b/Utilities/GDAL/frmts/sdts/sdtsiref.cpp new file mode 100644 index 0000000000..ff214b8338 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsiref.cpp @@ -0,0 +1,312 @@ +/****************************************************************************** + * $Id: sdtsiref.cpp,v 1.7 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTS_IREF class for reading IREF module. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsiref.cpp,v $ + * Revision 1.7 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.6 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.5 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.4 1999/09/21 17:26:31 warmerda + * generalized SADR reading + * + * Revision 1.3 1999/06/03 14:03:34 warmerda + * Added offset/res info from iref + * + * Revision 1.2 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.1 1999/03/23 13:56:13 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtsiref.cpp,v 1.7 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTS_IREF() */ +/************************************************************************/ + +SDTS_IREF::SDTS_IREF() + +{ + dfXScale = 1.0; + dfYScale = 1.0; + dfXOffset = 0.0; + dfYOffset = 0.0; + dfXRes = 1.0; + dfYRes = 1.0; + + pszXAxisName = CPLStrdup(""); + pszYAxisName = CPLStrdup(""); + pszCoordinateFormat = CPLStrdup(""); +} + +/************************************************************************/ +/* ~SDTS_IREF() */ +/************************************************************************/ + +SDTS_IREF::~SDTS_IREF() +{ + CPLFree( pszXAxisName ); + CPLFree( pszYAxisName ); + CPLFree( pszCoordinateFormat ); +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read the named file to initialize this structure. */ +/************************************************************************/ + +int SDTS_IREF::Read( const char * pszFilename ) + +{ + DDFModule oIREFFile; + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Open the file, and read the header. */ +/* -------------------------------------------------------------------- */ + if( !oIREFFile.Open( pszFilename ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read the first record, and verify that this is an IREF record. */ +/* -------------------------------------------------------------------- */ + poRecord = oIREFFile.ReadRecord(); + if( poRecord == NULL ) + return FALSE; + + if( poRecord->GetStringSubfield( "IREF", 0, "MODN", 0 ) == NULL ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Get the labels. */ +/* -------------------------------------------------------------------- */ + CPLFree( pszXAxisName ); + pszXAxisName = CPLStrdup( poRecord->GetStringSubfield( "IREF", 0, + "XLBL", 0 ) ); + CPLFree( pszYAxisName ); + pszYAxisName = CPLStrdup( poRecord->GetStringSubfield( "IREF", 0, + "YLBL", 0 ) ); + +/* -------------------------------------------------------------------- */ +/* Get the coordinate encoding. */ +/* -------------------------------------------------------------------- */ + CPLFree( pszCoordinateFormat ); + pszCoordinateFormat = + CPLStrdup( poRecord->GetStringSubfield( "IREF", 0, "HFMT", 0 ) ); + +/* -------------------------------------------------------------------- */ +/* Get the transformation information, and resolution. */ +/* -------------------------------------------------------------------- */ + dfXScale = poRecord->GetFloatSubfield( "IREF", 0, "SFAX", 0 ); + dfYScale = poRecord->GetFloatSubfield( "IREF", 0, "SFAY", 0 ); + + dfXOffset = poRecord->GetFloatSubfield( "IREF", 0, "XORG", 0 ); + dfYOffset = poRecord->GetFloatSubfield( "IREF", 0, "YORG", 0 ); + + dfXRes = poRecord->GetFloatSubfield( "IREF", 0, "XHRS", 0 ); + dfYRes = poRecord->GetFloatSubfield( "IREF", 0, "YHRS", 0 ); + + nDefaultSADRFormat = EQUAL(pszCoordinateFormat,"BI32"); + + return TRUE; +} + +/************************************************************************/ +/* GetSADRCount() */ +/* */ +/* Return the number of SADR'es in the passed field. */ +/************************************************************************/ + +int SDTS_IREF::GetSADRCount( DDFField * poField ) + +{ + if( nDefaultSADRFormat ) + return poField->GetDataSize() / SDTS_SIZEOF_SADR; + else + return poField->GetRepeatCount(); +} + +/************************************************************************/ +/* GetSADR() */ +/************************************************************************/ + +int SDTS_IREF::GetSADR( DDFField * poField, int nVertices, + double *padfX, double * padfY, double * padfZ ) + +{ +/* -------------------------------------------------------------------- */ +/* For the sake of efficiency we depend on our knowledge that */ +/* the SADR field is a series of bigendian int32's and decode */ +/* them directly. */ +/* -------------------------------------------------------------------- */ + if( nDefaultSADRFormat + && poField->GetFieldDefn()->GetSubfieldCount() == 2 ) + { + GInt32 anXY[2]; + const char *pachRawData = poField->GetData(); + + CPLAssert( poField->GetDataSize() >= nVertices * SDTS_SIZEOF_SADR ); + + for( int iVertex = 0; iVertex < nVertices; iVertex++ ) + { + // we copy to a temp buffer to ensure it is world aligned. + memcpy( anXY, pachRawData, 8 ); + pachRawData += 8; + + // possibly byte swap, and always apply scale factor + padfX[iVertex] = dfXOffset + + dfXScale * ((int) CPL_MSBWORD32( anXY[0] )); + padfY[iVertex] = dfYOffset + + dfYScale * ((int) CPL_MSBWORD32( anXY[1] )); + + padfZ[iVertex] = 0.0; + } + } + +/* -------------------------------------------------------------------- */ +/* This is the generic case. We assume either two or three */ +/* subfields, and treat these as X, Y and Z regardless of */ +/* name. */ +/* -------------------------------------------------------------------- */ + else + { + DDFFieldDefn *poFieldDefn = poField->GetFieldDefn(); + int nBytesRemaining = poField->GetDataSize(); + const char *pachFieldData = poField->GetData(); + int iVertex; + + CPLAssert( poFieldDefn->GetSubfieldCount() == 2 + || poFieldDefn->GetSubfieldCount() == 3 ); + + for( iVertex = 0; iVertex < nVertices; iVertex++ ) + { + double adfXYZ[3]; + GByte *pabyBString; + + adfXYZ[2] = 0.0; + + for( int iEntry = 0; + iEntry < poFieldDefn->GetSubfieldCount(); + iEntry++ ) + { + int nBytesConsumed; + DDFSubfieldDefn *poSF = poFieldDefn->GetSubfield(iEntry); + + switch( poSF->GetType() ) + { + case DDFInt: + adfXYZ[iEntry] = + poSF->ExtractIntData( pachFieldData, + nBytesRemaining, + &nBytesConsumed ); + break; + + case DDFFloat: + adfXYZ[iEntry] = + poSF->ExtractFloatData( pachFieldData, + nBytesRemaining, + &nBytesConsumed ); + break; + + case DDFBinaryString: + pabyBString = (GByte *) + poSF->ExtractStringData( pachFieldData, + nBytesRemaining, + &nBytesConsumed ); + + if( EQUAL(pszCoordinateFormat,"BI32") ) + { + GInt32 nValue; + memcpy( &nValue, pabyBString, 4 ); + adfXYZ[iEntry] = ((int) CPL_MSBWORD32( nValue )); + } + else if( EQUAL(pszCoordinateFormat,"BI16") ) + { + GInt16 nValue; + memcpy( &nValue, pabyBString, 2 ); + adfXYZ[iEntry] = ((int) CPL_MSBWORD16( nValue )); + } + else if( EQUAL(pszCoordinateFormat,"BU32") ) + { + GUInt32 nValue; + memcpy( &nValue, pabyBString, 4 ); + adfXYZ[iEntry] = ((GUInt32) CPL_MSBWORD32( nValue )); + } + else if( EQUAL(pszCoordinateFormat,"BU16") ) + { + GUInt16 nValue; + memcpy( &nValue, pabyBString, 2 ); + adfXYZ[iEntry] = ((GUInt16) CPL_MSBWORD16( nValue )); + } + else if( EQUAL(pszCoordinateFormat,"BFP32") ) + { + float fValue; + + memcpy( &fValue, pabyBString, 4 ); + CPL_MSBPTR32( &fValue ); + adfXYZ[iEntry] = fValue; + } + else if( EQUAL(pszCoordinateFormat,"BFP64") ) + { + double dfValue; + + memcpy( &dfValue, pabyBString, 8 ); + CPL_MSBPTR64( &dfValue ); + adfXYZ[iEntry] = dfValue; + } + break; + + default: + adfXYZ[iEntry] = 0.0; + break; + } + + pachFieldData += nBytesConsumed; + nBytesRemaining -= nBytesConsumed; + } /* next iEntry */ + + padfX[iVertex] = dfXOffset + adfXYZ[0] * dfXScale; + padfY[iVertex] = dfYOffset + adfXYZ[1] * dfYScale; + padfZ[iVertex] = adfXYZ[2]; + } /* next iVertex */ + } + + return TRUE; +} + diff --git a/Utilities/GDAL/frmts/sdts/sdtslib.cpp b/Utilities/GDAL/frmts/sdts/sdtslib.cpp new file mode 100644 index 0000000000..42dfeeca94 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtslib.cpp @@ -0,0 +1,290 @@ +/****************************************************************************** + * $Id: sdtslib.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Various utility functions that apply to all SDTS profiles. + * SDTSModId, and SDTSFeature methods. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtslib.cpp,v $ + * Revision 1.14 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.13 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.12 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.11 2000/04/14 15:00:53 warmerda + * Ensure that SDTSModId extraction works for variable sized MODN + * + * Revision 1.10 1999/11/04 22:52:52 warmerda + * added dynamic ATID support + * + * Revision 1.9 1999/09/21 17:26:31 warmerda + * generalized SADR reading + * + * Revision 1.8 1999/09/12 23:42:23 warmerda + * treat coords as signed + * + * Revision 1.7 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.6 1999/08/16 20:59:50 warmerda + * added szOBRP support for SDTSModId + * + * Revision 1.5 1999/08/10 02:52:13 warmerda + * introduce use of SDTSApplyModIdList to capture multi-attributes + * + * Revision 1.4 1999/07/30 19:15:56 warmerda + * added module reference counting + * + * Revision 1.3 1999/05/11 12:55:54 warmerda + * added GetName() method to SDTSModId + * + * Revision 1.2 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.1 1999/03/23 13:56:13 warmerda + * New + * + */ + +#include "sdts_al.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: sdtslib.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTSFeature() */ +/************************************************************************/ + +SDTSFeature::SDTSFeature() + +{ + nAttributes = 0; + paoATID = NULL; +} + +/************************************************************************/ +/* SDTSFeature::ApplyATID() */ +/************************************************************************/ + +void SDTSFeature::ApplyATID( DDFField * poField ) + +{ + int nRepeatCount = poField->GetRepeatCount(); + int bUsualFormat; + DDFSubfieldDefn *poMODN; + + poMODN = poField->GetFieldDefn()->FindSubfieldDefn( "MODN" ); + if( poMODN == NULL ) + { + CPLAssert( FALSE ); + return; + } + + bUsualFormat = poMODN->GetWidth() == 4; + for( int iRepeat = 0; iRepeat < nRepeatCount; iRepeat++ ) + { + paoATID = (SDTSModId *) CPLRealloc(paoATID, + sizeof(SDTSModId)*(nAttributes+1)); + + const char * pabyData; + SDTSModId *poModId = paoATID + nAttributes; + + if( bUsualFormat ) + { + pabyData = poField->GetSubfieldData( poMODN, NULL, iRepeat ); + + memcpy( poModId->szModule, pabyData, 4 ); + poModId->szModule[4] = '\0'; + poModId->nRecord = atoi(pabyData + 4); + poModId->szOBRP[0] = '\0'; + } + else + { + poModId->Set( poField ); + } + + nAttributes++; + } +} + +/************************************************************************/ +/* ~SDTSFeature() */ +/************************************************************************/ + +SDTSFeature::~SDTSFeature() + +{ + CPLFree( paoATID ); + paoATID = NULL; +} + +/************************************************************************/ +/* SDTSModId::Set() */ +/* */ +/* Set a module from a field. We depend on our pre-knowledge */ +/* of the data layout to fetch more efficiently. */ +/************************************************************************/ + +int SDTSModId::Set( DDFField *poField ) + +{ + const char *pachData = poField->GetData(); + DDFFieldDefn *poDefn = poField->GetFieldDefn(); + + if( poDefn->GetSubfieldCount() >= 2 + && poDefn->GetSubfield(0)->GetWidth() == 4 ) + { + memcpy( szModule, pachData, 4 ); + szModule[4] = '\0'; + + nRecord = atoi( pachData + 4 ); + } + else + { + DDFSubfieldDefn *poSF; + int nBytesRemaining; + const char *pachData; + + szModule[4] = '\0'; + poSF = poField->GetFieldDefn()->FindSubfieldDefn( "MODN" ); + pachData = poField->GetSubfieldData(poSF, &nBytesRemaining); + strncpy( szModule, + poSF->ExtractStringData( pachData, nBytesRemaining, NULL), + sizeof(szModule) ); + + poSF = poField->GetFieldDefn()->FindSubfieldDefn( "RCID" ); + pachData = poField->GetSubfieldData(poSF, &nBytesRemaining); + nRecord = poSF->ExtractIntData( pachData, nBytesRemaining, NULL); + } + + if( poDefn->GetSubfieldCount() == 3 ) + { + DDFSubfieldDefn *poSF; + + poSF = poField->GetFieldDefn()->FindSubfieldDefn( "OBRP" ); + if( poSF != NULL ) + { + int nBytesRemaining; + const char *pachData; + + pachData = poField->GetSubfieldData(poSF, &nBytesRemaining); + strncpy( szOBRP, + poSF->ExtractStringData( pachData, nBytesRemaining, NULL), + sizeof(szOBRP) ); + + szOBRP[sizeof(szOBRP)-1] = '\0'; + } + } + + return FALSE; +} + +/************************************************************************/ +/* SDTSModId::GetName() */ +/************************************************************************/ + +const char * SDTSModId::GetName() + +{ + static char szName[20]; + + sprintf( szName, "%s:%ld", szModule, nRecord ); + + return szName; +} + +/************************************************************************/ +/* SDTSScanModuleReferences() */ +/* */ +/* Find all modules references by records in this module based */ +/* on a particular field name. That field must be in module */ +/* reference form (contain MODN/RCID subfields). */ +/************************************************************************/ + +char **SDTSScanModuleReferences( DDFModule * poModule, const char * pszFName ) + +{ +/* -------------------------------------------------------------------- */ +/* Identify the field, and subfield we are interested in. */ +/* -------------------------------------------------------------------- */ + DDFFieldDefn *poIDField; + DDFSubfieldDefn *poMODN; + + poIDField = poModule->FindFieldDefn( pszFName ); + + if( poIDField == NULL ) + return NULL; + + poMODN = poIDField->FindSubfieldDefn( "MODN" ); + if( poMODN == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Scan the file. */ +/* -------------------------------------------------------------------- */ + DDFRecord *poRecord; + char **papszModnList = NULL; + + poModule->Rewind(); + while( (poRecord = poModule->ReadRecord()) != NULL ) + { + int iField; + + for( iField = 0; iField < poRecord->GetFieldCount(); iField++ ) + { + DDFField *poField = poRecord->GetField( iField ); + + if( poField->GetFieldDefn() == poIDField ) + { + const char *pszModName; + int i; + + for( i = 0; i < poField->GetRepeatCount(); i++ ) + { + char szName[5]; + + pszModName = poField->GetSubfieldData(poMODN,NULL,i); + + strncpy( szName, pszModName, 4 ); + szName[4] = '\0'; + + if( CSLFindString( papszModnList, szName ) == -1 ) + papszModnList = CSLAddString( papszModnList, szName ); + } + } + } + } + + poModule->Rewind(); + + return papszModnList; +} + + diff --git a/Utilities/GDAL/frmts/sdts/sdtslinereader.cpp b/Utilities/GDAL/frmts/sdts/sdtslinereader.cpp new file mode 100644 index 0000000000..2aa5561f94 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtslinereader.cpp @@ -0,0 +1,394 @@ +/****************************************************************************** + * $Id: sdtslinereader.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSLineReader and SDTSRawLine classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtslinereader.cpp,v $ + * Revision 1.14 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.13 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.12 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.11 1999/11/04 22:52:53 warmerda + * added dynamic ATID support + * + * Revision 1.10 1999/09/21 17:26:31 warmerda + * generalized SADR reading + * + * Revision 1.9 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.8 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.7 1999/08/10 02:52:13 warmerda + * introduce use of SDTSApplyModIdList to capture multi-attributes + * + * Revision 1.6 1999/07/30 19:15:56 warmerda + * added module reference counting + * + * Revision 1.5 1999/06/03 14:11:42 warmerda + * Avoid redeclaration of i. + * + * Revision 1.4 1999/05/07 13:45:01 warmerda + * major upgrade to use iso8211lib + * + * Revision 1.3 1999/04/21 04:39:17 warmerda + * converter related fixes. + * + * Revision 1.2 1999/03/23 16:00:05 warmerda + * doc typo fixed + * + * Revision 1.1 1999/03/23 13:56:13 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtslinereader.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSRawLine */ +/* */ +/* This is a simple class for holding the data related with a */ +/* line feature. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSRawLine() */ +/************************************************************************/ + +SDTSRawLine::SDTSRawLine() + +{ + nVertices = 0; + padfX = padfY = padfZ = NULL; + nAttributes = 0; +} + +/************************************************************************/ +/* ~STDSRawLine() */ +/************************************************************************/ + +SDTSRawLine::~SDTSRawLine() + +{ + CPLFree( padfX ); +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read a record from the passed SDTSLineReader, and assign the */ +/* values from that record to this line. This is the bulk of */ +/* the work in this whole file. */ +/************************************************************************/ + +int SDTSRawLine::Read( SDTS_IREF * poIREF, DDFRecord * poRecord ) + +{ + CPLAssert( poRecord->GetStringSubfield( "LINE", 0, "MODN", 0 ) != NULL ); + +/* ==================================================================== */ +/* Loop over fields in this record, looking for those we */ +/* recognise, and need. I don't use the getSubfield() */ +/* interface on the record in order to retain some slight bit */ +/* of efficiency. */ +/* ==================================================================== */ + for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ ) + { + DDFField *poField = poRecord->GetField( iField ); + const char *pszFieldName; + + CPLAssert( poField != NULL ); + pszFieldName = poField->GetFieldDefn()->GetName(); + + if( EQUAL(pszFieldName,"LINE") ) + oModId.Set( poField ); + + else if( EQUAL(pszFieldName,"ATID") ) + ApplyATID( poField ); + + else if( EQUAL(pszFieldName,"PIDL") ) + oLeftPoly.Set( poField ); + + else if( EQUAL(pszFieldName,"PIDR") ) + oRightPoly.Set( poField ); + + else if( EQUAL(pszFieldName,"SNID") ) + oStartNode.Set( poField ); + + else if( EQUAL(pszFieldName,"ENID") ) + oEndNode.Set( poField ); + + else if( EQUAL(pszFieldName,"SADR") ) + { + nVertices = poIREF->GetSADRCount( poField ); + + padfX = (double*) CPLRealloc(padfX,sizeof(double)*nVertices*3); + padfY = padfX + nVertices; + padfZ = padfX + 2*nVertices; + + poIREF->GetSADR( poField, nVertices, padfX, padfY, padfZ ); + } + } + + return TRUE; +} + +/************************************************************************/ +/* Dump() */ +/* */ +/* Write info about this object to a text file. */ +/************************************************************************/ + +void SDTSRawLine::Dump( FILE * fp ) + +{ + int i; + + fprintf( fp, "SDTSRawLine\n" ); + fprintf( fp, " Module=%s, Record#=%ld\n", + oModId.szModule, oModId.nRecord ); + if( oLeftPoly.nRecord != -1 ) + fprintf( fp, " LeftPoly (Module=%s, Record=%ld)\n", + oLeftPoly.szModule, oLeftPoly.nRecord ); + if( oRightPoly.nRecord != -1 ) + fprintf( fp, " RightPoly (Module=%s, Record=%ld)\n", + oRightPoly.szModule, oRightPoly.nRecord ); + if( oStartNode.nRecord != -1 ) + fprintf( fp, " StartNode (Module=%s, Record=%ld)\n", + oStartNode.szModule, oStartNode.nRecord ); + if( oEndNode.nRecord != -1 ) + fprintf( fp, " EndNode (Module=%s, Record=%ld)\n", + oEndNode.szModule, oEndNode.nRecord ); + for( i = 0; i < nAttributes; i++ ) + fprintf( fp, " Attribute (Module=%s, Record=%ld)\n", + paoATID[i].szModule, paoATID[i].nRecord ); + + for( i = 0; i < nVertices; i++ ) + { + fprintf( fp, " Vertex[%3d] = (%.2f,%.2f,%.2f)\n", + i, padfX[i], padfY[i], padfZ[i] ); + } +} + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSLineReader */ +/* */ +/* This is the class used to read a line module. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSLineReader() */ +/************************************************************************/ + +SDTSLineReader::SDTSLineReader( SDTS_IREF * poIREFIn ) + +{ + poIREF = poIREFIn; +} + +/************************************************************************/ +/* ~SDTSLineReader() */ +/************************************************************************/ + +SDTSLineReader::~SDTSLineReader() +{ + Close(); +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSLineReader::Close() + +{ + oDDFModule.Close(); +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open the requested line file, and prepare to start reading */ +/* data records. */ +/************************************************************************/ + +int SDTSLineReader::Open( const char * pszFilename ) + +{ + return( oDDFModule.Open( pszFilename ) ); +} + +/************************************************************************/ +/* GetNextLine() */ +/* */ +/* Fetch the next line feature as an STDSRawLine. */ +/************************************************************************/ + +SDTSRawLine * SDTSLineReader::GetNextLine() + +{ +/* -------------------------------------------------------------------- */ +/* Are we initialized? */ +/* -------------------------------------------------------------------- */ + if( oDDFModule.GetFP() == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Read the record. */ +/* -------------------------------------------------------------------- */ + DDFRecord *poRecord = oDDFModule.ReadRecord(); + + if( poRecord == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Transform into a line feature. */ +/* -------------------------------------------------------------------- */ + SDTSRawLine *poRawLine = new SDTSRawLine(); + + if( poRawLine->Read( poIREF, poRecord ) ) + { + return( poRawLine ); + } + else + { + delete poRawLine; + return NULL; + } +} + +/************************************************************************/ +/* AttachToPolygons() */ +/* */ +/* Attach line features to all the polygon features they relate */ +/* to. */ +/************************************************************************/ + +/** + Attach lines in this module to their polygons as the first step in + polygon formation. + + See also the SDTSRawPolygon::AssembleRings() method. + + @param poTransfer the SDTSTransfer of this SDTSLineReader, and from + which the related SDTSPolygonReader will be instantiated. + +*/ + +void SDTSLineReader::AttachToPolygons( SDTSTransfer * poTransfer ) + +{ +/* -------------------------------------------------------------------- */ +/* We force a filling of the index because when we attach the */ +/* lines we are just providing a pointer back to the line */ +/* features in this readers index. If they aren't cached in */ +/* the index then the pointer will be invalid. */ +/* -------------------------------------------------------------------- */ + FillIndex(); + +/* ==================================================================== */ +/* Loop over all lines, attaching them to the polygons they */ +/* have as right and left faces. */ +/* ==================================================================== */ + SDTSRawLine *poLine; + SDTSPolygonReader *poPolyReader = NULL; + + Rewind(); + while( (poLine = (SDTSRawLine *) GetNextFeature()) != NULL ) + { +/* -------------------------------------------------------------------- */ +/* Skip lines with the same left and right polygon face. These */ +/* are dangles, and will not contribute in any useful fashion */ +/* to the resulting polygon. */ +/* -------------------------------------------------------------------- */ + if( poLine->oLeftPoly.nRecord == poLine->oRightPoly.nRecord ) + continue; + +/* -------------------------------------------------------------------- */ +/* If we don't have our indexed polygon reader yet, try to get */ +/* it now. */ +/* -------------------------------------------------------------------- */ + if( poPolyReader == NULL ) + { + int iPolyLayer = -1; + + if( poLine->oLeftPoly.nRecord != -1 ) + { + iPolyLayer = poTransfer->FindLayer(poLine->oLeftPoly.szModule); + } + else if( poLine->oRightPoly.nRecord != -1 ) + { + iPolyLayer = poTransfer->FindLayer(poLine->oRightPoly.szModule); + } + + if( iPolyLayer == -1 ) + continue; + + poPolyReader = (SDTSPolygonReader *) + poTransfer->GetLayerIndexedReader(iPolyLayer); + + if( poPolyReader == NULL ) + return; + } + +/* -------------------------------------------------------------------- */ +/* Attach line to right and/or left polygons. */ +/* -------------------------------------------------------------------- */ + if( poLine->oLeftPoly.nRecord != -1 ) + { + SDTSRawPolygon *poPoly; + + poPoly = (SDTSRawPolygon *) poPolyReader->GetIndexedFeatureRef( + poLine->oLeftPoly.nRecord ); + if( poPoly != NULL ) + poPoly->AddEdge( poLine ); + } + + if( poLine->oRightPoly.nRecord != -1 ) + { + SDTSRawPolygon *poPoly; + + poPoly = (SDTSRawPolygon *) poPolyReader->GetIndexedFeatureRef( + poLine->oRightPoly.nRecord ); + + if( poPoly != NULL ) + poPoly->AddEdge( poLine ); + } + } +} diff --git a/Utilities/GDAL/frmts/sdts/sdtspointreader.cpp b/Utilities/GDAL/frmts/sdts/sdtspointreader.cpp new file mode 100644 index 0000000000..e61c8f7c2f --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtspointreader.cpp @@ -0,0 +1,247 @@ +/****************************************************************************** + * $Id: sdtspointreader.cpp,v 1.11 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSPointReader and SDTSRawPoint classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtspointreader.cpp,v $ + * Revision 1.11 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.10 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.9 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.8 1999/11/04 22:52:53 warmerda + * added dynamic ATID support + * + * Revision 1.7 1999/09/21 17:26:31 warmerda + * generalized SADR reading + * + * Revision 1.6 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.5 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.4 1999/08/10 02:52:13 warmerda + * introduce use of SDTSApplyModIdList to capture multi-attributes + * + * Revision 1.3 1999/07/30 19:15:56 warmerda + * added module reference counting + * + * Revision 1.2 1999/05/11 14:09:00 warmerda + * fixed up to use PNTS for point record id + * + * Revision 1.1 1999/05/07 13:44:57 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtspointreader.cpp,v 1.11 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSRawPoint */ +/* */ +/* This is a simple class for holding the data related with a */ +/* point feature. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSRawPoint() */ +/************************************************************************/ + +SDTSRawPoint::SDTSRawPoint() + +{ + nAttributes = 0; +} + +/************************************************************************/ +/* ~STDSRawPoint() */ +/************************************************************************/ + +SDTSRawPoint::~SDTSRawPoint() + +{ +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read a record from the passed SDTSPointReader, and assign the */ +/* values from that record to this point. This is the bulk of */ +/* the work in this whole file. */ +/************************************************************************/ + +int SDTSRawPoint::Read( SDTS_IREF * poIREF, DDFRecord * poRecord ) + +{ +/* ==================================================================== */ +/* Loop over fields in this record, looking for those we */ +/* recognise, and need. */ +/* ==================================================================== */ + for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ ) + { + DDFField *poField = poRecord->GetField( iField ); + const char *pszFieldName; + + CPLAssert( poField != NULL ); + pszFieldName = poField->GetFieldDefn()->GetName(); + + if( EQUAL(pszFieldName,"PNTS") ) + oModId.Set( poField ); + + else if( EQUAL(pszFieldName,"ATID") ) + ApplyATID( poField ); + + else if( EQUAL(pszFieldName,"ARID") ) + { + oAreaId.Set( poField ); + } + else if( EQUAL(pszFieldName,"SADR") ) + { + poIREF->GetSADR( poField, 1, &dfX, &dfY, &dfZ ); + } + } + + return TRUE; +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void SDTSRawPoint::Dump( FILE * fp ) + +{ + int i; + + fprintf( fp, "SDTSRawPoint %s: ", oModId.GetName() ); + + if( oAreaId.nRecord != -1 ) + fprintf( fp, " AreaId=%s", oAreaId.GetName() ); + + for( i = 0; i < nAttributes; i++ ) + fprintf( fp, " ATID[%d]=%s", i, paoATID[i].GetName() ); + + fprintf( fp, " Vertex = (%.2f,%.2f,%.2f)\n", dfX, dfY, dfZ ); +} + + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSPointReader */ +/* */ +/* This is the class used to read a point module. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSPointReader() */ +/************************************************************************/ + +SDTSPointReader::SDTSPointReader( SDTS_IREF * poIREFIn ) + +{ + poIREF = poIREFIn; +} + +/************************************************************************/ +/* ~SDTSLineReader() */ +/************************************************************************/ + +SDTSPointReader::~SDTSPointReader() +{ +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSPointReader::Close() + +{ + oDDFModule.Close(); +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open the requested line file, and prepare to start reading */ +/* data records. */ +/************************************************************************/ + +int SDTSPointReader::Open( const char * pszFilename ) + +{ + return( oDDFModule.Open( pszFilename ) ); +} + +/************************************************************************/ +/* GetNextPoint() */ +/* */ +/* Fetch the next feature as an STDSRawPoint. */ +/************************************************************************/ + +SDTSRawPoint * SDTSPointReader::GetNextPoint() + +{ + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Read a record. */ +/* -------------------------------------------------------------------- */ + if( oDDFModule.GetFP() == NULL ) + return NULL; + + poRecord = oDDFModule.ReadRecord(); + + if( poRecord == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Transform into a point feature. */ +/* -------------------------------------------------------------------- */ + SDTSRawPoint *poRawPoint = new SDTSRawPoint(); + + if( poRawPoint->Read( poIREF, poRecord ) ) + { + return( poRawPoint ); + } + else + { + delete poRawPoint; + return NULL; + } +} + diff --git a/Utilities/GDAL/frmts/sdts/sdtspolygonreader.cpp b/Utilities/GDAL/frmts/sdts/sdtspolygonreader.cpp new file mode 100644 index 0000000000..d626cf8812 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtspolygonreader.cpp @@ -0,0 +1,674 @@ +/****************************************************************************** + * $Id: sdtspolygonreader.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSPolygonReader and SDTSRawPolygon classes. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtspolygonreader.cpp,v $ + * Revision 1.14 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.13 2004/04/29 13:45:48 warmerda + * fixed bug with assembling polygons if edges not read + * + * Revision 1.12 2002/04/16 17:51:57 warmerda + * Avoid warnings. + * + * Revision 1.11 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.10 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.9 1999/11/04 22:52:53 warmerda + * added dynamic ATID support + * + * Revision 1.8 1999/09/22 13:35:31 warmerda + * added SDTSPolygonReader::AssembleRings() + * + * Revision 1.7 1999/09/21 02:23:25 warmerda + * added logic to put outer ring first, and set ring direction + * + * Revision 1.6 1999/09/03 13:35:05 warmerda + * cleanup array in assemblerings + * + * Revision 1.5 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.4 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.3 1999/08/10 02:52:13 warmerda + * introduce use of SDTSApplyModIdList to capture multi-attributes + * + * Revision 1.2 1999/07/30 19:15:56 warmerda + * added module reference counting + * + * Revision 1.1 1999/05/11 14:04:42 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtspolygonreader.cpp,v 1.14 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSRawPolygon */ +/* */ +/* This is a simple class for holding the data related with a */ +/* polygon feature. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSRawPolygon() */ +/************************************************************************/ + +SDTSRawPolygon::SDTSRawPolygon() + +{ + nAttributes = 0; + nEdges = nRings = nVertices = 0; + papoEdges = NULL; + + panRingStart = NULL; + padfX = padfY = padfZ = NULL; +} + +/************************************************************************/ +/* ~SDTSRawPolygon() */ +/************************************************************************/ + +SDTSRawPolygon::~SDTSRawPolygon() + +{ + CPLFree( papoEdges ); + CPLFree( panRingStart ); + CPLFree( padfX ); + CPLFree( padfY ); + CPLFree( padfZ ); +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read a record from the passed SDTSPolygonReader, and assign the */ +/* values from that record to this object. This is the bulk of */ +/* the work in this whole file. */ +/************************************************************************/ + +int SDTSRawPolygon::Read( DDFRecord * poRecord ) + +{ +/* ==================================================================== */ +/* Loop over fields in this record, looking for those we */ +/* recognise, and need. */ +/* ==================================================================== */ + for( int iField = 0; iField < poRecord->GetFieldCount(); iField++ ) + { + DDFField *poField = poRecord->GetField( iField ); + const char *pszFieldName; + + CPLAssert( poField != NULL ); + pszFieldName = poField->GetFieldDefn()->GetName(); + + if( EQUAL(pszFieldName,"POLY") ) + { + oModId.Set( poField ); + } + + else if( EQUAL(pszFieldName,"ATID") ) + { + ApplyATID( poField ); + } + } + + return TRUE; +} + +/************************************************************************/ +/* AddEdge() */ +/************************************************************************/ + +void SDTSRawPolygon::AddEdge( SDTSRawLine * poNewLine ) + +{ + nEdges++; + + papoEdges = (SDTSRawLine **) CPLRealloc(papoEdges, sizeof(void*)*nEdges ); + papoEdges[nEdges-1] = poNewLine; +} + +/************************************************************************/ +/* AddEdgeToRing() */ +/************************************************************************/ + +void SDTSRawPolygon::AddEdgeToRing( int nVertToAdd, + double * padfXToAdd, + double * padfYToAdd, + double * padfZToAdd, + int bReverse, int bDropVertex ) + +{ + int iStart=0, iEnd=nVertToAdd-1, iStep=1; + + if( bDropVertex && bReverse ) + { + iStart = nVertToAdd - 2; + iEnd = 0; + iStep = -1; + } + else if( bDropVertex && !bReverse ) + { + iStart = 1; + iEnd = nVertToAdd - 1; + iStep = 1; + } + else if( !bDropVertex && !bReverse ) + { + iStart = 0; + iEnd = nVertToAdd - 1; + iStep = 1; + } + else if( !bDropVertex && bReverse ) + { + iStart = nVertToAdd - 1; + iEnd = 0; + iStep = -1; + } + + for( int i = iStart; i != (iEnd+iStep); i += iStep ) + { + padfX[nVertices] = padfXToAdd[i]; + padfY[nVertices] = padfYToAdd[i]; + padfZ[nVertices] = padfZToAdd[i]; + + nVertices++; + } +} + +/************************************************************************/ +/* AssembleRings() */ +/************************************************************************/ + +/** + * Form border lines (arcs) into outer and inner rings. + * + * See SDTSPolygonReader::AssemblePolygons() for a simple one step process + * to assembling geometry for all polygons in a transfer. + * + * This method will assemble the lines attached to a polygon into + * an outer ring, and zero or more inner rings. Before calling it is + * necessary that all the lines associated with this polygon have already + * been attached. Normally this is accomplished by calling + * SDTSLineReader::AttachToPolygons() on all line layers that might + * contain edges related to this layer. + * + * This method then forms the lines into rings. Rings are formed by: + * <ol> + * <li> Take a previously unconsumed line, and start a ring with it. Mark + * it as consumed, and keep track of it's start and end node ids as + * being the start and end node ids of the ring. + * <li> If the rings start id is the same as the end node id then this ring + * is completely formed, return to step 1. + * <li> Search all unconsumed lines for a line with the same start or end + * node id as the rings current node id. If none are found then the + * assembly has failed. Return to step 1 but report failure on + * completion. + * <li> Once found, add the line to the current ring, dropping the duplicated + * vertex and reverse order if necessary. Mark the line as consumed, + * and update the rings end node id accordingly. + * <li> go to step 2. + * </ol> + * + * Once ring assembly from lines is complete, another pass is made to + * order the rings such that the exterior ring is first, the first ring + * has counter-clockwise vertex ordering and the inner rings have clockwise + * vertex ordering. This is accomplished based on the assumption that the + * outer ring has the largest area, and using the +/- sign of area to establish + * direction of rings. + * + * @return TRUE if all rings assembled without problems or FALSE if a problem + * occured. If a problem occurs rings are still formed from all lines, but + * some of the rings will not be closed, and rings will have no particular + * order or direction. + */ + +int SDTSRawPolygon::AssembleRings() + +{ + int iEdge; + int bSuccess = TRUE; + + if( nRings > 0 ) + return TRUE; + + if( nEdges == 0 ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Allocate ring arrays. */ +/* -------------------------------------------------------------------- */ + panRingStart = (int *) CPLMalloc(sizeof(int) * nEdges); + + nVertices = 0; + for( iEdge = 0; iEdge < nEdges; iEdge++ ) + { + nVertices += papoEdges[iEdge]->nVertices; + } + + padfX = (double *) CPLMalloc(sizeof(double) * nVertices); + padfY = (double *) CPLMalloc(sizeof(double) * nVertices); + padfZ = (double *) CPLMalloc(sizeof(double) * nVertices); + + nVertices = 0; + +/* -------------------------------------------------------------------- */ +/* Setup array of line markers indicating if they have been */ +/* added to a ring yet. */ +/* -------------------------------------------------------------------- */ + int *panEdgeConsumed, nRemainingEdges = nEdges; + + panEdgeConsumed = (int *) CPLCalloc(sizeof(int),nEdges); + +/* ==================================================================== */ +/* Loop generating rings. */ +/* ==================================================================== */ + while( nRemainingEdges > 0 ) + { + int nStartNode, nLinkNode; + +/* -------------------------------------------------------------------- */ +/* Find the first unconsumed edge. */ +/* -------------------------------------------------------------------- */ + SDTSRawLine *poEdge; + + for( iEdge = 0; panEdgeConsumed[iEdge]; iEdge++ ) {} + + poEdge = papoEdges[iEdge]; + +/* -------------------------------------------------------------------- */ +/* Start a new ring, copying in the current line directly */ +/* -------------------------------------------------------------------- */ + panRingStart[nRings++] = nVertices; + + AddEdgeToRing( poEdge->nVertices, + poEdge->padfX, poEdge->padfY, poEdge->padfZ, + FALSE, FALSE ); + + panEdgeConsumed[iEdge] = TRUE; + nRemainingEdges--; + + nStartNode = poEdge->oStartNode.nRecord; + nLinkNode = poEdge->oEndNode.nRecord; + +/* ==================================================================== */ +/* Loop adding edges to this ring until we make a whole pass */ +/* within finding anything to add. */ +/* ==================================================================== */ + int bWorkDone = TRUE; + + while( nLinkNode != nStartNode + && nRemainingEdges > 0 + && bWorkDone ) + { + bWorkDone = FALSE; + + for( iEdge = 0; iEdge < nEdges; iEdge++ ) + { + if( panEdgeConsumed[iEdge] ) + continue; + + poEdge = papoEdges[iEdge]; + if( poEdge->oStartNode.nRecord == nLinkNode ) + { + AddEdgeToRing( poEdge->nVertices, + poEdge->padfX, poEdge->padfY, poEdge->padfZ, + FALSE, TRUE ); + nLinkNode = poEdge->oEndNode.nRecord; + } + else if( poEdge->oEndNode.nRecord == nLinkNode ) + { + AddEdgeToRing( poEdge->nVertices, + poEdge->padfX, poEdge->padfY, poEdge->padfZ, + TRUE, TRUE ); + nLinkNode = poEdge->oStartNode.nRecord; + } + else + { + continue; + } + + panEdgeConsumed[iEdge] = TRUE; + nRemainingEdges--; + bWorkDone = TRUE; + } + } + +/* -------------------------------------------------------------------- */ +/* Did we fail to complete the ring? */ +/* -------------------------------------------------------------------- */ + if( nLinkNode != nStartNode ) + bSuccess = FALSE; + + } /* next ring */ + + CPLFree( panEdgeConsumed ); + + if( !bSuccess ) + return bSuccess; + +/* ==================================================================== */ +/* Compute the area of each ring. The sign will be positive */ +/* for counter clockwise rings, otherwise negative. */ +/* */ +/* The algorithm used in this function was taken from _Graphics */ +/* Gems II_, James Arvo, 1991, Academic Press, Inc., section 1.1, */ +/* "The Area of a Simple Polygon", Jon Rokne, pp. 5-6. */ +/* ==================================================================== */ + double *padfRingArea, dfMaxArea = 0.0; + int iRing, iBiggestRing = -1; + + padfRingArea = (double *) CPLCalloc(sizeof(double),nRings); + + for( iRing = 0; iRing < nRings; iRing++ ) + { + double dfSum1 = 0.0, dfSum2 = 0.0; + int i, nRingVertices; + + if( iRing == nRings - 1 ) + nRingVertices = nVertices - panRingStart[iRing]; + else + nRingVertices = panRingStart[iRing+1] - panRingStart[iRing]; + + for( i = panRingStart[iRing]; + i < panRingStart[iRing] + nRingVertices - 1; + i++) + { + dfSum1 += padfX[i] * padfY[i+1]; + dfSum2 += padfY[i] * padfX[i+1]; + } + + padfRingArea[iRing] = (dfSum1 - dfSum2) / 2; + + if( ABS(padfRingArea[iRing]) > dfMaxArea ) + { + dfMaxArea = ABS(padfRingArea[iRing]); + iBiggestRing = iRing; + } + } + +/* ==================================================================== */ +/* Make a new set of vertices, and copy the largest ring into */ +/* it, adjusting the direction if necessary to ensure that this */ +/* outer ring is counter clockwise. */ +/* ==================================================================== */ + double *padfXRaw = padfX; + double *padfYRaw = padfY; + double *padfZRaw = padfZ; + int *panRawRingStart = panRingStart; + int nRawVertices = nVertices; + int nRawRings = nRings; + int nRingVertices; + + padfX = (double *) CPLMalloc(sizeof(double) * nVertices); + padfY = (double *) CPLMalloc(sizeof(double) * nVertices); + padfZ = (double *) CPLMalloc(sizeof(double) * nVertices); + panRingStart = (int *) CPLMalloc(sizeof(int) * nRawRings); + nVertices = 0; + nRings = 0; + + if( iBiggestRing == nRawRings - 1 ) + nRingVertices = nRawVertices - panRawRingStart[iBiggestRing]; + else + nRingVertices = + panRawRingStart[iBiggestRing+1] - panRawRingStart[iBiggestRing]; + + panRingStart[nRings++] = 0; + AddEdgeToRing( nRingVertices, + padfXRaw + panRawRingStart[iBiggestRing], + padfYRaw + panRawRingStart[iBiggestRing], + padfZRaw + panRawRingStart[iBiggestRing], + padfRingArea[iBiggestRing] < 0.0, FALSE ); + +/* ==================================================================== */ +/* Add the rest of the rings, which must be holes, in clockwise */ +/* order. */ +/* ==================================================================== */ + for( iRing = 0; iRing < nRawRings; iRing++ ) + { + if( iRing == iBiggestRing ) + continue; + + if( iRing == nRawRings - 1 ) + nRingVertices = nRawVertices - panRawRingStart[iRing]; + else + nRingVertices = panRawRingStart[iRing+1] - panRawRingStart[iRing]; + + panRingStart[nRings++] = nVertices; + AddEdgeToRing( nRingVertices, + padfXRaw + panRawRingStart[iRing], + padfYRaw + panRawRingStart[iRing], + padfZRaw + panRawRingStart[iRing], + padfRingArea[iRing] > 0.0, FALSE ); + } + +/* -------------------------------------------------------------------- */ +/* Cleanup */ +/* -------------------------------------------------------------------- */ + CPLFree( padfXRaw ); + CPLFree( padfYRaw ); + CPLFree( padfZRaw ); + CPLFree( padfRingArea ); + CPLFree( panRawRingStart ); + + CPLFree( papoEdges ); + papoEdges = NULL; + nEdges = 0; + + return TRUE; +} + +/************************************************************************/ +/* Dump() */ +/************************************************************************/ + +void SDTSRawPolygon::Dump( FILE * fp ) + +{ + int i; + + fprintf( fp, "SDTSRawPolygon %s: ", oModId.GetName() ); + + for( i = 0; i < nAttributes; i++ ) + fprintf( fp, " ATID[%d]=%s", i, paoATID[i].GetName() ); + + fprintf( fp, "\n" ); +} + +/************************************************************************/ +/* ==================================================================== */ +/* SDTSPolygonReader */ +/* */ +/* This is the class used to read a Polygon module. */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* SDTSPolygonReader() */ +/************************************************************************/ + +SDTSPolygonReader::SDTSPolygonReader() + +{ + bRingsAssembled = FALSE; +} + +/************************************************************************/ +/* ~SDTSPolygonReader() */ +/************************************************************************/ + +SDTSPolygonReader::~SDTSPolygonReader() +{ +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSPolygonReader::Close() + +{ + oDDFModule.Close(); +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open the requested line file, and prepare to start reading */ +/* data records. */ +/************************************************************************/ + +int SDTSPolygonReader::Open( const char * pszFilename ) + +{ + return( oDDFModule.Open( pszFilename ) ); +} + +/************************************************************************/ +/* GetNextPolygon() */ +/* */ +/* Fetch the next feature as an STDSRawPolygon. */ +/************************************************************************/ + +SDTSRawPolygon * SDTSPolygonReader::GetNextPolygon() + +{ + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Read a record. */ +/* -------------------------------------------------------------------- */ + if( oDDFModule.GetFP() == NULL ) + return NULL; + + poRecord = oDDFModule.ReadRecord(); + + if( poRecord == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Transform into a Polygon feature. */ +/* -------------------------------------------------------------------- */ + SDTSRawPolygon *poRawPolygon = new SDTSRawPolygon(); + + if( poRawPolygon->Read( poRecord ) ) + { + return( poRawPolygon ); + } + else + { + delete poRawPolygon; + return NULL; + } +} + +/************************************************************************/ +/* AssembleRings() */ +/************************************************************************/ + +/** + * Assemble geometry for a polygon transfer. + * + * This method takes care of attaching lines from all the line layers in + * this transfer to this polygon layer, assembling the lines into rings on + * the polygons, and then cleaning up unnecessary intermediate results. + * + * Currently this method will leave the line layers rewound to the beginning + * but indexed, and the polygon layer rewound but indexed. In the future + * it may restore reading positions, and possibly flush line indexes if they + * were not previously indexed. + * + * This method does nothing if the rings have already been assembled on + * this layer using this method. + * + * See SDTSRawPolygon::AssembleRings() for more information on how the lines + * are assembled into rings. + * + * @param poTransfer the SDTSTransfer that this reader is a part of. Used + * to get a list of line layers that might be needed. + */ + +void SDTSPolygonReader::AssembleRings( SDTSTransfer * poTransfer ) + +{ + if( bRingsAssembled ) + return; + + bRingsAssembled = TRUE; + +/* -------------------------------------------------------------------- */ +/* To write polygons we need to build them from their related */ +/* arcs. We don't know off hand which arc (line) layers */ +/* contribute so we process all line layers, attaching them to */ +/* polygons as appropriate. */ +/* -------------------------------------------------------------------- */ + for( int iLineLayer = 0; + iLineLayer < poTransfer->GetLayerCount(); + iLineLayer++ ) + { + SDTSLineReader *poLineReader; + + if( poTransfer->GetLayerType(iLineLayer) != SLTLine ) + continue; + + poLineReader = (SDTSLineReader *) + poTransfer->GetLayerIndexedReader( iLineLayer ); + if( poLineReader == NULL ) + continue; + + poLineReader->AttachToPolygons( poTransfer ); + poLineReader->Rewind(); + } + +/* -------------------------------------------------------------------- */ +/* Scan all polygons indexed on this reader, and assemble their */ +/* rings. */ +/* -------------------------------------------------------------------- */ + SDTSFeature *poFeature; + + Rewind(); + while( (poFeature = GetNextFeature()) != NULL ) + { + SDTSRawPolygon *poPoly = (SDTSRawPolygon *) poFeature; + + poPoly->AssembleRings(); + } + + Rewind(); +} diff --git a/Utilities/GDAL/frmts/sdts/sdtsrasterreader.cpp b/Utilities/GDAL/frmts/sdts/sdtsrasterreader.cpp new file mode 100644 index 0000000000..3e88d9bec5 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsrasterreader.cpp @@ -0,0 +1,609 @@ +/****************************************************************************** + * $Id: sdtsrasterreader.cpp,v 1.12 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSRasterReader class. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsrasterreader.cpp,v $ + * Revision 1.12 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.11 2003/02/06 03:19:21 warmerda + * dont bomb if FMT, UNIT or ATLB missing + * + * Revision 1.10 2001/11/30 05:00:17 warmerda + * added error detection in GetBlock() to avoid infinite recursion + * + * Revision 1.9 2001/09/10 19:27:36 warmerda + * added GetMinMax() and raster data types + * + * Revision 1.8 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.7 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.6 1999/10/12 19:08:33 warmerda + * Undo last change. + * + * Revision 1.5 1999/10/12 19:02:41 warmerda + * The SADR for the raster represents the center of the top left pixel, not + * it's top left corner. + * + * Revision 1.4 1999/09/21 17:25:04 warmerda + * Read raster data type from DDSH + * + * Revision 1.3 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.2 1999/06/03 21:13:18 warmerda + * Added transform support. + * + * Revision 1.1 1999/06/03 14:02:28 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtsrasterreader.cpp,v 1.12 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTSRasterReader() */ +/************************************************************************/ + +SDTSRasterReader::SDTSRasterReader() + +{ + nXSize = 0; + nYSize = 0; + nXBlockSize = 0; + nYBlockSize = 0; + nXStart = 0; + nYStart = 0; + + strcpy( szINTR, "CE" ); +} + +/************************************************************************/ +/* ~SDTSRasterReader() */ +/************************************************************************/ + +SDTSRasterReader::~SDTSRasterReader() +{ +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSRasterReader::Close() + +{ + oDDFModule.Close(); +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open the requested cell file, and collect required */ +/* information. */ +/************************************************************************/ + +int SDTSRasterReader::Open( SDTS_CATD * poCATD, SDTS_IREF * poIREF, + const char * pszModule ) + +{ + strncpy( szModule, pszModule, sizeof(szModule) ); + +/* ==================================================================== */ +/* Search the LDEF module for the requested cell module. */ +/* ==================================================================== */ + DDFModule oLDEF; + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Open the LDEF module, and report failure if it is missing. */ +/* -------------------------------------------------------------------- */ + if( poCATD->GetModuleFilePath("LDEF") == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find LDEF entry in CATD module ... " + "can't treat as raster.\n" ); + return FALSE; + } + + if( !oLDEF.Open( poCATD->GetModuleFilePath("LDEF") ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read each record, till we find what we want. */ +/* -------------------------------------------------------------------- */ + while( (poRecord = oLDEF.ReadRecord() ) != NULL ) + { + if( EQUAL(poRecord->GetStringSubfield("LDEF",0,"CMNM",0), pszModule) ) + break; + } + + if( poRecord == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find module `%s' in LDEF file.\n", + pszModule ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Extract raster dimensions, and origin offset (0/1). */ +/* -------------------------------------------------------------------- */ + nXSize = poRecord->GetIntSubfield( "LDEF", 0, "NCOL", 0 ); + nYSize = poRecord->GetIntSubfield( "LDEF", 0, "NROW", 0 ); + + nXStart = poRecord->GetIntSubfield( "LDEF", 0, "SOCI", 0 ); + nYStart = poRecord->GetIntSubfield( "LDEF", 0, "SORI", 0 ); + +/* -------------------------------------------------------------------- */ +/* Get the point in the pixel that the origin defines. We only */ +/* support top left and center. */ +/* -------------------------------------------------------------------- */ + strcpy( szINTR, poRecord->GetStringSubfield( "LDEF", 0, "INTR", 0 ) ); + if( EQUAL(szINTR,"") ) + strcpy( szINTR, "CE" ); + + if( !EQUAL(szINTR,"CE") && !EQUAL(szINTR,"TL") ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Unsupported INTR value of `%s', assume CE.\n" + "Positions may be off by one pixel.\n", + szINTR ); + strcpy( szINTR, "CE" ); + } + +/* -------------------------------------------------------------------- */ +/* Record the LDEF record number we used so we can find the */ +/* corresponding RSDF record. */ +/* -------------------------------------------------------------------- */ + int nLDEF_RCID; + + nLDEF_RCID = poRecord->GetIntSubfield( "LDEF", 0, "RCID", 0 ); + + oLDEF.Close(); + +/* ==================================================================== */ +/* Search the RSDF module for the requested cell module. */ +/* ==================================================================== */ + DDFModule oRSDF; + +/* -------------------------------------------------------------------- */ +/* Open the RSDF module, and report failure if it is missing. */ +/* -------------------------------------------------------------------- */ + if( poCATD->GetModuleFilePath("RSDF") == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find RSDF entry in CATD module ... " + "can't treat as raster.\n" ); + return FALSE; + } + + if( !oRSDF.Open( poCATD->GetModuleFilePath("RSDF") ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read each record, till we find what we want. */ +/* -------------------------------------------------------------------- */ + while( (poRecord = oRSDF.ReadRecord() ) != NULL ) + { + if( poRecord->GetIntSubfield("LYID",0,"RCID",0) == nLDEF_RCID ) + break; + } + + if( poRecord == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find LDEF:%d record in RSDF file.\n", + nLDEF_RCID ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Establish the raster pixel/line to georef transformation. */ +/* -------------------------------------------------------------------- */ + double dfZ; + + if( poRecord->FindField( "SADR" ) == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find SADR field in RSDF record.\n" ); + return FALSE; + } + + poIREF->GetSADR( poRecord->FindField( "SADR" ), 1, + adfTransform + 0, adfTransform + 3, &dfZ ); + + adfTransform[1] = poIREF->dfXRes; + adfTransform[2] = 0.0; + adfTransform[4] = 0.0; + adfTransform[5] = -1 * poIREF->dfYRes; + +/* -------------------------------------------------------------------- */ +/* If the origin is the center of the pixel, then shift it back */ +/* half a pixel to the top left of the top left. */ +/* -------------------------------------------------------------------- */ + if( EQUAL(szINTR,"CE") ) + { + adfTransform[0] -= adfTransform[1] * 0.5; + adfTransform[3] -= adfTransform[5] * 0.5; + } + +/* -------------------------------------------------------------------- */ +/* Verify some other assumptions. */ +/* -------------------------------------------------------------------- */ + const char *pszString; + + pszString = poRecord->GetStringSubfield( "RSDF", 0, "OBRP", 0); + if( !EQUAL(pszString,"G2") ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "OBRP value of `%s' not expected 2D raster code (G2).\n", + pszString ); + return FALSE; + } + + pszString = poRecord->GetStringSubfield( "RSDF", 0, "SCOR", 0); + if( !EQUAL(pszString,"TL") ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "SCOR (origin) is `%s' instead of expected top left.\n" + "Georef coordinates will likely be incorrect.\n", + pszString ); + } + + oRSDF.Close(); + +/* -------------------------------------------------------------------- */ +/* For now we will assume that the block size is one scanline. */ +/* We will blow a gasket later while reading the cell file if */ +/* this isn't the case. */ +/* */ +/* This isn't a very flexible raster implementation! */ +/* -------------------------------------------------------------------- */ + nXBlockSize = nXSize; + nYBlockSize = 1; + +/* ==================================================================== */ +/* Fetch the data type used for the raster, and the units from */ +/* the data dictionary/schema record (DDSH). */ +/* ==================================================================== */ + DDFModule oDDSH; + +/* -------------------------------------------------------------------- */ +/* Open the DDSH module, and report failure if it is missing. */ +/* -------------------------------------------------------------------- */ + if( poCATD->GetModuleFilePath("DDSH") == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find DDSH entry in CATD module ... " + "can't treat as raster.\n" ); + return FALSE; + } + + if( !oDDSH.Open( poCATD->GetModuleFilePath("DDSH") ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read each record, till we find what we want. */ +/* -------------------------------------------------------------------- */ + while( (poRecord = oDDSH.ReadRecord() ) != NULL ) + { + if( EQUAL(poRecord->GetStringSubfield("DDSH",0,"NAME",0),pszModule) ) + break; + } + + if( poRecord == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find DDSH record for %s.\n", + pszModule ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Get some values we are interested in. */ +/* -------------------------------------------------------------------- */ + if( poRecord->GetStringSubfield("DDSH",0,"FMT",0) != NULL ) + strcpy( szFMT, poRecord->GetStringSubfield("DDSH",0,"FMT",0) ); + else + strcpy( szFMT, "BUI16" ); + + if( poRecord->GetStringSubfield("DDSH",0,"UNIT",0) != NULL ) + strcpy( szUNITS, poRecord->GetStringSubfield("DDSH",0,"UNIT",0) ); + else + strcpy( szUNITS, "METERS" ); + + if( poRecord->GetStringSubfield("DDSH",0,"ATLB",0) != NULL ) + strcpy( szLabel, poRecord->GetStringSubfield("DDSH",0,"ATLB",0) ); + else + strcpy( szLabel, "" ); + +/* -------------------------------------------------------------------- */ +/* Open the cell file. */ +/* -------------------------------------------------------------------- */ + return( oDDFModule.Open( poCATD->GetModuleFilePath(pszModule) ) ); +} + +/************************************************************************/ +/* GetBlock() */ +/* */ +/* Read a requested block of raster data from the file. */ +/* */ +/* Currently we will always use sequential access. In the */ +/* future we should modify the iso8211 library to support */ +/* seeking, and modify this to seek directly to the right */ +/* record once it's location is known. */ +/************************************************************************/ + +/** + Read a block of raster data from the file. + + @param nXOffset X block offset into the file. Normally zero for scanline + organized raster files. + + @param nYOffset Y block offset into the file. Normally the scanline offset + from top of raster for scanline organized raster files. + + @param pData pointer to GInt16 (signed short) buffer of data into which to + read the raster. + + @return TRUE on success and FALSE on error. + + */ + +int SDTSRasterReader::GetBlock( int nXOffset, int nYOffset, void * pData ) + +{ + DDFRecord *poRecord; + int nBytesPerValue; + + CPLAssert( nXOffset == 0 ); + +/* -------------------------------------------------------------------- */ +/* Analyse the datatype. */ +/* -------------------------------------------------------------------- */ + CPLAssert( EQUAL(szFMT,"BI16") || EQUAL(szFMT,"BFP32") ); + + if( EQUAL(szFMT,"BI16") ) + nBytesPerValue = 2; + else + nBytesPerValue = 4; + +/* -------------------------------------------------------------------- */ +/* Read through till we find the desired record. */ +/* -------------------------------------------------------------------- */ + CPLErrorReset(); + while( (poRecord = oDDFModule.ReadRecord()) != NULL ) + { + if( poRecord->GetIntSubfield( "CELL", 0, "ROWI", 0 ) + == nYOffset + nYStart ) + { + break; + } + } + + if( CPLGetLastErrorType() == CE_Failure ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* If we didn't get what we needed just start over. */ +/* -------------------------------------------------------------------- */ + if( poRecord == NULL ) + { + oDDFModule.Rewind(); + return GetBlock( nXOffset, nYOffset, pData ); + } + +/* -------------------------------------------------------------------- */ +/* Validate the records size. Does it represent exactly one */ +/* scanline? */ +/* -------------------------------------------------------------------- */ + DDFField *poCVLS; + + poCVLS = poRecord->FindField( "CVLS" ); + if( poCVLS == NULL ) + return FALSE; + + if( poCVLS->GetRepeatCount() != nXSize ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Cell record is %d long, but we expected %d, the number\n" + "of pixels in a scanline. Raster access failed.\n", + poCVLS->GetRepeatCount(), nXSize ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Does the CVLS field consist of exactly 1 B(16) field? */ +/* -------------------------------------------------------------------- */ + if( poCVLS->GetDataSize() < nBytesPerValue * nXSize + || poCVLS->GetDataSize() > nBytesPerValue * nXSize + 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Cell record is not of expected format. Raster access " + "failed.\n" ); + + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Copy the data to the application buffer, and byte swap if */ +/* required. */ +/* -------------------------------------------------------------------- */ + memcpy( pData, poCVLS->GetData(), nXSize * nBytesPerValue ); + +#ifdef CPL_LSB + if( nBytesPerValue == 2 ) + { + for( int i = 0; i < nXSize; i++ ) + { + ((GInt16 *) pData)[i] = CPL_MSBWORD16(((GInt16 *) pData)[i]); + } + } + else + { + for( int i = 0; i < nXSize; i++ ) + { + CPL_MSBPTR32( ((GByte *)pData) + i*4 ); + } + } +#endif + + return TRUE; +} + +/************************************************************************/ +/* GetTransform() */ +/************************************************************************/ + +/** + Fetch the transformation between pixel/line coordinates and georeferenced + coordinates. + + @param padfTransformOut pointer to an array of six doubles which will be + filled with the georeferencing transform. + + @return TRUE is returned, indicating success. + + The padfTransformOut array consists of six values. The pixel/line coordinate + (Xp,Yp) can be related to a georeferenced coordinate (Xg,Yg) or (Easting, + Northing). + + <pre> + Xg = padfTransformOut[0] + Xp * padfTransform[1] + Yp * padfTransform[2] + Yg = padfTransformOut[3] + Xp * padfTransform[4] + Yp * padfTransform[5] + </pre> + + In other words, for a north up image the top left corner of the top left + pixel is at georeferenced coordinate (padfTransform[0],padfTransform[3]) + the pixel width is padfTransform[1], the pixel height is padfTransform[5] + and padfTransform[2] and padfTransform[4] will be zero. + + */ + +int SDTSRasterReader::GetTransform( double * padfTransformOut ) + +{ + memcpy( padfTransformOut, adfTransform, sizeof(double)*6 ); + + return TRUE; +} + +/************************************************************************/ +/* GetRasterType() */ +/************************************************************************/ + +/** + * Fetch the pixel data type. + * + * Returns one of SDTS_RT_INT16 (1) or SDTS_RT_FLOAT32 (6) indicating the + * type of buffer that should be passed to GetBlock(). + */ + +int SDTSRasterReader::GetRasterType() + +{ + if( EQUAL(szFMT,"BFP32") ) + return 6; + else + return 1; +} + +/************************************************************************/ +/* GetMinMax() */ +/************************************************************************/ + +/** + * Fetch the minimum and maximum raster values that occur in the file. + * + * Note this operation current results in a scan of the entire file. + * + * @param pdfMin variable in which the minimum value encountered is returned. + * @param pdfMax variable in which the maximum value encountered is returned. + * @param dfNoData a value to ignore when computing min/max, defaults to + * -32766. + * + * @return TRUE on success, or FALSE if an error occurs. + */ + +int SDTSRasterReader::GetMinMax( double * pdfMin, double * pdfMax, + double dfNoData ) + +{ + void *pBuffer; + int bFirst = TRUE; + int b32Bit = GetRasterType() == SDTS_RT_FLOAT32; + + CPLAssert( GetBlockXSize() == GetXSize() && GetBlockYSize() == 1 ); + + pBuffer = CPLMalloc(sizeof(float) * GetXSize()); + + for( int iLine = 0; iLine < GetYSize(); iLine++ ) + { + if( !GetBlock( 0, iLine, pBuffer ) ) + { + CPLFree( pBuffer ); + return FALSE; + } + + for( int iPixel = 0; iPixel < GetXSize(); iPixel++ ) + { + double dfValue; + + if( b32Bit ) + dfValue = ((float *) pBuffer)[iPixel]; + else + dfValue = ((short *) pBuffer)[iPixel]; + + if( dfValue != dfNoData ) + { + if( bFirst ) + { + *pdfMin = *pdfMax = dfValue; + bFirst = FALSE; + } + else + { + *pdfMin = MIN(*pdfMin,dfValue); + *pdfMax = MAX(*pdfMax,dfValue); + } + } + } + } + + CPLFree( pBuffer ); + + return !bFirst; +} + + diff --git a/Utilities/GDAL/frmts/sdts/sdtstransfer.cpp b/Utilities/GDAL/frmts/sdts/sdtstransfer.cpp new file mode 100644 index 0000000000..4b89e192d5 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtstransfer.cpp @@ -0,0 +1,730 @@ +/****************************************************************************** + * $Id: sdtstransfer.cpp,v 1.15 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTSTransfer class. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtstransfer.cpp,v $ + * Revision 1.15 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.14 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.13 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.12 2000/02/04 16:36:46 warmerda + * Added raster support to GetBounds(). + * + * Revision 1.11 2000/02/03 19:44:52 warmerda + * added method for getting bounds of transfer + * + * Revision 1.10 1999/09/27 11:24:11 warmerda + * Fixed SLTRaster type spelling. + * + * Revision 1.9 1999/09/03 19:04:38 warmerda + * added more help + * + * Revision 1.8 1999/09/03 13:01:39 warmerda + * added docs + * + * Revision 1.7 1999/09/02 03:40:03 warmerda + * added indexed readers + * + * Revision 1.6 1999/08/16 19:25:05 warmerda + * added GetLayerPolygonReader() method + * + * Revision 1.5 1999/06/03 21:13:39 warmerda + * pass IREF to SDTSRasterReader + * + * Revision 1.4 1999/06/03 14:03:10 warmerda + * Added raster layer support + * + * Revision 1.3 1999/05/13 15:32:30 warmerda + * added SLTPoly as an interesting layer + * + * Revision 1.2 1999/05/11 14:06:20 warmerda + * added GetLayerModuleReader() + * + * Revision 1.1 1999/05/11 12:55:31 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtstransfer.cpp,v 1.15 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTSTransfer() */ +/************************************************************************/ + +SDTSTransfer::SDTSTransfer() + +{ + nLayers = 0; + panLayerCATDEntry = NULL; + papoLayerReader = NULL; +} + +/************************************************************************/ +/* ~SDTSTransfer() */ +/************************************************************************/ + +SDTSTransfer::~SDTSTransfer() + +{ + Close(); +} + + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +/** + * Open an SDTS transfer, and establish a list of data layers in the + * transfer. + * + * @param pszFilename The name of the CATD file within the transfer. + * + * @return TRUE if the open success, or FALSE if it fails. + */ + +int SDTSTransfer::Open( const char * pszFilename ) + +{ +/* -------------------------------------------------------------------- */ +/* Open the catalog. */ +/* -------------------------------------------------------------------- */ + if( !oCATD.Read( pszFilename ) ) + return FALSE; + + +/* -------------------------------------------------------------------- */ +/* Read the IREF file. */ +/* -------------------------------------------------------------------- */ + if( oCATD.GetModuleFilePath( "IREF" ) == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find IREF module in transfer `%s'.\n", + pszFilename ); + return FALSE; + } + + if( !oIREF.Read( oCATD.GetModuleFilePath( "IREF" ) ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read the XREF file. */ +/* -------------------------------------------------------------------- */ + if( oCATD.GetModuleFilePath( "XREF" ) == NULL ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Can't find XREF module in transfer `%s'.\n", + pszFilename ); + } + else if( !oXREF.Read( oCATD.GetModuleFilePath( "XREF" ) ) ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Can't read XREF module, even though found in transfer `%s'.\n", + pszFilename ); + } + +/* -------------------------------------------------------------------- */ +/* Build an index of layer types we recognise and care about. */ +/* -------------------------------------------------------------------- */ + int iCATDLayer; + + panLayerCATDEntry = (int *) CPLMalloc(sizeof(int) * oCATD.GetEntryCount()); + + for( iCATDLayer = 0; iCATDLayer < oCATD.GetEntryCount(); iCATDLayer++ ) + { + switch( oCATD.GetEntryType(iCATDLayer) ) + { + case SLTPoint: + case SLTLine: + case SLTAttr: + case SLTPoly: + case SLTRaster: + panLayerCATDEntry[nLayers++] = iCATDLayer; + break; + + default: + /* ignore */ + break; + } + } + +/* -------------------------------------------------------------------- */ +/* Initialized the related indexed readers list. */ +/* -------------------------------------------------------------------- */ + papoLayerReader = (SDTSIndexedReader **) + CPLCalloc(sizeof(SDTSIndexedReader*),oCATD.GetEntryCount()); + + return TRUE; +} + +/************************************************************************/ +/* Close() */ +/************************************************************************/ + +void SDTSTransfer::Close() + +{ + for( int i = 0; i < nLayers; i++ ) + { + if( papoLayerReader[i] != NULL ) + delete papoLayerReader[i]; + } + CPLFree( papoLayerReader ); + papoLayerReader = NULL; + CPLFree( panLayerCATDEntry ); + panLayerCATDEntry = NULL; + nLayers = 0; +} + +/************************************************************************/ +/* GetLayerType() */ +/************************************************************************/ + +/** + Fetch type of requested feature layer. + + @param iEntry the index of the layer to fetch information on. A value + from zero to GetLayerCount()-1. + + @return the layer type. + + <ul> + <li> SLTPoint: A point layer. An SDTSPointReader is returned by + SDTSTransfer::GetLayerIndexedReader(). + + <li> SLTLine: A line layer. An SDTSLineReader is returned by + SDTSTransfer::GetLayerIndexedReader(). + + <li> SLTAttr: An attribute primary or secondary layer. An SDTSAttrReader + is returned by SDTSTransfer::GetLayerIndexedReader(). + + <li> SLTPoly: A polygon layer. An SDTSPolygonReader is returned by + SDTSTransfer::GetLayerIndexedReader(). + + <li> SLTRaster: A raster layer. SDTSTransfer::GetLayerIndexedReader() + is not implemented. Use SDTSTransfer::GetLayerRasterReader() instead. + </ul> + + */ + +SDTSLayerType SDTSTransfer::GetLayerType( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nLayers ) + return SLTUnknown; + + return oCATD.GetEntryType( panLayerCATDEntry[iEntry] ); +} + +/************************************************************************/ +/* GetLayerCATDEntry() */ +/************************************************************************/ + +/** + Fetch the CATD module index for a layer. This can be used to fetch + details about the layer/module from the SDTS_CATD object, such as it's + filename, and description. + + @param iEntry the layer index from 0 to GetLayerCount()-1. + + @return the module index suitable for use with the various SDTS_CATD + methods. + */ + +int SDTSTransfer::GetLayerCATDEntry( int iEntry ) + +{ + if( iEntry < 0 || iEntry >= nLayers ) + return -1; + + return panLayerCATDEntry[iEntry]; +} + +/************************************************************************/ +/* GetLayerLineReader() */ +/************************************************************************/ + +SDTSLineReader *SDTSTransfer::GetLayerLineReader( int iEntry ) + +{ + SDTSLineReader *poLineReader; + + if( iEntry < 0 + || iEntry >= nLayers + || oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) != SLTLine ) + { + return NULL; + } + + + poLineReader = new SDTSLineReader( &oIREF ); + + if( !poLineReader->Open( + oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) + { + delete poLineReader; + return NULL; + } + else + { + return poLineReader; + } +} + +/************************************************************************/ +/* GetLayerPointReader() */ +/************************************************************************/ + +SDTSPointReader *SDTSTransfer::GetLayerPointReader( int iEntry ) + +{ + SDTSPointReader *poPointReader; + + if( iEntry < 0 + || iEntry >= nLayers + || oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) != SLTPoint ) + { + return NULL; + } + + + poPointReader = new SDTSPointReader( &oIREF ); + + if( !poPointReader->Open( + oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) + { + delete poPointReader; + return NULL; + } + else + { + return poPointReader; + } +} + +/************************************************************************/ +/* GetLayerPolygonReader() */ +/************************************************************************/ + +SDTSPolygonReader *SDTSTransfer::GetLayerPolygonReader( int iEntry ) + +{ + SDTSPolygonReader *poPolyReader; + + if( iEntry < 0 + || iEntry >= nLayers + || oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) != SLTPoly ) + { + return NULL; + } + + + poPolyReader = new SDTSPolygonReader(); + + if( !poPolyReader->Open( + oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) + { + delete poPolyReader; + return NULL; + } + else + { + return poPolyReader; + } +} + +/************************************************************************/ +/* GetLayerAttrReader() */ +/************************************************************************/ + +SDTSAttrReader *SDTSTransfer::GetLayerAttrReader( int iEntry ) + +{ + SDTSAttrReader *poAttrReader; + + if( iEntry < 0 + || iEntry >= nLayers + || oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) != SLTAttr ) + { + return NULL; + } + + + poAttrReader = new SDTSAttrReader( &oIREF ); + + if( !poAttrReader->Open( + oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) + { + delete poAttrReader; + return NULL; + } + else + { + return poAttrReader; + } +} + +/************************************************************************/ +/* GetLayerRasterReader() */ +/************************************************************************/ + +/** + Instantiate an SDTSRasterReader for the indicated layer. + + @param iEntry the index of the layer to instantiate a reader for. A + value between 0 and GetLayerCount()-1. + + @return a pointer to a new SDTSRasterReader object, or NULL if the method + fails. + + NOTE: The reader returned from GetLayerRasterReader() becomes the + responsibility of the caller to delete, and isn't automatically deleted + when the SDTSTransfer is destroyed. This method is different from + the GetLayerIndexedReader() method in this regard. + */ + +SDTSRasterReader *SDTSTransfer::GetLayerRasterReader( int iEntry ) + +{ + SDTSRasterReader *poRasterReader; + + if( iEntry < 0 + || iEntry >= nLayers + || oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) != SLTRaster ) + { + return NULL; + } + + poRasterReader = new SDTSRasterReader(); + + if( !poRasterReader->Open( &oCATD, &oIREF, + oCATD.GetEntryModule(panLayerCATDEntry[iEntry] ) ) ) + { + delete poRasterReader; + return NULL; + } + else + { + return poRasterReader; + } +} + +/************************************************************************/ +/* GetLayerModuleReader() */ +/************************************************************************/ + +DDFModule *SDTSTransfer::GetLayerModuleReader( int iEntry ) + +{ + DDFModule *poModuleReader; + + if( iEntry < 0 || iEntry >= nLayers ) + { + return NULL; + } + + + poModuleReader = new DDFModule; + + if( !poModuleReader->Open( + oCATD.GetEntryFilePath( panLayerCATDEntry[iEntry] ) ) ) + { + delete poModuleReader; + return NULL; + } + else + { + return poModuleReader; + } +} + +/************************************************************************/ +/* GetLayerIndexedReader() */ +/************************************************************************/ + +/** + Returns a pointer to a reader of the appropriate type to the requested + layer. + + Notes: + <ul> + <li> The returned reader remains owned by the SDTSTransfer, and will be + destroyed when the SDTSTransfer is destroyed. It should not be + destroyed by the application. + + <li> If an indexed reader was already created for this layer using + GetLayerIndexedReader(), it will be returned instead of creating a new + reader. Amoung other things this means that the returned reader may not + be positioned to read from the beginning of the module, and may already + have it's index filled. + + <li> The returned reader will be of a type appropriate to the layer. + See SDTSTransfer::GetLayerType() to see what reader classes correspond + to what layer types, so it can be cast accordingly (if necessary). + + </ul> + + @param iEntry the index of the layer to instantiate a reader for. A + value between 0 and GetLayerCount()-1. + + @return a pointer to an appropriate reader or NULL if the method fails. + */ + +SDTSIndexedReader *SDTSTransfer::GetLayerIndexedReader( int iEntry ) + +{ + if( papoLayerReader[iEntry] == NULL ) + { + switch( oCATD.GetEntryType( panLayerCATDEntry[iEntry] ) ) + { + case SLTAttr: + papoLayerReader[iEntry] = GetLayerAttrReader( iEntry ); + break; + + case SLTPoint: + papoLayerReader[iEntry] = GetLayerPointReader( iEntry ); + break; + + case SLTLine: + papoLayerReader[iEntry] = GetLayerLineReader( iEntry ); + break; + + case SLTPoly: + papoLayerReader[iEntry] = GetLayerPolygonReader( iEntry ); + break; + + default: + break; + } + } + + return papoLayerReader[iEntry]; +} + +/************************************************************************/ +/* FindLayer() */ +/************************************************************************/ + +/** + Fetch the SDTSTransfer layer number corresponding to a module name. + + @param pszModule the name of the module to search for, such as "PC01". + + @return the layer number (between 0 and GetLayerCount()-1 corresponding to + the module, or -1 if it doesn't correspond to a layer. + */ + +int SDTSTransfer::FindLayer( const char * pszModule ) + +{ + int iLayer; + + for( iLayer = 0; iLayer < nLayers; iLayer++ ) + { + if( EQUAL(pszModule, + oCATD.GetEntryModule( panLayerCATDEntry[iLayer] ) ) ) + { + return iLayer; + } + } + + return -1; +} + +/************************************************************************/ +/* GetIndexedFeatureRef() */ +/************************************************************************/ + +SDTSFeature *SDTSTransfer::GetIndexedFeatureRef( SDTSModId *poModId, + SDTSLayerType *peType ) + +{ +/* -------------------------------------------------------------------- */ +/* Find the desired layer ... this is likely a significant slow */ +/* point in the whole process ... perhaps the last found could */ +/* be cached or something. */ +/* -------------------------------------------------------------------- */ + int iLayer = FindLayer( poModId->szModule ); + if( iLayer == -1 ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Get the reader, and read a feature from it. */ +/* -------------------------------------------------------------------- */ + SDTSIndexedReader *poReader; + + poReader = GetLayerIndexedReader( iLayer ); + if( poReader == NULL ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* return type, if requested. */ +/* -------------------------------------------------------------------- */ + if( peType != NULL ) + *peType = GetLayerType(iLayer); + + return poReader->GetIndexedFeatureRef( poModId->nRecord ); +} + +/************************************************************************/ +/* GetAttr() */ +/* */ +/* Fetch the attribute information corresponding to a given */ +/* SDTSModId. */ +/************************************************************************/ + +/** + Fetch the attribute fields given a particular module/record id. + + @param poModId an attribute record identifer, normally taken from the + aoATID[] array of an SDTSIndexedFeature. + + @return a pointer to the DDFField containing the user attribute values as + subfields. + */ + +DDFField *SDTSTransfer::GetAttr( SDTSModId *poModId ) + +{ + SDTSAttrRecord *poAttrRecord; + + poAttrRecord = (SDTSAttrRecord *) GetIndexedFeatureRef( poModId ); + + if( poAttrRecord == NULL ) + return NULL; + + return poAttrRecord->poATTR; +} + +/************************************************************************/ +/* GetBounds() */ +/************************************************************************/ + +/** + Fetch approximate bounds for a transfer by scanning all point layers + and raster layers. + + For TVP datasets (where point layers are scanned) the results can, in + theory miss some lines that go outside the bounds of the point layers. + However, this isn't common since most TVP sets contain a bounding rectangle + whose corners will define the most extreme extents. + + @param pdfMinX western edge of dataset + @param pdfMinY southern edge of dataset + @param pdfMaxX eastern edge of dataset + @param pdfMaxY northern edge of dataset + + @return TRUE if success, or FALSE on a failure. + */ + +int SDTSTransfer::GetBounds( double *pdfMinX, double *pdfMinY, + double *pdfMaxX, double *pdfMaxY ) + +{ + int bFirst = TRUE; + + for( int iLayer = 0; iLayer < GetLayerCount(); iLayer++ ) + { + if( GetLayerType( iLayer ) == SLTPoint ) + { + SDTSPointReader *poLayer; + SDTSRawPoint *poPoint; + + poLayer = (SDTSPointReader *) GetLayerIndexedReader( iLayer ); + if( poLayer == NULL ) + continue; + + poLayer->Rewind(); + while( (poPoint = (SDTSRawPoint*) poLayer->GetNextFeature()) ) + { + if( bFirst ) + { + *pdfMinX = *pdfMaxX = poPoint->dfX; + *pdfMinY = *pdfMaxY = poPoint->dfY; + bFirst = FALSE; + } + else + { + *pdfMinX = MIN(*pdfMinX,poPoint->dfX); + *pdfMaxX = MAX(*pdfMaxX,poPoint->dfX); + *pdfMinY = MIN(*pdfMinY,poPoint->dfY); + *pdfMaxY = MAX(*pdfMaxY,poPoint->dfY); + } + + if( !poLayer->IsIndexed() ) + delete poPoint; + } + } + + else if( GetLayerType( iLayer ) == SLTRaster ) + { + SDTSRasterReader *poRL; + double adfGeoTransform[6]; + double dfMinX, dfMaxX, dfMinY, dfMaxY; + + poRL = GetLayerRasterReader( iLayer ); + if( poRL == NULL ) + continue; + + poRL->GetTransform( adfGeoTransform ); + + dfMinX = adfGeoTransform[0]; + dfMaxY = adfGeoTransform[3]; + dfMaxX = adfGeoTransform[0] + poRL->GetXSize()*adfGeoTransform[1]; + dfMinY = adfGeoTransform[3] + poRL->GetYSize()*adfGeoTransform[5]; + + if( bFirst ) + { + *pdfMinX = dfMinX; + *pdfMaxX = dfMaxX; + *pdfMinY = dfMinY; + *pdfMaxY = dfMaxY; + bFirst = FALSE; + } + else + { + *pdfMinX = MIN(dfMinX,*pdfMinX); + *pdfMaxX = MAX(dfMaxX,*pdfMaxX); + *pdfMinY = MIN(dfMinY,*pdfMinY); + *pdfMaxY = MAX(dfMaxY,*pdfMaxY); + } + + delete poRL; + } + } + + return !bFirst; +} + diff --git a/Utilities/GDAL/frmts/sdts/sdtsxref.cpp b/Utilities/GDAL/frmts/sdts/sdtsxref.cpp new file mode 100644 index 0000000000..a160474820 --- /dev/null +++ b/Utilities/GDAL/frmts/sdts/sdtsxref.cpp @@ -0,0 +1,114 @@ +/****************************************************************************** + * $Id: sdtsxref.cpp,v 1.4 2006/04/10 16:34:19 fwarmerdam Exp $ + * + * Project: SDTS Translator + * Purpose: Implementation of SDTS_XREF class for reading XREF module. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, 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: sdtsxref.cpp,v $ + * Revision 1.4 2006/04/10 16:34:19 fwarmerdam + * updated contact info + * + * Revision 1.3 2001/07/18 04:51:57 warmerda + * added CPL_CVSID + * + * Revision 1.2 2001/01/19 21:20:29 warmerda + * expanded tabs + * + * Revision 1.1 1999/06/03 14:02:36 warmerda + * New + * + */ + +#include "sdts_al.h" + +CPL_CVSID("$Id: sdtsxref.cpp,v 1.4 2006/04/10 16:34:19 fwarmerdam Exp $"); + +/************************************************************************/ +/* SDTS_XREF() */ +/************************************************************************/ + +SDTS_XREF::SDTS_XREF() + +{ + pszSystemName = CPLStrdup( "" ); + pszDatum = CPLStrdup( "" ); + nZone = 0; +} + +/************************************************************************/ +/* ~SDTS_XREF() */ +/************************************************************************/ + +SDTS_XREF::~SDTS_XREF() +{ + CPLFree( pszSystemName ); + CPLFree( pszDatum ); +} + +/************************************************************************/ +/* Read() */ +/* */ +/* Read the named file to initialize this structure. */ +/************************************************************************/ + +int SDTS_XREF::Read( const char * pszFilename ) + +{ + DDFModule oXREFFile; + DDFRecord *poRecord; + +/* -------------------------------------------------------------------- */ +/* Open the file, and read the header. */ +/* -------------------------------------------------------------------- */ + if( !oXREFFile.Open( pszFilename ) ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read the first record, and verify that this is an XREF record. */ +/* -------------------------------------------------------------------- */ + poRecord = oXREFFile.ReadRecord(); + if( poRecord == NULL ) + return FALSE; + + if( poRecord->GetStringSubfield( "XREF", 0, "MODN", 0 ) == NULL ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Read fields of interest. */ +/* -------------------------------------------------------------------- */ + + CPLFree( pszSystemName ); + pszSystemName = + CPLStrdup( poRecord->GetStringSubfield( "XREF", 0, "RSNM", 0 ) ); + + CPLFree( pszDatum ); + pszDatum = + CPLStrdup( poRecord->GetStringSubfield( "XREF", 0, "HDAT", 0 ) ); + + nZone = poRecord->GetIntSubfield( "XREF", 0, "ZONE", 0 ); + + return TRUE; +} diff --git a/Utilities/GDAL/frmts/usgsdem/CDED.notes b/Utilities/GDAL/frmts/usgsdem/CDED.notes new file mode 100644 index 0000000000..a332550caa --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/CDED.notes @@ -0,0 +1,106 @@ + + +Field Map +========= + + +Offset Length Name Notes +------ ------ ---- ----- + + 0 40 Filename Generated from output filename. + + 40 60 Producer of Data Template or blank. + + 100 9 Filler Blank + + 109 26 SW Geographic Corner Generated. + + 135 1 Process Code Template or blank. + + 136 1 Filler Blank + + 137 3 Sectional Indicator Template or blank. + + 140 4 Origin Code Template or blank. + + 144 6 DEM Level Code Template or blank. + "1" for PRODUCT=CDED50K + + 150 6 Elevation Pattern Hardcoded to "1" (regular) + + 156 6 Horizontal Reference Hardcoded to "0" (Geographic) + System + + 162 6 UTM/SP Zone Harcoded to "0". + + 168 360 Projection Parameters Each hardcoded to 0.0. + + 528 6 Horz. Unit of Measure Hardcoded to "3" (arc seconds) + + 534 6 Vert. Unit of Measure Hardcoded to "2" (meters) + + 540 6 Cov. Polygon Sides Hardcoded to "4". + + 546 192 Corner Coordinates Generated + + 738 24 Minimum Elevation Generated + + 762 24 Maximum Elevation Generated + + 786 24 Rotation Angle Hardcoded to "0". + + 810 6 Accurancy Code Hardcoded to "0" + + 816 36 Spatial Resolution X/Y generated, Z hardcoded to 1.0. + + 852 6 Rows of Profiles Hardcoded to "1". + + 858 6 Columns of Profiles Generated (height of dem in pixels) + + 864 12 Largest/Smallest Primary Blank + Contour Intervals and Units + + 876 4 Data source data Template or blank. + + 880 4 Data inspection or Template or blank. + revision date + + 884 1 Inspect. Revision Flag Template or blank. + + 885 1 Data Validation Flag Template or blank. + + 886 2 Suspect/Void Flag Generated (0=none,2=void area) + + 888 2 Vertical Datum Template or "1" (MSL). + + 890 2 Horizontal Datum Template or "4" (NAD83). + + 892 4 Data edition/version Template or blank. + Spec edition/version "1020" for PRODUCT=CDED50K + + 896 4 Percent Void Generated. + + 900 8 Edge Matching Flags Template or blank. + + 908 7 Vertical Datum Shift Hardcoded to "0.0". + + + +CDED Production Issues +====================== + +The following fields should be addressed in a template file. + +Offset Length Name Notes +------ ------ ---- ----- + + 40 60 Producer of Data + + 135 1 Process Code The CDED spec lists options as + "8" = ANUDEM + "9" = FME for LINUX, Build 842 + "A" = TopoGrid + + 140 4 Origin Code Should be "YT" in Yukon I believe. + + diff --git a/Utilities/GDAL/frmts/usgsdem/GNUmakefile b/Utilities/GDAL/frmts/usgsdem/GNUmakefile new file mode 100644 index 0000000000..fa61d033f6 --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/GNUmakefile @@ -0,0 +1,13 @@ + +include ../../GDALmake.opt + +OBJ = usgsdemdataset.o usgsdem_create.o + +CPPFLAGS := $(GDAL_INCLUDE) -I../../alg $(CPPFLAGS) + +default: $(OBJ) + +clean: + rm -f *.o + +install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/usgsdem/frmt_usgsdem.html b/Utilities/GDAL/frmts/usgsdem/frmt_usgsdem.html new file mode 100644 index 0000000000..b636ad09af --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/frmt_usgsdem.html @@ -0,0 +1,110 @@ +<html> +<head> +<title>USGSDEM -- USGS ASCII DEM (and CDED)</title> +</head> + +<body bgcolor="#ffffff"> + +<h1>USGSDEM -- USGS ASCII DEM (and CDED)</h1> + +GDAL includes support for reading USGS ASCII DEM files. This is the +traditional format used by USGS before being replaced by SDTS, and is the +format used for CDED DEM data products from the Canada. Most popular +variations on USGS DEM files should be supported, including correct +recognition of coordinate system, and georerenced positioning.<p> + +The 7.5 minute (UTM grid) USGS DEM files will generally have regions of +missing data around the edges, and these are properly marked with +a nodata value. Elevation values in USGS DEM files may be in meters or +feet, and this will be indicated by the return value of +GDALRasterBand::GetUnitType() (either "m" or "ft").<p> + +Note that USGS DEM files are represented as one big tile. This may cause +cache thrashing problems if the GDAL tile cache size is small. It will also +result in a substantial delay when the first pixel is read as the whole file +will be ingested. <p> + +Some of the code for implementing usgsdemdataset.cpp was derived from +VTP code by Ben Discoe. See the <a href="http://www.vterrain.org/">Virtual +Terrain</a> project for more information on VTP.<p> + +<h2>Creation Issues</h2> + +GDAL supports export of geographic (and UTM) USGS DEM and CDED data +files, including the ability to generate CDED 2.0 50K products to Canadian +federal govenment specifications. <p> + +Input data must already be sampled in a geographic or UTM coordinate +system. By default the entire area of the input file will be output, +but for CDED50K products the output file will be sampled at the +production specified resolution and on product tile boundaries.<P> + +If the input file has appropriate coordinate system information set, +export to specific product formats can take input in different coordinate +systems (ie. from Albers projection to NAD83 geographic for CDED50K +production).<p> + +Creation Options:<p> + +<ul> + +<li> <b>PRODUCT=CDED50K</b>: When selected, the output file will be forced to +adhere to CDED 50K product specifications. The output will always be 1201x1201 +and generally a 15 minute by 15 minute tile (though wider in longitude in +far north areas). <p> + +<li> <b>TOPLEFT=long,lat</b>: For CDED50K products, this is used to +specify the top left corner of the tile to be generated. It should be +on a 15 minute boundary and can be given in decimal degrees or degrees and +minutes (eg. TOPLEFT=117d15w,52d30n). <P> + +<li> <b>RESAMPLE=Nearest/Bilinear/Cubic/CubicSpline</b>: Set the resampling +kernel used for resampling the data to the target grid. Only has an effect +when particular products like CDED50K are being produced. Defaults to +Bilinear.<p> + +<li> <b>PRODUCER=text</b>: Up to 60 characters to be put into the producer +field of the generated file.<p> + +<li> <b>OriginCode=text</b>: Up to 4 characters to be put into the origin +code field of the generated file.<p> + +<li> <b>ProcessCode=code</b>: One character to be put into the process +code field of the generated file.<p> + +<li> <b>TEMPLATE=filename</b>: For any output file, a template file can be +specified. A number of fields (including the Data Producer) will be copied +from the template file if provided, and are otherwise left blank. + +<li> <b>ZRESOLUTION=float</b>: DEM's store elevation information as +positive integers, and these integers are scaled using the "z resolution." +By default, this resolution is written as 1.0. However, you may specify a +different resolution here, if you would like your integers to be scaled +into floating point numbers. + +</ul> + +Example: + +The following would generate a single CDED50K tile, extracting from the +larger DEM coverage yk_3arcsec for a tile with the top left corner -117w,60n. +The file yk_template.dem is used to set some product fields including the +Producer of Data, Process Code and Origin Code fields. + +<pre> +gdal_translate -of USGSDEM -co PRODUCT=CDED50K -co TEMPLATE=yk_template.dem \ + -co TOPLEFT=-117w,60n yk_3arcsec 031a01_e.dem +</pre> + +<hr> + +NOTE: Implemented as <tt>gdal/frmts/sdts/usgsdemdataset.cpp</tt>.<p> + +The USGS DEM reading code in GDAL was derived from the importer in the +<a href="http://www.vterrain.org/">VTP</a> software. The export capability +was developed with the financial support of the Yukon Department of +Environment.<p> + +</body> +</html> + diff --git a/Utilities/GDAL/frmts/usgsdem/makefile.vc b/Utilities/GDAL/frmts/usgsdem/makefile.vc new file mode 100644 index 0000000000..6f0c5ae8f2 --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/makefile.vc @@ -0,0 +1,15 @@ + +OBJ = usgsdemdataset.obj usgsdem_create.obj + +EXTRAFLAGS = -I..\..\alg + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/usgsdem/usgsdem_create.cpp b/Utilities/GDAL/frmts/usgsdem/usgsdem_create.cpp new file mode 100644 index 0000000000..2c45a4fda1 --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/usgsdem_create.cpp @@ -0,0 +1,1619 @@ +/****************************************************************************** + * $Id: usgsdem_create.cpp,v 1.22 2005/05/05 15:54:49 fwarmerdam Exp $ + * + * Project: USGS DEM Driver + * Purpose: CreateCopy() implementation. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + * This writing code based on the format specification: + * Canadian Digital Elevation Data Product Specification - Edition 2.0 + * + ****************************************************************************** + * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: usgsdem_create.cpp,v $ + * Revision 1.22 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.21 2005/03/29 20:56:32 fwarmerdam + * Ensure that DataSpecVersion can be overridden even if CDED50K product + * is selected. + * + * Revision 1.20 2005/03/23 20:30:57 fwarmerdam + * Fixed "east" check for NTS option case. + * + * Revision 1.19 2005/03/23 17:41:42 fwarmerdam + * added NTS and INTERNALNAME options for Matt + * + * Revision 1.18 2004/12/17 19:50:03 fwarmerdam + * Fixed last bug reference. + * + * Revision 1.17 2004/12/17 19:49:06 fwarmerdam + * Applied patch for min/max elevation values per bug 708. + * + * Revision 1.16 2004/12/10 21:59:55 fwarmerdam + * added ZRESOLUTION support from Hunter Blanks (bug 708) + * + * Revision 1.15 2004/11/21 22:13:54 fwarmerdam + * use new pointer encode/decode functions + * + * Revision 1.14 2004/09/01 19:10:32 warmerda + * added UTM support care of Hunter Blanks (newwireless.com) + * + * Revision 1.13 2004/05/11 00:40:45 warmerda + * fixed single precision resolution fields + * + * Revision 1.12 2004/05/03 14:13:42 warmerda + * fine tuned MSVC hack + * + * Revision 1.11 2004/05/03 13:45:33 warmerda + * correct old double formatting of MSVC++ (3 digit exponent) + * + * Revision 1.10 2004/04/29 13:46:46 warmerda + * flush CPLReadLine() memory + * + * Revision 1.9 2004/04/27 14:54:56 warmerda + * fixed filename checking, and DATAPOINTER support + * + * Revision 1.8 2004/04/23 20:27:24 warmerda + * completed mapsheet support for CDED50K + * + * Revision 1.7 2004/04/23 19:43:00 warmerda + * added partial NTS mapsheet db support + * + * Revision 1.6 2004/04/15 17:34:11 warmerda + * Left rather than right justify the origin code. + * + * Revision 1.5 2004/04/01 21:06:36 warmerda + * Added creation options for PRODUCER, OriginCode, and ProcessCode. + * Added support for reprojecting to NAD83. + * Fixed bug in A/B/C zone computation. + * + * Revision 1.4 2004/04/01 18:36:01 warmerda + * fixed rounding issue in testing quarter degree boundaries + * + * Revision 1.3 2004/03/28 21:23:06 warmerda + * minor nodata item + * + * Revision 1.2 2004/03/28 19:30:05 warmerda + * implement CDED50K product specs, use warper + * + * Revision 1.1 2004/03/27 17:02:00 warmerda + * New + * + */ + +#include "gdal_pam.h" +#include "ogr_spatialref.h" +#include "cpl_string.h" +#include "gdalwarper.h" +#include "cpl_csv.h" + +CPL_CVSID("$Id: usgsdem_create.cpp,v 1.22 2005/05/05 15:54:49 fwarmerdam Exp $"); + +typedef struct +{ + GDALDataset *poSrcDS; + char *pszFilename; + int nXSize, nYSize; + + char *pszDstSRS; + + double dfLLX, dfLLY; // These are adjusted in to center of + double dfULX, dfULY; // corner pixels, and in decimal degrees. + double dfURX, dfURY; + double dfLRX, dfLRY; + + int utmzone; + char horizdatum[2]; + + double dfHorizStepSize; + double dfVertStepSize; + double dfElevStepSize; + + char **papszOptions; + int bStrict; + + FILE *fp; + + GInt16 *panData; + +} USGSDEMWriteInfo; + +#define DEM_NODATA -32767 + +/************************************************************************/ +/* USGSDEMWriteCleanup() */ +/************************************************************************/ + +static void USGSDEMWriteCleanup( USGSDEMWriteInfo *psWInfo ) + +{ + CSLDestroy( psWInfo->papszOptions ); + CPLFree( psWInfo->pszDstSRS ); + CPLFree( psWInfo->pszFilename ); + if( psWInfo->fp != NULL ) + VSIFClose( psWInfo->fp ); + if( psWInfo->panData != NULL ) + VSIFree( psWInfo->panData ); +} + +/************************************************************************/ +/* USGSDEMDectoPackedDMS() */ +/************************************************************************/ +const char *USGSDEMDecToPackedDMS( double dfDec ) +{ + double dfSeconds; + int nDegrees, nMinutes, nSign; + static char szPackBuf[100]; + + nSign = ( dfDec < 0.0 )? -1 : 1; + + dfDec = ABS( dfDec ); + nDegrees = (int) floor( dfDec ); + nMinutes = (int) floor( ( dfDec - nDegrees ) * 60.0 ); + dfSeconds = (dfDec - nDegrees) * 3600.0 - nMinutes * 60.0; + + sprintf( szPackBuf, "%4d%2d%7.4f", + nSign * nDegrees, nMinutes, dfSeconds ); + return szPackBuf; +} + +/************************************************************************/ +/* TextFill() */ +/************************************************************************/ + +static void TextFill( char *pszTarget, unsigned int nMaxChars, + const char *pszSrc ) + +{ + if( strlen(pszSrc) < nMaxChars ) + { + memcpy( pszTarget, pszSrc, strlen(pszSrc) ); + memset( pszTarget + strlen(pszSrc), ' ', nMaxChars - strlen(pszSrc)); + } + else + { + memcpy( pszTarget, pszSrc, nMaxChars ); + } +} + +/************************************************************************/ +/* TextFillR() */ +/* */ +/* Right justified. */ +/************************************************************************/ + +static void TextFillR( char *pszTarget, unsigned int nMaxChars, + const char *pszSrc ) + +{ + if( strlen(pszSrc) < nMaxChars ) + { + memset( pszTarget, ' ', nMaxChars - strlen(pszSrc) ); + memcpy( pszTarget + nMaxChars - strlen(pszSrc), pszSrc, + strlen(pszSrc) ); + } + else + memcpy( pszTarget, pszSrc, nMaxChars ); +} + +/************************************************************************/ +/* USGSDEMPrintDouble() */ +/* */ +/* On MS Visual C++ system the C runtime library uses 3 digits */ +/* for the exponent. This causes various problems, so we try */ +/* to correct it here. */ +/************************************************************************/ + +#ifdef _MSC_VER +# define MSVC_HACK +#endif + +static void USGSDEMPrintDouble( char *pszBuffer, double dfValue ) + +{ +#define DOUBLE_BUFFER_SIZE 64 + + char szTemp[DOUBLE_BUFFER_SIZE]; + int i; +#ifdef MSVC_HACK + const char *pszFormat = "%25.15e"; +#else + const char *pszFormat = "%24.15e"; +#endif + + if ( !pszBuffer ) + return; + +#if defined(HAVE_SNPRINTF) + snprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ); +#else + sprintf( szTemp, pszFormat, dfValue ); +#endif + szTemp[DOUBLE_BUFFER_SIZE - 1] = '\0'; + + for( i = 0; szTemp[i] != '\0'; i++ ) + { + if( szTemp[i] == 'E' || szTemp[i] == 'e' ) + szTemp[i] = 'D'; +#ifdef MSVC_HACK + if( (szTemp[i] == '+' || szTemp[i] == '-') + && szTemp[i+1] == '0' && isdigit(szTemp[i+2]) + && isdigit(szTemp[i+3]) && szTemp[i+4] == '\0' ) + { + memmove( szTemp+i+1, szTemp+i+2, 2 ); + szTemp[i+3] = '\0'; + break; + } +#endif + } + + TextFillR( pszBuffer, 24, szTemp ); +} + +/************************************************************************/ +/* USGSDEMPrintSingle() */ +/* */ +/* On MS Visual C++ system the C runtime library uses 3 digits */ +/* for the exponent. This causes various problems, so we try */ +/* to correct it here. */ +/************************************************************************/ + +static void USGSDEMPrintSingle( char *pszBuffer, double dfValue ) + +{ +#define DOUBLE_BUFFER_SIZE 64 + + char szTemp[DOUBLE_BUFFER_SIZE]; + int i; +#ifdef MSVC_HACK + const char *pszFormat = "%13.6e"; +#else + const char *pszFormat = "%12.6e"; +#endif + + if ( !pszBuffer ) + return; + +#if defined(HAVE_SNPRINTF) + snprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ); +#else + sprintf( szTemp, pszFormat, dfValue ); +#endif + szTemp[DOUBLE_BUFFER_SIZE - 1] = '\0'; + + for( i = 0; szTemp[i] != '\0'; i++ ) + { + if( szTemp[i] == 'E' || szTemp[i] == 'e' ) + szTemp[i] = 'D'; +#ifdef MSVC_HACK + if( (szTemp[i] == '+' || szTemp[i] == '-') + && szTemp[i+1] == '0' && isdigit(szTemp[i+2]) + && isdigit(szTemp[i+3]) && szTemp[i+4] == '\0' ) + { + memmove( szTemp+i+1, szTemp+i+2, 2 ); + szTemp[i+3] = '\0'; + break; + } +#endif + } + + TextFillR( pszBuffer, 12, szTemp ); +} + +/************************************************************************/ +/* USGSDEMWriteARecord() */ +/************************************************************************/ + +static int USGSDEMWriteARecord( USGSDEMWriteInfo *psWInfo ) + +{ + char achARec[1024]; + int i; + const char *pszOption; + +/* -------------------------------------------------------------------- */ +/* Init to blanks. */ +/* -------------------------------------------------------------------- */ + memset( achARec, ' ', sizeof(achARec) ); + +/* -------------------------------------------------------------------- */ +/* Load template file, if one is indicated. */ +/* -------------------------------------------------------------------- */ + const char *pszTemplate = + CSLFetchNameValue( psWInfo->papszOptions, "TEMPLATE" ); + if( pszTemplate != NULL ) + { + FILE *fpTemplate; + + fpTemplate = VSIFOpen( pszTemplate, "rb" ); + if( fpTemplate == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Unable to open template file '%s'.\n%s", + pszTemplate, VSIStrerror( errno ) ); + return FALSE; + } + + if( VSIFRead( achARec, 1, 1024, fpTemplate ) != 1024 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Unable to read 1024 byte A Record from template file '%s'.\n%s", + pszTemplate, VSIStrerror( errno ) ); + return FALSE; + } + VSIFClose( fpTemplate ); + } + +/* -------------------------------------------------------------------- */ +/* Filename (right justify) */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 0, 40, CPLGetFilename( psWInfo->pszFilename ) ); + +/* -------------------------------------------------------------------- */ +/* Producer */ +/* -------------------------------------------------------------------- */ + pszOption = CSLFetchNameValue( psWInfo->papszOptions, "PRODUCER" ); + + if( pszOption != NULL ) + TextFillR( achARec + 40, 60, pszOption ); + + else if( pszTemplate == NULL ) + TextFill( achARec + 40, 60, "" ); + +/* -------------------------------------------------------------------- */ +/* Filler */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 100, 9, "" ); + +/* -------------------------------------------------------------------- */ +/* SW Geographic Corner - SDDDMMSS.SSSS - longitude then latitude */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + TextFill( achARec + 109, 13, + USGSDEMDecToPackedDMS( psWInfo->dfLLX ) ); // longitude + TextFill( achARec + 122, 13, + USGSDEMDecToPackedDMS( psWInfo->dfLLY ) ); // latitude + } + /* this may not be best according to the spec. But for now, + * we won't try to convert the UTM coordinates to lat/lon + */ + +/* -------------------------------------------------------------------- */ +/* Process code. */ +/* -------------------------------------------------------------------- */ + pszOption = CSLFetchNameValue( psWInfo->papszOptions, "ProcessCode" ); + + if( pszOption != NULL ) + TextFill( achARec + 135, 1, pszOption ); + + else if( pszTemplate == NULL ) + TextFill( achARec + 135, 1, " " ); + +/* -------------------------------------------------------------------- */ +/* Filler */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 136, 1, "" ); + +/* -------------------------------------------------------------------- */ +/* Sectional indicator */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 137, 3, "" ); + +/* -------------------------------------------------------------------- */ +/* Origin code */ +/* -------------------------------------------------------------------- */ + pszOption = CSLFetchNameValue( psWInfo->papszOptions, "OriginCode" ); + + if( pszOption != NULL ) + TextFill( achARec + 140, 4, pszOption ); // Should be YT for Yukon. + + else if( pszTemplate == NULL ) + TextFill( achARec + 140, 4, "" ); + +/* -------------------------------------------------------------------- */ +/* DEM level code (right justify) */ +/* -------------------------------------------------------------------- */ + pszOption = CSLFetchNameValue( psWInfo->papszOptions, "DEMLevelCode" ); + + if( pszOption != NULL ) + TextFillR( achARec + 144, 6, pszOption ); // 1, 2 or 3. + + else if( pszTemplate == NULL ) + TextFillR( achARec + 144, 6, "1" ); // 1, 2 or 3. + /* some DEM readers require a value, 1 seems to be a + * default + */ + +/* -------------------------------------------------------------------- */ +/* Elevation Pattern */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 150, 6, "1" ); // "1" for regular (random is 2) + +/* -------------------------------------------------------------------- */ +/* Horizontal Reference System. */ +/* */ +/* 0 = Geographic */ +/* 1 = UTM */ +/* 2 = Stateplane */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + TextFillR( achARec + 156, 6, "0" ); + } + else + { + TextFillR( achARec + 156, 6, "1" ); + } + +/* -------------------------------------------------------------------- */ +/* UTM / State Plane zone. */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + TextFillR( achARec + 162, 6, "0"); + } + else + { + TextFillR( achARec + 162, 6, + CPLSPrintf( "%02d", psWInfo->utmzone) ); + } + +/* -------------------------------------------------------------------- */ +/* Map Projection Parameters (all 0.0). */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < 15; i++ ) + TextFillR( achARec + 168 + i*24, 24, "0.0" ); + +/* -------------------------------------------------------------------- */ +/* Horizontal Unit of Measure */ +/* 0 = radians */ +/* 1 = feet */ +/* 2 = meters */ +/* 3 = arc seconds */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + TextFillR( achARec + 528, 6, "3" ); + } + else + { + TextFillR( achARec + 528, 6, "2" ); + } + +/* -------------------------------------------------------------------- */ +/* Vertical unit of measure. */ +/* 1 = feet */ +/* 2 = meters */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 534, 6, "2" ); + +/* -------------------------------------------------------------------- */ +/* Number of sides in coverage polygon (always 4) */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 540, 6, "4" ); + +/* -------------------------------------------------------------------- */ +/* 4 corner coordinates: SW, NW, NE, SE */ +/* Corners are in 24.15 format in arc seconds. */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + // SW - longitude + USGSDEMPrintDouble( achARec + 546, psWInfo->dfLLX * 3600.0 ); + // SW - latitude + USGSDEMPrintDouble( achARec + 570, psWInfo->dfLLY * 3600.0 ); + + // NW - longitude + USGSDEMPrintDouble( achARec + 594, psWInfo->dfULX * 3600.0 ); + // NW - latitude + USGSDEMPrintDouble( achARec + 618, psWInfo->dfULY * 3600.0 ); + + // NE - longitude + USGSDEMPrintDouble( achARec + 642, psWInfo->dfURX * 3600.0 ); + // NE - latitude + USGSDEMPrintDouble( achARec + 666, psWInfo->dfURY * 3600.0 ); + + // SE - longitude + USGSDEMPrintDouble( achARec + 690, psWInfo->dfLRX * 3600.0 ); + // SE - latitude + USGSDEMPrintDouble( achARec + 714, psWInfo->dfLRY * 3600.0 ); + } + else + { + // SW - easting + USGSDEMPrintDouble( achARec + 546, psWInfo->dfLLX ); + // SW - northing + USGSDEMPrintDouble( achARec + 570, psWInfo->dfLLY ); + + // NW - easting + USGSDEMPrintDouble( achARec + 594, psWInfo->dfULX ); + // NW - northing + USGSDEMPrintDouble( achARec + 618, psWInfo->dfULY ); + + // NE - easting + USGSDEMPrintDouble( achARec + 642, psWInfo->dfURX ); + // NE - northing + USGSDEMPrintDouble( achARec + 666, psWInfo->dfURY ); + + // SE - easting + USGSDEMPrintDouble( achARec + 690, psWInfo->dfLRX ); + // SE - northing + USGSDEMPrintDouble( achARec + 714, psWInfo->dfLRY ); + } + +/* -------------------------------------------------------------------- */ +/* Minimum and Maximum elevations for this cell. */ +/* 24.15 format. */ +/* -------------------------------------------------------------------- */ + GInt16 nMin = DEM_NODATA, nMax = DEM_NODATA; + int nVoid = 0; + + for( i = psWInfo->nXSize*psWInfo->nYSize-1; i >= 0; i-- ) + { + if( psWInfo->panData[i] != DEM_NODATA ) + { + if( nMin == DEM_NODATA ) + { + nMin = nMax = psWInfo->panData[i]; + } + else + { + nMin = MIN(nMin,psWInfo->panData[i]); + nMax = MAX(nMax,psWInfo->panData[i]); + } + } + else + nVoid++; + } + + /* take into account z resolutions that are not 1.0 */ + nMin = (int) floor(nMin * psWInfo->dfElevStepSize); + nMax = (int) ceil(nMax * psWInfo->dfElevStepSize); + + USGSDEMPrintDouble( achARec + 738, (double) nMin ); + USGSDEMPrintDouble( achARec + 762, (double) nMax ); + +/* -------------------------------------------------------------------- */ +/* Counter Clockwise angle (in radians). Normally 0 */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 786, 24, "0.0" ); + +/* -------------------------------------------------------------------- */ +/* Accurancy code for elevations. 0 means there will be no C */ +/* record. */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 810, 6, "0" ); + +/* -------------------------------------------------------------------- */ +/* Spatial Resolution (x, y and z). 12.6 format. */ +/* -------------------------------------------------------------------- */ + if ( ! psWInfo->utmzone ) + { + USGSDEMPrintSingle( achARec + 816, + psWInfo->dfHorizStepSize*3600.0 ); + USGSDEMPrintSingle( achARec + 828, + psWInfo->dfVertStepSize*3600.0 ); + } + else + { + USGSDEMPrintSingle( achARec + 816, + psWInfo->dfHorizStepSize ); + USGSDEMPrintSingle( achARec + 828, + psWInfo->dfVertStepSize ); + } + + USGSDEMPrintSingle( achARec + 840, psWInfo->dfElevStepSize); + +/* -------------------------------------------------------------------- */ +/* Rows and Columns of profiles. */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 852, 6, CPLSPrintf( "%d", 1 ) ); + TextFillR( achARec + 858, 6, CPLSPrintf( "%d", psWInfo->nXSize ) ); + +/* -------------------------------------------------------------------- */ +/* Largest primary contour interval (blank). */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 864, 5, "" ); + +/* -------------------------------------------------------------------- */ +/* Largest source contour internal unit (blank). */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 869, 1, "" ); + +/* -------------------------------------------------------------------- */ +/* Smallest primary contour interval. */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 870, 5, "" ); + +/* -------------------------------------------------------------------- */ +/* Smallest source contour interval unit. */ +/* -------------------------------------------------------------------- */ + TextFill( achARec + 875, 1, "" ); + +/* -------------------------------------------------------------------- */ +/* Data source data - YYMM */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 876, 4, "" ); + +/* -------------------------------------------------------------------- */ +/* Data inspection/revision data (YYMM). */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 880, 4, "" ); + +/* -------------------------------------------------------------------- */ +/* Inspection revision flag (I or R) (blank) */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 884, 1, "" ); + +/* -------------------------------------------------------------------- */ +/* Data validation flag. */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 885, 1, "" ); + +/* -------------------------------------------------------------------- */ +/* Suspect and void area flag. */ +/* 0 = none */ +/* 1 = suspect areas */ +/* 2 = void areas */ +/* 3 = suspect and void areas */ +/* -------------------------------------------------------------------- */ + if( nVoid > 0 ) + TextFillR( achARec + 886, 2, "2" ); + else + TextFillR( achARec + 886, 2, "0" ); + +/* -------------------------------------------------------------------- */ +/* Vertical datum */ +/* 1 = MSL */ +/* 2 = NGVD29 */ +/* 3 = NAVD88 */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFillR( achARec + 888, 2, "1" ); + +/* -------------------------------------------------------------------- */ +/* Horizonal Datum */ +/* 1 = NAD27 */ +/* 2 = WGS72 */ +/* 3 = WGS84 */ +/* 4 = NAD83 */ +/* -------------------------------------------------------------------- */ + if( strlen( psWInfo->horizdatum ) == 0) { + if( pszTemplate == NULL ) + TextFillR( achARec + 890, 2, "4" ); + } + else + { + if( pszTemplate == NULL ) + TextFillR( achARec + 890, 2, psWInfo->horizdatum ); + } + +/* -------------------------------------------------------------------- */ +/* Data edition/version, specification edition/version. */ +/* -------------------------------------------------------------------- */ + pszOption = CSLFetchNameValue( psWInfo->papszOptions, "DataSpecVersion" ); + + if( pszOption != NULL ) + TextFill( achARec + 892, 4, pszOption ); + + else if( pszTemplate == NULL ) + TextFill( achARec + 892, 4, "" ); + +/* -------------------------------------------------------------------- */ +/* Percent void. */ +/* */ +/* Round to nearest integer percentage. */ +/* -------------------------------------------------------------------- */ + int nPercent; + + nPercent = (int) + (((nVoid * 100.0) / (psWInfo->nXSize * psWInfo->nYSize)) + 0.5); + + TextFillR( achARec + 896, 4, CPLSPrintf( "%4d", nPercent ) ); + +/* -------------------------------------------------------------------- */ +/* Edge matching flags. */ +/* -------------------------------------------------------------------- */ + if( pszTemplate == NULL ) + TextFill( achARec + 900, 8, "" ); + +/* -------------------------------------------------------------------- */ +/* Vertical datum shift (F7.2). */ +/* -------------------------------------------------------------------- */ + TextFillR( achARec + 908, 7, "" ); + +/* -------------------------------------------------------------------- */ +/* Write to file. */ +/* -------------------------------------------------------------------- */ + if( VSIFWrite( achARec, 1, 1024, psWInfo->fp ) != 1024 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Error writing DEM/CDED A record.\n%s", + VSIStrerror( errno ) ); + return FALSE; + } + + return TRUE; +} + +/************************************************************************/ +/* USGSDEMWriteProfile() */ +/* */ +/* Write B logical record. Split into 1024 byte chunks. */ +/************************************************************************/ + +static int USGSDEMWriteProfile( USGSDEMWriteInfo *psWInfo, int iProfile ) + +{ + char achBuffer[1024]; + + memset( achBuffer, ' ', sizeof(achBuffer) ); + +/* -------------------------------------------------------------------- */ +/* Row #. */ +/* -------------------------------------------------------------------- */ + TextFillR( achBuffer + 0, 6, "1" ); + +/* -------------------------------------------------------------------- */ +/* Column #. */ +/* -------------------------------------------------------------------- */ + TextFillR( achBuffer + 6, 6, CPLSPrintf( "%d", iProfile + 1 ) ); + +/* -------------------------------------------------------------------- */ +/* Number of data items. */ +/* -------------------------------------------------------------------- */ + TextFillR( achBuffer + 12, 6, CPLSPrintf( "%d", psWInfo->nYSize ) ); + TextFillR( achBuffer + 18, 6, "1" ); + +/* -------------------------------------------------------------------- */ +/* Location of center of bottom most sample in profile. */ +/* Format D24.15. In arc-seconds if geographic, meters */ +/* if UTM. */ +/* -------------------------------------------------------------------- */ + if( ! psWInfo->utmzone ) + { + // longitude + USGSDEMPrintDouble( achBuffer + 24, + 3600 * (psWInfo->dfLLX + + iProfile * psWInfo->dfHorizStepSize) ); + + // latitude + USGSDEMPrintDouble( achBuffer + 48, psWInfo->dfLLY * 3600.0 ); + } + else + { + // easting + USGSDEMPrintDouble( achBuffer + 24, + (psWInfo->dfLLX + + iProfile * psWInfo->dfHorizStepSize) ); + + // northing + USGSDEMPrintDouble( achBuffer + 48, psWInfo->dfLLY ); + } + + +/* -------------------------------------------------------------------- */ +/* Local vertical datum offset. */ +/* -------------------------------------------------------------------- */ + TextFillR( achBuffer + 72, 24, "0.000000D+00" ); + +/* -------------------------------------------------------------------- */ +/* Min/Max elevation values for this profile. */ +/* -------------------------------------------------------------------- */ + int iY; + GInt16 nMin = DEM_NODATA, nMax = DEM_NODATA; + + for( iY = 0; iY < psWInfo->nYSize; iY++ ) + { + int iData = (psWInfo->nYSize-iY-1) * psWInfo->nXSize + iProfile; + + if( psWInfo->panData[iData] != DEM_NODATA ) + { + if( nMin == DEM_NODATA ) + { + nMin = nMax = psWInfo->panData[iData]; + } + else + { + nMin = MIN(nMin,psWInfo->panData[iData]); + nMax = MAX(nMax,psWInfo->panData[iData]); + } + } + } + + /* take into account z resolutions that are not 1.0 */ + nMin = (int) floor(nMin * psWInfo->dfElevStepSize); + nMax = (int) ceil(nMax * psWInfo->dfElevStepSize); + + USGSDEMPrintDouble( achBuffer + 96, (double) nMin ); + USGSDEMPrintDouble( achBuffer + 120, (double) nMax ); + +/* -------------------------------------------------------------------- */ +/* Output all the actually elevation values, flushing blocks */ +/* when they fill up. */ +/* -------------------------------------------------------------------- */ + int iOffset = 144; + + for( iY = 0; iY < psWInfo->nYSize; iY++ ) + { + int iData = (psWInfo->nYSize-iY-1) * psWInfo->nXSize + iProfile; + char szWord[10]; + + if( iOffset + 6 > 1024 ) + { + if( VSIFWrite( achBuffer, 1, 1024, psWInfo->fp ) != 1024 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failure writing profile to disk.\n%s", + VSIStrerror( errno ) ); + return FALSE; + } + iOffset = 0; + memset( achBuffer, ' ', 1024 ); + } + + sprintf( szWord, "%d", psWInfo->panData[iData] ); + TextFillR( achBuffer + iOffset, 6, szWord ); + + iOffset += 6; + } + +/* -------------------------------------------------------------------- */ +/* Flush final partial block. */ +/* -------------------------------------------------------------------- */ + if( VSIFWrite( achBuffer, 1, 1024, psWInfo->fp ) != 1024 ) + { + CPLError( CE_Failure, CPLE_FileIO, + "Failure writing profile to disk.\n%s", + VSIStrerror( errno ) ); + return FALSE; + } + + return TRUE; +} + +/************************************************************************/ +/* USGSDEM_LookupNTSByLoc() */ +/************************************************************************/ + +static int +USGSDEM_LookupNTSByLoc( double dfULLong, double dfULLat, + char *pszTile, char *pszName ) + +{ +/* -------------------------------------------------------------------- */ +/* Access NTS 1:50k sheet CSV file. */ +/* -------------------------------------------------------------------- */ + const char *pszNTSFilename = CSVFilename( "NTS-50kindex.csv" ); + FILE *fpNTS; + + fpNTS = VSIFOpen( pszNTSFilename, "rb" ); + if( fpNTS == NULL ) + { + CPLDebug( "Unable to find NTS mapsheet lookup file: %s", + pszNTSFilename ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Skip column titles line. */ +/* -------------------------------------------------------------------- */ + CSLDestroy( CSVReadParseLine( fpNTS ) ); + +/* -------------------------------------------------------------------- */ +/* Find desired sheet. */ +/* -------------------------------------------------------------------- */ + int bGotHit = FALSE; + char **papszTokens; + + while( !bGotHit + && (papszTokens = CSVReadParseLine( fpNTS )) != NULL ) + { + if( CSLCount( papszTokens ) != 4 ) + continue; + + if( ABS(dfULLong - atof(papszTokens[2])) < 0.01 + && ABS(dfULLat - atof(papszTokens[3])) < 0.01 ) + { + bGotHit = TRUE; + strncpy( pszTile, papszTokens[0], 7 ); + if( pszName != NULL ) + strncpy( pszName, papszTokens[1], 100 ); + } + + CSLDestroy( papszTokens ); + } + + VSIFClose( fpNTS ); + + return bGotHit; +} + +/************************************************************************/ +/* USGSDEM_LookupNTSByTile() */ +/************************************************************************/ + +static int +USGSDEM_LookupNTSByTile( const char *pszTile, char *pszName, + double *pdfULLong, double *pdfULLat ) + +{ +/* -------------------------------------------------------------------- */ +/* Access NTS 1:50k sheet CSV file. */ +/* -------------------------------------------------------------------- */ + const char *pszNTSFilename = CSVFilename( "NTS-50kindex.csv" ); + FILE *fpNTS; + + fpNTS = VSIFOpen( pszNTSFilename, "rb" ); + if( fpNTS == NULL ) + { + CPLDebug( "Unable to find NTS mapsheet lookup file: %s", + pszNTSFilename ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Skip column titles line. */ +/* -------------------------------------------------------------------- */ + CSLDestroy( CSVReadParseLine( fpNTS ) ); + +/* -------------------------------------------------------------------- */ +/* Find desired sheet. */ +/* -------------------------------------------------------------------- */ + int bGotHit = FALSE; + char **papszTokens; + + while( !bGotHit + && (papszTokens = CSVReadParseLine( fpNTS )) != NULL ) + { + if( CSLCount( papszTokens ) != 4 ) + continue; + + if( EQUAL(pszTile,papszTokens[0]) ) + { + bGotHit = TRUE; + if( pszName != NULL ) + strncpy( pszName, papszTokens[1], 100 ); + *pdfULLong = atof(papszTokens[2]); + *pdfULLat = atof(papszTokens[3]); + } + + CSLDestroy( papszTokens ); + } + + VSIFClose( fpNTS ); + + return bGotHit; +} + +/************************************************************************/ +/* USGSDEMProductSetup_CDED50K() */ +/************************************************************************/ + +static int USGSDEMProductSetup_CDED50K( USGSDEMWriteInfo *psWInfo ) + +{ +/* -------------------------------------------------------------------- */ +/* Fetch TOPLEFT location so we know what cell we are dealing */ +/* with. */ +/* -------------------------------------------------------------------- */ + const char *pszNTS = + CSLFetchNameValue( psWInfo->papszOptions, "NTS" ); + const char *pszTOPLEFT = CSLFetchNameValue( psWInfo->papszOptions, + "TOPLEFT" ); + double dfULX = (psWInfo->dfULX+psWInfo->dfURX)*0.5; + double dfULY = (psWInfo->dfULY+psWInfo->dfURY)*0.5; + + // Have we been given an explicit NTS mapsheet name? + if( pszNTS != NULL ) + { + char szTrimmedTile[7]; + + strncpy( szTrimmedTile, pszNTS, 6 ); + szTrimmedTile[6] = '\0'; + + if( !USGSDEM_LookupNTSByTile( szTrimmedTile, NULL, &dfULX, &dfULY ) ) + return FALSE; + + if( EQUALN(pszNTS+6,"e",1) ) + dfULX += 0.25; + } + + // Try looking up TOPLEFT as a NTS mapsheet name. + else if( pszTOPLEFT != NULL && strstr(pszTOPLEFT,",") == NULL + && (strlen(pszTOPLEFT) == 6 || strlen(pszTOPLEFT) == 7) ) + { + char szTrimmedTile[7]; + + strncpy( szTrimmedTile, pszTOPLEFT, 6 ); + szTrimmedTile[6] = '\0'; + + if( !USGSDEM_LookupNTSByTile( szTrimmedTile, NULL, &dfULX, &dfULY ) ) + return FALSE; + + if( EQUAL(pszTOPLEFT+6,"e") ) + dfULX += 0.25; + } + + // Assume TOPLEFT is a long/lat corner. + else if( pszTOPLEFT != NULL ) + { + char **papszTokens = CSLTokenizeString2( pszTOPLEFT, ",", 0 ); + + if( CSLCount( papszTokens ) != 2 ) + { + CSLDestroy( papszTokens ); + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to parse TOPLEFT, should have form like '138d15W,59d0N'." ); + return FALSE; + } + + dfULX = CPLDMSToDec( papszTokens[0] ); + dfULY = CPLDMSToDec( papszTokens[1] ); + CSLDestroy( papszTokens ); + + if( ABS(dfULX*4-floor(dfULX*4+0.00005)) > 0.0001 + || ABS(dfULY*4-floor(dfULY*4+0.00005)) > 0.0001 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "TOPLEFT must be on a 15\" boundary for CDED50K, but is not." ); + return FALSE; + } + } + else if( strlen(psWInfo->pszFilename) == 12 + && psWInfo->pszFilename[6] == '_' + && EQUAL(psWInfo->pszFilename+8,".dem") ) + { + char szTrimmedTile[7]; + + strncpy( szTrimmedTile, psWInfo->pszFilename, 6 ); + szTrimmedTile[6] = '\0'; + + if( !USGSDEM_LookupNTSByTile( szTrimmedTile, NULL, &dfULX, &dfULY ) ) + return FALSE; + + if( EQUALN(psWInfo->pszFilename+7,"e",1) ) + dfULX += 0.25; + } + + else if( strlen(psWInfo->pszFilename) == 14 + && EQUALN(psWInfo->pszFilename+6,"DEM",3) + && EQUAL(psWInfo->pszFilename+10,".dem") ) + { + char szTrimmedTile[7]; + + strncpy( szTrimmedTile, psWInfo->pszFilename, 6 ); + szTrimmedTile[6] = '\0'; + + if( !USGSDEM_LookupNTSByTile( szTrimmedTile, NULL, &dfULX, &dfULY ) ) + return FALSE; + + if( EQUALN(psWInfo->pszFilename+9,"e",1) ) + dfULX += 0.25; + } + +/* -------------------------------------------------------------------- */ +/* Set resolution and size information. */ +/* -------------------------------------------------------------------- */ + + dfULX = floor( dfULX * 4 + 0.00005 ) / 4.0; + dfULY = floor( dfULY * 4 + 0.00005 ) / 4.0; + + psWInfo->nXSize = 1201; + psWInfo->nYSize = 1201; + psWInfo->dfVertStepSize = 0.75 / 3600.0; + + /* Region A */ + if( dfULY < 68.1 ) + { + psWInfo->dfHorizStepSize = 0.75 / 3600.0; + } + + /* Region B */ + else if( dfULY < 80.1 ) + { + psWInfo->dfHorizStepSize = 1.5 / 3600.0; + dfULX = floor( dfULX * 2 + 0.001 ) / 2.0; + } + + /* Region C */ + else + { + psWInfo->dfHorizStepSize = 3.0 / 3600.0; + dfULX = floor( dfULX + 0.001 ); + } + +/* -------------------------------------------------------------------- */ +/* Set bounds based on this top left anchor. */ +/* -------------------------------------------------------------------- */ + + psWInfo->dfULX = dfULX; + psWInfo->dfULY = dfULY; + psWInfo->dfLLX = dfULX; + psWInfo->dfLLY = dfULY - 0.25; + psWInfo->dfURX = dfULX + psWInfo->dfHorizStepSize * 1200.0; + psWInfo->dfURY = dfULY; + psWInfo->dfLRX = dfULX + psWInfo->dfHorizStepSize * 1200.0; + psWInfo->dfLRY = dfULY - 0.25; + +/* -------------------------------------------------------------------- */ +/* Can we find the NTS 50k tile name that corresponds with */ +/* this? */ +/* -------------------------------------------------------------------- */ + const char *pszINTERNAL = + CSLFetchNameValue( psWInfo->papszOptions, "INTERNALNAME" ); + char szTile[10]; + char chEWFlag = ' '; + + if( USGSDEM_LookupNTSByLoc( dfULX, dfULY, szTile, NULL ) ) + { + chEWFlag = 'w'; + } + else if( USGSDEM_LookupNTSByLoc( dfULX-0.25, dfULY, szTile, NULL ) ) + { + chEWFlag = 'e'; + } + + if( pszINTERNAL != NULL ) + { + CPLFree( psWInfo->pszFilename ); + psWInfo->pszFilename = CPLStrdup( pszINTERNAL ); + } + else if( chEWFlag != ' ' ) + { + CPLFree( psWInfo->pszFilename ); + psWInfo->pszFilename = + CPLStrdup( CPLSPrintf("%sDEM%c", szTile, chEWFlag ) ); + } + else + { + const char *pszBasename = CPLGetFilename( psWInfo->pszFilename); + if( !EQUALN(pszBasename+6,"DEM",3) + || strlen(pszBasename) != 10 ) + CPLError( CE_Warning, CPLE_AppDefined, + "Internal filename required to be of 'nnnannDEMz', the output\n" + "filename is not of the required format, and the tile could not be\n" + "identified in the NTS mapsheet list (or the NTS mapsheet could not\n" + "be found). Correct output filename for correct CDED production." ); + } + +/* -------------------------------------------------------------------- */ +/* Set some specific options for CDED 50K. */ +/* -------------------------------------------------------------------- */ + psWInfo->papszOptions = + CSLSetNameValue( psWInfo->papszOptions, "DEMLevelCode", "1" ); + + if( CSLFetchNameValue( psWInfo->papszOptions, "DataSpecVersion" ) == NULL ) + psWInfo->papszOptions = + CSLSetNameValue( psWInfo->papszOptions, "DataSpecVersion", + "1020" ); + +/* -------------------------------------------------------------------- */ +/* Set the destination coordinate system. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference oSRS; + oSRS.SetWellKnownGeogCS( "NAD83" ); + strncpy( psWInfo->horizdatum, "4", 2 ); //USGS DEM code for NAD83 + + oSRS.exportToWkt( &(psWInfo->pszDstSRS) ); + +/* -------------------------------------------------------------------- */ +/* Cleanup. */ +/* -------------------------------------------------------------------- */ + CPLReadLine( NULL ); + + return TRUE; +} + +/************************************************************************/ +/* USGSDEMProductSetup_DEFAULT() */ +/* */ +/* Sets up the new DEM dataset parameters, using the source */ +/* dataset's parameters. If the source dataset uses UTM or */ +/* geographic coordinates, the coordinate system is carried over */ +/* to the new DEM file's parameters. If the source dataset has a */ +/* DEM compatible horizontal datum, the datum is carried over. */ +/* Otherwise, the DEM dataset is configured to use geographic */ +/* coordinates and a default datum. */ +/* (Hunter Blanks, 8/31/04, hblanks@artifex.org) */ +/************************************************************************/ + +static int USGSDEMProductSetup_DEFAULT( USGSDEMWriteInfo *psWInfo ) + +{ + +/* -------------------------------------------------------------------- */ +/* Set the destination coordinate system. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference DstoSRS; + OGRSpatialReference SrcoSRS; + char *sourceWkt; + int bNorth = TRUE; + /* XXX here we are assume (!) northern hemisphere UTM datasets */ + char **readSourceWkt; + int i; + int numdatums = 4; + const char DatumCodes[4][2] = { "1", "2", "3", "4" }; + char Datums[4][6] = { "NAD27", "WGS72", "WGS84", + "NAD83" }; + + /* get the source dataset's projection */ + sourceWkt = (char *) psWInfo->poSrcDS->GetProjectionRef(); + readSourceWkt = &sourceWkt; + if (SrcoSRS.importFromWkt(readSourceWkt) != OGRERR_NONE) + { + CPLError( CE_Failure, CPLE_AppDefined, + "DEM Default Setup: Importing source dataset projection failed" ); + return FALSE; + } + + /* Set the destination dataset's projection. If the source datum + * used is DEM compatible, just use it. Otherwise, default to the + * last datum in the Datums array. + */ + for( i=0; i < numdatums; i++ ) + { + if (DstoSRS.SetWellKnownGeogCS(Datums[i]) != OGRERR_NONE) + { + CPLError( CE_Failure, CPLE_AppDefined, + "DEM Default Setup: Failed to set datum of destination" ); + return FALSE; + } + /* XXX Hopefully it's ok, to just keep changing the projection + * of our destination. If not, we'll want to reinitialize the + * OGRSpatialReference each time. + */ + if ( DstoSRS.IsSameGeogCS( &SrcoSRS ) ) + { + break; + } + } + strncpy( psWInfo->horizdatum, DatumCodes[i], 2 ); + + /* get the UTM zone, if any */ + psWInfo->utmzone = SrcoSRS.GetUTMZone(&bNorth); + if (psWInfo->utmzone) + { + if (DstoSRS.SetUTM(psWInfo->utmzone) != OGRERR_NONE) + { + CPLError( CE_Failure, CPLE_AppDefined, + "DEM Default Setup: Failed to set utm zone of destination" ); + /* SetUTM isn't documented to return OGRERR_NONE + * on success, but it does, so, we'll check for it. + */ + return FALSE; + } + } + + /* export the projection to sWInfo */ + if (DstoSRS.exportToWkt( &(psWInfo->pszDstSRS) ) != OGRERR_NONE) + { + CPLError( CE_Failure, CPLE_AppDefined, + "UTMDEM: Failed to export destination Wkt to psWInfo" ); + } + return TRUE; +} + +/************************************************************************/ +/* USGSDEMLoadRaster() */ +/* */ +/* Loads the raster from the source dataset (not normally USGS */ +/* DEM) into memory. If nodata is marked, a special effort is */ +/* made to translate it properly into the USGS nodata value. */ +/************************************************************************/ + +static int USGSDEMLoadRaster( USGSDEMWriteInfo *psWInfo, + GDALRasterBand *poSrcBand ) + +{ + CPLErr eErr; + int i; + +/* -------------------------------------------------------------------- */ +/* Allocate output array, and pre-initialize to NODATA value. */ +/* -------------------------------------------------------------------- */ + psWInfo->panData = + (GInt16 *) VSIMalloc( 2 * psWInfo->nXSize * psWInfo->nYSize ); + if( psWInfo->panData == NULL ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "Out of memory allocating %d byte internal copy of DEM.", + 2 * psWInfo->nXSize * psWInfo->nYSize ); + return FALSE; + } + + for( i = 0; i < psWInfo->nXSize * psWInfo->nYSize; i++ ) + psWInfo->panData[i] = DEM_NODATA; + +/* -------------------------------------------------------------------- */ +/* Make a "memory dataset" wrapper for this data array. */ +/* -------------------------------------------------------------------- */ + GDALDriver *poMemDriver = (GDALDriver *) GDALGetDriverByName( "MEM" ); + GDALDataset *poMemDS; + + if( poMemDriver == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to find MEM driver." ); + return FALSE; + } + + poMemDS = + poMemDriver->Create( "USGSDEM_temp", psWInfo->nXSize, psWInfo->nYSize, + 0, GDT_Int16, NULL ); + if( poMemDS == NULL ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Now add the array itself as a band. */ +/* -------------------------------------------------------------------- */ + char szDataPointer[100]; + char *apszOptions[] = { szDataPointer, NULL }; + + memset( szDataPointer, 0, sizeof(szDataPointer) ); + sprintf( szDataPointer, "DATAPOINTER=" ); + CPLPrintPointer( szDataPointer+strlen(szDataPointer), + psWInfo->panData, + sizeof(szDataPointer) - strlen(szDataPointer) ); + + if( poMemDS->AddBand( GDT_Int16, apszOptions ) != CE_None ) + return FALSE; + +/* -------------------------------------------------------------------- */ +/* Assign geotransform and nodata indicators. */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + + adfGeoTransform[0] = psWInfo->dfULX - psWInfo->dfHorizStepSize * 0.5; + adfGeoTransform[1] = psWInfo->dfHorizStepSize; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = psWInfo->dfULY + psWInfo->dfVertStepSize * 0.5; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = -psWInfo->dfVertStepSize; + + poMemDS->SetGeoTransform( adfGeoTransform ); + +/* -------------------------------------------------------------------- */ +/* Set coordinate system if we have a special one to set. */ +/* -------------------------------------------------------------------- */ + if( psWInfo->pszDstSRS ) + poMemDS->SetProjection( psWInfo->pszDstSRS ); + +/* -------------------------------------------------------------------- */ +/* Establish the resampling kernel to use. */ +/* -------------------------------------------------------------------- */ + GDALResampleAlg eResampleAlg = GRA_Bilinear; + const char *pszResample = CSLFetchNameValue( psWInfo->papszOptions, + "RESAMPLE" ); + + if( pszResample == NULL ) + /* bilinear */; + else if( EQUAL(pszResample,"Nearest") ) + eResampleAlg = GRA_NearestNeighbour; + else if( EQUAL(pszResample,"Bilinear") ) + eResampleAlg = GRA_Bilinear; + else if( EQUAL(pszResample,"Cubic") ) + eResampleAlg = GRA_Cubic; + else if( EQUAL(pszResample,"CubicSpline") ) + eResampleAlg = GRA_CubicSpline; + else + { + CPLError( CE_Failure, CPLE_NotSupported, + "RESAMPLE=%s, not a supported resampling kernel.", + pszResample ); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Perform a warp from source dataset to destination buffer */ +/* (memory dataset). */ +/* -------------------------------------------------------------------- */ + eErr = GDALReprojectImage( (GDALDatasetH) psWInfo->poSrcDS, + psWInfo->poSrcDS->GetProjectionRef(), + (GDALDatasetH) poMemDS, + psWInfo->pszDstSRS, + eResampleAlg, 0.0, 0.0, NULL, NULL, + NULL ); + +/* -------------------------------------------------------------------- */ +/* Deallocate memory wrapper for the buffer. */ +/* -------------------------------------------------------------------- */ + delete poMemDS; + + return eErr == CE_None; +} + + +/************************************************************************/ +/* CreateCopy() */ +/************************************************************************/ + +GDALDataset * +USGSDEMCreateCopy( const char *pszFilename, GDALDataset *poSrcDS, + int bStrict, char **papszOptions, + GDALProgressFunc pfnProgress, void * pProgressData ) + +{ + USGSDEMWriteInfo sWInfo; + + if( poSrcDS->GetRasterCount() != 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to create multi-band USGS DEM / CDED files." ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Capture some preliminary information. */ +/* -------------------------------------------------------------------- */ + memset( &sWInfo, 0, sizeof(sWInfo) ); + + sWInfo.poSrcDS = poSrcDS; + sWInfo.pszFilename = CPLStrdup(pszFilename); + sWInfo.nXSize = poSrcDS->GetRasterXSize(); + sWInfo.nYSize = poSrcDS->GetRasterYSize(); + sWInfo.papszOptions = CSLDuplicate( papszOptions ); + sWInfo.bStrict = bStrict; + sWInfo.utmzone = 0; + strncpy( sWInfo.horizdatum, "", 1 ); + +/* -------------------------------------------------------------------- */ +/* Work out corner coordinates. */ +/* -------------------------------------------------------------------- */ + double adfGeoTransform[6]; + + poSrcDS->GetGeoTransform( adfGeoTransform ); + + sWInfo.dfLLX = adfGeoTransform[0] + adfGeoTransform[1] * 0.5; + sWInfo.dfLLY = adfGeoTransform[3] + + adfGeoTransform[5] * (sWInfo.nYSize - 0.5); + + sWInfo.dfULX = adfGeoTransform[0] + adfGeoTransform[1] * 0.5; + sWInfo.dfULY = adfGeoTransform[3] + adfGeoTransform[5] * 0.5; + + sWInfo.dfURX = adfGeoTransform[0] + + adfGeoTransform[1] * (sWInfo.nXSize - 0.5); + sWInfo.dfURY = adfGeoTransform[3] + adfGeoTransform[5] * 0.5; + + sWInfo.dfLRX = adfGeoTransform[0] + + adfGeoTransform[1] * (sWInfo.nXSize - 0.5); + sWInfo.dfLRY = adfGeoTransform[3] + + adfGeoTransform[5] * (sWInfo.nYSize - 0.5); + + sWInfo.dfHorizStepSize = (sWInfo.dfURX - sWInfo.dfULX) / (sWInfo.nXSize-1); + sWInfo.dfVertStepSize = (sWInfo.dfURY - sWInfo.dfLRY) / (sWInfo.nYSize-1); + +/* -------------------------------------------------------------------- */ +/* Allow override of z resolution, but default to 1.0. */ +/* -------------------------------------------------------------------- */ + const char *zResolution = CSLFetchNameValue( + sWInfo.papszOptions, "ZRESOLUTION" ); + + if( zResolution == NULL || EQUAL(zResolution,"DEFAULT") ) + { + sWInfo.dfElevStepSize = 1.0; + } + else + { + sWInfo.dfElevStepSize = CPLScanDouble( + zResolution, strlen(zResolution), NULL); + if ( sWInfo.dfElevStepSize <= 0 ) + { + /* don't allow negative values */ + sWInfo.dfElevStepSize = 1.0; + } + } + +/* -------------------------------------------------------------------- */ +/* Initialize for special product configurations. */ +/* -------------------------------------------------------------------- */ + const char *pszProduct = CSLFetchNameValue( sWInfo.papszOptions, + "PRODUCT" ); + + if( pszProduct == NULL || EQUAL(pszProduct,"DEFAULT") ) + { + if ( !USGSDEMProductSetup_DEFAULT( &sWInfo ) ) + return NULL; + } + else if( EQUAL(pszProduct,"CDED50K") ) + { + if( !USGSDEMProductSetup_CDED50K( &sWInfo ) ) + return NULL; + } + else + { + CPLError( CE_Failure, CPLE_NotSupported, + "DEM PRODUCT='%s' not recognised.", + pszProduct ); + USGSDEMWriteCleanup( &sWInfo ); + return NULL; + } + + +/* -------------------------------------------------------------------- */ +/* Read the whole area of interest into memory. */ +/* -------------------------------------------------------------------- */ + if( !USGSDEMLoadRaster( &sWInfo, poSrcDS->GetRasterBand( 1 ) ) ) + { + USGSDEMWriteCleanup( &sWInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create the output file. */ +/* -------------------------------------------------------------------- */ + sWInfo.fp = VSIFOpen( pszFilename, "wb" ); + if( sWInfo.fp == NULL ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "%s", VSIStrerror( errno ) ); + USGSDEMWriteCleanup( &sWInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Write the A record. */ +/* -------------------------------------------------------------------- */ + if( !USGSDEMWriteARecord( &sWInfo ) ) + { + USGSDEMWriteCleanup( &sWInfo ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Write profiles. */ +/* -------------------------------------------------------------------- */ + int iProfile; + + for( iProfile = 0; iProfile < sWInfo.nXSize; iProfile++ ) + { + if( !USGSDEMWriteProfile( &sWInfo, iProfile ) ) + { + USGSDEMWriteCleanup( &sWInfo ); + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Cleanup. */ +/* -------------------------------------------------------------------- */ + USGSDEMWriteCleanup( &sWInfo ); + +/* -------------------------------------------------------------------- */ +/* Re-open dataset, and copy any auxilary pam information. */ +/* -------------------------------------------------------------------- */ + GDALPamDataset *poDS = (GDALPamDataset *) + GDALOpen( pszFilename, GA_ReadOnly ); + + if( poDS ) + poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT ); + + return poDS; +} diff --git a/Utilities/GDAL/frmts/usgsdem/usgsdemdataset.cpp b/Utilities/GDAL/frmts/usgsdem/usgsdemdataset.cpp new file mode 100644 index 0000000000..4391afb864 --- /dev/null +++ b/Utilities/GDAL/frmts/usgsdem/usgsdemdataset.cpp @@ -0,0 +1,688 @@ +/****************************************************************************** + * $Id: usgsdemdataset.cpp,v 1.18 2005/10/20 17:28:20 fwarmerdam Exp $ + * + * Project: USGS DEM Driver + * Purpose: All reader for USGS DEM Reader + * Author: Frank Warmerdam, warmerdam@pobox.com + * + * Portions of this module derived from the VTP USGS DEM driver by Ben + * Discoe, see http://www.vterrain.org + * + ****************************************************************************** + * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com> + * + * 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: usgsdemdataset.cpp,v $ + * Revision 1.18 2005/10/20 17:28:20 fwarmerdam + * Added overview support. + * + * Revision 1.17 2005/05/05 15:54:49 fwarmerdam + * PAM Enabled + * + * Revision 1.16 2005/04/15 19:28:57 fwarmerdam + * added AREA_OR_POINT=Point metadata + * + * Revision 1.15 2004/04/08 12:59:10 warmerda + * fixed sides of polygon fixed value + * + * Revision 1.14 2004/04/01 21:03:40 warmerda + * added new creation options to listing + * + * Revision 1.13 2004/03/27 17:03:12 warmerda + * added preliminary creation support + * + * Revision 1.12 2004/03/10 18:07:00 warmerda + * Avoid double/float casting warning. + * + * Revision 1.11 2004/02/24 21:43:39 warmerda + * apply elevation offset as well as fVRes + * + * Revision 1.10 2004/02/14 23:26:45 warmerda + * Added extension metadata. + * + * Revision 1.9 2003/09/19 19:19:37 warmerda + * Fixed nodata value (-32767), and avoid transforming nodata with fVRes. + * + * Revision 1.8 2003/07/08 21:30:45 warmerda + * avoid warnings + * + * Revision 1.7 2002/11/25 15:27:00 warmerda + * relax testopen restrictions to work with adams.dem - PA NED data + * + * Revision 1.6 2002/09/04 06:50:37 warmerda + * avoid static driver pointers + * + * Revision 1.5 2002/08/26 06:45:54 warmerda + * removed use of bool + * + * Revision 1.4 2002/06/12 21:12:25 warmerda + * update to metadata based driver info + * + * Revision 1.3 2001/11/27 16:09:26 warmerda + * Added credit notes + * + * Revision 1.2 2001/11/27 15:16:53 warmerda + * Added header check before trying to open. + * + * Revision 1.1 2001/11/27 14:45:18 warmerda + * New + * + */ + +#include "gdal_pam.h" +#include "ogr_spatialref.h" + +CPL_CVSID("$Id: usgsdemdataset.cpp,v 1.18 2005/10/20 17:28:20 fwarmerdam Exp $"); + +CPL_C_START +void GDALRegister_USGSDEM(void); +CPL_C_END + +typedef struct { + double x; + double y; +} DPoint2; + +#define USGSDEM_NODATA -32767 + +GDALDataset *USGSDEMCreateCopy( const char *, GDALDataset *, int, char **, + GDALProgressFunc pfnProgress, + void * pProgressData ); + +/************************************************************************/ +/* DConvert() */ +/************************************************************************/ + +static double DConvert( FILE *fp, int nCharCount ) + +{ + char szBuffer[100]; + int i; + + VSIFRead( szBuffer, nCharCount, 1, fp ); + szBuffer[nCharCount] = '\0'; + + for( i = 0; i < nCharCount; i++ ) + { + if( szBuffer[i] == 'D' ) + szBuffer[i] = 'E'; + } + + return atof(szBuffer); +} + +/************************************************************************/ +/* ==================================================================== */ +/* USGSDEMDataset */ +/* ==================================================================== */ +/************************************************************************/ + +class USGSDEMRasterBand; + +class USGSDEMDataset : public GDALPamDataset +{ + friend class USGSDEMRasterBand; + + int nDataStartOffset; + GDALDataType eNaturalDataFormat; + + double adfGeoTransform[6]; + char *pszProjection; + + double fVRes; + + const char *pszUnits; + + int LoadFromFile( FILE * ); + + FILE *fp; + + public: + USGSDEMDataset(); + ~USGSDEMDataset(); + + static GDALDataset *Open( GDALOpenInfo * ); + CPLErr GetGeoTransform( double * padfTransform ); + const char *GetProjectionRef(); +}; + +/************************************************************************/ +/* ==================================================================== */ +/* USGSDEMRasterBand */ +/* ==================================================================== */ +/************************************************************************/ + +class USGSDEMRasterBand : public GDALPamRasterBand +{ + friend class USGSDEMDataset; + + public: + + USGSDEMRasterBand( USGSDEMDataset * ); + + virtual const char *GetUnitType(); + virtual double GetNoDataValue( int *pbSuccess = NULL ); + virtual CPLErr IReadBlock( int, int, void * ); +}; + + +/************************************************************************/ +/* USGSDEMRasterBand() */ +/************************************************************************/ + +USGSDEMRasterBand::USGSDEMRasterBand( USGSDEMDataset *poDS ) + +{ + this->poDS = poDS; + this->nBand = 1; + + eDataType = poDS->eNaturalDataFormat; + + nBlockXSize = poDS->GetRasterXSize(); + nBlockYSize = poDS->GetRasterYSize(); + +} + +/************************************************************************/ +/* IReadBlock() */ +/************************************************************************/ + +CPLErr USGSDEMRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, + void * pImage ) + +{ + double dfYMin; + int bad = FALSE; + USGSDEMDataset *poGDS = (USGSDEMDataset *) poDS; + +/* -------------------------------------------------------------------- */ +/* Initialize image buffer to nodata value. */ +/* -------------------------------------------------------------------- */ + for( int k = GetXSize() * GetYSize() - 1; k >= 0; k-- ) + { + if( GetRasterDataType() == GDT_Int16 ) + ((GInt16 *) pImage)[k] = USGSDEM_NODATA; + else + ((float *) pImage)[k] = USGSDEM_NODATA; + } + +/* -------------------------------------------------------------------- */ +/* Seek to data. */ +/* -------------------------------------------------------------------- */ + VSIFSeek(poGDS->fp, poGDS->nDataStartOffset, 0); + + dfYMin = poGDS->adfGeoTransform[3] + + (GetYSize()-0.5) * poGDS->adfGeoTransform[5]; + +/* -------------------------------------------------------------------- */ +/* Read all the profiles into the image buffer. */ +/* -------------------------------------------------------------------- */ + for( int i = 0; i < GetXSize(); i++) + { + int njunk, nCPoints, lygap; + double djunk, dxStart, dyStart, dfElevOffset; + + fscanf(poGDS->fp, "%d", &njunk); + fscanf(poGDS->fp, "%d", &njunk); + fscanf(poGDS->fp, "%d", &nCPoints); + fscanf(poGDS->fp, "%d", &njunk); + + dxStart = DConvert(poGDS->fp, 24); + dyStart = DConvert(poGDS->fp, 24); + dfElevOffset = DConvert(poGDS->fp, 24); + djunk = DConvert(poGDS->fp, 24); + djunk = DConvert(poGDS->fp, 24); + + if( strstr(poGDS->pszProjection,"PROJCS") == NULL ) + dyStart = dyStart / 3600.0; + + lygap = (int)((dfYMin - dyStart)/poGDS->adfGeoTransform[5]+ 0.5); + + for (int j=lygap; j < (nCPoints+(int)lygap); j++) + { + int iY = GetYSize() - j - 1; + int nElev; + + fscanf(poGDS->fp, "%d", &nElev); + if (iY < 0 || iY >= GetYSize() ) + bad = TRUE; + else if( nElev == USGSDEM_NODATA ) + /* leave in output buffer as nodata */; + else + { + float fComputedElev = + (float)(nElev * poGDS->fVRes + dfElevOffset); + + if( GetRasterDataType() == GDT_Int16 ) + { + ((GInt16 *) pImage)[i + iY*GetXSize()] = + (GInt16) fComputedElev; + } + else + { + ((float *) pImage)[i + iY*GetXSize()] = fComputedElev; + } + } + } + } + + return CE_None; +} + +/************************************************************************/ +/* GetNoDataValue() */ +/************************************************************************/ + +double USGSDEMRasterBand::GetNoDataValue( int *pbSuccess ) + +{ + if( pbSuccess != NULL ) + *pbSuccess = TRUE; + + return USGSDEM_NODATA; +} + +/************************************************************************/ +/* GetUnitType() */ +/************************************************************************/ +const char *USGSDEMRasterBand::GetUnitType() +{ + USGSDEMDataset *poGDS = (USGSDEMDataset *) poDS; + + return poGDS->pszUnits; +} + +/************************************************************************/ +/* ==================================================================== */ +/* USGSDEMDataset */ +/* ==================================================================== */ +/************************************************************************/ + +/************************************************************************/ +/* USGSDEMDataset() */ +/************************************************************************/ + +USGSDEMDataset::USGSDEMDataset() + +{ + fp = NULL; + pszProjection = NULL; +} + +/************************************************************************/ +/* ~USGSDEMDataset() */ +/************************************************************************/ + +USGSDEMDataset::~USGSDEMDataset() + +{ + FlushCache(); + + CPLFree( pszProjection ); + if( fp != NULL ) + VSIFClose( fp ); +} + +/************************************************************************/ +/* LoadFromFile() */ +/* */ +/* If the data from DEM is in meters, then values are stored as */ +/* shorts. If DEM data is in feet, then height data will be */ +/* stored in float, to preserve the precision of the original */ +/* data. returns true if the file was successfully opened and */ +/* read. */ +/************************************************************************/ + +int USGSDEMDataset::LoadFromFile(FILE *InDem) +{ + int i, j; + int nRow, nColumn; + int nVUnit, nGUnit; + double dxdelta, dydelta; + double dElevMax, dElevMin; + int bNewFormat; + int nCoordSystem; + int nProfiles; + char szDateBuffer[5]; + DPoint2 corners[4]; // SW, NW, NE, SE + DPoint2 extent_min, extent_max; + int iUTMZone; + + // check for version of DEM format + VSIFSeek(InDem, 864, 0); + + // Read DEM into matrix + fscanf(InDem, "%d", &nRow); + fscanf(InDem, "%d", &nColumn); + bNewFormat = ((nRow!=1)||(nColumn!=1)); + if (bNewFormat) + { + VSIFSeek(InDem, 1024, 0); // New Format + fscanf(InDem, "%d", &i); + fscanf(InDem, "%d", &j); + if ((i!=1)||(j!=1)) // File OK? + { + VSIFSeek(InDem, 893, 0); // Undocumented Format (39109h1.dem) + fscanf(InDem, "%d", &i); + fscanf(InDem, "%d", &j); + if ((i!=1)||(j!=1)) // File OK? + { + CPLError( CE_Failure, CPLE_AppDefined, + "Does not appear to be a USGS DEM file." ); + return FALSE; + } + else + nDataStartOffset = 893; + } + else + nDataStartOffset = 1024; + } + else + nDataStartOffset = 864; + + VSIFSeek(InDem, 156, 0); + fscanf(InDem, "%d", &nCoordSystem); + fscanf(InDem, "%d", &iUTMZone); + + VSIFSeek(InDem, 528, 0); + fscanf(InDem, "%d", &nGUnit); + fscanf(InDem, "%d", &nVUnit); + + // Vertical Units in meters + if (nVUnit==1) + pszUnits = "ft"; + else + pszUnits = "m"; + + VSIFSeek(InDem, 816, 0); + dxdelta = DConvert(InDem, 12); + dydelta = DConvert(InDem, 12); + fVRes = DConvert(InDem, 12); + +/* -------------------------------------------------------------------- */ +/* Should we treat this as floating point, or GInt16. */ +/* -------------------------------------------------------------------- */ + if (nVUnit==1 || fVRes < 1.0) + eNaturalDataFormat = GDT_Float32; + else + eNaturalDataFormat = GDT_Int16; + +/* -------------------------------------------------------------------- */ +/* Read four corner coordinates. */ +/* -------------------------------------------------------------------- */ + VSIFSeek(InDem, 546, 0); + for (i = 0; i < 4; i++) + { + corners[i].x = DConvert(InDem, 24); + corners[i].y = DConvert(InDem, 24); + } + + // find absolute extents of raw vales + extent_min.x = MIN(corners[0].x, corners[1].x); + extent_max.x = MAX(corners[2].x, corners[3].x); + extent_min.y = MIN(corners[0].y, corners[3].y); + extent_max.y = MAX(corners[1].y, corners[2].y); + + dElevMin = DConvert(InDem, 48); + dElevMax = DConvert(InDem, 48); + + VSIFSeek(InDem, 858, 0); + fscanf(InDem, "%d", &nProfiles); + +/* -------------------------------------------------------------------- */ +/* Collect the spatial reference system. */ +/* -------------------------------------------------------------------- */ + OGRSpatialReference sr; + + // OLD format header ends at byte 864 + if (bNewFormat) + { + char szHorzDatum[3]; + + // year of data compilation + VSIFSeek(InDem, 876, 0); + fread(szDateBuffer, 4, 1, InDem); + szDateBuffer[4] = 0; + + // Horizontal datum + // 1=North American Datum 1927 (NAD 27) + // 2=World Geodetic System 1972 (WGS 72) + // 3=WGS 84 + // 4=NAD 83 + // 5=Old Hawaii Datum + // 6=Puerto Rico Datum + int datum; + VSIFSeek(InDem, 890, 0); + VSIFRead( szHorzDatum, 1, 2, InDem ); + szHorzDatum[2] = '\0'; + datum = atoi(szHorzDatum); + switch (datum) + { + case 1: + sr.SetWellKnownGeogCS( "NAD27" ); + break; + + case 2: + sr.SetWellKnownGeogCS( "WGS72" ); + break; + + case 3: + sr.SetWellKnownGeogCS( "WGS84" ); + break; + + case 4: + sr.SetWellKnownGeogCS( "NAD83" ); + break; + + default: + sr.SetWellKnownGeogCS( "NAD27" ); + break; + } + } + else + sr.SetWellKnownGeogCS( "NAD27" ); + + if (nCoordSystem == 1) // UTM + sr.SetUTM( iUTMZone, TRUE ); + + sr.exportToWkt( &pszProjection ); + +/* -------------------------------------------------------------------- */ +/* For UTM we use the extents (really the UTM coordinates of */ +/* the lat/long corners of the quad) to determine the size in */ +/* pixels and lines, but we have to make the anchors be modulus */ +/* the pixel size which what really gets used. */ +/* -------------------------------------------------------------------- */ + if (nCoordSystem == 1) // UTM + { + int njunk; + double dxStart; + + // expand extents modulus the pixel size. + extent_min.y = floor(extent_min.y/dydelta) * dydelta; + extent_max.y = ceil(extent_max.y/dydelta) * dydelta; + + // Forceably compute X extents based on first profile and pixelsize. + VSIFSeek(InDem, nDataStartOffset, 0); + fscanf(InDem, "%d", &njunk); + fscanf(InDem, "%d", &njunk); + fscanf(InDem, "%d", &njunk); + fscanf(InDem, "%d", &njunk); + dxStart = DConvert(InDem, 24); + + nRasterYSize = (int) ((extent_max.y - extent_min.y)/dydelta + 1.5); + nRasterXSize = nProfiles; + + adfGeoTransform[0] = dxStart - dxdelta/2.0; + adfGeoTransform[1] = dxdelta; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = extent_max.y + dydelta/2.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = -dydelta; + } +/* -------------------------------------------------------------------- */ +/* Geographic -- use corners directly. */ +/* -------------------------------------------------------------------- */ + else + { + nRasterYSize = (int) ((extent_max.y - extent_min.y)/dydelta + 1.5); + nRasterXSize = nProfiles; + + // Translate extents from arc-seconds to decimal degrees. + adfGeoTransform[0] = (extent_min.x - dxdelta/2.0) / 3600.0; + adfGeoTransform[1] = dxdelta / 3600.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = (extent_max.y + dydelta/2.0) / 3600.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = (-dydelta) / 3600.0; + } + + return TRUE; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr USGSDEMDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double) * 6 ); + return CE_None; +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *USGSDEMDataset::GetProjectionRef() + +{ + return pszProjection; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *USGSDEMDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + if( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 200 ) + return NULL; + + if( !EQUALN((const char *) poOpenInfo->pabyHeader+156, " 0",6) + && !EQUALN((const char *) poOpenInfo->pabyHeader+156, " 1",6) + && !EQUALN((const char *) poOpenInfo->pabyHeader+156, " 2",6) + && !EQUALN((const char *) poOpenInfo->pabyHeader+156, " 3",6) ) + return NULL; + + if( !EQUALN((const char *) poOpenInfo->pabyHeader+150, " 1",6) ) + return NULL; + +/* -------------------------------------------------------------------- */ +/* Create a corresponding GDALDataset. */ +/* -------------------------------------------------------------------- */ + USGSDEMDataset *poDS; + + poDS = new USGSDEMDataset(); + + poDS->fp = poOpenInfo->fp; + poOpenInfo->fp = NULL; + +/* -------------------------------------------------------------------- */ +/* Read the file. */ +/* -------------------------------------------------------------------- */ + if( !poDS->LoadFromFile( poDS->fp ) ) + { + delete poDS; + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + poDS->SetBand( 1, new USGSDEMRasterBand( poDS )); + + poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT ); + +/* -------------------------------------------------------------------- */ +/* Open overviews. */ +/* -------------------------------------------------------------------- */ + poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); + +/* -------------------------------------------------------------------- */ +/* Initialize any PAM information. */ +/* -------------------------------------------------------------------- */ + poDS->SetDescription( poOpenInfo->pszFilename ); + poDS->TryLoadXML(); + + return( poDS ); +} + +/************************************************************************/ +/* GDALRegister_USGSDEM() */ +/************************************************************************/ + +void GDALRegister_USGSDEM() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "USGSDEM" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "USGSDEM" ); + poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, + "dem" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "USGS Optional ASCII DEM (and CDED)" ); + poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, + "frmt_usgsdem.html" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONDATATYPES, "Int16" ); + poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, +"<CreationOptionList>" +" <Option name='PRODUCT' type='string-select' description='Specific Product Type'>" +" <Value>DEFAULT</Value>" +" <Value>CDED50</Value>" +" </Option>" +" <Option name='TOPLEFT' type='string' description='Top left product corner (ie. 117d15w,52d30n'/>" +" <Option name='RESAMPLE' type='string-select' description='Resampling kernel to use if resampled.'>" +" <Value>Nearest</Value>" +" <Value>Bilinear</Value>" +" <Value>Cubic</Value>" +" <Value>CubicSpline</Value>" +" </Option>" +" <Option name='TEMPLATE' type='string' description='File to default metadata from.'/>" +" <Option name='DEMLevelCode' type='int' description='DEM Level (1, 2 or 3 if set)'/>" +" <Option name='DataSpecVersion' type='int' description='Data and Specification version/revision (eg. 1020)'/>" +" <Option name='PRODUCER' type='string' description='Producer Agency (up to 60 characters)'/>" +" <Option name='OriginCode' type='string' description='Origin code (up to 4 characters, YT for Yukon)'/>" +" <Option name='ProcessCode' type='string' description='Processing Code (8=ANUDEM, 9=FME, A=TopoGrid)'/>" +"</CreationOptionList>" ); + + poDriver->pfnOpen = USGSDEMDataset::Open; + poDriver->pfnCreateCopy = USGSDEMCreateCopy; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/frmts/zlib/GNUmakefile b/Utilities/GDAL/frmts/zlib/GNUmakefile new file mode 100644 index 0000000000..b0ca5d2603 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/GNUmakefile @@ -0,0 +1,15 @@ + + +include ../../GDALmake.opt + +OBJ = adler32.o compress.o crc32.o deflate.o gzio.o \ + infblock.o infcodes.o inffast.o inflate.o \ + infutil.o inftrees.o trees.o uncompr.o zutil.o + + +default: $(OBJ) + +clean: + rm -f *.o + +install-obj: $(O_OBJ) diff --git a/Utilities/GDAL/frmts/zlib/README b/Utilities/GDAL/frmts/zlib/README new file mode 100644 index 0000000000..8ff458799b --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/README @@ -0,0 +1,148 @@ +zlib 1.1.3 is a general purpose data compression library. All the code +is thread safe. The data format used by the zlib library +is described by RFCs (Request for Comments) 1950 to 1952 in the files +ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate +format) and rfc1952.txt (gzip format). These documents are also available in +other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html + +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact jloup@gzip.org). A usage +example of the library is given in the file example.c which also tests that +the library is working correctly. Another example is given in the file +minigzip.c. The compression library itself is composed of all source files +except example.c and minigzip.c. + +To compile all files and run the test program, follow the instructions +given at the top of Makefile. In short "make test; make install" +should work for most machines. For Unix: "configure; make test; make install" +For MSDOS, use one of the special makefiles such as Makefile.msc. +For VMS, use Make_vms.com or descrip.mms. + +Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov>, or to +Gilles Vollant <info@winimage.com> for the Windows DLL version. +The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ +The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/ +Before reporting a problem, please check those sites to verify that +you have the latest version of zlib; otherwise get the latest version and +check whether the problem still exists or not. + +Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997 +issue of Dr. Dobb's Journal; a copy of the article is available in +http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm + +The changes made in version 1.1.3 are documented in the file ChangeLog. +The main changes since 1.1.2 are: + +- fix "an inflate input buffer bug that shows up on rare but persistent + occasions" (Mark) +- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) +- fix gzseek(..., SEEK_SET) in write mode +- fix crc check after a gzeek (Frank Faubert) +- fix miniunzip when the last entry in a zip file is itself a zip file + (J Lillge) +- add contrib/asm586 and contrib/asm686 (Brian Raiter) + See http://www.muppetlabs.com/~breadbox/software/assembly.html +- add support for Delphi 3 in contrib/delphi (Bob Dellaca) +- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) +- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) +- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) +- added a FAQ file + +plus many changes for portability. + +Unsupported third party contributions are provided in directory "contrib". + +A Java implementation of zlib is available in the Java Development Kit 1.1 +http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html +See the zlib home page http://www.cdrom.com/pub/infozip/zlib/ for details. + +A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> +is in the CPAN (Comprehensive Perl Archive Network) sites, such as: +ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* + +A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> +is available in Python 1.5 and later versions, see +http://www.python.org/doc/lib/module-zlib.html + +A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> +is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html + +An experimental package to read and write files in .zip format, +written on top of zlib by Gilles Vollant <info@winimage.com>, is +available at http://www.winimage.com/zLibDll/unzip.html +and also in the contrib/minizip directory of zlib. + + +Notes for some targets: + +- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc + and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL + The zlib DLL support was initially done by Alessandro Iacopetti and is + now maintained by Gilles Vollant <info@winimage.com>. Check the zlib DLL + home page at http://www.winimage.com/zLibDll + + From Visual Basic, you can call the DLL functions which do not take + a structure as argument: compress, uncompress and all gz* functions. + See contrib/visual-basic.txt for more information, or get + http://www.tcfb.com/dowseware/cmp-z-it.zip + +- For 64-bit Irix, deflate.c must be compiled without any optimization. + With -O, one libpng test fails. The test works in 32 bit mode (with + the -n32 compiler flag). The compiler bug has been reported to SGI. + +- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 + it works when compiled with cc. + +- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 + is necessary to get gzprintf working correctly. This is done by configure. + +- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works + with other compilers. Use "make test" to check your compiler. + +- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. + +- For Turbo C the small model is supported only with reduced performance to + avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 + +- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html + Per Harald Myrvang <perm@stud.cs.uit.no> + + +Acknowledgments: + + The deflate format used by zlib was defined by Phil Katz. The deflate + and zlib specifications were written by L. Peter Deutsch. Thanks to all the + people who reported problems and suggested various improvements in zlib; + they are too numerous to cite here. + +Copyright notice: + + (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* +receiving lengthy legal documents to sign. The sources are provided +for free but without warranty of any kind. The library has been +entirely written by Jean-loup Gailly and Mark Adler; it does not +include third-party code. + +If you redistribute modified sources, we would appreciate that you include +in the file ChangeLog history information documenting your changes. diff --git a/Utilities/GDAL/frmts/zlib/adler32.c b/Utilities/GDAL/frmts/zlib/adler32.c new file mode 100644 index 0000000000..16cf9a703f --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/adler32.c @@ -0,0 +1,48 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" + +#define BASE 65521L /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {s1 += buf[i]; s2 += s1;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* ========================================================================= */ +uLong ZEXPORT adler32(adler, buf, len) + uLong adler; + const Bytef *buf; + uInt len; +{ + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + int k; + + if (buf == Z_NULL) return 1L; + + while (len > 0) { + k = len < NMAX ? len : NMAX; + len -= k; + while (k >= 16) { + DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) do { + s1 += *buf++; + s2 += s1; + } while (--k); + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; +} diff --git a/Utilities/GDAL/frmts/zlib/compress.c b/Utilities/GDAL/frmts/zlib/compress.c new file mode 100644 index 0000000000..1cee470913 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/compress.c @@ -0,0 +1,68 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; + int level; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} diff --git a/Utilities/GDAL/frmts/zlib/crc32.c b/Utilities/GDAL/frmts/zlib/crc32.c new file mode 100644 index 0000000000..a91101a81c --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/crc32.c @@ -0,0 +1,162 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" + +#define local static + +#ifdef DYNAMIC_CRC_TABLE + +local int crc_table_empty = 1; +local uLongf crc_table[256]; +local void make_crc_table OF((void)); + +/* + Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The table is simply the CRC of all possible eight bit values. This is all + the information needed to generate CRC's on data a byte at a time for all + combinations of CRC register values and incoming bytes. +*/ +local void make_crc_table() +{ + uLong c; + int n, k; + uLong poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* make exclusive-or pattern from polynomial (0xedb88320L) */ + poly = 0L; + for (n = 0; n < sizeof(p)/sizeof(Byte); n++) + poly |= 1L << (31 - p[n]); + + for (n = 0; n < 256; n++) + { + c = (uLong)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[n] = c; + } + crc_table_empty = 0; +} +#else +/* ======================================================================== + * Table of CRC-32's of all single-byte values (made by make_crc_table) + */ +local const uLongf crc_table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; +#endif + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const uLongf * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) make_crc_table(); +#endif + return (const uLongf *)crc_table; +} + +/* ========================================================================= */ +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + +/* ========================================================================= */ +uLong ZEXPORT crc32(crc, buf, len) + uLong crc; + const Bytef *buf; + uInt len; +{ + if (buf == Z_NULL) return 0L; +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif + crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do { + DO1(buf); + } while (--len); + return crc ^ 0xffffffffL; +} diff --git a/Utilities/GDAL/frmts/zlib/deflate.c b/Utilities/GDAL/frmts/zlib/deflate.c new file mode 100644 index 0000000000..25d5818e2e --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/deflate.c @@ -0,0 +1,1350 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in ftp://ds.internic.net/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* @(#) $Id$ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_slow OF((deflate_state *s, int flush)); +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */ + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_(strm, level, version, stream_size) + z_streamp strm; + int level; + const char *version; + int stream_size; +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, + version, stream_size) + z_streamp strm; + int level; + int method; + int windowBits; + int memLevel; + int strategy; + const char *version; + int stream_size; +{ + deflate_state *s; + int noheader = 0; + static const char* my_version = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == Z_NULL) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == Z_NULL) strm->zfree = zcfree; + + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#ifdef FASTEST + level = 1; +#endif + + if (windowBits < 0) { /* undocumented feature: suppress zlib header */ + noheader = 1; + windowBits = -windowBits; + } + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->strm = strm; + + s->noheader = noheader; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) + z_streamp strm; + const Bytef *dictionary; + uInt dictLength; +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->status != INIT_STATE) return Z_STREAM_ERROR; + + s = strm->state; + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > MAX_DIST(s)) { + length = MAX_DIST(s); +#ifndef USE_DICT_HEAD + dictionary += dictLength - length; /* use the tail of the dictionary */ +#endif + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset (strm) + z_streamp strm; +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->noheader < 0) { + s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ + } + s->status = s->noheader ? BUSY_STATE : INIT_STATE; + strm->adler = 1; + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams(strm, level, strategy) + z_streamp strm; + int level; + int strategy; +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + + if (level == Z_DEFAULT_COMPRESSION) { + level = 6; + } + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if (func != configuration_table[level].func && strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_PARTIAL_FLUSH); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB (s, b) + deflate_state *s; + uInt b; +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending(strm) + z_streamp strm; +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate (strm, flush) + z_streamp strm; + int flush; +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the zlib header */ + if (s->status == INIT_STATE) { + + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags = (s->level-1) >> 1; + + if (level_flags > 3) level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = 1L; + } + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUFF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->noheader) return Z_STREAM_END; + + /* Write the zlib trailer (adler32) */ + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + s->noheader = -1; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd (strm) + z_streamp strm; +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy (dest, source) + z_streamp dest; + z_streamp source; +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + *dest = *source; + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + *ds = *ss; + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf(strm, buf, size) + z_streamp strm; + Bytef *buf; + unsigned size; +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (!strm->state->noheader) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init (s) + deflate_state *s; +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +} + +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +#ifndef FASTEST +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} + +#else /* FASTEST */ +/* --------------------------------------------------------------------------- + * Optimized version for level == 1 only + */ +local uInt longest_match(s, cur_match) + deflate_state *s; + IPos cur_match; /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return len <= s->lookahead ? len : s->lookahead; +} +#endif /* FASTEST */ +#endif /* ASMV */ + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match(s, start, match, length) + deflate_state *s; + IPos start, match; + int length; +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(s) + deflate_state *s; +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if strstart == 0 + * and lookahead == 1 (input done one byte at time) + */ + more--; + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + } else if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, eof) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, eof) { \ + FLUSH_BLOCK_ONLY(s, eof); \ + if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored(s, flush) + deflate_state *s; + int flush; +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy != Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--; /* string at strstart already in hash table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow(s, flush) + deflate_state *s; + int flush; +{ + IPos hash_head = NIL; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy != Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } + /* longest_match() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED || + (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR))) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} diff --git a/Utilities/GDAL/frmts/zlib/deflate.h b/Utilities/GDAL/frmts/zlib/deflate.h new file mode 100644 index 0000000000..962676da86 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/deflate.h @@ -0,0 +1,318 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-1998 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef _DEFLATE_H +#define _DEFLATE_H + +#include "zutil.h" + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + int pending; /* nb of bytes in the pending buffer */ + int noheader; /* suppress zlib header and adler32 */ + Byte data_type; /* UNKNOWN, BINARY or ASCII */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + + /* in trees.c */ +void _tr_init OF((deflate_state *s)); +int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); +void _tr_align OF((deflate_state *s)); +void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch _length_code[]; + extern uch _dist_code[]; +#else + extern const uch _length_code[]; + extern const uch _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif diff --git a/Utilities/GDAL/frmts/zlib/gzio.c b/Utilities/GDAL/frmts/zlib/gzio.c new file mode 100644 index 0000000000..f7c336a55a --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/gzio.c @@ -0,0 +1,875 @@ +/* gzio.c -- IO on .gz files + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Compile this file with -DNO_DEFLATE to avoid the compression code. + */ + +/* @(#) $Id$ */ + +#include <stdio.h> + +#include "zutil.h" + +struct internal_state {int dummy;}; /* for buggy compilers */ + +#ifndef Z_BUFSIZE +# ifdef MAXSEG_64K +# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ +# else +# define Z_BUFSIZE 16384 +# endif +#endif +#ifndef Z_PRINTF_BUFSIZE +# define Z_PRINTF_BUFSIZE 4096 +#endif + +#define ALLOC(size) malloc(size) +#define TRYFREE(p) {if (p) free(p);} + +static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ + +/* gzip flag byte */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ + +typedef struct gz_stream { + z_stream stream; + int z_err; /* error code for last stream operation */ + int z_eof; /* set if end of input file */ + FILE *file; /* .gz file */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ + uLong crc; /* crc32 of uncompressed data */ + char *msg; /* error message */ + char *path; /* path name for debugging only */ + int transparent; /* 1 if input file is not a .gz file */ + char mode; /* 'w' or 'r' */ + long startpos; /* start of compressed data in file (header skipped) */ +} gz_stream; + + +local gzFile gz_open OF((const char *path, const char *mode, int fd)); +local int do_flush OF((gzFile file, int flush)); +local int get_byte OF((gz_stream *s)); +local void check_header OF((gz_stream *s)); +local int destroy OF((gz_stream *s)); +local void putLong OF((FILE *file, uLong x)); +local uLong getLong OF((gz_stream *s)); + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb"). The file is given either by file descriptor + or path name (if fd == -1). + gz_open return NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). +*/ +local gzFile gz_open (path, mode, fd) + const char *path; + const char *mode; + int fd; +{ + int err; + int level = Z_DEFAULT_COMPRESSION; /* compression level */ + int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ + char *p = (char*)mode; + gz_stream *s; + char fmode[80]; /* copy of mode, without the compression level */ + char *m = fmode; + + if (!path || !mode) return Z_NULL; + + s = (gz_stream *)ALLOC(sizeof(gz_stream)); + if (!s) return Z_NULL; + + s->stream.zalloc = (alloc_func)0; + s->stream.zfree = (free_func)0; + s->stream.opaque = (voidpf)0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; + s->file = NULL; + s->z_err = Z_OK; + s->z_eof = 0; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + + s->path = (char*)ALLOC(strlen(path)+1); + if (s->path == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + strcpy(s->path, path); /* do this early for debugging */ + + s->mode = '\0'; + do { + if (*p == 'r') s->mode = 'r'; + if (*p == 'w' || *p == 'a') s->mode = 'w'; + if (*p >= '0' && *p <= '9') { + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + } else { + *m++ = *p; /* copy the mode */ + } + } while (*p++ && m != fmode + sizeof(fmode)); + if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; + + if (s->mode == 'w') { +#ifdef NO_DEFLATE + err = Z_STREAM_ERROR; +#else + err = deflateInit2(&(s->stream), level, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); + /* windowBits is passed < 0 to suppress zlib header */ + + s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); +#endif + if (err != Z_OK || s->outbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } else { + s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); + + err = inflateInit2(&(s->stream), -MAX_WBITS); + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are + * present after the compressed stream. + */ + if (err != Z_OK || s->inbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } + s->stream.avail_out = Z_BUFSIZE; + + errno = 0; + s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode); + + if (s->file == NULL) { + return destroy(s), (gzFile)Z_NULL; + } + if (s->mode == 'w') { + /* Write a very simple .gz header: + */ + fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], + Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); + s->startpos = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * startpos anyway in write mode, so this initialization is not + * necessary. + */ + } else { + check_header(s); /* skip the .gz header */ + s->startpos = (ftell(s->file) - s->stream.avail_in); + } + + return (gzFile)s; +} + +/* =========================================================================== + Opens a gzip (.gz) file for reading or writing. +*/ +gzFile ZEXPORT gzopen (path, mode) + const char *path; + const char *mode; +{ + return gz_open (path, mode, -1); +} + +/* =========================================================================== + Associate a gzFile with the file descriptor fd. fd is not dup'ed here + to mimic the behavio(u)r of fdopen. +*/ +gzFile ZEXPORT gzdopen (fd, mode) + int fd; + const char *mode; +{ + char name[20]; + + if (fd < 0) return (gzFile)Z_NULL; + sprintf(name, "<fd:%d>", fd); /* for debugging */ + + return gz_open (name, mode, fd); +} + +/* =========================================================================== + * Update the compression level and strategy + */ +int ZEXPORT gzsetparams (file, level, strategy) + gzFile file; + int level; + int strategy; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + /* Make room to allow flushing */ + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + } + s->stream.avail_out = Z_BUFSIZE; + } + + return deflateParams (&(s->stream), level, strategy); +} + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ +local int get_byte(s) + gz_stream *s; +{ + if (s->z_eof) return EOF; + if (s->stream.avail_in == 0) { + errno = 0; + s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; +} + +/* =========================================================================== + Check the gzip header of a gz_stream opened for reading. Set the stream + mode to transparent if the gzip magic header is not present; set s->err + to Z_DATA_ERROR if the magic header is present but the rest of the header + is incorrect. + IN assertion: the stream s has already been created sucessfully; + s->stream.avail_in is zero for the first time, but may be non-zero + for concatenated .gz files. +*/ +local void check_header(s) + gz_stream *s; +{ + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; + + /* Check the gzip magic header */ + for (len = 0; len < 2; len++) { + c = get_byte(s); + if (c != gz_magic[len]) { + if (len != 0) s->stream.avail_in++, s->stream.next_in--; + if (c != EOF) { + s->stream.avail_in++, s->stream.next_in--; + s->transparent = 1; + } + s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; + return; + } + } + method = get_byte(s); + flags = get_byte(s); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + s->z_err = Z_DATA_ERROR; + return; + } + + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) (void)get_byte(s); + + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s))<<8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(s)) != 0 && c != EOF) ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) (void)get_byte(s); + } + s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; +} + + /* =========================================================================== + * Cleanup then free the given gz_stream. Return a zlib error code. + Try freeing in the reverse order of allocations. + */ +local int destroy (s) + gz_stream *s; +{ + int err = Z_OK; + + if (!s) return Z_STREAM_ERROR; + + TRYFREE(s->msg); + + if (s->stream.state != NULL) { + if (s->mode == 'w') { +#ifdef NO_DEFLATE + err = Z_STREAM_ERROR; +#else + err = deflateEnd(&(s->stream)); +#endif + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } + } + if (s->file != NULL && fclose(s->file)) { +#ifdef ESPIPE + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ +#endif + err = Z_ERRNO; + } + if (s->z_err < 0) err = s->z_err; + + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s->path); + TRYFREE(s); + return err; +} + +/* =========================================================================== + Reads the given number of uncompressed bytes from the compressed file. + gzread returns the number of bytes actually read (0 for end of file). +*/ +int ZEXPORT gzread (file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + gz_stream *s = (gz_stream*)file; + Bytef *start = (Bytef*)buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + + if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; + + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; + if (s->z_err == Z_STREAM_END) return 0; /* EOF */ + + next_out = (Byte*)buf; + s->stream.next_out = (Bytef*)buf; + s->stream.avail_out = len; + + while (s->stream.avail_out != 0) { + + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, + s->file); + } + len -= s->stream.avail_out; + s->stream.total_in += (uLong)len; + s->stream.total_out += (uLong)len; + if (len == 0) s->z_eof = 1; + return (int)len; + } + if (s->stream.avail_in == 0 && !s->z_eof) { + + errno = 0; + s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (ferror(s->file)) { + s->z_err = Z_ERRNO; + break; + } + } + s->stream.next_in = s->inbuf; + } + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; + + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); + /* The uncompressed length returned by above getlong() may + * be different from s->stream.total_out) in case of + * concatenated .gz files. Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + uLong total_in = s->stream.total_in; + uLong total_out = s->stream.total_out; + + inflateReset(&(s->stream)); + s->stream.total_in = total_in; + s->stream.total_out = total_out; + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) break; + } + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + + return (int)(len - s->stream.avail_out); +} + + +/* =========================================================================== + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ +int ZEXPORT gzgetc(file) + gzFile file; +{ + unsigned char c; + + return gzread(file, &c, 1) == 1 ? c : -1; +} + + +/* =========================================================================== + Reads bytes from the compressed file until len-1 characters are + read, or a newline character is read and transferred to buf, or an + end-of-file condition is encountered. The string is then terminated + with a null character. + gzgets returns buf, or Z_NULL in case of error. + + The current implementation is not optimized at all. +*/ +char * ZEXPORT gzgets(file, buf, len) + gzFile file; + char *buf; + int len; +{ + char *b = buf; + if (buf == Z_NULL || len <= 0) return Z_NULL; + + while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ; + *buf = '\0'; + return b == buf && len > 0 ? Z_NULL : b; +} + + +#ifndef NO_DEFLATE +/* =========================================================================== + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of bytes actually written (0 in case of error). +*/ +int ZEXPORT gzwrite (file, buf, len) + gzFile file; + const voidp buf; + unsigned len; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.next_in = (Bytef*)buf; + s->stream.avail_in = len; + + while (s->stream.avail_in != 0) { + + if (s->stream.avail_out == 0) { + + s->stream.next_out = s->outbuf; + if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + break; + } + s->stream.avail_out = Z_BUFSIZE; + } + s->z_err = deflate(&(s->stream), Z_NO_FLUSH); + if (s->z_err != Z_OK) break; + } + s->crc = crc32(s->crc, (const Bytef *)buf, len); + + return (int)(len - s->stream.avail_in); +} + +/* =========================================================================== + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ +#ifdef STDC +#include <stdarg.h> + +int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) +{ + char buf[Z_PRINTF_BUFSIZE]; + va_list va; + int len; + + va_start(va, format); +#ifdef HAS_vsnprintf + (void)vsnprintf(buf, sizeof(buf), format, va); +#else + (void)vsprintf(buf, format, va); +#endif + va_end(va); + len = strlen(buf); /* some *sprintf don't return the nb of bytes written */ + if (len <= 0) return 0; + + return gzwrite(file, buf, (unsigned)len); +} +#else /* not ANSI C */ + +int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) + gzFile file; + const char *format; + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, + a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; +{ + char buf[Z_PRINTF_BUFSIZE]; + int len; + +#ifdef HAS_snprintf + snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +#else + sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); +#endif + len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ + if (len <= 0) return 0; + + return gzwrite(file, buf, len); +} +#endif + +/* =========================================================================== + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ +int ZEXPORT gzputc(file, c) + gzFile file; + int c; +{ + unsigned char cc = (unsigned char) c; /* required for big endian systems */ + + return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; +} + + +/* =========================================================================== + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ +int ZEXPORT gzputs(file, s) + gzFile file; + const char *s; +{ + return gzwrite(file, (char*)s, (unsigned)strlen(s)); +} + + +/* =========================================================================== + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. +*/ +local int do_flush (file, flush) + gzFile file; + int flush; +{ + uInt len; + int done = 0; + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + + s->stream.avail_in = 0; /* should be zero already anyway */ + + for (;;) { + len = Z_BUFSIZE - s->stream.avail_out; + + if (len != 0) { + if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) break; + s->z_err = deflate(&(s->stream), flush); + + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; + + /* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; + } + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} + +int ZEXPORT gzflush (file, flush) + gzFile file; + int flush; +{ + gz_stream *s = (gz_stream*)file; + int err = do_flush (file, flush); + + if (err) return err; + fflush(s->file); + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; +} +#endif /* NO_DEFLATE */ + +/* =========================================================================== + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error. + SEEK_END is not implemented, returns error. + In this version of the library, gzseek can be extremely slow. +*/ +z_off_t ZEXPORT gzseek (file, offset, whence) + gzFile file; + z_off_t offset; + int whence; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || whence == SEEK_END || + s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) { + return -1L; + } + + if (s->mode == 'w') { +#ifdef NO_DEFLATE + return -1L; +#else + if (whence == SEEK_SET) { + offset -= s->stream.total_in; + } + if (offset < 0) return -1L; + + /* At this point, offset is the number of zero bytes to write. */ + if (s->inbuf == Z_NULL) { + s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */ + zmemzero(s->inbuf, Z_BUFSIZE); + } + while (offset > 0) { + uInt size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (uInt)offset; + + size = gzwrite(file, s->inbuf, size); + if (size == 0) return -1L; + + offset -= size; + } + return (z_off_t)s->stream.total_in; +#endif + } + /* Rest of function is for reading only */ + + /* compute absolute position */ + if (whence == SEEK_CUR) { + offset += s->stream.total_out; + } + if (offset < 0) return -1L; + + if (s->transparent) { + /* map to fseek */ + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; + + s->stream.total_in = s->stream.total_out = (uLong)offset; + return offset; + } + + /* For a negative seek, rewind and use positive seek */ + if ((uLong)offset >= s->stream.total_out) { + offset -= s->stream.total_out; + } else if (gzrewind(file) < 0) { + return -1L; + } + /* offset is now the number of bytes to skip. */ + + if (offset != 0 && s->outbuf == Z_NULL) { + s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + } + while (offset > 0) { + int size = Z_BUFSIZE; + if (offset < Z_BUFSIZE) size = (int)offset; + + size = gzread(file, s->outbuf, (uInt)size); + if (size <= 0) return -1L; + offset -= size; + } + return (z_off_t)s->stream.total_out; +} + +/* =========================================================================== + Rewinds input file. +*/ +int ZEXPORT gzrewind (file) + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + if (s == NULL || s->mode != 'r') return -1; + + s->z_err = Z_OK; + s->z_eof = 0; + s->stream.avail_in = 0; + s->stream.next_in = s->inbuf; + s->crc = crc32(0L, Z_NULL, 0); + + if (s->startpos == 0) { /* not a compressed file */ + rewind(s->file); + return 0; + } + + (void) inflateReset(&s->stream); + return fseek(s->file, s->startpos, SEEK_SET); +} + +/* =========================================================================== + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. +*/ +z_off_t ZEXPORT gztell (file) + gzFile file; +{ + return gzseek(file, 0L, SEEK_CUR); +} + +/* =========================================================================== + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ +int ZEXPORT gzeof (file) + gzFile file; +{ + gz_stream *s = (gz_stream*)file; + + return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; +} + +/* =========================================================================== + Outputs a long in LSB order to the given file +*/ +local void putLong (file, x) + FILE *file; + uLong x; +{ + int n; + for (n = 0; n < 4; n++) { + fputc((int)(x & 0xff), file); + x >>= 8; + } +} + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets z_err in case + of error. +*/ +local uLong getLong (s) + gz_stream *s; +{ + uLong x = (uLong)get_byte(s); + int c; + + x += ((uLong)get_byte(s))<<8; + x += ((uLong)get_byte(s))<<16; + c = get_byte(s); + if (c == EOF) s->z_err = Z_DATA_ERROR; + x += ((uLong)c)<<24; + return x; +} + +/* =========================================================================== + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. +*/ +int ZEXPORT gzclose (file) + gzFile file; +{ + int err; + gz_stream *s = (gz_stream*)file; + + if (s == NULL) return Z_STREAM_ERROR; + + if (s->mode == 'w') { +#ifdef NO_DEFLATE + return Z_STREAM_ERROR; +#else + err = do_flush (file, Z_FINISH); + if (err != Z_OK) return destroy((gz_stream*)file); + + putLong (s->file, s->crc); + putLong (s->file, s->stream.total_in); +#endif + } + return destroy((gz_stream*)file); +} + +/* =========================================================================== + Returns the error message for the last error which occured on the + given compressed file. errnum is set to zlib error number. If an + error occured in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ +const char* ZEXPORT gzerror (file, errnum) + gzFile file; + int *errnum; +{ + char *m; + gz_stream *s = (gz_stream*)file; + + if (s == NULL) { + *errnum = Z_STREAM_ERROR; + return (const char*)ERR_MSG(Z_STREAM_ERROR); + } + *errnum = s->z_err; + if (*errnum == Z_OK) return (const char*)""; + + m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); + + if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); + + TRYFREE(s->msg); + s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); + strcpy(s->msg, s->path); + strcat(s->msg, ": "); + strcat(s->msg, m); + return (const char*)s->msg; +} diff --git a/Utilities/GDAL/frmts/zlib/infblock.c b/Utilities/GDAL/frmts/zlib/infblock.c new file mode 100644 index 0000000000..3e1fc7d122 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infblock.c @@ -0,0 +1,401 @@ +/* infblock.c -- interpret and process block types to last block + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + +struct inflate_codes_state {int dummy;}; /* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +/* Table for deflate from PKZIP's appnote.txt. */ +local const uInt border[] = { /* Order of the bit length code lengths */ + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + +/* + Notes beyond the 1.93a appnote.txt: + + 1. Distance pointers never point before the beginning of the output + stream. + 2. Distance pointers can point back across blocks, up to 32k away. + 3. There is an implied maximum of 7 bits for the bit length table and + 15 bits for the actual data. + 4. If only one code exists, then it is encoded using one bit. (Zero + would be more efficient, but perhaps a little confusing.) If two + codes exist, they are coded using one bit each (0 and 1). + 5. There is no way of sending zero distance codes--a dummy must be + sent if there are none. (History: a pre 2.0 version of PKZIP would + store blocks with no distance codes, but this was discovered to be + too harsh a criterion.) Valid only for 1.93a. 2.04c does allow + zero distance codes, which is sent as one code of zero bits in + length. + 6. There are up to 286 literal/length codes. Code 256 represents the + end-of-block. Note however that the static length tree defines + 288 codes just to fill out the Huffman codes. Codes 286 and 287 + cannot be used though, since there is no length base or extra bits + defined for them. Similarily, there are up to 30 distance codes. + However, static trees define 32 codes (all 5 bits) to fill out the + Huffman codes, but the last two had better not show up in the data. + 7. Unzip can check dynamic Huffman blocks for complete code sets. + The exception is that a single code would not be complete (see #4). + 8. The five bits following the block type is really the number of + literal codes sent minus 257. + 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits + (1+6+6). Therefore, to output three times the length, you output + three codes (1+1+1), whereas to output four times the same length, + you only need two codes (1+3). Hmm. + 10. In the tree reconstruction algorithm, Code = Code + Increment + only if BitLength(i) is not zero. (Pretty obvious.) + 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) + 12. Note: length code 284 can represent 227-258, but length code 285 + really is 258. The last length deserves its own, short code + since it gets used a lot in very redundant files. The length + 258 is special since 258 - 3 (the min match length) is 255. + 13. The literal/length and distance code bit lengths are read as a + single stream of lengths. It is possible (and advantageous) for + a repeat code (16, 17, or 18) to go across the boundary between + the two sets of lengths. + */ + + +void inflate_blocks_reset(s, z, c) +inflate_blocks_statef *s; +z_streamp z; +uLongf *c; +{ + if (c != Z_NULL) + *c = s->check; + if (s->mode == BTREE || s->mode == DTREE) + ZFREE(z, s->sub.trees.blens); + if (s->mode == CODES) + inflate_codes_free(s->sub.decode.codes, z); + s->mode = TYPE; + s->bitk = 0; + s->bitb = 0; + s->read = s->write = s->window; + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); + Tracev((stderr, "inflate: blocks reset\n")); +} + + +inflate_blocks_statef *inflate_blocks_new(z, c, w) +z_streamp z; +check_func c; +uInt w; +{ + inflate_blocks_statef *s; + + if ((s = (inflate_blocks_statef *)ZALLOC + (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) + return s; + if ((s->hufts = + (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) + { + ZFREE(z, s); + return Z_NULL; + } + if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) + { + ZFREE(z, s->hufts); + ZFREE(z, s); + return Z_NULL; + } + s->end = s->window + w; + s->checkfn = c; + s->mode = TYPE; + Tracev((stderr, "inflate: blocks allocated\n")); + inflate_blocks_reset(s, z, Z_NULL); + return s; +} + + +int inflate_blocks(s, z, r) +inflate_blocks_statef *s; +z_streamp z; +int r; +{ + uInt t; /* temporary storage */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input based on current state */ + while (1) switch (s->mode) + { + case TYPE: + NEEDBITS(3) + t = (uInt)b & 7; + s->last = t & 1; + switch (t >> 1) + { + case 0: /* stored */ + Tracev((stderr, "inflate: stored block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + t = k & 7; /* go to byte boundary */ + DUMPBITS(t) + s->mode = LENS; /* get length of stored block */ + break; + case 1: /* fixed */ + Tracev((stderr, "inflate: fixed codes block%s\n", + s->last ? " (last)" : "")); + { + uInt bl, bd; + inflate_huft *tl, *td; + + inflate_trees_fixed(&bl, &bd, &tl, &td, z); + s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); + if (s->sub.decode.codes == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + } + DUMPBITS(3) + s->mode = CODES; + break; + case 2: /* dynamic */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + s->mode = TABLE; + break; + case 3: /* illegal */ + DUMPBITS(3) + s->mode = BAD; + z->msg = (char*)"invalid block type"; + r = Z_DATA_ERROR; + LEAVE + } + break; + case LENS: + NEEDBITS(32) + if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) + { + s->mode = BAD; + z->msg = (char*)"invalid stored block lengths"; + r = Z_DATA_ERROR; + LEAVE + } + s->sub.left = (uInt)b & 0xffff; + b = k = 0; /* dump bits */ + Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); + s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); + break; + case STORED: + if (n == 0) + LEAVE + NEEDOUT + t = s->sub.left; + if (t > n) t = n; + if (t > m) t = m; + zmemcpy(q, p, t); + p += t; n -= t; + q += t; m -= t; + if ((s->sub.left -= t) != 0) + break; + Tracev((stderr, "inflate: stored end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + s->mode = s->last ? DRY : TYPE; + break; + case TABLE: + NEEDBITS(14) + s->sub.trees.table = t = (uInt)b & 0x3fff; +#ifndef PKZIP_BUG_WORKAROUND + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) + { + s->mode = BAD; + z->msg = (char*)"too many length or distance symbols"; + r = Z_DATA_ERROR; + LEAVE + } +#endif + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + DUMPBITS(14) + s->sub.trees.index = 0; + Tracev((stderr, "inflate: table sizes ok\n")); + s->mode = BTREE; + case BTREE: + while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) + { + NEEDBITS(3) + s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; + DUMPBITS(3) + } + while (s->sub.trees.index < 19) + s->sub.trees.blens[border[s->sub.trees.index++]] = 0; + s->sub.trees.bb = 7; + t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, + &s->sub.trees.tb, s->hufts, z); + if (t != Z_OK) + { + r = t; + if (r == Z_DATA_ERROR){ + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + LEAVE + } + s->sub.trees.index = 0; + Tracev((stderr, "inflate: bits tree ok\n")); + s->mode = DTREE; + case DTREE: + while (t = s->sub.trees.table, + s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) + { + inflate_huft *h; + uInt i, j, c; + + t = s->sub.trees.bb; + NEEDBITS(t) + h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); + t = h->bits; + c = h->base; + if (c < 16) + { + DUMPBITS(t) + s->sub.trees.blens[s->sub.trees.index++] = c; + } + else /* c == 16..18 */ + { + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + NEEDBITS(t + i) + DUMPBITS(t) + j += (uInt)b & inflate_mask[i]; + DUMPBITS(i) + i = s->sub.trees.index; + t = s->sub.trees.table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || + (c == 16 && i < 1)) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + z->msg = (char*)"invalid bit length repeat"; + r = Z_DATA_ERROR; + LEAVE + } + c = c == 16 ? s->sub.trees.blens[i - 1] : 0; + do { + s->sub.trees.blens[i++] = c; + } while (--j); + s->sub.trees.index = i; + } + } + s->sub.trees.tb = Z_NULL; + { + uInt bl, bd; + inflate_huft *tl, *td; + inflate_codes_statef *c; + + bl = 9; /* must be <= 9 for lookahead assumptions */ + bd = 6; /* must be <= 9 for lookahead assumptions */ + t = s->sub.trees.table; + t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), + s->sub.trees.blens, &bl, &bd, &tl, &td, + s->hufts, z); + if (t != Z_OK) + { + if (t == (uInt)Z_DATA_ERROR){ + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + r = t; + LEAVE + } + Tracev((stderr, "inflate: trees ok\n")); + if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + s->sub.decode.codes = c; + } + ZFREE(z, s->sub.trees.blens); + s->mode = CODES; + case CODES: + UPDATE + if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) + return inflate_flush(s, z, r); + r = Z_OK; + inflate_codes_free(s->sub.decode.codes, z); + LOAD + Tracev((stderr, "inflate: codes end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + if (!s->last) + { + s->mode = TYPE; + break; + } + s->mode = DRY; + case DRY: + FLUSH + if (s->read != s->write) + LEAVE + s->mode = DONE; + case DONE: + r = Z_STREAM_END; + LEAVE + case BAD: + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +} + + +int inflate_blocks_free(s, z) +inflate_blocks_statef *s; +z_streamp z; +{ + inflate_blocks_reset(s, z, Z_NULL); + ZFREE(z, s->window); + ZFREE(z, s->hufts); + ZFREE(z, s); + Tracev((stderr, "inflate: blocks freed\n")); + return Z_OK; +} + + +void inflate_set_dictionary(s, d, n) +inflate_blocks_statef *s; +const Bytef *d; +uInt n; +{ + zmemcpy(s->window, d, n); + s->read = s->write = s->window + n; +} + + +/* Returns true if inflate is currently at the end of a block generated + * by Z_SYNC_FLUSH or Z_FULL_FLUSH. + * IN assertion: s != Z_NULL + */ +int inflate_blocks_sync_point(s) +inflate_blocks_statef *s; +{ + return s->mode == LENS; +} diff --git a/Utilities/GDAL/frmts/zlib/infblock.h b/Utilities/GDAL/frmts/zlib/infblock.h new file mode 100644 index 0000000000..bd25c80753 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infblock.h @@ -0,0 +1,39 @@ +/* infblock.h -- header to use infblock.c + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +struct inflate_blocks_state; +typedef struct inflate_blocks_state FAR inflate_blocks_statef; + +extern inflate_blocks_statef * inflate_blocks_new OF(( + z_streamp z, + check_func c, /* check function */ + uInt w)); /* window size */ + +extern int inflate_blocks OF(( + inflate_blocks_statef *, + z_streamp , + int)); /* initial return code */ + +extern void inflate_blocks_reset OF(( + inflate_blocks_statef *, + z_streamp , + uLongf *)); /* check value on output */ + +extern int inflate_blocks_free OF(( + inflate_blocks_statef *, + z_streamp)); + +extern void inflate_set_dictionary OF(( + inflate_blocks_statef *s, + const Bytef *d, /* dictionary */ + uInt n)); /* dictionary length */ + +extern int inflate_blocks_sync_point OF(( + inflate_blocks_statef *s)); diff --git a/Utilities/GDAL/frmts/zlib/infcodes.c b/Utilities/GDAL/frmts/zlib/infcodes.c new file mode 100644 index 0000000000..d4e5ee9a55 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infcodes.c @@ -0,0 +1,257 @@ +/* infcodes.c -- process literals and length/distance pairs + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#include "inffast.h" + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + START, /* x: set up for LEN */ + LEN, /* i: get length/literal/eob next */ + LENEXT, /* i: getting length extra (have base) */ + DIST, /* i: get distance next */ + DISTEXT, /* i: getting distance extra */ + COPY, /* o: copying bytes in window, waiting for space */ + LIT, /* o: got literal, waiting for output space */ + WASH, /* o: got eob, possibly still output waiting */ + END, /* x: got eob and all data flushed */ + BADCODE} /* x: got error */ +inflate_codes_mode; + +/* inflate codes private state */ +struct inflate_codes_state { + + /* mode */ + inflate_codes_mode mode; /* current inflate_codes mode */ + + /* mode dependent information */ + uInt len; + union { + struct { + inflate_huft *tree; /* pointer into tree */ + uInt need; /* bits needed */ + } code; /* if LEN or DIST, where in tree */ + uInt lit; /* if LIT, literal */ + struct { + uInt get; /* bits to get for extra */ + uInt dist; /* distance back to copy from */ + } copy; /* if EXT or COPY, where and how much */ + } sub; /* submode */ + + /* mode independent information */ + Byte lbits; /* ltree bits decoded per branch */ + Byte dbits; /* dtree bits decoder per branch */ + inflate_huft *ltree; /* literal/length/eob tree */ + inflate_huft *dtree; /* distance tree */ + +}; + + +inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) +uInt bl, bd; +inflate_huft *tl; +inflate_huft *td; /* need separate declaration for Borland C++ */ +z_streamp z; +{ + inflate_codes_statef *c; + + if ((c = (inflate_codes_statef *) + ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) + { + c->mode = START; + c->lbits = (Byte)bl; + c->dbits = (Byte)bd; + c->ltree = tl; + c->dtree = td; + Tracev((stderr, "inflate: codes new\n")); + } + return c; +} + + +int inflate_codes(s, z, r) +inflate_blocks_statef *s; +z_streamp z; +int r; +{ + uInt j; /* temporary storage */ + inflate_huft *t; /* temporary pointer */ + uInt e; /* extra bits or operation */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + Bytef *f; /* pointer to copy strings from */ + inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input and output based on current state */ + while (1) switch (c->mode) + { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + case START: /* x: set up for LEN */ +#ifndef SLOW + if (m >= 258 && n >= 10) + { + UPDATE + r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); + LOAD + if (r != Z_OK) + { + c->mode = r == Z_STREAM_END ? WASH : BADCODE; + break; + } + } +#endif /* !SLOW */ + c->sub.code.need = c->lbits; + c->sub.code.tree = c->ltree; + c->mode = LEN; + case LEN: /* i: get length/literal/eob next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e == 0) /* literal */ + { + c->sub.lit = t->base; + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", t->base)); + c->mode = LIT; + break; + } + if (e & 16) /* length */ + { + c->sub.copy.get = e & 15; + c->len = t->base; + c->mode = LENEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + if (e & 32) /* end of block */ + { + Tracevv((stderr, "inflate: end of block\n")); + c->mode = WASH; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid literal/length code"; + r = Z_DATA_ERROR; + LEAVE + case LENEXT: /* i: getting length extra (have base) */ + j = c->sub.copy.get; + NEEDBITS(j) + c->len += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + c->sub.code.need = c->dbits; + c->sub.code.tree = c->dtree; + Tracevv((stderr, "inflate: length %u\n", c->len)); + c->mode = DIST; + case DIST: /* i: get distance next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e & 16) /* distance */ + { + c->sub.copy.get = e & 15; + c->sub.copy.dist = t->base; + c->mode = DISTEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid distance code"; + r = Z_DATA_ERROR; + LEAVE + case DISTEXT: /* i: getting distance extra */ + j = c->sub.copy.get; + NEEDBITS(j) + c->sub.copy.dist += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); + c->mode = COPY; + case COPY: /* o: copying bytes in window, waiting for space */ +#ifndef __TURBOC__ /* Turbo C bug for following expression */ + f = (uInt)(q - s->window) < c->sub.copy.dist ? + s->end - (c->sub.copy.dist - (q - s->window)) : + q - c->sub.copy.dist; +#else + f = q - c->sub.copy.dist; + if ((uInt)(q - s->window) < c->sub.copy.dist) + f = s->end - (c->sub.copy.dist - (uInt)(q - s->window)); +#endif + while (c->len) + { + NEEDOUT + OUTBYTE(*f++) + if (f == s->end) + f = s->window; + c->len--; + } + c->mode = START; + break; + case LIT: /* o: got literal, waiting for output space */ + NEEDOUT + OUTBYTE(c->sub.lit) + c->mode = START; + break; + case WASH: /* o: got eob, possibly more output */ + if (k > 7) /* return unused byte, if any */ + { + Assert(k < 16, "inflate_codes grabbed too many bytes") + k -= 8; + n++; + p--; /* can always return one */ + } + FLUSH + if (s->read != s->write) + LEAVE + c->mode = END; + case END: + r = Z_STREAM_END; + LEAVE + case BADCODE: /* x: got error */ + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + + +void inflate_codes_free(c, z) +inflate_codes_statef *c; +z_streamp z; +{ + ZFREE(z, c); + Tracev((stderr, "inflate: codes free\n")); +} diff --git a/Utilities/GDAL/frmts/zlib/infcodes.h b/Utilities/GDAL/frmts/zlib/infcodes.h new file mode 100644 index 0000000000..6c750d896f --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infcodes.h @@ -0,0 +1,27 @@ +/* infcodes.h -- header to use infcodes.c + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +struct inflate_codes_state; +typedef struct inflate_codes_state FAR inflate_codes_statef; + +extern inflate_codes_statef *inflate_codes_new OF(( + uInt, uInt, + inflate_huft *, inflate_huft *, + z_streamp )); + +extern int inflate_codes OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +extern void inflate_codes_free OF(( + inflate_codes_statef *, + z_streamp )); + diff --git a/Utilities/GDAL/frmts/zlib/inffast.c b/Utilities/GDAL/frmts/zlib/inffast.c new file mode 100644 index 0000000000..61a78ee933 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inffast.c @@ -0,0 +1,170 @@ +/* inffast.c -- process literals and length/distance pairs fast + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#include "inffast.h" + +struct inflate_codes_state {int dummy;}; /* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +/* macros for bit input with no checking and for returning unused bytes */ +#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} +#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} + +/* Called with number of bytes left to write in window at least 258 + (the maximum string length) and number of input bytes available + at least ten. The ten bytes are six bytes for the longest length/ + distance pair plus four bytes for overloading the bit buffer. */ + +int inflate_fast(bl, bd, tl, td, s, z) +uInt bl, bd; +inflate_huft *tl; +inflate_huft *td; /* need separate declaration for Borland C++ */ +inflate_blocks_statef *s; +z_streamp z; +{ + inflate_huft *t; /* temporary pointer */ + uInt e; /* extra bits or operation */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + uInt ml; /* mask for literal/length tree */ + uInt md; /* mask for distance tree */ + uInt c; /* bytes to copy */ + uInt d; /* distance back to copy from */ + Bytef *r; /* copy source pointer */ + + /* load input, output, bit values */ + LOAD + + /* initialize masks */ + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + /* do until not enough input or output space for fast loop */ + do { /* assume called with m >= 258 && n >= 10 */ + /* get literal/length code */ + GRABBITS(20) /* max bits for literal/length code */ + if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + continue; + } + do { + DUMPBITS(t->bits) + if (e & 16) + { + /* get extra bits for length */ + e &= 15; + c = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * length %u\n", c)); + + /* decode distance base of block to copy */ + GRABBITS(15); /* max bits for distance code */ + e = (t = td + ((uInt)b & md))->exop; + do { + DUMPBITS(t->bits) + if (e & 16) + { + /* get extra bits to add to distance base */ + e &= 15; + GRABBITS(e) /* get extra bits (up to 13) */ + d = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * distance %u\n", d)); + + /* do the copy */ + m -= c; + if ((uInt)(q - s->window) >= d) /* offset before dest */ + { /* just copy */ + r = q - d; + *q++ = *r++; c--; /* minimum count is three, */ + *q++ = *r++; c--; /* so unroll loop a little */ + } + else /* else offset after destination */ + { + e = d - (uInt)(q - s->window); /* bytes from offset to end */ + r = s->end - e; /* pointer to offset */ + if (c > e) /* if source crosses, */ + { + c -= e; /* copy to end of window */ + do { + *q++ = *r++; + } while (--e); + r = s->window; /* copy rest from start of window */ + } + } + do { /* copy all or what's left */ + *q++ = *r++; + } while (--c); + break; + } + else if ((e & 64) == 0) + { + t += t->base; + e = (t += ((uInt)b & inflate_mask[e]))->exop; + } + else + { + z->msg = (char*)"invalid distance code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + } while (1); + break; + } + if ((e & 64) == 0) + { + t += t->base; + if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + break; + } + } + else if (e & 32) + { + Tracevv((stderr, "inflate: * end of block\n")); + UNGRAB + UPDATE + return Z_STREAM_END; + } + else + { + z->msg = (char*)"invalid literal/length code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + } while (1); + } while (m >= 258 && n >= 10); + + /* not enough input or output--restore pointers and return */ + UNGRAB + UPDATE + return Z_OK; +} diff --git a/Utilities/GDAL/frmts/zlib/inffast.h b/Utilities/GDAL/frmts/zlib/inffast.h new file mode 100644 index 0000000000..8facec5531 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inffast.h @@ -0,0 +1,17 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +extern int inflate_fast OF(( + uInt, + uInt, + inflate_huft *, + inflate_huft *, + inflate_blocks_statef *, + z_streamp )); diff --git a/Utilities/GDAL/frmts/zlib/inffixed.h b/Utilities/GDAL/frmts/zlib/inffixed.h new file mode 100644 index 0000000000..77f7e76314 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inffixed.h @@ -0,0 +1,151 @@ +/* inffixed.h -- table for decoding fixed codes + * Generated automatically by the maketree.c program + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +local uInt fixed_bl = 9; +local uInt fixed_bd = 5; +local inflate_huft fixed_tl[] = { + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} + }; +local inflate_huft fixed_td[] = { + {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, + {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, + {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, + {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, + {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, + {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, + {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, + {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} + }; diff --git a/Utilities/GDAL/frmts/zlib/inflate.c b/Utilities/GDAL/frmts/zlib/inflate.c new file mode 100644 index 0000000000..32e9b8de67 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inflate.c @@ -0,0 +1,366 @@ +/* inflate.c -- zlib interface to inflate modules + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" + +struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ + +typedef enum { + METHOD, /* waiting for method byte */ + FLAG, /* waiting for flag byte */ + DICT4, /* four dictionary check bytes to go */ + DICT3, /* three dictionary check bytes to go */ + DICT2, /* two dictionary check bytes to go */ + DICT1, /* one dictionary check byte to go */ + DICT0, /* waiting for inflateSetDictionary */ + BLOCKS, /* decompressing blocks */ + CHECK4, /* four check bytes to go */ + CHECK3, /* three check bytes to go */ + CHECK2, /* two check bytes to go */ + CHECK1, /* one check byte to go */ + DONE, /* finished check, done */ + BAD} /* got an error--stay here */ +inflate_mode; + +/* inflate private state */ +struct internal_state { + + /* mode */ + inflate_mode mode; /* current inflate mode */ + + /* mode dependent information */ + union { + uInt method; /* if FLAGS, method byte */ + struct { + uLong was; /* computed check value */ + uLong need; /* stream check value */ + } check; /* if CHECK, check values to compare */ + uInt marker; /* if BAD, inflateSync's marker bytes count */ + } sub; /* submode */ + + /* mode independent information */ + int nowrap; /* flag for no wrapper */ + uInt wbits; /* log2(window size) (8..15, defaults to 15) */ + inflate_blocks_statef + *blocks; /* current inflate_blocks state */ + +}; + + +int ZEXPORT inflateReset(z) +z_streamp z; +{ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + z->total_in = z->total_out = 0; + z->msg = Z_NULL; + z->state->mode = z->state->nowrap ? BLOCKS : METHOD; + inflate_blocks_reset(z->state->blocks, z, Z_NULL); + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + + +int ZEXPORT inflateEnd(z) +z_streamp z; +{ + if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->blocks != Z_NULL) + inflate_blocks_free(z->state->blocks, z); + ZFREE(z, z->state); + z->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + + +int ZEXPORT inflateInit2_(z, w, version, stream_size) +z_streamp z; +int w; +const char *version; +int stream_size; +{ + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != sizeof(z_stream)) + return Z_VERSION_ERROR; + + /* initialize state */ + if (z == Z_NULL) + return Z_STREAM_ERROR; + z->msg = Z_NULL; + if (z->zalloc == Z_NULL) + { + z->zalloc = zcalloc; + z->opaque = (voidpf)0; + } + if (z->zfree == Z_NULL) z->zfree = zcfree; + if ((z->state = (struct internal_state FAR *) + ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) + return Z_MEM_ERROR; + z->state->blocks = Z_NULL; + + /* handle undocumented nowrap option (no zlib header or check) */ + z->state->nowrap = 0; + if (w < 0) + { + w = - w; + z->state->nowrap = 1; + } + + /* set window size */ + if (w < 8 || w > 15) + { + inflateEnd(z); + return Z_STREAM_ERROR; + } + z->state->wbits = (uInt)w; + + /* create inflate_blocks state */ + if ((z->state->blocks = + inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) + == Z_NULL) + { + inflateEnd(z); + return Z_MEM_ERROR; + } + Tracev((stderr, "inflate: allocated\n")); + + /* reset state */ + inflateReset(z); + return Z_OK; +} + + +int ZEXPORT inflateInit_(z, version, stream_size) +z_streamp z; +const char *version; +int stream_size; +{ + return inflateInit2_(z, DEF_WBITS, version, stream_size); +} + + +#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} +#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) + +int ZEXPORT inflate(z, f) +z_streamp z; +int f; +{ + int r; + uInt b; + + if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) + return Z_STREAM_ERROR; + f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; + r = Z_BUF_ERROR; + while (1) switch (z->state->mode) + { + case METHOD: + NEEDBYTE + if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) + { + z->state->mode = BAD; + z->msg = (char*)"unknown compression method"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + if ((z->state->sub.method >> 4) + 8 > z->state->wbits) + { + z->state->mode = BAD; + z->msg = (char*)"invalid window size"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + z->state->mode = FLAG; + case FLAG: + NEEDBYTE + b = NEXTBYTE; + if (((z->state->sub.method << 8) + b) % 31) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect header check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib header ok\n")); + if (!(b & PRESET_DICT)) + { + z->state->mode = BLOCKS; + break; + } + z->state->mode = DICT4; + case DICT4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = DICT3; + case DICT3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = DICT2; + case DICT2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = DICT1; + case DICT1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + z->adler = z->state->sub.check.need; + z->state->mode = DICT0; + return Z_NEED_DICT; + case DICT0: + z->state->mode = BAD; + z->msg = (char*)"need dictionary"; + z->state->sub.marker = 0; /* can try inflateSync */ + return Z_STREAM_ERROR; + case BLOCKS: + r = inflate_blocks(z->state->blocks, z, r); + if (r == Z_DATA_ERROR) + { + z->state->mode = BAD; + z->state->sub.marker = 0; /* can try inflateSync */ + break; + } + if (r == Z_OK) + r = f; + if (r != Z_STREAM_END) + return r; + r = f; + inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); + if (z->state->nowrap) + { + z->state->mode = DONE; + break; + } + z->state->mode = CHECK4; + case CHECK4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = CHECK3; + case CHECK3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = CHECK2; + case CHECK2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = CHECK1; + case CHECK1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + + if (z->state->sub.check.was != z->state->sub.check.need) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect data check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib check ok\n")); + z->state->mode = DONE; + case DONE: + return Z_STREAM_END; + case BAD: + return Z_DATA_ERROR; + default: + return Z_STREAM_ERROR; + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + + +int ZEXPORT inflateSetDictionary(z, dictionary, dictLength) +z_streamp z; +const Bytef *dictionary; +uInt dictLength; +{ + uInt length = dictLength; + + if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) + return Z_STREAM_ERROR; + + if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; + z->adler = 1L; + + if (length >= ((uInt)1<<z->state->wbits)) + { + length = (1<<z->state->wbits)-1; + dictionary += dictLength - length; + } + inflate_set_dictionary(z->state->blocks, dictionary, length); + z->state->mode = BLOCKS; + return Z_OK; +} + + +int ZEXPORT inflateSync(z) +z_streamp z; +{ + uInt n; /* number of bytes to look at */ + Bytef *p; /* pointer to bytes */ + uInt m; /* number of marker bytes found in a row */ + uLong r, w; /* temporaries to save total_in and total_out */ + + /* set up */ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->mode != BAD) + { + z->state->mode = BAD; + z->state->sub.marker = 0; + } + if ((n = z->avail_in) == 0) + return Z_BUF_ERROR; + p = z->next_in; + m = z->state->sub.marker; + + /* search */ + while (n && m < 4) + { + static const Byte mark[4] = {0, 0, 0xff, 0xff}; + if (*p == mark[m]) + m++; + else if (*p) + m = 0; + else + m = 4 - m; + p++, n--; + } + + /* restore */ + z->total_in += p - z->next_in; + z->next_in = p; + z->avail_in = n; + z->state->sub.marker = m; + + /* return no joy or set up to restart on a new block */ + if (m != 4) + return Z_DATA_ERROR; + r = z->total_in; w = z->total_out; + inflateReset(z); + z->total_in = r; z->total_out = w; + z->state->mode = BLOCKS; + return Z_OK; +} + + +/* Returns true if inflate is currently at the end of a block generated + * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH + * but removes the length bytes of the resulting empty stored block. When + * decompressing, PPP checks that at the end of input packet, inflate is + * waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint(z) +z_streamp z; +{ + if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) + return Z_STREAM_ERROR; + return inflate_blocks_sync_point(z->state->blocks); +} diff --git a/Utilities/GDAL/frmts/zlib/inftrees.c b/Utilities/GDAL/frmts/zlib/inftrees.c new file mode 100644 index 0000000000..ef1e0b6b87 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inftrees.c @@ -0,0 +1,455 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "inftrees.h" + +#if !defined(BUILDFIXED) && !defined(STDC) +# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ +#endif + +const char inflate_copyright[] = + " inflate 1.1.3 Copyright 1995-1998 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ +struct internal_state {int dummy;}; /* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + + +local int huft_build OF(( + uIntf *, /* code lengths in bits */ + uInt, /* number of codes */ + uInt, /* number of "simple" codes */ + const uIntf *, /* list of base values for non-simple codes */ + const uIntf *, /* list of extra bits for non-simple codes */ + inflate_huft * FAR*,/* result: starting table */ + uIntf *, /* maximum lookup bits (returns actual) */ + inflate_huft *, /* space for trees */ + uInt *, /* hufts used in space */ + uIntf * )); /* space for values */ + +/* Tables for deflate from PKZIP's appnote.txt. */ +local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + /* see note #13 above about 258 */ +local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ +local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; +local const uInt cpdext[30] = { /* Extra bits for distance codes */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + +/* + Huffman code decoding is performed using a multi-level table lookup. + The fastest way to decode is to simply build a lookup table whose + size is determined by the longest code. However, the time it takes + to build this table can also be a factor if the data being decoded + is not very long. The most common codes are necessarily the + shortest codes, so those codes dominate the decoding time, and hence + the speed. The idea is you can have a shorter table that decodes the + shorter, more probable codes, and then point to subsidiary tables for + the longer codes. The time it costs to decode the longer codes is + then traded against the time it takes to make longer tables. + + This results of this trade are in the variables lbits and dbits + below. lbits is the number of bits the first level table for literal/ + length codes can decode in one step, and dbits is the same thing for + the distance codes. Subsequent tables are also less than or equal to + those sizes. These values may be adjusted either when all of the + codes are shorter than that, in which case the longest code length in + bits is used, or when the shortest code is *longer* than the requested + table size, in which case the length of the shortest code in bits is + used. + + There are two different values for the two tables, since they code a + different number of possibilities each. The literal/length table + codes 286 possible values, or in a flat code, a little over eight + bits. The distance table codes 30 possible values, or a little less + than five bits, flat. The optimum values for speed end up being + about one bit more than those, so lbits is 8+1 and dbits is 5+1. + The optimum values may differ though from machine to machine, and + possibly even between compilers. Your mileage may vary. + */ + + +/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ +#define BMAX 15 /* maximum bit length of any code */ + +local int huft_build(b, n, s, d, e, t, m, hp, hn, v) +uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ +uInt n; /* number of codes (assumed <= 288) */ +uInt s; /* number of simple-valued codes (0..s-1) */ +const uIntf *d; /* list of base values for non-simple codes */ +const uIntf *e; /* list of extra bits for non-simple codes */ +inflate_huft * FAR *t; /* result: starting table */ +uIntf *m; /* maximum lookup bits, returns actual */ +inflate_huft *hp; /* space for trees */ +uInt *hn; /* hufts used in space */ +uIntf *v; /* working area: values in order of bit length */ +/* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR + if the given code set is incomplete (the tables are still built in this + case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of + lengths), or Z_MEM_ERROR if not enough memory. */ +{ + + uInt a; /* counter for codes of length k */ + uInt c[BMAX+1]; /* bit length count table */ + uInt f; /* i repeats in table every f entries */ + int g; /* maximum code length */ + int h; /* table level */ + register uInt i; /* counter, current code */ + register uInt j; /* counter */ + register int k; /* number of bits in current code */ + int l; /* bits per table (returned in m) */ + uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ + register uIntf *p; /* pointer into c[], b[], or v[] */ + inflate_huft *q; /* points to current table */ + struct inflate_huft_s r; /* table entry for structure assignment */ + inflate_huft *u[BMAX]; /* table stack */ + register int w; /* bits before this table == (l * h) */ + uInt x[BMAX+1]; /* bit offsets, then code stack */ + uIntf *xp; /* pointer into x */ + int y; /* number of dummy codes added */ + uInt z; /* number of entries in current table */ + + + /* Generate counts for each bit length */ + p = c; +#define C0 *p++ = 0; +#define C2 C0 C0 C0 C0 +#define C4 C2 C2 C2 C2 + C4 /* clear c[]--assume BMAX+1 is 16 */ + p = b; i = n; + do { + c[*p++]++; /* assume all entries <= BMAX */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ + { + *t = (inflate_huft *)Z_NULL; + *m = 0; + return Z_OK; + } + + + /* Find minimum and maximum length, bound *m by those */ + l = *m; + for (j = 1; j <= BMAX; j++) + if (c[j]) + break; + k = j; /* minimum code length */ + if ((uInt)l < j) + l = j; + for (i = BMAX; i; i--) + if (c[i]) + break; + g = i; /* maximum code length */ + if ((uInt)l > i) + l = i; + *m = l; + + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return Z_DATA_ERROR; + if ((y -= c[i]) < 0) + return Z_DATA_ERROR; + c[i] += y; + + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; xp = x + 2; + while (--i) { /* note that i == g from above */ + *xp++ = (j += *p++); + } + + + /* Make a table of values in order of bit lengths */ + p = b; i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + n = x[g]; /* set n to length of v */ + + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + h = -1; /* no tables yet--level -1 */ + w = -l; /* bits decoded == (l * h) */ + u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ + q = (inflate_huft *)Z_NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > w + l) + { + h++; + w += l; /* previous table always l bits */ + + /* compute minimum size table less than or equal to l bits */ + z = g - w; + z = z > (uInt)l ? l : z; /* table size upper limit */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + if (j < z) + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + f -= *xp; /* else deduct codes from patterns */ + } + } + z = 1 << j; /* table entries for j-bit table */ + + /* allocate new table */ + if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ + return Z_MEM_ERROR; /* not enough memory */ + u[h] = q = hp + *hn; + *hn += z; + + /* connect to last table, if there is one */ + if (h) + { + x[h] = i; /* save pattern for backing up */ + r.bits = (Byte)l; /* bits to dump before this table */ + r.exop = (Byte)j; /* bits in this table */ + j = i >> (w - l); + r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ + u[h-1][j] = r; /* connect to last table */ + } + else + *t = q; /* first table is returned result */ + } + + /* set up table entry in r */ + r.bits = (Byte)(k - w); + if (p >= v + n) + r.exop = 128 + 64; /* out of values--invalid code */ + else if (*p < s) + { + r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ + r.base = *p++; /* simple code is just the value */ + } + else + { + r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ + r.base = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + + /* backup over finished tables */ + mask = (1 << w) - 1; /* needed on HP, cc -O bug */ + while ((i & mask) != x[h]) + { + h--; /* don't need to update q */ + w -= l; + mask = (1 << w) - 1; + } + } + } + + + /* Return Z_BUF_ERROR if we were given an incomplete table */ + return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; +} + + +int inflate_trees_bits(c, bb, tb, hp, z) +uIntf *c; /* 19 code lengths */ +uIntf *bb; /* bits tree desired/actual depth */ +inflate_huft * FAR *tb; /* bits tree result */ +inflate_huft *hp; /* space for trees */ +z_streamp z; /* for messages */ +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, + tb, bb, hp, &hn, v); + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed dynamic bit lengths tree"; + else if (r == Z_BUF_ERROR || *bb == 0) + { + z->msg = (char*)"incomplete dynamic bit lengths tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +} + + +int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) +uInt nl; /* number of literal/length codes */ +uInt nd; /* number of distance codes */ +uIntf *c; /* that many (total) code lengths */ +uIntf *bl; /* literal desired/actual bit depth */ +uIntf *bd; /* distance desired/actual bit depth */ +inflate_huft * FAR *tl; /* literal/length tree result */ +inflate_huft * FAR *td; /* distance tree result */ +inflate_huft *hp; /* space for trees */ +z_streamp z; /* for messages */ +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + /* allocate work area */ + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + + /* build literal/length tree */ + r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); + if (r != Z_OK || *bl == 0) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed literal/length tree"; + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"incomplete literal/length tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; + } + + /* build distance tree */ + r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); + if (r != Z_OK || (*bd == 0 && nl > 257)) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed distance tree"; + else if (r == Z_BUF_ERROR) { +#ifdef PKZIP_BUG_WORKAROUND + r = Z_OK; + } +#else + z->msg = (char*)"incomplete distance tree"; + r = Z_DATA_ERROR; + } + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"empty distance tree with lengths"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +#endif + } + + /* done */ + ZFREE(z, v); + return Z_OK; +} + + +/* build fixed tables only once--keep them here */ +#ifdef BUILDFIXED +local int fixed_built = 0; +#define FIXEDH 544 /* number of hufts used by fixed tables */ +local inflate_huft fixed_mem[FIXEDH]; +local uInt fixed_bl; +local uInt fixed_bd; +local inflate_huft *fixed_tl; +local inflate_huft *fixed_td; +#else +#include "inffixed.h" +#endif + + +int inflate_trees_fixed(bl, bd, tl, td, z) +uIntf *bl; /* literal desired/actual bit depth */ +uIntf *bd; /* distance desired/actual bit depth */ +inflate_huft * FAR *tl; /* literal/length tree result */ +inflate_huft * FAR *td; /* distance tree result */ +z_streamp z; /* for memory allocation */ +{ +#ifdef BUILDFIXED + /* build fixed tables if not already */ + if (!fixed_built) + { + int k; /* temporary variable */ + uInt f = 0; /* number of hufts used in fixed_mem */ + uIntf *c; /* length list for huft_build */ + uIntf *v; /* work area for huft_build */ + + /* allocate memory */ + if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + { + ZFREE(z, c); + return Z_MEM_ERROR; + } + + /* literal table */ + for (k = 0; k < 144; k++) + c[k] = 8; + for (; k < 256; k++) + c[k] = 9; + for (; k < 280; k++) + c[k] = 7; + for (; k < 288; k++) + c[k] = 8; + fixed_bl = 9; + huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, + fixed_mem, &f, v); + + /* distance table */ + for (k = 0; k < 30; k++) + c[k] = 5; + fixed_bd = 5; + huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, + fixed_mem, &f, v); + + /* done */ + ZFREE(z, v); + ZFREE(z, c); + fixed_built = 1; + } +#endif + *bl = fixed_bl; + *bd = fixed_bd; + *tl = fixed_tl; + *td = fixed_td; + return Z_OK; +} diff --git a/Utilities/GDAL/frmts/zlib/inftrees.h b/Utilities/GDAL/frmts/zlib/inftrees.h new file mode 100644 index 0000000000..85853e097b --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/inftrees.h @@ -0,0 +1,58 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Huffman code lookup table entry--this entry is four bytes for machines + that have 16-bit pointers (e.g. PC's in the small or medium model). */ + +typedef struct inflate_huft_s FAR inflate_huft; + +struct inflate_huft_s { + union { + struct { + Byte Exop; /* number of extra bits or operation */ + Byte Bits; /* number of bits in this code or subcode */ + } what; + uInt pad; /* pad structure to a power of 2 (4 bytes for */ + } word; /* 16-bit, 8 bytes for 32-bit int's) */ + uInt base; /* literal, length base, distance base, + or table offset */ +}; + +/* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1004 huft structures (850 for length/literals + and 154 for distances, the latter actually the result of an + exhaustive search). The actual maximum is not known, but the + value below is more than safe. */ +#define MANY 1440 + +extern int inflate_trees_bits OF(( + uIntf *, /* 19 code lengths */ + uIntf *, /* bits tree desired/actual depth */ + inflate_huft * FAR *, /* bits tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +extern int inflate_trees_dynamic OF(( + uInt, /* number of literal/length codes */ + uInt, /* number of distance codes */ + uIntf *, /* that many (total) code lengths */ + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + inflate_huft * FAR *, /* literal/length tree result */ + inflate_huft * FAR *, /* distance tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +extern int inflate_trees_fixed OF(( + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + inflate_huft * FAR *, /* literal/length tree result */ + inflate_huft * FAR *, /* distance tree result */ + z_streamp)); /* for memory allocation */ diff --git a/Utilities/GDAL/frmts/zlib/infutil.c b/Utilities/GDAL/frmts/zlib/infutil.c new file mode 100644 index 0000000000..824dab5712 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infutil.c @@ -0,0 +1,87 @@ +/* inflate_util.c -- data and routines common to blocks and codes + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + +struct inflate_codes_state {int dummy;}; /* for buggy compilers */ + +/* And'ing with mask[n] masks the lower n bits */ +uInt inflate_mask[17] = { + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + + +/* copy as much as possible from the sliding window to the output area */ +int inflate_flush(s, z, r) +inflate_blocks_statef *s; +z_streamp z; +int r; +{ + uInt n; + Bytef *p; + Bytef *q; + + /* local copies of source and destination pointers */ + p = z->next_out; + q = s->read; + + /* compute number of bytes to copy as far as end of window */ + n = (uInt)((q <= s->write ? s->write : s->end) - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy as far as end of window */ + zmemcpy(p, q, n); + p += n; + q += n; + + /* see if more to copy at beginning of window */ + if (q == s->end) + { + /* wrap pointers */ + q = s->window; + if (s->write == s->end) + s->write = s->window; + + /* compute bytes to copy */ + n = (uInt)(s->write - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy */ + zmemcpy(p, q, n); + p += n; + q += n; + } + + /* update pointers */ + z->next_out = p; + s->read = q; + + /* done */ + return r; +} diff --git a/Utilities/GDAL/frmts/zlib/infutil.h b/Utilities/GDAL/frmts/zlib/infutil.h new file mode 100644 index 0000000000..99d1135d06 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/infutil.h @@ -0,0 +1,98 @@ +/* infutil.h -- types and macros common to blocks and codes + * Copyright (C) 1995-1998 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +#ifndef _INFUTIL_H +#define _INFUTIL_H + +typedef enum { + TYPE, /* get type bits (3, including end bit) */ + LENS, /* get lengths for stored */ + STORED, /* processing stored block */ + TABLE, /* get table lengths */ + BTREE, /* get bit lengths tree for a dynamic block */ + DTREE, /* get length, distance trees for a dynamic block */ + CODES, /* processing fixed or dynamic block */ + DRY, /* output remaining window bytes */ + DONE, /* finished last block, done */ + BAD} /* got a data error--stuck here */ +inflate_block_mode; + +/* inflate blocks semi-private state */ +struct inflate_blocks_state { + + /* mode */ + inflate_block_mode mode; /* current inflate_block mode */ + + /* mode dependent information */ + union { + uInt left; /* if STORED, bytes left to copy */ + struct { + uInt table; /* table lengths (14 bits) */ + uInt index; /* index into blens (or border) */ + uIntf *blens; /* bit lengths of codes */ + uInt bb; /* bit length tree depth */ + inflate_huft *tb; /* bit length decoding tree */ + } trees; /* if DTREE, decoding info for trees */ + struct { + inflate_codes_statef + *codes; + } decode; /* if CODES, current state */ + } sub; /* submode */ + uInt last; /* true if this block is the last block */ + + /* mode independent information */ + uInt bitk; /* bits in bit buffer */ + uLong bitb; /* bit buffer */ + inflate_huft *hufts; /* single malloc for tree space */ + Bytef *window; /* sliding window */ + Bytef *end; /* one byte after sliding window */ + Bytef *read; /* window read pointer */ + Bytef *write; /* window write pointer */ + check_func checkfn; /* check function */ + uLong check; /* check on output */ + +}; + + +/* defines for inflate input/output */ +/* update pointers and return */ +#define UPDBITS {s->bitb=b;s->bitk=k;} +#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} +#define UPDOUT {s->write=q;} +#define UPDATE {UPDBITS UPDIN UPDOUT} +#define LEAVE {UPDATE return inflate_flush(s,z,r);} +/* get bytes and bits */ +#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} +#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} +#define NEXTBYTE (n--,*p++) +#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} +#define DUMPBITS(j) {b>>=(j);k-=(j);} +/* output bytes */ +#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) +#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} +#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} +#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} +#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} +#define OUTBYTE(a) {*q++=(Byte)(a);m--;} +/* load local pointers */ +#define LOAD {LOADIN LOADOUT} + +/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ +extern uInt inflate_mask[17]; + +/* copy as much as possible from the sliding window to the output area */ +extern int inflate_flush OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +struct internal_state {int dummy;}; /* for buggy compilers */ + +#endif diff --git a/Utilities/GDAL/frmts/zlib/makefile.vc b/Utilities/GDAL/frmts/zlib/makefile.vc new file mode 100644 index 0000000000..664d127fc7 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/makefile.vc @@ -0,0 +1,16 @@ + +OBJ = \ + adler32.obj compress.obj crc32.obj deflate.obj gzio.obj \ + infblock.obj infcodes.obj inffast.obj inflate.obj \ + infutil.obj inftrees.obj trees.obj uncompr.obj zutil.obj + +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj ..\o + +clean: + -del *.obj + diff --git a/Utilities/GDAL/frmts/zlib/trees.c b/Utilities/GDAL/frmts/zlib/trees.c new file mode 100644 index 0000000000..f01fb30d85 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/trees.c @@ -0,0 +1,1214 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-1998 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* @(#) $Id$ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include <ctype.h> +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local void set_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits(s, value, length) + deflate_state *s; + int value; /* value to send */ + int length; /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (value << s->bi_valid); + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (val << s->bi_valid);\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +#define MAX(a,b) (a >= b ? a : b) +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1<<extra_lbits[code]); n++) { + _length_code[length++] = (uch)code; + } + } + Assert (length == 256, "tr_static_init: length != 256"); + /* Note that the length 255 (match length 258) can be represented + * in two different ways: code 284 + 5 bits or code 285, so we + * overwrite length_code[255] to use the best encoding: + */ + _length_code[length-1] = (uch)code; + + /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<<extra_dbits[code]); n++) { + _dist_code[dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: dist != 256"); + dist >>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include <stdio.h> +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void _tr_init(s) + deflate_state *s; +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block(s) + deflate_state *s; +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap(s, tree, k) + deflate_state *s; + ct_data *tree; /* the tree to restore */ + int k; /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if (tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes (tree, max_code, bl_count) + ct_data *tree; /* the tree to decorate */ + int max_code; /* largest code with non zero frequency */ + ushf *bl_count; /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1, + "inconsistent bit counts"); + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + if (len == 0) continue; + /* Now reverse the bits */ + tree[n].Code = bi_reverse(next_code[len]++, len); + + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1)); + } +} + +/* =========================================================================== + * Construct one Huffman tree and assigns the code bit strings and lengths. + * Update the total bit length for the current block. + * IN assertion: the field freq is set for all tree elements. + * OUT assertions: the fields len and code are set to the optimal bit length + * and corresponding code. The length opt_len is updated; static_len is + * also updated if stree is not null. The field max_code is set. + */ +local void build_tree(s, desc) + deflate_state *s; + tree_desc *desc; /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree (s, tree, max_code) + deflate_state *s; + ct_data *tree; /* the tree to be scanned */ + int max_code; /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree(s) + deflate_state *s; +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees(s, lcodes, dcodes, blcodes) + deflate_state *s; + int lcodes, dcodes, blcodes; /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void _tr_stored_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void _tr_align(s) + deflate_state *s; +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void _tr_flush_block(s, buf, stored_len, eof) + deflate_state *s; + charf *buf; /* input block, or NULL if too old */ + ulg stored_len; /* length of input block */ + int eof; /* true if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is ascii or binary */ + if (s->data_type == Z_UNKNOWN) set_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /* Determine the best encoding. Compute first the block length in bytes*/ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, eof); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+eof, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+eof, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (eof) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*eof)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int _tr_tally (s, dist, lc) + deflate_state *s; + unsigned dist; /* distance of matched string */ + unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(s, ltree, dtree) + deflate_state *s; + ct_data *ltree; /* literal tree */ + ct_data *dtree; /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert(s->pending < s->lit_bufsize + 2*lx, "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Set the data type to ASCII or BINARY, using a crude approximation: + * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. + * IN assertion: the fields freq of dyn_ltree are set and the total of all + * frequencies does not exceed 64K (to fit in an int on 16 bit machines). + */ +local void set_data_type(s) + deflate_state *s; +{ + int n = 0; + unsigned ascii_freq = 0; + unsigned bin_freq = 0; + while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; + while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; + while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; + s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse(code, len) + unsigned code; /* the value to invert */ + int len; /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(s) + deflate_state *s; +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(s) + deflate_state *s; +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block(s, buf, len, header) + deflate_state *s; + charf *buf; /* the input data */ + unsigned len; /* its length */ + int header; /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/Utilities/GDAL/frmts/zlib/trees.h b/Utilities/GDAL/frmts/zlib/trees.h new file mode 100644 index 0000000000..72facf900f --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/trees.h @@ -0,0 +1,128 @@ +/* header created automatically with -DGEN_TREES_H */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/Utilities/GDAL/frmts/zlib/uncompr.c b/Utilities/GDAL/frmts/zlib/uncompr.c new file mode 100644 index 0000000000..d103321378 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/uncompr.c @@ -0,0 +1,58 @@ +/* uncompr.c -- decompress a memory buffer + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ +int ZEXPORT uncompress (dest, destLen, source, sourceLen) + Bytef *dest; + uLongf *destLen; + const Bytef *source; + uLong sourceLen; +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; + + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = inflateInit(&stream); + if (err != Z_OK) return err; + + err = inflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + inflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = inflateEnd(&stream); + return err; +} diff --git a/Utilities/GDAL/frmts/zlib/zconf.h b/Utilities/GDAL/frmts/zlib/zconf.h new file mode 100644 index 0000000000..6d450fc793 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/zconf.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include <windows.h> +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include <windows.h> +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include <sys/types.h> /* for off_t */ +# include <unistd.h> /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/Utilities/GDAL/frmts/zlib/zlib.h b/Utilities/GDAL/frmts/zlib/zlib.h new file mode 100644 index 0000000000..49f56b43bc --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/zlib.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/Utilities/GDAL/frmts/zlib/zutil.c b/Utilities/GDAL/frmts/zlib/zutil.c new file mode 100644 index 0000000000..b3de4e8837 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/zutil.c @@ -0,0 +1,225 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zutil.h" + +struct internal_state {int dummy;}; /* for buggy compilers */ + +#ifndef STDC +extern void exit OF((int)); +#endif + +const char *z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int z_verbose = verbose; + +void z_error (m) + char *m; +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError(err) + int err; +{ + return ERR_MSG(err); +} + + +#ifndef HAVE_MEMCPY + +void zmemcpy(dest, source, len) + Bytef* dest; + const Bytef* source; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp(s1, s2, len) + const Bytef* s1; + const Bytef* s2; + uInt len; +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero(dest, len) + Bytef* dest; + uInt len; +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + +#ifdef __TURBOC__ +#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) +/* Small and medium model in Turbo C are for now limited to near allocation + * with reduced MAX_WBITS and MAX_MEM_LEVEL + */ +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} +#endif +#endif /* __TURBOC__ */ + + +#if defined(M_I86) && !defined(__32BIT__) +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* MSC */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf zcalloc (opaque, items, size) + voidpf opaque; + unsigned items; + unsigned size; +{ + if (opaque) items += size - size; /* make compiler happy */ + return (voidpf)calloc(items, size); +} + +void zcfree (opaque, ptr) + voidpf opaque; + voidpf ptr; +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/Utilities/GDAL/frmts/zlib/zutil.h b/Utilities/GDAL/frmts/zlib/zutil.h new file mode 100644 index 0000000000..6f2cb97ca1 --- /dev/null +++ b/Utilities/GDAL/frmts/zlib/zutil.h @@ -0,0 +1,220 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id$ */ + +#ifndef _Z_UTIL_H +#define _Z_UTIL_H + +#include "zlib.h" + +#ifdef STDC +# include <stddef.h> +# include <string.h> +# include <stdlib.h> +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include <errno.h> +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#ifdef MSDOS +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include <alloc.h> +# endif +# else /* MSC or DJGPP */ +# include <malloc.h> +# endif +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +#endif + +#ifdef WIN32 /* Window 95 & Windows NT */ +# define OS_CODE 0x0b +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include <unix.h> /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0F +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# define fdopen(fd,type) _fdopen(fd,type) +#endif + + + /* Common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#ifdef HAVE_STRERROR + extern char *strerror OF((int)); +# define zstrerror(errnum) strerror(errnum) +#else +# define zstrerror(errnum) "" +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include <stdio.h> + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, + uInt len)); +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* _Z_UTIL_H */ diff --git a/Utilities/GDAL/install-sh b/Utilities/GDAL/install-sh new file mode 100755 index 0000000000..cb3cac151d --- /dev/null +++ b/Utilities/GDAL/install-sh @@ -0,0 +1,256 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ -x "$src".exe ] ; then + src=${src}.exe + echo "Cygwin hack - actually installing "$src +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/Utilities/GDAL/ltmain.sh b/Utilities/GDAL/ltmain.sh new file mode 100644 index 0000000000..b8d1ad159e --- /dev/null +++ b/Utilities/GDAL/ltmain.sh @@ -0,0 +1,6401 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003 +# Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<EOF +$* +EOF + exit 0 +fi + +# The name of this program. +progname=`$echo "$0" | ${SED} 's%^.*/%%'` +modename="$progname" + +# Constants. +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.2 +TIMESTAMP=" (1.1220.2.60 2004/01/25 12:25:08) Debian$Rev: 192 $" + +default_mode= +help="Try \`$progname --help' for more information." +magic="%%%MAGIC variable%%%" +mkdir="mkdir" +mv="mv -f" +rm="rm -f" + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' +# test EBCDIC or ASCII +case `echo A|tr A '\301'` in + A) # EBCDIC based system + SP2NL="tr '\100' '\n'" + NL2SP="tr '\r\n' '\100\100'" + ;; + *) # Assume ASCII based system + SP2NL="tr '\040' '\012'" + NL2SP="tr '\015\012' '\040\040'" + ;; +esac + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +# We save the old values to restore during execute mode. +if test "${LC_ALL+set}" = set; then + save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL +fi +if test "${LANG+set}" = set; then + save_LANG="$LANG"; LANG=C; export LANG +fi + +# Make sure IFS has a sensible default +: ${IFS=" +"} + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + $echo "$modename: not configured to build any kind of library" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +win32_libid () { + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` + if test "X$win32_nmres" = "Ximport" ; then + win32_libid_type="x86 archive import" + else + win32_libid_type="x86 archive static" + fi + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + +# End of Shell function definitions +##################################### + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit 1 + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo + $echo "Copyright (C) 2003 Free Software Foundation, Inc." + $echo "This is free software; see the source for copying conditions. There is NO" + $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit 0 + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0" + done + exit 0 + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --features) + $echo "host: $host" + if test "$build_libtool_libs" = yes; then + $echo "enable shared libraries" + else + $echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + $echo "enable static libraries" + else + $echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) prevopt="--tag" prev=tag ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case "$arg_mode" in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit 1 + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + *.java) xform=java ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + # Infer tagged configuration to use if any are available and + # if one wasn't chosen via the "--tag" command line option. + # Only attempt this if the compiler in the base compile + # command doesn't match the default compiler. + if test -n "$available_tags" && test -z "$tagname"; then + case $base_compile in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" + case "$base_compile " in + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit 1 +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + $echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T <<EOF +# $libobj - a libtool object file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +EOF + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $srcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $srcfile" + fi + + if test ! -d "${xdir}$objdir"; then + $show "$mkdir ${xdir}$objdir" + $run $mkdir ${xdir}$objdir + status=$? + if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then + exit $status + fi + fi + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + $run $rm "$lobj" "$output_obj" + + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <<EOF +pic_object='$objdir/$objname' + +EOF + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + else + # No PIC object so indicate it doesn't exist in the libtool + # object file. + test -z "$run" && cat >> ${libobj}T <<EOF +pic_object=none + +EOF + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $srcfile" + else + command="$base_compile $srcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$obj" "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <<EOF +# Name of the non-PIC object. +non_pic_object='$objname' + +EOF + else + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <<EOF +# Name of the non-PIC object. +non_pic_object=none + +EOF + $show " cp $lobj $obj" + $run cp $lobj $obj + fi + + $run $mv "${libobj}T" "${libobj}" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $run $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link | relink) + modename="$modename: link" + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args="$nonopt" + base_compile="$nonopt $@" + compile_command="$nonopt" + finalize_command="$nonopt" + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + + # Infer tagged configuration to use if any are available and + # if one wasn't chosen via the "--tag" command line option. + # Only attempt this if the compiler in the base link + # command doesn't match the default compiler. + if test -n "$available_tags" && test -z "$tagname"; then + case $base_compile in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" + case $base_compile in + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) + # The compiler in $compile_command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit 1 +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -all-static | -static) + if test "X$arg" = "X-all-static"; then + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit 1 + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit 1 + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit 1 + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-mingw* | *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" + continue + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # gcc -m* arguments should be passed to the linker via $compiler_flags + # in order to pass architecture information to the linker + # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo + # but this is not reliable with gcc because gcc may use -mfoo to + # select a different linker, different libraries, etc, while + # -Wl,-mfoo simply passes -mfoo to the linker. + -m*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + if test "$with_gcc" = "yes" ; then + compiler_flags="$compiler_flags $arg" + fi + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # The PATH hackery in wrapper scripts is required on Windows + # in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit 1 + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit 1 + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test "$status" -ne 0 && test ! -d "$output_objdir"; then + exit $status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplcations in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit 1 + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do + for search_ext in .la $shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + if test "$deplibs_check_method" != pass_all; then + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test "$found" = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit 1 + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit 1 + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit 1 + fi + if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit 1 + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5* ) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against it, someone + # is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$deplibs $depdepl" ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$deplibs $path" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit 1 + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor - 1` + age="$number_minor" + revision="$number_minor" + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case $revision in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case $age in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + major=`expr $current - $age + 1` + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + for path in $notinst_path; do + lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` + deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` + done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c <<EOF + int main() { return 0; } +EOF + $rm conftest + $LTCC -o conftest conftest.c $deplibs + if test "$?" -eq 0 ; then + ldd_output=`ldd conftest` + for i in $deplibs; do + name="`expr $i : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" -ne "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which I believe you do not have" + $echo "*** because a test_compile did reveal that the linker did not use it for" + $echo "*** its dynamic dependency list that programs get resolved with at runtime." + fi + fi + else + newdeplibs="$newdeplibs $i" + fi + done + else + # Error occurred in the first compile. Let's try to salvage + # the situation: Compile a separate program for each library. + for i in $deplibs; do + name="`expr $i : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + $rm conftest + $LTCC -o conftest conftest.c $i + # Did it work? + if test "$?" -eq 0 ; then + ldd_output=`ldd conftest` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because a test_compile did reveal that the linker did not use this one" + $echo "*** as a dynamic dependency that programs can get resolved with at runtime." + fi + fi + else + droppeddeps=yes + $echo + $echo "*** Warning! Library $i is needed by this library but I was not able to" + $echo "*** make it link in! You will probably need to install it or some" + $echo "*** library that it depends on before this library will be fully" + $echo "*** functional. Installing it before continuing would be even better." + fi + else + newdeplibs="$newdeplibs $i" + fi + done + fi + ;; + file_magic*) + set dummy $deplibs_check_method + file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name="`expr $a_deplib : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name="`expr $a_deplib : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo + if test "X$deplibs_check_method" = "Xnone"; then + $echo "*** Warning: inter-library dependencies are not supported in this platform." + else + $echo "*** Warning: inter-library dependencies are not known to be supported." + fi + $echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$save_output-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$save_output-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$save_output-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadale object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + exit 0 + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | + if sort -k 3 </dev/null >/dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit 0 + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case $0 in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + cwrappersource=`$echo ${objdir}/lt-${output}.c` + cwrapper=`$echo ${output}.exe` + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit 1" 1 2 15 + + cat > $cwrappersource <<EOF + +/* $cwrappersource - temporary wrapper executable for $objdir/$outputname + Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP + + The $output program cannot be directly executed until all the libtool + libraries that it depends on are installed. + + This wrapper executable should never be moved out of the build directory. + If it is, it will not operate correctly. + + Currently, it simply execs the wrapper *script* "/bin/sh $output", + but could eventually absorb all of the scripts functionality and + exec $objdir/$outputname directly. +*/ +EOF + cat >> $cwrappersource<<"EOF" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <malloc.h> +#include <stdarg.h> +#include <assert.h> + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +#define HAVE_DOS_BASED_FILE_SYSTEM +#ifndef DIR_SEPARATOR_2 +#define DIR_SEPARATOR_2 '\\' +#endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +char * basename (const char *name); +char * fnqualify(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup ((char *) basename (argv[0])); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <<EOF + newargz[0] = "$SHELL"; +EOF + + cat >> $cwrappersource <<"EOF" + newargz[1] = fnqualify(argv[0]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; +EOF + + cat >> $cwrappersource <<EOF + execv("$SHELL",newargz); +EOF + + cat >> $cwrappersource <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +char * +basename (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha (name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return (char *) base; +} + +char * +fnqualify(const char *path) +{ + size_t size; + char *p; + char tmp[LT_PATHMAX + 1]; + + assert(path != NULL); + + /* Is it qualified already? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha (path[0]) && path[1] == ':') + return xstrdup (path); +#endif + if (IS_DIR_SEPARATOR (path[0])) + return xstrdup (path); + + /* prepend the current directory */ + /* doesn't handle '~' */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ + p = XMALLOC(char, size); + sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); + return p; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + $echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test "$status" -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$xdir"; then + exit $status + fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + # GNU ar 2.10+ was changed to match POSIX; thus no paths are + # encoded into archives. This makes 'ar r' malfunction in + # this piecewise linking case whenever conflicting object + # names appear in distinct ar calls; check, warn and compensate. + if (for obj in $save_oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 + $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 + AR_FLAGS=cq + fi + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $0 $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit 1 + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit 1 + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyways + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $0 $preserve_args --finish$current_libdirs' + else + exit 0 + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + $echo "----------------------------------------------------------------------" + $echo "Libraries have been installed in:" + for libdir in $libdirs; do + $echo " $libdir" + done + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" + fi + if test -n "$runpath_var"; then + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + + if test "$mode" = uninstall; then + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + fi + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit 1 +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to <bug-libtool@gnu.org>." + exit 0 + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/Utilities/GDAL/makefile.vc b/Utilities/GDAL/makefile.vc new file mode 100644 index 0000000000..151c85dd73 --- /dev/null +++ b/Utilities/GDAL/makefile.vc @@ -0,0 +1,204 @@ +GDAL_ROOT = . + +!INCLUDE nmake.opt + +############################################################################## +# We need to add vb6 support if STDCALL is defined. +!IFDEF STDCALL +VB6_OBJ = vb6\vb6_support.obj +VB6_TARGET = vb6_dir +!ENDIF + +############################################################################## +# The following determines whether we are linking all the OGR formats +# into the DLL, or only the minimum spatial reference related stuff required +# for a raster-gdal build. + +#OGR_BASE_INCLUDE = /INCLUDE:_OCTNewCoordinateTransformation@8 \ +# /INCLUDE:_OGRFeatureStylePuller@0 \ +# /INCLUDE:_OSRValidate@4 \ +# /INCLUDE:_OPTGetProjectionMethods@0 \ +# /INCLUDE:_OGR_G_GetPointCount@4 + +OGR_BASE_INCLUDE = /INCLUDE:_OGRFeatureStylePuller \ + /INCLUDE:_OSRValidate \ + /INCLUDE:_OPTGetProjectionMethods \ + /INCLUDE:_OGR_G_GetPointCount + + +!IFDEF INCLUDE_OGR_FRMTS +CPPFLAGS = $(CPPFLAGS) -DOGR_ENABLED +OGR_OBJ = ogr\ogrsf_frmts\ogrsf_frmts.lib ogr\ogr.lib +OGR_INCLUDE = $(OGR_BASE_INCLUDE) \ + /INCLUDE:_OGRRegisterAll + +!ELSE +OGR_OBJ = ogr\ogr.lib +OGR_INCLUDE = $(OGR_BASE_INCLUDE) +!ENDIF + +!IFDEF STDCALL +BASE_INCLUDE = /INCLUDE:_GDALSimpleImageWarp@36 \ + /INCLUDE:_GDALReprojectImage@48 \ + /INCLUDE:_GDALComputeMedianCutPCT@32 \ + /INCLUDE:_GDALDitherRGB2PCT@28 \ + /INCLUDE:_vbSafeArrayToPtr@16 \ + /INCLUDE:_OCTNewCoordinateTransformation@8 +!ELSE +BASE_INCLUDE = /INCLUDE:_GDALSimpleImageWarp \ + /INCLUDE:_GDALReprojectImage \ + /INCLUDE:_GDALComputeMedianCutPCT \ + /INCLUDE:_GDALDitherRGB2PCT \ + /INCLUDE:_OCTNewCoordinateTransformation +!ENDIF + +LIBOBJ = port\*.obj gcore\*.obj alg\*.obj frmts\o\*.obj $(OGR_OBJ) $(VB6_OBJ) + +DISTDIR = gdal_$(VERSION) + +default: port_dir ogr_dir core_dir frmts_dir $(VB6_TARGET) $(GDAL_DLL) \ + apps_dir pymod_dir ogr_apps + +staticlib: + if exist gdal.lib del gdal.lib + lib /out:gdal.lib $(LIBOBJ) + +clean: + cd port + $(MAKE) /f makefile.vc clean + cd .. + cd gcore + $(MAKE) /f makefile.vc clean + cd .. + cd alg + $(MAKE) /f makefile.vc clean + cd .. + cd frmts + $(MAKE) /f makefile.vc clean + cd .. + cd ogr + $(MAKE) allclean + cd .. + cd apps + $(MAKE) /f makefile.vc clean + cd .. + cd pymod + $(MAKE) /f makefile.vc clean + cd .. + cd vb6 + $(MAKE) /f makefile.vc clean + cd .. + if exist gdal.lib del gdal.lib + if exist $(GDAL_DLL) del $(GDAL_DLL) + if exist gdal_i.lib del gdal_i.* + -del *.ilk + -del *.pdb + +port_dir: + cd port + $(MAKE) /f makefile.vc + cd .. + +ogr_min: + cd ogr + $(MAKE) ogr.lib + cd .. + +core_dir: + cd gcore + $(MAKE) /f makefile.vc + cd ..\alg + $(MAKE) /f makefile.vc + cd .. + +frmts_dir: + cd frmts + $(MAKE) /f makefile.vc + cd .. + +apps_dir: + cd apps + $(MAKE) /f makefile.vc + cd .. + +pymod_dir: + cd pymod + if exist $(PYDIR)\python.exe $(MAKE) /f makefile.vc + cd .. + +vb6_dir: + cd vb6 + $(MAKE) /f makefile.vc + cd .. + +ogr_dir: port_dir + cd frmts/iso8211 + $(MAKE) /f makefile.vc + cd ..\sdts + $(MAKE) /f makefile.vc + cd ..\..\ogr +!IFDEF INCLUDE_OGR_FRMTS + $(MAKE) ogr.lib frmts +!ELSE + $(MAKE) ogr.lib +!ENDIF + cd .. + +ogr_apps: + cd ogr +!IFDEF INCLUDE_OGR_FRMTS + $(MAKE) default +!ENDIF + cd .. + +lib_dist: default + rm -rf $(DISTDIR) + mkdir $(DISTDIR) + cp gdal.lib port\*.h gcore\*.h ogr\*.h $(DISTDIR) + zip -r $(DISTDIR).zip $(DISTDIR) + +$(GDAL_DLL): staticlib + link /dll /debug $(OGR_INCLUDE) $(BASE_INCLUDE) $(LIBOBJ) \ + $(EXTERNAL_LIBS) gcore\Version.res \ + /out:$(GDAL_DLL) /implib:gdal_i.lib $(LINKER_FLAGS) + +install: $(GDAL_DLL) apps_dir pymod_dir + -mkdir $(BINDIR) + -mkdir $(DATADIR) + xcopy /y /r /d /f $(GDAL_DLL) $(BINDIR) + if exist $(GDAL_DLL).manifest xcopy /y /r /d /f $(GDAL_DLL).manifest $(BINDIR) + cd apps + $(MAKE) /f makefile.vc install + cd ..\pymod + if exist $(PYDIR)\python.exe $(MAKE) /f makefile.vc install + cd .. + xcopy /y /r /d /f data\*.* $(DATADIR) +!IFDEF HTMLDIR + -mkdir $(HTMLDIR) + cd frmts + $(MAKE) /f makefile.vc html-install + cd .. +!ENDIF +!IFDEF INCLUDE_OGR_FRMTS + cd ogr + $(MAKE) install + cd .. +!IFDEF HTMLDIR + cd ogr\ogrsf_frmts + $(MAKE) /f Makefile html-install + cd ..\.. +!ENDIF +!ENDIF + +devinstall: install + -mkdir $(INCDIR) + -mkdir $(LIBDIR) + copy port\*.h $(INCDIR) + copy gcore\*.h $(INCDIR) + copy alg\*.h $(INCDIR) + copy ogr\*.h $(INCDIR) +!IFDEF INCLUDE_OGR_FRMTS + copy ogr\ogrsf_frmts\*.h $(INCDIR) +!ENDIF + copy gdal_i.lib $(LIBDIR) + diff --git a/Utilities/GDAL/nmake-wince.opt b/Utilities/GDAL/nmake-wince.opt new file mode 100644 index 0000000000..1794eae946 --- /dev/null +++ b/Utilities/GDAL/nmake-wince.opt @@ -0,0 +1,145 @@ +# $Id: nmake-wince.opt,v 1.2 2006/02/20 00:57:47 mloskot Exp $ +# +# Building options for Windows CE target +# +# Created by Mateusz Loskot <mateusz@loskot.net> +# + +################################################# +# NOTE: Macros below are going to be changed +# and waits for configure script. +# Configure script will make it possible to +# specify target CPU and system platform, etc. +################################################# +# Target platform definitions +CEVersion = 420 +CESubsystem = "windowsce,$(CEVersion)" +CEConfigName = "POCKET PC 2003" + +# Target CPU +TARGET_CPU = ARM +TARGET_CPU_ARCH = ARMV4 + +CECrt = C +CECrtDebug = C +CECrtMT = C +CECrtMTDebug = C +CENoDefaultLib = libc.lib \ + /nodefaultlib:libcd.lib \ + /nodefaultlib:libcmt.lib \ + /nodefaultlib:libcmtd.lib \ + /nodefaultlib:msvcrt.lib \ + /nodefaultlib:msvcrtd.lib +CEx86Corelibc = corelibc.lib + +# Commands +MAKE = nmake /nologo +CC = clarm + +################################################# +# END OF TEMPORARY MACROS BLOCK +################################################# + +# Location to install .exe, .dll and python stuff +# Edit as required. GDAL_HOME is used for convenience here, +# but this particular relative organization is not mandatory. + +GDAL_HOME = "build" +BINDIR = $(GDAL_HOME)\bin +LIBDIR = $(GDAL_HOME)\lib +INCDIR = $(GDAL_HOME)\include +DATADIR = $(GDAL_HOME)\data +HTMLDIR = $(GDAL_HOME)\html + +# Uncomment the first for an optimized build or the second for a debug build. +#OPTFLAGS= /MD /GX /Ox /nologo +OPTFLAGS = /W3 /GR /GX /Zi /Od /nologo /D "DEBUG" + +# If you don't want some entry points to have STDCALL conventions, +# comment out the following and add -DCPL_DISABLE_STDCALL in OPTFLAGS +STDCALL = YES + +# Version number embedded in DLL name. +VERSION = 13 + +# Uncomment the following to link OGR utilities against main GDAL DLL +# instead of statically linking against OGR libraries. +DLLBUILD = 1 + +# OGR Drivers supported on Windows CE +# Uncomment OGR drivers you want to include. +# NOTE: Only few drivers are supported by Windows CE (shape, tab) +# and some are going to be supported in future (csv, gml, sqlite). +# Rest of drivers are not going to be supported. +# +#AVCBIN_SUPPORTED = 1 +#CSV_SUPPORTED = 1 +#DGN_SUPPORTED = 1 +#GML_SUPPORTED = 1 +#MEM_SUPPORTED = 1 +#NTF_SUPPORTED = 1 +#REC_SUPPORTED = 1 +#S57_SUPPORTED = 1 +#SDTS_SUPPORTED = 1 +SHAPE_SUPPORTED = 1 +TAB_SUPPORTED = 1 +#TIGER_SUPPORTED= 1 +#VRT_SUPPORTED = 1 + +# Paths +STLPORT_USE = 1 +STLPORT_DIR = C:\STLport-5.0.0 +WCELIBCEX_DIR = wince\wcelibcex + +########### END OF STUFF THAT NORMALLY NEEDS TO BE UPDATED ################## + +GDAL_OUTPUT = gdalce + +GDAL_DLL = $(GDAL_ROOT)\$(GDAL_OUTPUT)$(VERSION).dll +GDAL_I_LIB = $(GDAL_ROOT)\$(GDAL_OUTPUT)_i.lib +GDAL_LIB = $(GDAL_ROOT)\$(GDAL_OUTPUT).lib + +CPL_LIB = $(GDAL_ROOT)\port/cpl.lib +WCELIBCEX_LIB = $(GDAL_ROOT)\$(WCELIBCEX_DIR)\wcelibcex.lib + +INC = /I "$(GDAL_ROOT)\port" \ + /I "$(GDAL_ROOT)\ogr" \ + /I "$(GDAL_ROOT)\$(WCELIBCEX_DIR)" + +OPTFLAGS = $(OPTFLAGS) /Fd$(GDAL_ROOT)\$(GDAL_OUTPUT).pdb + +LINKER_FLAGS = /nologo \ + /entry:"_DllMainCRTStartup" \ + /base:"0x00100000" \ + /stack:0x10000,0x1000 \ + /align:"4096" \ + /incremental:no \ + /nodefaultlib:"$(CENoDefaultLib)" \ + /subsystem:$(CESubsystem) \ + /MACHINE:ARM + +#LINKER_FLAGS = /debug + +CFLAGS = $(OPTFLAGS) \ + $(INC) \ + $(EXTRAFLAGS) \ + /D "_LIB" \ + /D "$(CESubsystem)" \ + /D "_WIN32_WCE=$(CEVersion)" \ + /D "UNDER_CE=$(CEVersion)" \ + /D "$(TARGET_CPU)" \ + /D "_$(TARGET_CPU)_" \ + /D "$(TARGET_CPU_ARCH)" \ + /D "UNICODE" /D "_UNICODE" + +EXTERNAL_LIBS = commctrl.lib \ + coredll.lib \ + corelibc.lib \ + ccrtrtti.lib + +.c.obj: + $(CC) $(CFLAGS) /c $*.c + +.cpp.obj: + $(CC) $(CFLAGS) /c $*.cpp + diff --git a/Utilities/GDAL/rfc/RFC1_PMC.dox b/Utilities/GDAL/rfc/RFC1_PMC.dox new file mode 100644 index 0000000000..81afa1a17c --- /dev/null +++ b/Utilities/GDAL/rfc/RFC1_PMC.dox @@ -0,0 +1,96 @@ +/*! +\page rfc1_pmc RFC 1: Project Management Committee Guidelines + +Author: Frank Warmerdam<br> +Contact: warmerdam@pobox.com<br> +Status: Proposed<br> + +\section summary Summary + +This document describes how the GDAL/OGR Project Management Committee +determines membership, and makes decisions on GDAL/OGR project issues. + +In brief the committee votes on proposals on gdal-dev. Proposals are +available for review for at least two days, and a single veto is sufficient +to delay progress though ultimately a majority of members can pass a proposal. + +\section detailed_process Detailed Process + +<ol> + +<li> Proposals are written up and submitted on the gdal-dev mailing +list for discussion and voting, by any interested party, not just +committee members. + +<li> Proposals need to be available for review for at least two business +days before a final decision can be made. + +<li> Respondents may vote "+1" to indicate support for the proposal and a +willingness to support implementation. + +<li> Respondents may vote "-1" to veto a proposal, but must provide clear +reasoning and alternate approaches to resolving the problem within the two +days. + +<li> A vote of -0 indicates mild disagreement, but has no effect. A 0 +indicates no opinion. A +0 indicate mild support, but has no effect. + +<li> Anyone may comment on proposals on the list, but only members of the +Project Management Committee's votes will be counted. + +<li> A proposal will be accepted if it receives +2 (including the proposer) +and no vetos (-1). + +<li> If a proposal is vetoed, and it cannot be revised to satisfy all parties, +then it can be resubmitted for an override vote in which a majority of all +eligible voters indicating +1 is sufficient to pass it. Note that this is +a majority of all committee members, not just those who actively vote. + +<li> Upon completion of discussion and voting the proposer should announce +whether they are proceeding (proposal accepted) or are withdrawing their +proposal (vetoed). + +<li> The Chair gets a vote. + +<li> The Chair is responsible for keeping track of who is a member of +the Project Management Committee. + +<li> Addition and removal of members from the committee, as well as selection +of a Chair should be handled as a proposal to the committee. The +selection of a new Chair also requires approval of the OSGeo board. + +<li> The Chair adjudicates in cases of disputes about voting. + +</ol> + +\section when_vote When is Vote Required? + +<ul> +<li> Anything that could cause backward compatibility issues. +<li> Adding substantial amounts of new code. +<li> Changing inter-subsystem APIs, or objects. +<li> Issues of procedure. +<li> When releases should take place. +<li> Anything that might be controversial. +</ul> + +\section observations Observations + +<ul> +<li> The Chair is the ultimate adjudicator if things break down. + +<li> The absolute majority rule can be used to override an obstructionist +veto, but it is intended that in normal circumstances vetoers need to be +convinced to withdraw their veto. We are trying to reach consensus. +</ul> + + +\section bootstraping Bootstrapping + +Frank Warmerdam is declared initial Chair of the Project Management Committee. + +Daniel Morissette, Frank Warmerdam, Andrey Kiselev and Howard Butler are +declared to be the founding Project Management Committee. + +*/ + diff --git a/Utilities/GDAL/rfc/rfc_list.dox b/Utilities/GDAL/rfc/rfc_list.dox new file mode 100644 index 0000000000..6d4efaad45 --- /dev/null +++ b/Utilities/GDAL/rfc/rfc_list.dox @@ -0,0 +1,13 @@ +/*! +\page rfc_list RFC List + +A list of all GDAL/OGR RFC documents, with status. + +<ul> + +<li> \link rfc1_pmc RFC 1: Project Management Committee Guidelines\endlink (Proposed) + +</ul> + +*/ + diff --git a/Utilities/GDAL/swig/GNUmakefile b/Utilities/GDAL/swig/GNUmakefile new file mode 100644 index 0000000000..f7350cfe59 --- /dev/null +++ b/Utilities/GDAL/swig/GNUmakefile @@ -0,0 +1,32 @@ + +include ../GDALmake.opt + +# The BINDINGS variable in GDALmake.opt contains a list of language +# bindings to be built and installed by default. + +# The ALL_BINDINGS variable defines all the possible bindings. It's used +# in the dist and clean definitions. +ALL_BINDINGS = python php csharp ruby perl java + +default: generate + +# The dist target should generate all the wrapper files for all supported +# language bindings. This should be called by the top level distribution +# maker script prior to bundling up the source. It eliminates the installer +# from having the proper version of swig installled. +dist: generate + +clean: + for dir in ${BINDINGS}; do (cd $$dir; make clean ); done + +veryclean: + for dir in ${ALL_BINDINGS}; do (cd $$dir; make veryclean ); done + +generate: + for dir in ${ALL_BINDINGS}; do (cd $$dir; make generate ); done + +build: + for dir in ${BINDINGS}; do (cd $$dir; make build ); done + +install: + for dir in ${BINDINGS}; do (cd $$dir; make install ); done diff --git a/Utilities/GDAL/swig/SWIGmake.base b/Utilities/GDAL/swig/SWIGmake.base new file mode 100644 index 0000000000..415887398e --- /dev/null +++ b/Utilities/GDAL/swig/SWIGmake.base @@ -0,0 +1,17 @@ + +SWIG = swig +SWIGARGS = -Wall -I../include -I../include/$(BINDING) + +WRAPPERS = gdal_wrap.cpp gdalconst_wrap.c ogr_wrap.cpp osr_wrap.cpp + +gdal_wrap.cpp: ../include/gdal.i ../include/MajorObject.i ../include/Driver.i ../include/Dataset.i ../include/Band.i ../include/ColorTable.i ../include/cpl.i ../include/$(BINDING)/typemaps_$(BINDING).i + $(SWIG) $(SWIGARGS) -I$(GDAL_ROOT) -c++ -$(BINDING) -o $@ gdal.i + +gdalconst_wrap.c: ../include/gdalconst.i + $(SWIG) $(SWIGARGS) -I$(GDAL_ROOT) -$(BINDING) -o $@ gdalconst.i + +ogr_wrap.cpp: ../include/ogr.i ../include/$(BINDING)/typemaps_$(BINDING).i + $(SWIG) $(SWIGARGS) -I$(GDAL_ROOT) -c++ -$(BINDING) -o $@ ogr.i + +osr_wrap.cpp: ../include/osr.i ../include/$(BINDING)/typemaps_$(BINDING).i + $(SWIG) $(SWIGARGS) -I$(GDAL_ROOT) -c++ -$(BINDING) -o $@ osr.i diff --git a/Utilities/GDAL/swig/csharp/GNUmakefile b/Utilities/GDAL/swig/csharp/GNUmakefile new file mode 100644 index 0000000000..c3d33c6eb6 --- /dev/null +++ b/Utilities/GDAL/swig/csharp/GNUmakefile @@ -0,0 +1,24 @@ + + +include ../../GDALmake.opt + +all: build + +BINDING = csharp +include ../SWIGmake.base + +EXTRA_DIST = Band.cs ColorTable.cs CoordinateTransformation.cs DataSource.cs Dataset.cs Driver.cs Feature.cs FeatureDefn.cs FieldDefn.cs GCP.cs Geometry.cs Layer.cs MajorObject.cs SpatialReference.cs gdal.cs gdalPINVOKE.cs gdalconst.cs gdalconstPINVOKE.cs ogr.cs ogrPINVOKE.cs osr.cs osrPINVOKE.cs + +clean: + -rm -rf build + +veryclean: clean + -rm -f ${WRAPPERS} ${EXTRA_DIST} SWIGTYPE_p_*.cs + +generate: ${WRAPPERS} + +build: generate + @echo "What are you doing? C# modules needs to be built with msvc" + +install: generate + @echo "What are you doing? C# modules needs to be built with msvc" diff --git a/Utilities/GDAL/swig/csharp/const/makefile.vc b/Utilities/GDAL/swig/csharp/const/makefile.vc new file mode 100644 index 0000000000..d339c45c3e --- /dev/null +++ b/Utilities/GDAL/swig/csharp/const/makefile.vc @@ -0,0 +1,14 @@ +OBJ = gdalconst_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.c + diff --git a/Utilities/GDAL/swig/csharp/gdal/makefile.vc b/Utilities/GDAL/swig/csharp/gdal/makefile.vc new file mode 100644 index 0000000000..acff80c986 --- /dev/null +++ b/Utilities/GDAL/swig/csharp/gdal/makefile.vc @@ -0,0 +1,14 @@ +OBJ = gdal_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + diff --git a/Utilities/GDAL/swig/csharp/gdalconst_wrap.c b/Utilities/GDAL/swig/csharp/gdalconst_wrap.c new file mode 100644 index 0000000000..b44f7ccfa5 --- /dev/null +++ b/Utilities/GDAL/swig/csharp/gdalconst_wrap.c @@ -0,0 +1,1015 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.25 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + + +/* Support for throwing C# exceptions from C/C++. There are two types: + * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */ +typedef enum { + SWIG_CSharpApplicationException, + SWIG_CSharpArithmeticException, + SWIG_CSharpDivideByZeroException, + SWIG_CSharpIndexOutOfRangeException, + SWIG_CSharpInvalidOperationException, + SWIG_CSharpIOException, + SWIG_CSharpNullReferenceException, + SWIG_CSharpOutOfMemoryException, + SWIG_CSharpOverflowException, + SWIG_CSharpSystemException +} SWIG_CSharpExceptionCodes; + +typedef enum { + SWIG_CSharpArgumentException, + SWIG_CSharpArgumentNullException, + SWIG_CSharpArgumentOutOfRangeException +} SWIG_CSharpExceptionArgumentCodes; + +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *); +typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *); + +typedef struct { + SWIG_CSharpExceptionCodes code; + SWIG_CSharpExceptionCallback_t callback; +} SWIG_CSharpException_t; + +typedef struct { + SWIG_CSharpExceptionArgumentCodes code; + SWIG_CSharpExceptionArgumentCallback_t callback; +} SWIG_CSharpExceptionArgument_t; + +static SWIG_CSharpException_t SWIG_csharp_exceptions[] = { + { SWIG_CSharpApplicationException, NULL }, + { SWIG_CSharpArithmeticException, NULL }, + { SWIG_CSharpDivideByZeroException, NULL }, + { SWIG_CSharpIndexOutOfRangeException, NULL }, + { SWIG_CSharpInvalidOperationException, NULL }, + { SWIG_CSharpIOException, NULL }, + { SWIG_CSharpNullReferenceException, NULL }, + { SWIG_CSharpOutOfMemoryException, NULL }, + { SWIG_CSharpOverflowException, NULL }, + { SWIG_CSharpSystemException, NULL } +}; + +static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { + { SWIG_CSharpArgumentException, NULL }, + { SWIG_CSharpArgumentNullException, NULL }, + { SWIG_CSharpArgumentOutOfRangeException, NULL }, +}; + +static void SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { + SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; + if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + callback = SWIG_csharp_exceptions[code].callback; + } + callback(msg); +} + +static void SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { + SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; + if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + callback = SWIG_csharp_exceptions_argument[code].callback; + } + callback(msg, param_name); +} + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_gdalconst( + SWIG_CSharpExceptionCallback_t applicationCallback, + SWIG_CSharpExceptionCallback_t arithmeticCallback, + SWIG_CSharpExceptionCallback_t divideByZeroCallback, + SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback, + SWIG_CSharpExceptionCallback_t invalidOperationCallback, + SWIG_CSharpExceptionCallback_t ioCallback, + SWIG_CSharpExceptionCallback_t nullReferenceCallback, + SWIG_CSharpExceptionCallback_t outOfMemoryCallback, + SWIG_CSharpExceptionCallback_t overflowCallback, + SWIG_CSharpExceptionCallback_t systemCallback) { + SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback; + SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback; + SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback; + SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback; + SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback; + SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback; + SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback; + SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback; + SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback; + SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback; +} + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_gdalconst( + SWIG_CSharpExceptionArgumentCallback_t argumentCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback, + SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) { + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback; + SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback; +} + + +/* Callback for returning strings to C# without leaking memory */ +typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); +static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL; + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_gdalconst(SWIG_CSharpStringHelperCallback callback) { + SWIG_csharp_string_callback = callback; +} + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else + + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Unknown() { + int jresult = 0 ; + int result; + + result = (int) GDT_Unknown; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Byte() { + int jresult = 0 ; + int result; + + result = (int) GDT_Byte; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_UInt16() { + int jresult = 0 ; + int result; + + result = (int) GDT_UInt16; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Int16() { + int jresult = 0 ; + int result; + + result = (int) GDT_Int16; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_UInt32() { + int jresult = 0 ; + int result; + + result = (int) GDT_UInt32; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Int32() { + int jresult = 0 ; + int result; + + result = (int) GDT_Int32; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Float32() { + int jresult = 0 ; + int result; + + result = (int) GDT_Float32; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_Float64() { + int jresult = 0 ; + int result; + + result = (int) GDT_Float64; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_CInt16() { + int jresult = 0 ; + int result; + + result = (int) GDT_CInt16; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_CInt32() { + int jresult = 0 ; + int result; + + result = (int) GDT_CInt32; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_CFloat32() { + int jresult = 0 ; + int result; + + result = (int) GDT_CFloat32; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_CFloat64() { + int jresult = 0 ; + int result; + + result = (int) GDT_CFloat64; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GDT_TypeCount() { + int jresult = 0 ; + int result; + + result = (int) GDT_TypeCount; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GA_ReadOnly() { + int jresult = 0 ; + int result; + + result = (int) GA_ReadOnly; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GA_Update() { + int jresult = 0 ; + int result; + + result = (int) GA_Update; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GF_Read() { + int jresult = 0 ; + int result; + + result = (int) GF_Read; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GF_Write() { + int jresult = 0 ; + int result; + + result = (int) GF_Write; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_Undefined() { + int jresult = 0 ; + int result; + + result = (int) GCI_Undefined; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_GrayIndex() { + int jresult = 0 ; + int result; + + result = (int) GCI_GrayIndex; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_PaletteIndex() { + int jresult = 0 ; + int result; + + result = (int) GCI_PaletteIndex; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_RedBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_RedBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_GreenBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_GreenBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_BlueBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_BlueBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_AlphaBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_AlphaBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_HueBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_HueBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_SaturationBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_SaturationBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_LightnessBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_LightnessBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_CyanBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_CyanBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_MagentaBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_MagentaBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_YellowBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_YellowBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GCI_BlackBand() { + int jresult = 0 ; + int result; + + result = (int) GCI_BlackBand; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GRA_NearestNeighbour() { + int jresult = 0 ; + int result; + + result = (int) GRA_NearestNeighbour; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GRA_Bilinear() { + int jresult = 0 ; + int result; + + result = (int) GRA_Bilinear; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GRA_Cubic() { + int jresult = 0 ; + int result; + + result = (int) GRA_Cubic; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GRA_CubicSpline() { + int jresult = 0 ; + int result; + + result = (int) GRA_CubicSpline; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GPI_Gray() { + int jresult = 0 ; + int result; + + result = (int) GPI_Gray; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GPI_RGB() { + int jresult = 0 ; + int result; + + result = (int) GPI_RGB; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GPI_CMYK() { + int jresult = 0 ; + int result; + + result = (int) GPI_CMYK; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_GPI_HLS() { + int jresult = 0 ; + int result; + + result = (int) GPI_HLS; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CXT_Element() { + int jresult = 0 ; + int result; + + result = (int) CXT_Element; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CXT_Text() { + int jresult = 0 ; + int result; + + result = (int) CXT_Text; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CXT_Attribute() { + int jresult = 0 ; + int result; + + result = (int) CXT_Attribute; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CXT_Comment() { + int jresult = 0 ; + int result; + + result = (int) CXT_Comment; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CXT_Literal() { + int jresult = 0 ; + int result; + + result = (int) CXT_Literal; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CE_None() { + int jresult = 0 ; + int result; + + result = (int) CE_None; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CE_Debug() { + int jresult = 0 ; + int result; + + result = (int) CE_Debug; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CE_Warning() { + int jresult = 0 ; + int result; + + result = (int) CE_Warning; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CE_Failure() { + int jresult = 0 ; + int result; + + result = (int) CE_Failure; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CE_Fatal() { + int jresult = 0 ; + int result; + + result = (int) CE_Fatal; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_None() { + int jresult = 0 ; + int result; + + result = (int) CPLE_None; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_AppDefined() { + int jresult = 0 ; + int result; + + result = (int) CPLE_AppDefined; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_OutOfMemory() { + int jresult = 0 ; + int result; + + result = (int) CPLE_OutOfMemory; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_FileIO() { + int jresult = 0 ; + int result; + + result = (int) CPLE_FileIO; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_OpenFailed() { + int jresult = 0 ; + int result; + + result = (int) CPLE_OpenFailed; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_IllegalArg() { + int jresult = 0 ; + int result; + + result = (int) CPLE_IllegalArg; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_NotSupported() { + int jresult = 0 ; + int result; + + result = (int) CPLE_NotSupported; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_AssertionFailed() { + int jresult = 0 ; + int result; + + result = (int) CPLE_AssertionFailed; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_NoWriteAccess() { + int jresult = 0 ; + int result; + + result = (int) CPLE_NoWriteAccess; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLE_UserInterrupt() { + int jresult = 0 ; + int result; + + result = (int) CPLE_UserInterrupt; + + jresult = result; + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_LONGNAME() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_LONGNAME"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_HELPTOPIC() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_HELPTOPIC"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_MIMETYPE() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_MIMETYPE"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_EXTENSION() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_EXTENSION"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_CREATIONOPTIONLIST() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_CREATIONOPTIONLIST"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DMD_CREATIONDATATYPES() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DMD_CREATIONDATATYPES"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DCAP_CREATE() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DCAP_CREATE"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_get_DCAP_CREATECOPY() { + char * jresult = 0 ; + char *result; + + result = (char *) "GDAL_DCAP_CREATECOPY"; + + jresult = SWIG_csharp_string_callback(result); + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLES_BackslashQuotable() { + int jresult = 0 ; + int result; + + result = (int) CPLES_BackslashQuotable; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLES_XML() { + int jresult = 0 ; + int result; + + result = (int) CPLES_XML; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLES_URL() { + int jresult = 0 ; + int result; + + result = (int) CPLES_URL; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLES_SQL() { + int jresult = 0 ; + int result; + + result = (int) CPLES_SQL; + + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_get_CPLES_CSV() { + int jresult = 0 ; + int result; + + result = (int) CPLES_CSV; + + jresult = result; + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/Utilities/GDAL/swig/csharp/makefile.vc b/Utilities/GDAL/swig/csharp/makefile.vc new file mode 100644 index 0000000000..b35fc6cfa0 --- /dev/null +++ b/Utilities/GDAL/swig/csharp/makefile.vc @@ -0,0 +1,71 @@ +!INCLUDE ../../nmake.opt + + +OBJ = gdal_wrap.obj gdalconst_wrap.obj ogr_wrap.obj osr_wrap.obj + + +all: sign ogr_dir gdal_dir osr_dir const_dir + csc /debug:full /target:library /out:gdal_ogr_csharp.dll ogr\*.cs + csc /debug:full /target:library /out:gdal_gdal_csharp.dll gdal\*.cs + csc /debug:full /target:library /out:gdal_gdalconst_csharp.dll const\*.cs + csc /debug:full /target:library /out:gdal_osr_csharp.dll osr\*.cs + link /dll /debug $(OGR_INCLUDE) $(BASE_INCLUDE) ogr_wrap.obj \ + $(EXTERNAL_LIBS) ..\..\gdal.lib\ + /out:gdal_ogr_wrap.dll $(LINKER_FLAGS) + link /dll /debug $(OGR_INCLUDE) $(BASE_INCLUDE) gdal_wrap.obj \ + $(EXTERNAL_LIBS) ..\..\gdal.lib\ + /out:gdal_gdal_wrap.dll $(LINKER_FLAGS) + link /dll /debug $(OGR_INCLUDE) $(BASE_INCLUDE) gdalconst_wrap.obj \ + $(EXTERNAL_LIBS) ..\..\gdal.lib\ + /out:gdal_gdalconst_wrap.dll $(LINKER_FLAGS) + link /dll /debug $(OGR_INCLUDE) $(BASE_INCLUDE) osr_wrap.obj \ + $(EXTERNAL_LIBS) ..\..\gdal.lib\ + /out:gdal_osr_wrap.dll $(LINKER_FLAGS) +sign: + sn -k gdal.snk + +ogr_dir: + cd ogr + $(MAKE) /f makefile.vc + cd .. + +gdal_dir: + cd gdal + $(MAKE) /f makefile.vc + cd .. + +const_dir: + cd const + $(MAKE) /f makefile.vc + cd .. + +osr_dir: + cd osr + $(MAKE) /f makefile.vc + cd .. + + +clean: + cd gdal + $(MAKE) /f makefile.vc clean + cd .. + cd ogr + $(MAKE) /f makefile.vc clean + cd .. + cd const + $(MAKE) /f makefile.vc clean + cd .. + cd osr + $(MAKE) /f makefile.vc clean + cd .. + -del gdal.lib + -del *.dll + -del *.obj + -del *.exp + -del *.ilk + -del *.pdb + -del *.tlb + -del *.snk + -del *.cs + -del *.cpp + -del *.lib \ No newline at end of file diff --git a/Utilities/GDAL/swig/csharp/ogr/makefile.vc b/Utilities/GDAL/swig/csharp/ogr/makefile.vc new file mode 100644 index 0000000000..d51af9f3dd --- /dev/null +++ b/Utilities/GDAL/swig/csharp/ogr/makefile.vc @@ -0,0 +1,14 @@ +OBJ = ogr_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + diff --git a/Utilities/GDAL/swig/csharp/osr/makefile.vc b/Utilities/GDAL/swig/csharp/osr/makefile.vc new file mode 100644 index 0000000000..cefbb76ec1 --- /dev/null +++ b/Utilities/GDAL/swig/csharp/osr/makefile.vc @@ -0,0 +1,14 @@ +OBJ = osr_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + diff --git a/Utilities/GDAL/swig/include/Band.i b/Utilities/GDAL/swig/include/Band.i new file mode 100644 index 0000000000..5370d86ef6 --- /dev/null +++ b/Utilities/GDAL/swig/include/Band.i @@ -0,0 +1,282 @@ +/****************************************************************************** + * $Id: Band.i,v 1.20 2005/09/02 16:19:23 kruland Exp $ + * + * Name: Band.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: Band.i,v $ + * Revision 1.20 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.19 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.18 2005/08/04 20:48:32 kruland + * Recoded GetNoDataValue(), GetMaximum(), GetMinimum(), GetOffset(), GetScale() to have + * access to both the double return value and the has value flag. + * + * Revision 1.17 2005/08/04 19:16:06 kruland + * GetRasterColorTable does not return a newobject. + * + * Revision 1.16 2005/07/20 16:28:26 kruland + * Merge the two definitions of Checksum into one. Use the pointer trick + * to allow the passing of optional xsize,ysize parameters. + * + * Revision 1.15 2005/07/18 16:13:31 kruland + * Added MajorObject.i an interface specification to the MajorObject baseclass. + * Used inheritance in Band.i, Driver.i, and Dataset.i to access MajorObject + * functionality. + * Adjusted Makefile to have PYTHON be a variable, gdal wrapper depend on + * MajorObject.i, use rm (instead of libtool's wrapped RM) for removal because + * the libtool didn't accept -r. + * + * Revision 1.14 2005/07/18 15:41:27 kruland + * Added Set/Get Description. Some comment changes. + * + * Revision 1.13 2005/07/15 19:00:24 kruland + * Implement two GetMetadata methods, one which returns a dict and one + * which returns a List. Have python code determine which to use. + * + * Revision 1.12 2005/07/15 18:33:57 kruland + * Added SetMetadata with single string argument. + * + * Revision 1.11 2005/03/10 17:19:08 hobu + * #ifdefs for csharp + * + * Revision 1.10 2005/02/23 17:44:00 kruland + * Added GetMetadata, SetMetadata, SetRasterColorInterpretation. + * + * Revision 1.9 2005/02/22 23:27:39 kruland + * Implement GetRasterColorTable/SetRasterColorTable. + * + * Revision 1.8 2005/02/20 19:42:53 kruland + * Rename the Swig shadow classes so the names do not give the impression that + * they are any part of the GDAL/OSR apis. There were no bugs with the old + * names but they were confusing. + * + * Revision 1.7 2005/02/17 17:27:13 kruland + * Changed the handling of fixed size double arrays to make it fit more + * naturally with GDAL/OSR usage. Declare as typedef double * double_17; + * If used as return argument use: function ( ... double_17 argout ... ); + * If used as value argument use: function (... double_17 argin ... ); + * + * Revision 1.6 2005/02/17 04:12:09 kruland + * Reimplement Band::ReadRaster Band::WriteRaster so they use optional int + * argument. This allows keyword arguments in some languages. Added a + * sanity check to WriteRaster to ensure the buffer string is long enough. + * Fixed FlushCache by moving it into the class. + * + * Revision 1.5 2005/02/16 18:41:14 kruland + * Implemented more methods. Commented the ones still missing. + * + * Revision 1.4 2005/02/15 19:50:39 kruland + * Fixed ReadRaster/WriteRasters. They need to use buffers of char * with + * explicit length because they can contain '\0'. + * + * Revision 1.3 2005/02/15 18:56:52 kruland + * Added support for WriteRaster(). + * + * Revision 1.2 2005/02/15 16:56:46 kruland + * Remove use of vector<double> in ComputeRasterMinMax. Use double_2 instead. + * + * Revision 1.1 2005/02/15 06:23:48 kruland + * Extracted Band class (GDALRasterBandShadow) into seperate .i file. Does not use + * C++ API. + * + * +*/ + +/************************************************************************ + * + * Define the extensions for Band (nee GDALRasterBandShadow) + * +*************************************************************************/ +%{ +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} +%} + +%rename (Band) GDALRasterBandShadow; + +class GDALRasterBandShadow : public GDALMajorObjectShadow { +private: + GDALRasterBandShadow(); + ~GDALRasterBandShadow(); +public: +%extend { + +%immutable; + int XSize; + int YSize; + GDALDataType DataType; +%mutable; + + + GDALColorInterp GetRasterColorInterpretation() { + return GDALGetRasterColorInterpretation( self ); + } + + CPLErr SetRasterColorInterpretation( GDALColorInterp val ) { + return GDALSetRasterColorInterpretation( self, val ); + } + + void GetNoDataValue( double *val, int *hasval ) { + *val = GDALGetRasterNoDataValue( self, hasval ); + } + + CPLErr SetNoDataValue( double d) { + return GDALSetRasterNoDataValue( self, d ); + } + + void GetMinimum( double *val, int *hasval ) { + *val = GDALGetRasterMinimum( self, hasval ); + } + + void GetMaximum( double *val, int *hasval ) { + *val = GDALGetRasterMaximum( self, hasval ); + } + + void GetOffset( double *val, int *hasval ) { + *val = GDALGetRasterOffset( self, hasval ); + } + + void GetScale( double *val, int *hasval ) { + *val = GDALGetRasterScale( self, hasval ); + } + + int GetOverviewCount() { + return GDALGetOverviewCount( self ); + } + + GDALRasterBandShadow *GetOverview(int i) { + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } + +%apply (int *optional_int) {(int*)}; +%feature ("kwargs") Checksum; + int Checksum( int xoff = 0, int yoff = 0, int *xsize = 0, int *ysize = 0) { + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +%clear (int*); + + void ComputeRasterMinMax( double argout[2], int approx_ok = 0) { + GDALComputeRasterMinMax( self, approx_ok, argout ); + } + + CPLErr Fill( double real_fill, double imag_fill =0.0 ) { + return GDALFillRaster( self, real_fill, imag_fill ); + } + +%apply ( int *nLen, char **pBuf ) { (int *buf_len, char **buf ) }; +%apply ( int *optional_int ) {(int*)}; +%feature( "kwargs" ) ReadRaster; + CPLErr ReadRaster( int xoff, int yoff, int xsize, int ysize, + int *buf_len, char **buf, + int *buf_xsize = 0, + int *buf_ysize = 0, + int *buf_type = 0 ) { + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +%clear (int *buf_len, char **buf ); +%clear (int*); + +%apply (int nLen, char *pBuf) { (int buf_len, char *buf_string) }; +%apply ( int *optional_int ) {(int*)}; +%feature( "kwargs" ) WriteRaster; + CPLErr WriteRaster( int xoff, int yoff, int xsize, int ysize, + int buf_len, char *buf_string, + int *buf_xsize = 0, + int *buf_ysize = 0, + int *buf_type = 0 ) { + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +%clear (int buf_len, char *buf_string); +%clear (int*); + + void FlushCache() { + GDALFlushRasterCache( self ); + } + + GDALColorTable *GetRasterColorTable() { + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } + + int SetRasterColorTable( GDALColorTable *arg ) { + return GDALSetRasterColorTable( self, arg ); + } + +/* NEEDED */ +/* ReadAsArray */ +/* WriteArray */ +/* GetHistogram */ +/* ComputeBandStats */ +/* AdviseRead */ + +} /* %extend */ + +}; + +%{ +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} +%} diff --git a/Utilities/GDAL/swig/include/ColorTable.i b/Utilities/GDAL/swig/include/ColorTable.i new file mode 100644 index 0000000000..c6337a3707 --- /dev/null +++ b/Utilities/GDAL/swig/include/ColorTable.i @@ -0,0 +1,64 @@ +/****************************************************************************** + * $Id: ColorTable.i,v 1.4 2006/01/17 04:37:17 cfis Exp $ + * + * Name: ColorTable.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: ColorTable.i,v $ + * Revision 1.4 2006/01/17 04:37:17 cfis + * Added rename section for Ruby. + * + * Revision 1.3 2005/08/04 19:16:35 kruland + * Clone() returns a newobject. And changed some whitespace. + * + * Revision 1.2 2005/02/22 23:33:07 kruland + * Implement GetCount, and GetColorTableEntry correctly. + * + * Revision 1.1 2005/02/15 21:37:43 kruland + * Interface definition for ColorTable object. Cut&Paste from gdal_priv.h. + * + * +*/ + +//************************************************************************ +// +// Define the extensions for ColorTable (nee GDALColorTable) +// +//************************************************************************ +%rename (ColorTable) GDALColorTable; + +typedef int GDALPaletteInterp; + +class GDALColorTable +{ +public: + GDALColorTable( GDALPaletteInterp = GPI_RGB ); + ~GDALColorTable(); + +%newobject Clone(); + GDALColorTable *Clone() const; + + GDALPaletteInterp GetPaletteInterpretation() const; + +#ifdef SWIGRUBY +%rename (get_count) GetColorEntryCount; +#else +%rename (GetCount) GetColorEntryCount; +#endif + + int GetColorEntryCount() const; + + GDALColorEntry* GetColorEntry(int); + int GetColorEntryAsRGB( int, GDALColorEntry * ) const; + void SetColorEntry( int, const GDALColorEntry * ); + +/* NEEDED + * + * __str__; + * serialize(); + */ +}; diff --git a/Utilities/GDAL/swig/include/Dataset.i b/Utilities/GDAL/swig/include/Dataset.i new file mode 100644 index 0000000000..041cf86852 --- /dev/null +++ b/Utilities/GDAL/swig/include/Dataset.i @@ -0,0 +1,247 @@ +/****************************************************************************** + * $Id: Dataset.i,v 1.15 2005/09/02 16:19:23 kruland Exp $ + * + * Name: Dataset.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: Dataset.i,v $ + * Revision 1.15 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.14 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.13 2005/07/18 16:13:31 kruland + * Added MajorObject.i an interface specification to the MajorObject baseclass. + * Used inheritance in Band.i, Driver.i, and Dataset.i to access MajorObject + * functionality. + * Adjusted Makefile to have PYTHON be a variable, gdal wrapper depend on + * MajorObject.i, use rm (instead of libtool's wrapped RM) for removal because + * the libtool didn't accept -r. + * + * Revision 1.12 2005/07/15 19:00:55 kruland + * Implement the SetMetadata/GetMetadata methods as in Band.i + * + * Revision 1.11 2005/07/15 16:55:21 kruland + * Implemented SetDescription and GetDescription. + * + * Revision 1.10 2005/03/10 17:18:55 hobu + * #ifdefs for csharp + * + * Revision 1.9 2005/02/23 21:37:18 kruland + * Added GetProjectionRef(). Commented missing methods. + * + * Revision 1.8 2005/02/23 17:46:39 kruland + * Added r/o attribute RasterCount. + * Added AddBand method. + * Added WriteRaster method. + * + * Revision 1.7 2005/02/21 14:51:32 kruland + * Needed to rename GDALDriver to GDALDriverShadow in the last commit. + * + * Revision 1.6 2005/02/20 19:42:53 kruland + * Rename the Swig shadow classes so the names do not give the impression that + * they are any part of the GDAL/OSR apis. There were no bugs with the old + * names but they were confusing. + * + * Revision 1.5 2005/02/17 17:27:13 kruland + * Changed the handling of fixed size double arrays to make it fit more + * naturally with GDAL/OSR usage. Declare as typedef double * double_17; + * If used as return argument use: function ( ... double_17 argout ... ); + * If used as value argument use: function (... double_17 argin ... ); + * + * Revision 1.4 2005/02/16 17:41:19 kruland + * Added a few more methods to Dataset and marked the ones still missing. + * + * Revision 1.3 2005/02/15 20:50:49 kruland + * Added SetProjection. + * + * Revision 1.2 2005/02/15 16:53:36 kruland + * Removed use of vector<double> in the ?etGeoTransform() methods. Use fixed + * length double array type instead. + * + * Revision 1.1 2005/02/15 05:56:49 kruland + * Created the Dataset shadow class definition. Does not rely on the C++ api + * in gdal_priv.h. Need to remove the vector<>s and replace with fixed + * size arrays. + * + * +*/ + +//************************************************************************ +// +// Define the extensions for Dataset (nee GDALDatasetShadow) +// +//************************************************************************ + +%rename (Dataset) GDALDatasetShadow; + +class GDALDatasetShadow : public GDALMajorObjectShadow { +private: + GDALDatasetShadow(); +public: +%extend { + +%immutable; + int RasterXSize; + int RasterYSize; + int RasterCount; +// +// Needed +// _band list? +%mutable; + + ~GDALDatasetShadow() { + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } + + GDALDriverShadow* GetDriver() { + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } + + GDALRasterBandShadow* GetRasterBand(int nBand ) { + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } + + char const *GetProjection() { + return GDALGetProjectionRef( self ); + } + + char const *GetProjectionRef() { + return GDALGetProjectionRef( self ); + } + + CPLErr SetProjection( char const *prj ) { + return GDALSetProjection( self, prj ); + } + + void GetGeoTransform( double argout[6] ) { + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } + + CPLErr SetGeoTransform( double argin[6] ) { + return GDALSetGeoTransform( self, argin ); + } + + // The (int,int*) arguments are typemapped. The name of the first argument + // becomes the kwarg name for it. +%feature("kwargs") BuildOverviews; +%apply (int nList, int* pList) { (int overviewlist, int *pOverviews) }; + int BuildOverviews( const char *resampling = "NEAREST", + int overviewlist = 0 , int *pOverviews = 0 ) { + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +%clear (int overviewlist, int *pOverviews); + + int GetGCPCount() { + return GDALGetGCPCount( self ); + } + + const char *GetGCPProjection() { + return GDALGetGCPProjection( self ); + } + + void GetGCPs( int *nGCPs, GDAL_GCP const **pGCPs ) { + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } + + CPLErr SetGCPs( int nGCPs, GDAL_GCP const *pGCPs, const char *pszGCPProjection ) { + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } + + void FlushCache() { + GDALFlushCache( self ); + } + +%feature ("kwargs") AddBand; +/* uses the defined char **options typemap */ + CPLErr AddBand( GDALDataType datatype = GDT_Byte, char **options = 0 ) { + return GDALAddBand( self, datatype, options ); + } + +%feature("kwargs") WriteRaster; +%apply (int nLen, char *pBuf) { (int buf_len, char *buf_string) }; +%apply (int *optional_int) { (int*) }; +%apply (int *optional_int) { (GDALDataType *buf_type) }; +%apply (int nList, int *pList ) { (int band_list, int *pband_list ) }; + CPLErr WriteRaster( int xoff, int yoff, int xsize, int ysize, + int buf_len, char *buf_string, + int *buf_xsize = 0, int *buf_ysize = 0, + GDALDataType *buf_type = 0, + int band_list = 0, int *pband_list = 0 ) { + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } +%clear (int band_list, int *pband_list ); +%clear (GDALDataType *buf_type); +%clear (int*); +%clear (int buf_len, char *buf_string); + +/* NEEDED */ +/* GetSubDatasets */ +/* ReadAsArray */ +/* AddBand */ +/* AdviseRead */ +/* ReadRaster */ + +} /* extend */ +}; /* GDALDatasetShadow */ + +%{ +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} +%} diff --git a/Utilities/GDAL/swig/include/Driver.i b/Utilities/GDAL/swig/include/Driver.i new file mode 100644 index 0000000000..8c19a70d91 --- /dev/null +++ b/Utilities/GDAL/swig/include/Driver.i @@ -0,0 +1,117 @@ +/****************************************************************************** + * $Id: Driver.i,v 1.12 2005/09/02 16:19:23 kruland Exp $ + * + * Name: Driver.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: Driver.i,v $ + * Revision 1.12 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.11 2005/08/04 19:17:19 kruland + * The Open() and OpenShared() methods were incrementing the gdal internal + * reference count by mistake. + * + * Revision 1.10 2005/07/18 16:13:31 kruland + * Added MajorObject.i an interface specification to the MajorObject baseclass. + * Used inheritance in Band.i, Driver.i, and Dataset.i to access MajorObject + * functionality. + * Adjusted Makefile to have PYTHON be a variable, gdal wrapper depend on + * MajorObject.i, use rm (instead of libtool's wrapped RM) for removal because + * the libtool didn't accept -r. + * + * Revision 1.9 2005/07/15 16:55:46 kruland + * Implemented SetDescription and GetDescription. + * + * Revision 1.8 2005/03/10 17:18:42 hobu + * #ifdefs for csharp + * + * Revision 1.7 2005/02/24 16:33:07 kruland + * Marked missing methods. + * + * Revision 1.6 2005/02/20 19:42:53 kruland + * Rename the Swig shadow classes so the names do not give the impression that + * they are any part of the GDAL/OSR apis. There were no bugs with the old + * names but they were confusing. + * + * Revision 1.5 2005/02/16 17:11:27 kruland + * Added r/o data members for LongName, ShortName, and HelpTopic. + * + * Revision 1.4 2005/02/15 06:24:31 kruland + * Added out typemap for GetMetadata. (Removed extra log from comments) + * + * Revision 1.3 2005/02/15 05:57:43 kruland + * Moved the swig %newobject and %feature decls to immedately before the function + * def. Improves readability. + * + * Revision 1.2 2005/02/14 23:58:46 hobu + * Added log info and C99-style comments + * +*/ + +/************************************************************************* +* +* Define the extensions for Driver (nee GDALDriverShadow) +* +*************************************************************************/ + + +%rename (Driver) GDALDriverShadow; + +class GDALDriverShadow : public GDALMajorObjectShadow { +private: + ~GDALDriverShadow(); + GDALDriverShadow(); +public: +%extend { + +%immutable; + char const *ShortName; + char const *LongName; + char const *HelpTopic; +%mutable; + +%newobject Create; +%feature( "kwargs" ) Create; + GDALDatasetShadow *Create( const char *name, int xsize, int ysize, int bands =1, + GDALDataType eType=GDT_Byte, char **options = 0 ) { + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } + +%newobject CreateCopy; +%feature( "kwargs" ) CreateCopy; + GDALDatasetShadow *CreateCopy( const char *name, GDALDatasetShadow* src, int strict =1, char **options = 0 ) { + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } + + int Delete( const char *name ) { + return GDALDeleteDataset( self, name ); + } + +// NEEDED +// Register +// Deregister + +} +}; + +%{ +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} +%} + diff --git a/Utilities/GDAL/swig/include/MajorObject.i b/Utilities/GDAL/swig/include/MajorObject.i new file mode 100644 index 0000000000..ba8e63f209 --- /dev/null +++ b/Utilities/GDAL/swig/include/MajorObject.i @@ -0,0 +1,65 @@ + +%rename (MajorObject) GDALMajorObjectShadow; + +class GDALMajorObjectShadow { +private: + GDALMajorObjectShadow(); + ~GDALMajorObjectShadow(); + +public: +%extend { +/* + * GetDescription + */ + const char *GetDescription() { + return GDALGetDescription( self ); + } + +/* + * SetDescription + */ + void SetDescription( const char *pszNewDesc ) { + GDALSetDescription( self, pszNewDesc ); + } + +/* + * GetMetadata methods + */ +%apply (char **dict) { char ** }; + char ** GetMetadata_Dict( const char * pszDomain = "" ) { + return GDALGetMetadata( self, pszDomain ); + } +%clear char **; + +%apply (char **options) {char **}; + char **GetMetadata_List( const char *pszDomain = "" ) { + return GDALGetMetadata( self, pszDomain ); + } +%clear char **; + +/* + * SetMetadata methods + */ +%apply (char **dict) { char ** papszMetadata }; + CPLErr SetMetadata( char ** papszMetadata, const char * pszDomain = "" ) { + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +%clear char **papszMetadata; + + CPLErr SetMetadata( char * pszMetadataString , const char *pszDomain = "" ) { + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } + +/* + * GetMetadataItem + */ + +/* + * SetMetadataItem + */ + +} /* %extend */ +}; diff --git a/Utilities/GDAL/swig/include/README.typemaps b/Utilities/GDAL/swig/include/README.typemaps new file mode 100644 index 0000000000..301331c582 --- /dev/null +++ b/Utilities/GDAL/swig/include/README.typemaps @@ -0,0 +1,87 @@ + +Catalog of typemaps used + +Note: Use CSL routines for memory management. + +Note: If a typemap is listed as Required, it is explicitly used in an +%apply statement. This means that it must appear defined in the typemaps +even if it does nothing. + +--------------------------------------- + +argout (double *argout[ANY]) - Required: + This is used to return a fixed length array from function calls. The array is allocated + by the GDAL function and must be CPLFree'd by the caller. + +argout (double argout[ANY])- + Used to return fixed length array from function calls. The memory is allocated by the caller. + In a typical typemap implementation, the array is defined on the stack of fixed size. + +argout (int *nGCPs, GDAL_GCP const **pGCPs ) - + +argout (int *nLen, char **pBuf) - + Return a character buffer. Suggested use is to convert to native string + type. Typemap needs to deallocate memory. + FrankW: Should this be done with free? + +argout (char **argout ) - Required - + +argout (long *OUTPUT) - Required - + +------------------- + +in (char **dict) - Required + Convert a native dictionary/hash type into name value pairs. + +in (char **ignorechange) - Required + Used as in/out argument. The argument may be modified by the gdal routine. + In python, the mutated string is not returned to the caller. + +in (char **options) - + Convert a native tuple/list of strings into a char ** using the CSLAddString + routines. The converted char ** must be released with CSLDestroy. + +in (double argin[ANY]) - Required + Used to pass a fixed length array of doubles into a gdal function. + +in GDALColorEntry* - + Pass a GDALColorEntry into a function. + +in (int *optional_int) - Required - + Pass an optional integer argument into a function. If the value is not + specified by user of binding, pass in the null pointer. + +in (int nGCPs, GDAL_GCP const *pGCPs) - + Pass a fixed length array of GCP pointers into a function. + +in (int nList, int *pList) - Required - Pass a fixed length integer array into a function. + +in (int nLen, char *pBuf) - Required - Pass a fixed length character buffer into a function. + +in (tostring argin ) - Required - Converts any argument in the script types to a string representation. +In python this functionality directly calls AsString (ie str()) on the object. This functionality +could be reduced in other languages as long as it's documented. + +------------------- + +out (char **dict) - Required - The return value is a collection of name/value pairs. This can be +converted into a native dictionary or hash structure. Use CPLParseNameValue() to +access the char ** type. + +out (CPLErr) - CPLErr is an enum defined in port/cpl_error.h. This code is returned +by many functions in GDAL core. Suggested useage is to test the return code an convert +to an exception. + +out GDALColorEntry* - Return a GDALColorEntry from a function. + +out (IF_FALSE_RETURN_NONE) - Required - This is a typedef'd int. Must support use in conjunction with +argout typemaps. + +out OGRErr - + + + + + + + diff --git a/Utilities/GDAL/swig/include/cpl.i b/Utilities/GDAL/swig/include/cpl.i new file mode 100644 index 0000000000..03d45a68c0 --- /dev/null +++ b/Utilities/GDAL/swig/include/cpl.i @@ -0,0 +1,115 @@ +/****************************************************************************** + * $Id: cpl.i,v 1.5 2006/01/17 04:38:09 cfis Exp $ + * + * Name: cpl.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: cpl.i,v $ + * Revision 1.5 2006/01/17 04:38:09 cfis + * Switched #ifdef declarations to have a section for Ruby to be more consistent with other SWIG interface files. + * + * Revision 1.4 2006/01/16 08:07:04 cfis + * Exposed CPLHexToBinary and CPLHexToBinary to scripting languages. + * + * Revision 1.3 2005/10/02 23:31:27 cfis + * Updated the renames to include support for Ruby. + * + * Revision 1.2 2005/02/16 16:54:48 kruland + * Removed the python code from the wrapper for now. Wrapped a simple version + * of PushErrorHandler(char const*) which allows assignment of the CPL defined + * error handlers. + * + * +*/ + +%inline %{ + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + +%} + +#ifdef SWIGRUBY +%rename (push_error_handler) CPLPushErrorHandler; +%rename (pop_error_handler) CPLPopErrorHandler; +%rename (error_reset) CPLErrorReset; +%rename (get_last_error_no) CPLGetLastErrorNo; +%rename (get_last_error_type) CPLGetLastErrorType; +%rename (get_last_error_msg) CPLGetLastErrorMsg; +%rename (push_finder_location) CPLPushFinderLocation; +%rename (pop_finder_location) CPLPopFinderLocation; +%rename (finder_clean) CPLFinderClean; +%rename (find_file) CPLFindFile; +%rename (set_config_option) CPLSetConfigOption; +%rename (get_config_option) CPLGetConfigOption; +%rename (binary_to_hex) CPLBinaryToHex; +%rename (hex_to_binary) CPLHexToBinary; +#else +%rename (PushErrorHandler) CPLPushErrorHandler; +%rename (PopErrorHandler) CPLPopErrorHandler; +%rename (ErrorReset) CPLErrorReset; +%rename (GetLastErrorNo) CPLGetLastErrorNo; +%rename (GetLastErrorType) CPLGetLastErrorType; +%rename (GetLastErrorMsg) CPLGetLastErrorMsg; +%rename (PushFinderLocation) CPLPushFinderLocation; +%rename (PopFinderLocation) CPLPopFinderLocation; +%rename (FinderClean) CPLFinderClean; +%rename (FindFile) CPLFindFile; +%rename (SetConfigOption) CPLSetConfigOption; +%rename (GetConfigOption) CPLGetConfigOption; +%rename (CPLBinaryToHex) CPLBinaryToHex; +%rename (CPLHexToBinary) CPLHexToBinary; +#endif + +void CPLPushErrorHandler( CPLErrorHandler ); + +void CPLPopErrorHandler(); + +void CPLErrorReset(); + +int CPLGetLastErrorNo(); + +CPLErr CPLGetLastErrorType(); + +char const *CPLGetLastErrorMsg(); + +void CPLPushFinderLocation( const char * ); + +void CPLPopFinderLocation(); + +void CPLFinderClean(); + +const char * CPLFindFile( const char *, const char * ); + +void CPLSetConfigOption( const char *, const char * ); + +const char * CPLGetConfigOption( const char *, const char * ); + +/* Provide hooks to hex encoding methods */ +char *CPLBinaryToHex( int nBytes, const GByte *pabyData ); +GByte *CPLHexToBinary( const char *pszHex, int *pnBytes ); + diff --git a/Utilities/GDAL/swig/include/cpl_exceptions.i b/Utilities/GDAL/swig/include/cpl_exceptions.i new file mode 100644 index 0000000000..ffe3fd017c --- /dev/null +++ b/Utilities/GDAL/swig/include/cpl_exceptions.i @@ -0,0 +1,60 @@ +/* + * $Id: cpl_exceptions.i,v 1.4 2005/09/30 20:21:31 kruland Exp $ + * + * Code for Optional Exception Handling through UseExceptions(), + * DontUseExceptions() + * + * It uses CPLSetErrorHandler to provide a custom function + * which notifies the bindings of errors. + * + * This is not thread safe. + * + * $Log: cpl_exceptions.i,v $ + * Revision 1.4 2005/09/30 20:21:31 kruland + * Removed the file global variable bUseExceptions. + * + * Revision 1.3 2005/09/28 18:24:36 kruland + * Removed global flag bExceptionHappened. Create a custom error handler which + * writes messages for CE_Fatal errors. + * + * Revision 1.2 2005/09/18 07:36:18 cfis + * Only raise exceptions on failures or fatal errors. The previous code rose exceptions on debug messages, warning messages and when nothing at all happened. + * + * Revision 1.1 2005/09/13 03:04:27 kruland + * Pull the exception generation mechanism out of gdal_python.i so it could + * be used by other bindings. + * + * + */ + +%{ +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} +%} + +%inline %{ +void UseExceptions() { + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} +%} + +%include exception.i + +%exception { + CPLErrorReset(); + $action + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } +} diff --git a/Utilities/GDAL/swig/include/csharp/gdal_csharp.i b/Utilities/GDAL/swig/include/csharp/gdal_csharp.i new file mode 100644 index 0000000000..90d77f4299 --- /dev/null +++ b/Utilities/GDAL/swig/include/csharp/gdal_csharp.i @@ -0,0 +1,47 @@ +/* + * $Id: gdal_csharp.i,v 1.1 2005/09/02 16:19:23 kruland Exp $ + */ + +/* + * $Log: gdal_csharp.i,v $ + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +// When we switch to swig 1.3.26 these definitions can be removed + +%{ +GDALDataType GDALRasterBandShadow_get_DataType( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_get_XSize( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_get_YSize( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} +int GDALDatasetShadow_get_RasterXSize( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_get_RasterYSize( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_get_RasterCount( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} +char const *GDALDriverShadow_get_ShortName( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_get_LongName( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_get_HelpTopic( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} +%} + + +%include typemaps_csharp.i diff --git a/Utilities/GDAL/swig/include/csharp/ogr_csharp.i b/Utilities/GDAL/swig/include/csharp/ogr_csharp.i new file mode 100644 index 0000000000..8dd37829bc --- /dev/null +++ b/Utilities/GDAL/swig/include/csharp/ogr_csharp.i @@ -0,0 +1,24 @@ +/* + * $Id: ogr_csharp.i,v 1.2 2005/09/06 01:51:04 kruland Exp $ + */ + +/* + * $Log: ogr_csharp.i,v $ + * Revision 1.2 2005/09/06 01:51:04 kruland + * Removed GetDriverByName, GetDriver, Open, OpenShared because they are defined + * in ogr now. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%rename (GetFieldType) GetType; +%rename (GetDriverCount) OGRGetDriverCount; +%rename (GetOpenDSCount) OGRGetOpenDSCount; +%rename (SetGenerate_DB2_V72_BYTE_ORDER) OGRSetGenerate_DB2_V72_BYTE_ORDER; +%rename (RegisterAll) OGRRegisterAll(); + +%include typemaps_csharp.i diff --git a/Utilities/GDAL/swig/include/csharp/typemaps_csharp.i b/Utilities/GDAL/swig/include/csharp/typemaps_csharp.i new file mode 100644 index 0000000000..c76825fb5a --- /dev/null +++ b/Utilities/GDAL/swig/include/csharp/typemaps_csharp.i @@ -0,0 +1,269 @@ +/****************************************************************************** + * $Id: typemaps_csharp.i,v 1.6 2005/08/19 13:42:39 kruland Exp $ + * + * Name: typemaps_cshar.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for C# bindings + * Author: Howard Butler + * + + * + * $Log: typemaps_csharp.i,v $ + * Revision 1.6 2005/08/19 13:42:39 kruland + * Fix problem in a double[ANY] typemap which prevented compilation of wrapper. + * + * Revision 1.5 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.4 2005/08/05 18:49:26 hobu + * Add some more dummy typemaps to get us closer to where + * Kevin is with python + * + * Revision 1.3 2005/06/22 18:41:30 kruland + * Renamed type for OGRErr typemap to use OGRErr instead of the made up + * THROW_OGR_ERROR. + * + * Revision 1.2 2005/03/10 17:12:55 hobu + * dummy typemaps for csharp. Nothing here yet, but the names + * are there + * + * Revision 1.1 2005/02/24 17:42:03 kruland + * C# typemap file started. Code taken from gdal_typemaps.i + * + * +*/ + +%include "typemaps.i" + +/* CSHARP TYPEMAPS */ + +%typemap(csharp,in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen, char *pBuf ) +{ + /* %typemap(csharp, in,numinputs=0) (int *nLen, char **pBuf ) */ + $1 = &nLen; + $2 = &pBuf; +} + +%typemap(csharp,argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + +} +%typemap(csharp,freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(csharp,freearg) (int *nLen, char **pBuf ) */ + if( $1 ) { + free( *$2 ); + } +} + +%fragment("OGRErrMessages","header") %{ +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error %d: None"; + case 1: + return "OGR Error %d: Not enough data"; + case 2: + return "OGR Error %d: Unsupported geometry type"; + case 3: + return "OGR Error %d: Unsupported operation"; + case 4: + return "OGR Error %d: Corrupt data"; + case 5: + return "OGR Error %d: General Error"; + case 6: + return "OGR Error %d: Unsupported SRS"; + default: + return "OGR Error %d: Unknown"; + } +} +%} +%typemap(csharp,in,numinputs=1) (int nLen, char *pBuf ) +{ + /* %typemap(csharp, in,numinputs=1) (int nLen, char *pBuf ) */ + +} + + +%typemap(csharp,in) (tostring argin) (string str) +{ + /* %typemap(csharp,in) (tostring argin) */ + +} + +%typemap(csharp,in) (char **ignorechange) ( char *val ) +{ + /* %typemap(csharp, in) (char **ignorechange) */ + +} + +%typemap(csharp, out,fragment="OGRErrMessages") OGRErr +{ + /* %typemap(csharp, out) OGRErr */ + +} +%typemap(csharp, ret) OGRErr +{ + /* %typemap(csharp, ret) OGRErr */ + +} + + +/* GDAL Typemaps */ + +%typemap(csharp,out) IF_ERR_RETURN_NONE +{ + /* %typemap(csharp,out) IF_ERR_RETURN_NONE */ + +} +%typemap(csharp,ret) IF_ERR_RETURN_NONE +{ + /* %typemap(csharp,ret) IF_ERR_RETURN_NONE */ + +} +%typemap(csharp,out) IF_FALSE_RETURN_NONE +{ + /* %typemap(csharp,out) IF_FALSE_RETURN_NONE */ + +} +%typemap(ret) IF_FALSE_RETURN_NONE +{ + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + +} + +%typemap(csharp,in,numargs=1) (int nList, int* pList) +{ + /* %typemap(in,numargs=1) (int nList, int* pList)*/ + /* check if is List */ + +} +%typemap(csharp,freearg) (int nList, int* pList) +{ + /* %typemap(python,freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} + + +/* + * Typemap char ** -> dict + */ +%typemap(csharp,out) char **dict +{ + /* %typemap(out) char ** -> to hash */ + +} + +/* + * Typemap char **<- dict + */ +%typemap(csharp,in) char **dict +{ + /* %typemap(in) char **dict */ + +} +%typemap(csharp,freearg) char **dict +{ + /* %typemap(csharp,freearg) char **dict */ + CSLDestroy( $1 ); +} + +%define OPTIONAL_POD(type,argstring) +%typemap(csharp,in) (type *optional_##type) ( type val ) +{ + /* %typemap(csharp,in) (type *optional_##type) */ + +} +%typemap(csharp,typecheck,precedence=0) (type *optional_##type) +{ + /* %typemap(csharp,typecheck,precedence=0) (type *optionalInt) */ + +} +%enddef + +OPTIONAL_POD(int,i); + +/* + * Typemap maps char** arguments from Python Sequence Object + */ +%typemap(csharp,in) char **options +{ + /* %typemap(in) char **options */ + /* Check if is a list */ + +} +%typemap(csharp,freearg) char **options +{ + /* %typemap(freearg) char **options */ + CSLDestroy( $1 ); +} +%typemap(csharp,out) char **options +{ + /* %typemap(out) char ** -> ( string ) */ + +} + +/* + * Typemap for char **argout. + */ +%typemap(csharp,in,numinputs=0) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in,numinputs=0) (char **argout) */ + +} +%typemap(csharp,argout,fragment="t_output_helper") (char **argout) +{ + /* %typemap(argout) (char **argout) */ + +} +%typemap(csharp,freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + +} + + +%fragment("CreateTupleFromDoubleArray","header") %{ +static int +CreateTupleFromDoubleArray( double *first, unsigned int size ) { + + return 1; +} +%} + +%typemap(csharp,in,numinputs=0) ( double argout[ANY]) (double argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double argout[ANY]) */ + +} +%typemap(csharp,argout,fragment="t_output_helper,CreateTupleFromDoubleArray") ( double argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + +} +%typemap(csharp,in,numinputs=0) ( double *argout[ANY]) (double *argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double *argout[ANY]) */ + +} +%typemap(csharp,argout,fragment="t_output_helper,CreateTupleFromDoubleArray") ( double *argout[ANY]) +{ + /* %typemap(argout) (double *argout[ANY]) */ + +} +%typemap(csharp,freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + +} +%typemap(csharp,in) (double argin[ANY]) (double argin[$dim0]) +{ + /* %typemap(in) (double argin[ANY]) */ + +} diff --git a/Utilities/GDAL/swig/include/gdal.i b/Utilities/GDAL/swig/include/gdal.i new file mode 100644 index 0000000000..33d95992cc --- /dev/null +++ b/Utilities/GDAL/swig/include/gdal.i @@ -0,0 +1,568 @@ +/****************************************************************************** + * $Id: gdal.i,v 1.40 2006/02/02 20:52:40 collinsb Exp $ + * + * Name: gdal.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: gdal.i,v $ + * Revision 1.40 2006/02/02 20:52:40 collinsb + * Added SWIG JAVA bindings + * + * Revision 1.39 2006/01/17 04:38:44 cfis + * Grouped all renames together and added section for Ruby. + * + * Revision 1.38 2005/09/13 18:37:25 kruland + * Added binding for GDALGetDriver. + * + * Revision 1.37 2005/09/13 16:09:12 kruland + * Import gdal_perl.i for SWIGPERL. + * + * Revision 1.36 2005/09/06 01:43:06 kruland + * Include gdal_typemaps.i if no other file is specified. + * + * Revision 1.35 2005/09/02 21:42:42 kruland + * The compactdefaultargs feature should be turned on for all bindings not just + * python. + * + * Revision 1.34 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.33 2005/08/09 17:40:09 kruland + * Added support for ruby. + * + * Revision 1.32 2005/08/08 17:06:40 kruland + * Added bindings for ParseXMLString and SerializeXMLTree. + * + * Revision 1.31 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.30 2005/08/05 18:48:59 hobu + * gross hack of duplicate function names for the + * GCP stuff because C# module of swig is stupid + * + * Revision 1.29 2005/08/04 19:18:01 kruland + * The Open() and OpenShared() methods were incrementing the gdal internal + * reference count by mistake. + * + * Revision 1.28 2005/07/20 16:33:52 kruland + * Added wrapper for GDALGetDriverCount. + * Added %init for PHP. + * + * Revision 1.27 2005/07/18 16:13:32 kruland + * Added MajorObject.i an interface specification to the MajorObject baseclass. + * Used inheritance in Band.i, Driver.i, and Dataset.i to access MajorObject + * functionality. + * Adjusted Makefile to have PYTHON be a variable, gdal wrapper depend on + * MajorObject.i, use rm (instead of libtool's wrapped RM) for removal because + * the libtool didn't accept -r. + * + * Revision 1.26 2005/07/15 16:58:04 kruland + * In the %exception spec, if an error is detected while UseExceptions(), + * SWIG_fail immediately. + * + * Revision 1.25 2005/07/15 15:10:03 kruland + * Move the #ifdef SWIGPYTHON to include the exception flags. + * Correct some %inline to use %{ %}. + * + * Revision 1.24 2005/06/23 14:46:39 kruland + * Switch from using the poor-form exception in the custom CPLErrorHandler to + * using a global variable flag. + * + * Revision 1.23 2005/06/22 18:48:23 kruland + * Added bUseExceptions flag and supporting methods UseExceptions(), + * DontUseExceptions() to the python binding. This allows the user + * to determine if method invocations will throw exceptions in scripts or + * use the old return value method. + * Added PythonErrorHandler, a special CPLErrorHandler which will throw. + * + * Revision 1.22 2005/03/10 17:18:15 hobu + * #ifdefs for csharp + * + * Revision 1.21 2005/02/24 17:20:02 hobu + * return the dataset in AutoCreateWarpedVRT + * + * Revision 1.20 2005/02/24 16:34:14 kruland + * Defined GCP as an object. Manipulate as an object. Defined __str__ + * and serialize as python only methods. + * + * Revision 1.19 2005/02/23 21:38:28 kruland + * Added AutoCreateWarpedVRT() global algorithm method. Commented missing methods. + * + * Revision 1.18 2005/02/22 23:30:14 kruland + * Increment the reference count in the Dataset factory methods: Open, OpenShared. + * + * Revision 1.17 2005/02/20 19:42:53 kruland + * Rename the Swig shadow classes so the names do not give the impression that + * they are any part of the GDAL/OSR apis. There were no bugs with the old + * names but they were confusing. + * + * Revision 1.16 2005/02/18 18:41:37 kruland + * Added %feature("autodoc"); + * + * Revision 1.15 2005/02/18 16:09:53 kruland + * Added %feature("compactdefaultargs") which in python (and perhaps others) + * allows SWIG to code default arguments for C functions (like GDALDecToDMS). + * This also fixes a problem with Dataset::SetMetadata and there not being + * a %typecheck for char** <- dict. + * + * Revision 1.14 2005/02/17 21:12:48 kruland + * Added some more module level functions. + * + * Revision 1.13 2005/02/17 17:27:13 kruland + * Changed the handling of fixed size double arrays to make it fit more + * naturally with GDAL/OSR usage. Declare as typedef double * double_17; + * If used as return argument use: function ( ... double_17 argout ... ); + * If used as value argument use: function (... double_17 argin ... ); + * + * Revision 1.12 2005/02/16 18:40:34 kruland + * Added typedef for GDALColorInterp. + * + * Revision 1.11 2005/02/16 16:55:49 kruland + * Added typedef for CPLErr to prevent wrapping of the enum. + * Moved the AllRegister method definition. + * + * Revision 1.10 2005/02/15 22:31:52 kruland + * Moved CPL wrapping to cpl.i + * + * Revision 1.9 2005/02/15 22:02:16 kruland + * Previous revision introduced a problem. Put the #defines CPL_* back in + * until the cpl specific code is cleaned up. + * + * Revision 1.8 2005/02/15 21:40:00 kruland + * Stripped out all the extras by no longer including gdal.h or gdal_priv.h. + * Added CreateShared() method. + * + * Revision 1.7 2005/02/15 16:51:20 kruland + * Removed use of <vector> and <algorith> stdlib includes. Added typedefs for + * the fixed size array types which are needed for new mapping mechanism. + * + * Revision 1.6 2005/02/15 06:25:42 kruland + * Moved the Band definition to Band.i. + * + * Revision 1.5 2005/02/15 06:01:15 kruland + * Moved the Dataset definition to Dataset.i. + * + * Revision 1.4 2005/02/14 23:50:16 hobu + * Added log info + * +*/ + +%module gdal + +%feature ("compactdefaultargs"); + +// +// We register all the drivers upon module initialization +// + +%{ +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + +%} + +typedef int GDALColorInterp; +typedef int GDALAccess; +typedef int GDALDataType; +typedef int CPLErr; +typedef int GDALResampleAlg; + +#if defined(SWIGPYTHON) +%include "gdal_python.i" +#elif defined(SWIGRUBY) +%include "gdal_ruby.i" +#elif defined(SWIGPHP4) +%include "gdal_php.i" +#elif defined(SWIGCSHARP) +%include "gdal_csharp.i" +#elif defined(SWIGPERL) +%include "gdal_perl.i" +#elif defined(SWIGJAVA) +%include "gdal_java.i" +#else +%include "gdal_typemaps.i" +#endif + +//************************************************************************ +// +// Define the exposed CPL functions. +// +//************************************************************************ +%include "cpl.i" + +//************************************************************************ +// +// Define the MajorObject object +// +//************************************************************************ +%include "MajorObject.i" + +//************************************************************************ +// +// Define the Driver object. +// +//************************************************************************ +%include "Driver.i" + + +//************************************************************************ +// +// Define renames. +// +//************************************************************************ +%rename (GCP) GDAL_GCP; + +#ifdef SWIGRUBY +%rename (all_register) GDALAllRegister; +%rename (get_cache_max) GDALGetCacheMax; +%rename (set_cache_max) GDALSetCacheMax; +%rename (set_cache_used) GDALGetCacheUsed; +%rename (get_data_type_size) GDALGetDataTypeSize; +%rename (data_type_is_complex) GDALDataTypeIsComplex; +%rename (gcps_to_geo_transform) GDALGCPsToGeoTransform; +%rename (get_data_type_name) GDALGetDataTypeName; +%rename (get_data_type_by_name) GDALGetDataTypeByName; +%rename (get_color_interpretation_name) GDALGetColorInterpretationName; +%rename (get_palette_interpretation_name) GDALGetPaletteInterpretationName; +%rename (dec_to_dms) GDALDecToDMS; +%rename (packed_dms_to_dec) GDALPackedDMSToDec; +%rename (dec_to_packed_dms) GDALDecToPackedDMS; +%rename (parse_xml_string) CPLParseXMLString; +%rename (serialize_xml_tree) CPLSerializeXMLTree; +#else +%rename (GCP) GDAL_GCP; +%rename (GCPsToGeoTransform) GDALGCPsToGeoTransform; +%rename (AllRegister) GDALAllRegister; +%rename (GetCacheMax) GDALGetCacheMax; +%rename (SetCacheMax) GDALSetCacheMax; +%rename (GetCacheUsed) GDALGetCacheUsed; +%rename (GetDataTypeSize) GDALGetDataTypeSize; +%rename (DataTypeIsComplex) GDALDataTypeIsComplex; +%rename (GCPsToGeoTransform) GDALGCPsToGeoTransform; +%rename (GetDataTypeName) GDALGetDataTypeName; +%rename (GetDataTypeByName) GDALGetDataTypeByName; +%rename (GetColorInterpretationName) GDALGetColorInterpretationName; +%rename (GetPaletteInterpretationName) GDALGetPaletteInterpretationName; +%rename (DecToDMS) GDALDecToDMS; +%rename (PackedDMSToDec) GDALPackedDMSToDec; +%rename (DecToPackedDMS) GDALDecToPackedDMS; +%rename (ParseXMLString) CPLParseXMLString; +%rename (SerializeXMLTree) CPLSerializeXMLTree; +#endif + + +//************************************************************************ +// +// Define the Ground Control Point structure. +// +//************************************************************************ +// GCP - class? serialize() method missing. +struct GDAL_GCP { +%extend { +%mutable; + double GCPX; + double GCPY; + double GCPZ; + double GCPPixel; + double GCPLine; + char *Info; + char *Id; +%immutable; + + GDAL_GCP( double x = 0.0, double y = 0.0, double z = 0.0, + double pixel = 0.0, double line = 0.0, + const char *info = "", const char *id = "" ) { + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } + + ~GDAL_GCP() { + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } + + +} /* extend */ +}; /* GDAL_GCP */ +%inline %{ + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + +%} //%inline + +%apply (IF_FALSE_RETURN_NONE) { (FALSE_IS_ERR) }; +FALSE_IS_ERR GDALGCPsToGeoTransform( int nGCPs, GDAL_GCP const * pGCPs, + double argout[6], int bApproxOK = 1 ); +%clear (FALSE_IS_ERR); + + +//************************************************************************ +// +// Define the Dataset object. +// +//************************************************************************ +%include "Dataset.i" + +//************************************************************************ +// +// Define the Band object. +// +//************************************************************************ +%include "Band.i" + +//************************************************************************ +// +// Define the ColorTable object. +// +//************************************************************************ +%include "ColorTable.i" + +//************************************************************************ +// +// Define the global methods +// +//************************************************************************ +// +// Missing +// +// GeneralCmdLineProcessor +// TermProgress +// + +void GDALAllRegister(); + +int GDALGetCacheMax(); + +void GDALSetCacheMax( int nBytes ); + +int GDALGetCacheUsed(); + +int GDALGetDataTypeSize( GDALDataType ); + +int GDALDataTypeIsComplex( GDALDataType ); + +const char *GDALGetDataTypeName( GDALDataType ); + +GDALDataType GDALGetDataTypeByName( const char * ); + +const char *GDALGetColorInterpretationName( GDALColorInterp ); + +const char *GDALGetPaletteInterpretationName( GDALPaletteInterp ); + +const char *GDALDecToDMS( double, const char *, int = 2 ); + +double GDALPackedDMSToDec( double ); + +double GDALDecToPackedDMS( double ); + +CPLXMLNode *CPLParseXMLString( char * ); + +char *CPLSerializeXMLTree( CPLXMLNode *xmlnode ); + +//************************************************************************ +// +// Define the factory functions for Drivers and Datasets +// +//************************************************************************ + +// Missing +// GetDriverList + +%inline %{ +int GetDriverCount() { + return GDALGetDriverCount(); +} +%} + +%inline %{ +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} +%} + +%inline %{ +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} +%} + +%newobject Open; +%inline %{ +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} +%} + +%newobject OpenShared; +%inline %{ +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} +%} + +//************************************************************************ +// +// Define Algorithms +// +//************************************************************************ + +// Missing +// ComputeMedianCutPCT +// DitherRGB2PCT +// RGBFile2PCTFile +// AutoCreateWarpedVRT +// ReprojectImage +// CreateAndReprojectImage +// GCPsToGeoTransform + +%newobject AutoCreateWarpedVRT; +%inline %{ +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} +%} diff --git a/Utilities/GDAL/swig/include/gdal_typemaps.i b/Utilities/GDAL/swig/include/gdal_typemaps.i new file mode 100644 index 0000000000..0f43426bc3 --- /dev/null +++ b/Utilities/GDAL/swig/include/gdal_typemaps.i @@ -0,0 +1,53 @@ +/****************************************************************************** + * $Id: gdal_typemaps.i,v 1.5 2006/02/02 20:52:40 collinsb Exp $ + * + * Name: typemaps.i + * Project: GDAL Typemap library + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: gdal_typemaps.i,v $ + * Revision 1.5 2006/02/02 20:52:40 collinsb + * Added SWIG JAVA bindings + * + * Revision 1.4 2005/09/06 01:41:06 kruland + * Added SWIGPERL include. + * + * Revision 1.3 2005/08/09 17:40:09 kruland + * Added support for ruby. + * + * Revision 1.2 2005/07/20 16:30:32 kruland + * Import the php typemaps. + * + * Revision 1.1 2005/02/24 17:44:54 kruland + * Generic typemap.i file which delegates to the appropriate language + * specific file. + * + * +*/ + +#ifdef SWIGCSHARP +%import typemaps_csharp.i +#endif + +#ifdef SWIGPYTHON +%import typemaps_python.i +#endif + +#ifdef SWIGPHP +%import typemaps_php.i +#endif + +#ifdef SWIGRUBY +%import typemaps_ruby.i +#endif + +#ifdef SWIGPERL +%import typemaps_perl.i +#endif + +#ifdef SWIGJAVA +%import typemaps_java.i +#endif diff --git a/Utilities/GDAL/swig/include/gdalconst.i b/Utilities/GDAL/swig/include/gdalconst.i new file mode 100644 index 0000000000..f1868e2bbb --- /dev/null +++ b/Utilities/GDAL/swig/include/gdalconst.i @@ -0,0 +1,107 @@ +%module gdalconst + +#if defined(SWIGJAVA) +%include gdalconst_java.i +#endif + +%{ +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" +%} + +// GDALDataType +%constant GDT_Unknown = GDT_Unknown; +%constant GDT_Byte = GDT_Byte; +%constant GDT_UInt16 = GDT_UInt16; +%constant GDT_Int16 = GDT_Int16; +%constant GDT_UInt32 = GDT_UInt32; +%constant GDT_Int32 = GDT_Int32; +%constant GDT_Float32 = GDT_Float32; +%constant GDT_Float64 = GDT_Float64; +%constant GDT_CInt16 = GDT_CInt16; +%constant GDT_CInt32 = GDT_CInt32; +%constant GDT_CFloat32 = GDT_CFloat32; +%constant GDT_CFloat64 = GDT_CFloat64; +%constant GDT_TypeCount = GDT_TypeCount; + +// GDALAccess +%constant GA_ReadOnly = GA_ReadOnly; +%constant GA_Update = GA_Update; + +// GDALRWFlag +%constant GF_Read = GF_Read; +%constant GF_Write = GF_Write; + +// GDALColorInterp +%constant GCI_Undefined = GCI_Undefined; +%constant GCI_GrayIndex = GCI_GrayIndex; +%constant GCI_PaletteIndex = GCI_PaletteIndex; +%constant GCI_RedBand = GCI_RedBand; +%constant GCI_GreenBand = GCI_GreenBand; +%constant GCI_BlueBand = GCI_BlueBand; +%constant GCI_AlphaBand = GCI_AlphaBand; +%constant GCI_HueBand = GCI_HueBand; +%constant GCI_SaturationBand= GCI_SaturationBand; +%constant GCI_LightnessBand = GCI_LightnessBand; +%constant GCI_CyanBand = GCI_CyanBand; +%constant GCI_MagentaBand = GCI_MagentaBand; +%constant GCI_YellowBand = GCI_YellowBand; +%constant GCI_BlackBand = GCI_BlackBand; + +// GDALResampleAlg + +%constant GRA_NearestNeighbour = GRA_NearestNeighbour; +%constant GRA_Bilinear = GRA_Bilinear; +%constant GRA_Cubic = GRA_Cubic; +%constant GRA_CubicSpline = GRA_CubicSpline; + +// GDALPaletteInterp +%constant GPI_Gray = GPI_Gray; +%constant GPI_RGB = GPI_RGB; +%constant GPI_CMYK = GPI_CMYK; +%constant GPI_HLS = GPI_HLS; + +%constant CXT_Element = CXT_Element; +%constant CXT_Text = CXT_Text; +%constant CXT_Attribute = CXT_Attribute; +%constant CXT_Comment = CXT_Comment; +%constant CXT_Literal = CXT_Literal; + +// Error classes + +%constant CE_None = CE_None; +%constant CE_Debug = CE_Debug; +%constant CE_Warning = CE_Warning; +%constant CE_Failure = CE_Failure; +%constant CE_Fatal = CE_Fatal; + +// Error codes + +%constant CPLE_None = CPLE_None; +%constant CPLE_AppDefined = CPLE_AppDefined; +%constant CPLE_OutOfMemory = CPLE_OutOfMemory; +%constant CPLE_FileIO = CPLE_FileIO; +%constant CPLE_OpenFailed = CPLE_OpenFailed; +%constant CPLE_IllegalArg = CPLE_IllegalArg; +%constant CPLE_NotSupported = CPLE_NotSupported; +%constant CPLE_AssertionFailed = CPLE_AssertionFailed; +%constant CPLE_NoWriteAccess = CPLE_NoWriteAccess; +%constant CPLE_UserInterrupt = CPLE_UserInterrupt; + +%constant char *DMD_LONGNAME = GDAL_DMD_LONGNAME; +%constant char *DMD_HELPTOPIC = GDAL_DMD_HELPTOPIC; +%constant char *DMD_MIMETYPE = GDAL_DMD_MIMETYPE; +%constant char *DMD_EXTENSION = GDAL_DMD_EXTENSION; +%constant char *DMD_CREATIONOPTIONLIST = GDAL_DMD_CREATIONOPTIONLIST; +%constant char *DMD_CREATIONDATATYPES = GDAL_DMD_CREATIONDATATYPES; + +%constant char *DCAP_CREATE = GDAL_DCAP_CREATE; +%constant char *DCAP_CREATECOPY = GDAL_DCAP_CREATECOPY; + +%constant CPLES_BackslashQuotable = CPLES_BackslashQuotable; +%constant CPLES_XML = CPLES_XML; +%constant CPLES_URL = CPLES_URL; +%constant CPLES_SQL = CPLES_SQL; +%constant CPLES_CSV = CPLES_CSV; diff --git a/Utilities/GDAL/swig/include/java/gdal_java.i b/Utilities/GDAL/swig/include/java/gdal_java.i new file mode 100644 index 0000000000..31c92744d3 --- /dev/null +++ b/Utilities/GDAL/swig/include/java/gdal_java.i @@ -0,0 +1,94 @@ +/****************************************************************************** + * $Id: gdal_java.i,v 1.2 2006/02/16 17:21:12 collinsb Exp $ + * + * Name: gdal_java.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for Java bindings + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: gdal_java.i,v $ + * Revision 1.2 2006/02/16 17:21:12 collinsb + * Updates to Java bindings to keep the code from halting execution if the native libraries cannot be found. + * + * Revision 1.1 2006/02/02 20:56:07 collinsb + * Added Java specific typemap code + * + * +*/ + +%pragma(java) jniclasscode=%{ + private static boolean available = false; + + static { + try { + System.loadLibrary("gdaljni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } +%} + + +%extend GDALRasterBandShadow { + CPLErr ReadRaster_Direct( int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + void *buf ) +{ + + return GDALRasterIO( self, GF_Read, xoff, yoff, xsize, ysize, + buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + +} + + CPLErr WriteRaster_Direct( int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + void *buf ) +{ + + return GDALRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + +} +} /* extend */ + +%typemap(javaimports) GDALColorTable %{ +/* imports for getIndexColorModel */ +import java.awt.image.IndexColorModel; +import java.awt.Color; +%} + +%typemap(javacode) GDALColorTable %{ +/* convienance method */ + public IndexColorModel getIndexColorModel(int bits) { + int size = GetCount(); + byte[] reds = new byte[size]; + byte[] greens = new byte[size]; + byte[] blues = new byte[size]; + byte[] alphas = new byte[size]; + + Color entry = null; + for(int i = 0; i < size; i++) { + entry = GetColorEntry(i); + reds[i] = (byte)entry.getRed(); + greens[i] = (byte)entry.getGreen(); + blues[i] = (byte)entry.getBlue(); + byte alpha = (byte)entry.getAlpha(); + alphas[i] = (alpha != -1) ? alpha : 0; + } + return new IndexColorModel(bits, size, reds, greens, blues, alphas); + } +%} + +%include typemaps_java.i diff --git a/Utilities/GDAL/swig/include/java/gdalconst_java.i b/Utilities/GDAL/swig/include/java/gdalconst_java.i new file mode 100644 index 0000000000..2de934b27b --- /dev/null +++ b/Utilities/GDAL/swig/include/java/gdalconst_java.i @@ -0,0 +1,40 @@ +/****************************************************************************** + * $Id: gdalconst_java.i,v 1.2 2006/02/16 17:21:12 collinsb Exp $ + * + * Name: gdalconst_java.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for Java bindings + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: gdalconst_java.i,v $ + * Revision 1.2 2006/02/16 17:21:12 collinsb + * Updates to Java bindings to keep the code from halting execution if the native libraries cannot be found. + * + * Revision 1.1 2006/02/02 20:56:07 collinsb + * Added Java specific typemap code + * + * +*/ + +%pragma(java) jniclasscode=%{ + private static boolean available = false; + + static { + try { + System.loadLibrary("gdalconstjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } +%} + + +%include typemaps_java.i diff --git a/Utilities/GDAL/swig/include/java/ogr_java.i b/Utilities/GDAL/swig/include/java/ogr_java.i new file mode 100644 index 0000000000..e83270154f --- /dev/null +++ b/Utilities/GDAL/swig/include/java/ogr_java.i @@ -0,0 +1,65 @@ +/****************************************************************************** + * $Id: ogr_java.i,v 1.2 2006/02/16 17:21:12 collinsb Exp $ + * + * Name: ogr_java.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for Java bindings + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: ogr_java.i,v $ + * Revision 1.2 2006/02/16 17:21:12 collinsb + * Updates to Java bindings to keep the code from halting execution if the native libraries cannot be found. + * + * Revision 1.1 2006/02/02 20:56:07 collinsb + * Added Java specific typemap code + * + * +*/ + +%pragma(java) jniclasscode=%{ + private static boolean available = false; + + static { + try { + System.loadLibrary("ogrjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } +%} + + +%rename (GetFieldType) GetType; +%rename (GetDriverCount) OGRGetDriverCount; +%rename (GetOpenDSCount) OGRGetOpenDSCount; +%rename (SetGenerate_DB2_V72_BYTE_ORDER) OGRSetGenerate_DB2_V72_BYTE_ORDER; +%rename (RegisterAll) OGRRegisterAll(); + +/* + * + */ +%pragma(java) moduleimports=%{ +import org.gdal.osr.SpatialReference; +%} + +%typemap(javaimports) OGRLayerShadow %{ +import org.gdal.osr.SpatialReference; +%} +%typemap(javaimports) OGRDataSourceShadow %{ +import org.gdal.osr.SpatialReference; +%} +%typemap(javaimports) OGRGeometryShadow %{ +import org.gdal.osr.SpatialReference; +import org.gdal.osr.CoordinateTransformation; +%} + + +%include typemaps_java.i diff --git a/Utilities/GDAL/swig/include/java/osr_java.i b/Utilities/GDAL/swig/include/java/osr_java.i new file mode 100644 index 0000000000..d34f0f942b --- /dev/null +++ b/Utilities/GDAL/swig/include/java/osr_java.i @@ -0,0 +1,60 @@ +/****************************************************************************** + * $Id: osr_java.i,v 1.2 2006/02/16 17:21:12 collinsb Exp $ + * + * Name: osr_java.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for Java bindings + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: osr_java.i,v $ + * Revision 1.2 2006/02/16 17:21:12 collinsb + * Updates to Java bindings to keep the code from halting execution if the native libraries cannot be found. + * + * Revision 1.1 2006/02/02 20:56:07 collinsb + * Added Java specific typemap code + * + * +*/ + +%include arrays_java.i +%include typemaps_java.i + +%pragma(java) jniclasscode=%{ + private static boolean available = false; + + static { + try { + System.loadLibrary("osrjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } +%} + +/* + * Needed to make the Constructor and getCptr 'public' and not 'protected'. + * There is likely a better way to do this (with javamethodmodifiers) but + * none worked for me. + */ +%typemap(javabody) OSRSpatialReferenceShadow, OSRCoordinateTransformationShadow %{ + private long swigCPtr; + protected boolean swigCMemOwn; + + public $javaclassname(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + public static long getCPtr($javaclassname obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +%} + diff --git a/Utilities/GDAL/swig/include/java/typemaps_java.i b/Utilities/GDAL/swig/include/java/typemaps_java.i new file mode 100644 index 0000000000..713d0b622c --- /dev/null +++ b/Utilities/GDAL/swig/include/java/typemaps_java.i @@ -0,0 +1,682 @@ +/****************************************************************************** + * $Id: typemaps_java.i,v 1.2 2006/02/16 17:21:12 collinsb Exp $ + * + * Name: typemaps_java.i + * Project: GDAL SWIG Interface + * Purpose: Typemaps for Java bindings + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: typemaps_java.i,v $ + * Revision 1.2 2006/02/16 17:21:12 collinsb + * Updates to Java bindings to keep the code from halting execution if the native libraries cannot be found. + * + * Revision 1.1 2006/02/02 20:56:07 collinsb + * Added Java specific typemap code + * + * +*/ + +%include "arrays_java.i"; +%include "typemaps.i" + + +/* JAVA TYPEMAPS */ + + +%typemap(in) (double *val, int*hasval) ( double tmpval, int tmphasval ) { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + $1 = &tmpval; + $2 = &tmphasval; + if(jenv->GetArrayLength($input) < 1) { + return $null; + } +} +%typemap(argout) (double *val, int*hasval) { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*$2) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval$argnum); + jenv->SetObjectArrayElement($input, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement($input, (jsize)0, 0); + } +} + +%typemap(jni) (double *val, int*hasval) "jobjectArray" +%typemap(jtype) (double *val, int*hasval) "Double[]" +%typemap(jstype) (double *val, int*hasval) "Double[]" +%typemap(javain) (double *val, int*hasval) "$javainput" +%typemap(javaout) (double *val, int*hasval) { + return $jnicall; + } + + + +%typemap(in) (GDALColorEntry *) (GDALColorEntry tmp) { + /* %typemap(in) (GDALColorEntry *) (GDALColorEntry tmp) */ + $1 = NULL; + float *colorptr = 0; + const jclass Color = jenv->FindClass("java/awt/Color"); + const jmethodID colors = jenv->GetMethodID(Color, "getRGBComponents", + "([F)[F"); + + jfloatArray colorArr = jenv->NewFloatArray(4); + colorArr = (jfloatArray)jenv->CallObjectMethod($input, colors, colorArr); + + colorptr = (float *)jenv->GetFloatArrayElements(colorArr, 0); + tmp.c1 = (short)(colorptr[0] * 255); + tmp.c2 = (short)(colorptr[1] * 255); + tmp.c3 = (short)(colorptr[2] * 255); + tmp.c4 = (short)(colorptr[3] * 255); + /*printf( " %d, %d, %d, %d\n", + tmp.c1, tmp.c2, tmp.c3, tmp.c4 );*/ + $1 = &tmp; +} + +%typemap(out) (GDALColorEntry *) { + /* %typemap(out) (GDALColorEntry *) */ + const jclass Color = jenv->FindClass("java/awt/Color"); + const jmethodID ccon = jenv->GetMethodID(Color, "<init>", + "(IIII)V"); + $result = jenv->NewObject(Color, ccon, $1->c1, $1->c2, $1->c3, $1->c4); +} + +%typemap(jni) (GDALColorEntry *) "jobject" +%typemap(jtype) (GDALColorEntry *) "java.awt.Color" +%typemap(jstype) (GDALColorEntry *) "java.awt.Color" +%typemap(javain) (GDALColorEntry *) "$javainput" +%typemap(javaout) (GDALColorEntry *) { + return $jnicall; + } + + + + +/* + * Typemap argout of GDAL_GCP* used in Dataset::GetGCPs( ) + */ +%typemap(in, numinputs=1) (int *nGCPs, GDAL_GCP const **pGCPs ) (int nGCPs=0, GDAL_GCP *pGCPs=0 ) +{ + /* %typemap(in,numinputs=1) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + $1 = &nGCPs; + $2 = &pGCPs; +} +%typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) +{ + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + const jclass GCPClass = jenv->FindClass("org/gdal/gdal/GCP"); + const jclass vectorClass = jenv->FindClass("java/util/Vector"); + const jmethodID add = jenv->GetMethodID(vectorClass, "add", "(Ljava/lang/Object;)Z"); + const jmethodID GCPcon = jenv->GetMethodID(GCPClass, "<init>", + "(DDDDDLjava/lang/String;Ljava/lang/String;)V"); + + for( int i = 0; i < *$1; i++ ) { + jobject GCPobj = jenv->NewObject(GCPClass, GCPcon, + (*$2)[i].dfGCPX, + (*$2)[i].dfGCPY, + (*$2)[i].dfGCPZ, + (*$2)[i].dfGCPPixel, + (*$2)[i].dfGCPLine, + (*$2)[i].pszInfo, + (*$2)[i].pszId ); + + jenv->CallBooleanMethod($input, add, GCPobj); + } + //$result = $input; +} + +%typemap(jni) (int *nGCPs, GDAL_GCP const **pGCPs ) "jobject" +%typemap(jtype) (int *nGCPs, GDAL_GCP const **pGCPs ) "java.util.Vector" +%typemap(jstype) (int *nGCPs, GDAL_GCP const **pGCPs ) "java.util.Vector" +%typemap(javain) (int *nGCPs, GDAL_GCP const **pGCPs ) "$javainput" +%typemap(javaout) (int *nGCPs, GDAL_GCP const **pGCPs ) { + return $jnicall; + } + + + + + +%typemap(in) (int *nLen, char **pBuf ) ( int nLen, char *pBuf ) +{ + /* %typemap(in) (int *nLen, char **pBuf ) */ + $1 = &nLen; + $2 = &pBuf; +} + +%typemap(argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + /* make sure that the passed array is at lease length 1 */ + if(jenv->GetArrayLength($input) >= 1) { + jcharArray charArray = jenv->NewCharArray(nLen$argnum); + jenv->SetCharArrayRegion(charArray, (jsize)0, (jsize)nLen$argnum, (jchar*)pBuf$argnum); + jenv->SetObjectArrayElement($input,0,charArray); + } +} + +%typemap(freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( $1 ) { + free( *$2 ); + } +} + +%typemap(jni) (int *nLen, char **pBuf ) "jobjectArray" +%typemap(jtype) (int *nLen, char **pBuf ) "char[][]" +%typemap(jstype) (int *nLen, char **pBuf ) "char[][]" +%typemap(javain) (int *nLen, char **pBuf ) "$javainput" +%typemap(javaout) (int *nLen, char **pBuf ) { + return $jnicall; + } + + +%fragment("OGRErrMessages","header") %{ +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error %d: None"; + case 1: + return "OGR Error %d: Not enough data"; + case 2: + return "OGR Error %d: Unsupported geometry type"; + case 3: + return "OGR Error %d: Unsupported operation"; + case 4: + return "OGR Error %d: Corrupt data"; + case 5: + return "OGR Error %d: General Error"; + case 6: + return "OGR Error %d: Unsupported SRS"; + default: + return "OGR Error %d: Unknown"; + } +} +%} + +%typemap(in) (int nLen, char *pBuf ) (jboolean isCopy) +{ + /* %typemap(in) (int nLen, char *pBuf ) */ + $1 = jenv->GetArrayLength($input); + $2 = (char *)jenv->GetCharArrayElements($input, &isCopy); +} + +%typemap(argout) (int nLen, char *pBuf ) +{ + /* %typemap(argout) (int nLen, char *pBuf ) */ +} + +%typemap(freearg) (int nLen, char *pBuf ) +{ + /* %typemap(freearg) (int nLen, char *pBuf ) */ + /* This calls JNI_ABORT, so any modifications will not be passed back + into the Java caller + */ + if(isCopy$argnum == JNI_TRUE) { + jenv->ReleaseCharArrayElements($input, (jchar *)$2, 0); + } +} + +%typemap(jni) (int nLen, char *pBuf ) "jcharArray" +%typemap(jtype) (int nLen, char *pBuf ) "char[]" +%typemap(jstype) (int nLen, char *pBuf ) "char[]" +%typemap(javain) (int nLen, char *pBuf ) "$javainput" +%typemap(javaout) (int nLen, char *pBuf ) { + return $jnicall; + } + + +%typemap(in) (tostring argin) +{ + /* %typemap(in) (tostring argin) */ + $1 = (char *)jenv->GetStringUTFChars($input, 0); +} +%typemap(freearg) (tostring argin) +{ + /* %typemap(in) (tostring argin) */ + jenv->ReleaseStringUTFChars($input, (char*)$1); +} + +%typemap(jni) (tostring argin) "jstring" +%typemap(jtype) (tostring argin) "String" +%typemap(jstype) (tostring argin) "String" +%typemap(javain) (tostring argin) "$javainput" +%typemap(javaout) (tostring argin) { + return $jnicall; + } + + +%typemap(in) (char **ignorechange) (char *val) +{ + /* %typemap(in) (char **ignorechange) */ + val = (char *)jenv->GetStringUTFChars($input, 0); + $1 = &val; +} +%typemap(freearg) (char **ignorechange) +{ + /* %typemap(freearg) (char **ignorechange) */ + jenv->ReleaseStringUTFChars($input, val$argnum); +} + +%typemap(jni) (char **ignorechange) "jstring" +%typemap(jtype) (char **ignorechange) "String" +%typemap(jstype) (char **ignorechange) "String" +%typemap(javain) (char **ignorechange) "$javainput" +%typemap(javaout) (char **ignorechange) { + return $jnicall; + } + + +%typemap(out,fragment="OGRErrMessages") OGRErr +{ + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return $null; + } + $result = (jint)result; +} +%typemap(ret) OGRErr +{ + /* %typemap(ret) OGRErr */ + +} + + +/* GDAL Typemaps */ + +%typemap(out) IF_ERR_RETURN_NONE +{ + /* %typemap(out) IF_ERR_RETURN_NONE */ + $result = 0; +} +%typemap(ret) IF_ERR_RETURN_NONE +{ + /* %typemap(ret) IF_ERR_RETURN_NONE */ +} +%typemap(out) IF_FALSE_RETURN_NONE +{ + /* %typemap(out) IF_FALSE_RETURN_NONE */ + $result = 0; +} +%typemap(ret) IF_FALSE_RETURN_NONE +{ + /* %typemap(ret) IF_FALSE_RETURN_NONE */ +} + +/*************************************************** + * + * Java typemaps for (int nList, int* pList) + * + ***************************************************/ +%typemap(in) (int nList, int* pList) +{ + /* %typemap(in) (int nList, int* pList) */ + /* check if is List */ + $1 = jenv->GetArrayLength($input); + $2 = (int *)jenv->GetIntArrayElements($input, NULL); +} + +%typemap(argout) (int nList, int* pList) +{ + /* %typemap(argout) (int nList, int* pList) */ +} + +%typemap(freearg) (int nList, int* pList) +{ + /* %typemap(freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} + +%typemap(jni) (int nList, int* pList) "jintArray" +%typemap(jtype) (int nList, int* pList) "int[]" +%typemap(jstype) (int nList, int* pList) "int[]" +%typemap(javain) (int nLen, int *pList ) "$javainput" +%typemap(javaout) (int nLen, int *pList ) { + return $jnicall; + } + + + +%typemap(in) char **dict +{ + /* %typemap(in) char **dict */ + /* Convert the Hashtable to a char array */ + $1 = NULL; + if($input != 0) { + const jclass hashtable = jenv->FindClass("java/util/Hashtable"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID get = jenv->GetMethodID(hashtable, "get", + "(Ljava/lang/Object;)Ljava/lang/Object;"); + const jmethodID keys = jenv->GetMethodID(hashtable, "keys", + "()Ljava/lang/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "getNextElement", "()Ljava/lang/Object;"); + for (jobject keyset = jenv->CallObjectMethod($input, keys); + jenv->CallBooleanMethod(keyset, hasMoreElements) == JNI_TRUE;) { + jstring key = (jstring)jenv->CallObjectMethod(keyset, getNextElement); + jstring value = (jstring)jenv->CallObjectMethod($input, get, key); + const char *keyptr = jenv->GetStringUTFChars(key, 0); + const char *valptr = jenv->GetStringUTFChars(value, 0); + $1 = CSLAddNameValue($1, keyptr, valptr); + jenv->ReleaseStringUTFChars(key, keyptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } +} + +%typemap(out) char **dict +{ + /* %typemap(out) char ** -> to hash */ + /* Convert a char array to a Hashtable */ + char **stringarray = $1; + const jclass hashtable = jenv->FindClass("java/util/Hashtable"); + const jmethodID constructor = jenv->GetMethodID(hashtable, "<init>", "()V"); + const jmethodID put = jenv->GetMethodID(hashtable, "put", + "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + $result = jenv->NewObject(hashtable, constructor); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + /*printf("working on pair: %s\n", *stringarray);*/ + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + jstring name = jenv->NewStringUTF(keyptr); + jstring value = jenv->NewStringUTF(valptr); + jenv->CallObjectMethod($result, put, name, value); + CPLFree( keyptr ); + } + stringarray++; + } + } +} + +%typemap(freearg) char **dict +{ + /* %typemap(freearg) char **dict */ + CSLDestroy( $1 ); +} + +%typemap(jni) (char **dict) "jobject" +%typemap(jtype) (char **dict) "java.util.Hashtable" +%typemap(jstype) (char **dict) "java.util.Hashtable" +%typemap(javain) (char **dict) "$javainput" +%typemap(javaout) (char **dict) { + return $jnicall; + } + + + +/* + * Typemap maps char** arguments from a Vector + */ +%typemap(in) char **options +{ + /* %typemap(in) char **options */ + $1 = NULL; + if($input != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return $null; + } + for (jobject keys = jenv->CallObjectMethod($input, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + $1 = CSLAddString($1, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } +} +%typemap(freearg) char **options +{ + /* %typemap(freearg) char **options */ + CSLDestroy( $1 ); +} +%typemap(out) char **options +{ + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = $1; + const jclass vector = jenv->FindClass("java/util/Vector"); + const jmethodID constructor = jenv->GetMethodID(vector, "<init>", "()V"); + const jmethodID add = jenv->GetMethodID(vector, "add", "(Ljava/lang/Object;)Z"); + + $result = jenv->NewObject(vector, constructor); + if ( stringarray != NULL ) { + while(*stringarray != NULL) { + /*printf("working on string %s\n", *stringarray);*/ + jstring value = (jstring)jenv->NewStringUTF(*stringarray); + jenv->CallBooleanMethod($result, add, value); + stringarray++; + } + } +} + +%typemap(jni) (char **options) "jobject" +%typemap(jtype) (char **options) "java.util.Vector" +%typemap(jstype) (char **options) "java.util.Vector" +%typemap(javain) (char **options) "$javainput" +%typemap(javaout) (char **options) { + return $jnicall; + } + + + +%define OPTIONAL_POD(type,argstring) +%typemap(in) (type *optional_##type) +{ + /* %typemap(in) (type *optional_##type) */ + $1 = ($1_type)$input; +} +%typemap(argout) (type *optional_##type) +{ + /* %typemap(in) (type *optional_##type) */ +} +%typemap(typecheck,precedence=0) (type *optional_##type) +{ + /* %typemap(typecheck,precedence=0) (type *optionalInt) */ +} + +%typemap(jni) (type *optional_##type) "jintArray" +%typemap(jtype) (type *optional_##type) "int[]" +%typemap(jstype) (type *optional_##type) "int[]" +%typemap(javain) (type *optional_##type) "$javainput" +%typemap(javaout) (type *optional_##type) { + return $jnicall; + } +%enddef + +OPTIONAL_POD(int,i); + + + +/* + * Typemap for char **argout. + */ +%typemap(in) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in) (char **argout) */ + $1 = &argout; +} + +%typemap(argout) (char **argout) +{ + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength($input) >= 1) { + temp_string = jenv->NewStringUTF(argout$argnum); + jenv->SetObjectArrayElement($input, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } +} + +%typemap(freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + if($1) { + free((void *)argout$argnum); + } +} + +%typemap(jni) (char **argout) "jobjectArray" +%typemap(jtype) (char **argout) "String[]" +%typemap(jstype) (char **argout) "String[]" +%typemap(javain) (char **argout) "$javainput" +%typemap(javaout) (char **argout) { + return $jnicall; + } + + + + + +%typemap(in) (double *argout[ANY]) (double *argout[$dim0]) +{ + /* %typemap(in) (double *argout[ANY]) */ + $1 = argout; +} + +%typemap(argout) (double *argout[ANY]) +{ + /* %typemap(argout) (double *argout[ANY]) */ + jenv->SetDoubleArrayRegion($input, (jsize)0, (jsize)$dim0, $1[0]); +} + +%typemap(freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree($1); +} + +%typemap(jni) (double *argout[ANY]) "jdoubleArray" +%typemap(jtype) (double *argout[ANY]) "double[]" +%typemap(jstype) (double *argout[ANY]) "double[]" +%typemap(javain) (double *argout[ANY]) "$javainput" +%typemap(javaout) (double *argout[ANY]) { + return $jnicall; + } + + + +%typemap(in) (double argin[ANY]) (jboolean isCopy) +{ + /* %typemap(in) (double argin[ANY]) */ + $1 = (double *)jenv->GetDoubleArrayElements($input, &isCopy); +} + +%typemap(argout) (double argin[ANY]) +{ + /* %typemap(argout) (double argin[ANY]) */ +} + +%typemap(freearg) (double argin[ANY]) +{ + /* %typemap(in) (double argin[ANY]) */ + if(isCopy$argnum == JNI_TRUE) { + jenv->ReleaseDoubleArrayElements($input, (jdouble *)$1, 0); + } +} + +%typemap(jni) (double argin[ANY]) "jdoubleArray" +%typemap(jtype) (double argin[ANY]) "double[]" +%typemap(jstype) (double argin[ANY]) "double[]" +%typemap(javain) (double argin[ANY]) "$javainput" +%typemap(javaout) (double argin[ANY]) { + return $jnicall; + } + + +/* This tells SWIG to treat char ** as a special case when used as a parameter + in a function call */ +%typemap(in) char ** (jint size) { + /* %typemap(in) char ** (jint size) */ + int i = 0; + size = jenv->GetArrayLength($input); + $1 = (char **) malloc((size+1)*sizeof(char *)); + /* make a copy of each string */ + for (i = 0; i<size; i++) { + jstring j_string = (jstring)jenv->GetObjectArrayElement($input, i); + const char * c_string = jenv->GetStringUTFChars(j_string, 0); + $1[i] = (char *)malloc(strlen((c_string)+1)*sizeof(const char *)); + strcpy($1[i], c_string); + jenv->ReleaseStringUTFChars(j_string, c_string); + jenv->DeleteLocalRef(j_string); + } + $1[i] = 0; +} + +/* This cleans up the memory we malloc'd before the function call */ +%typemap(freearg) char ** { + /* %typemap(freearg) char ** */ + int i; + for (i=0; i<size$argnum-1; i++) + free($1[i]); + free($1); +} + +/* This allows a C function to return a char ** as a Java String array */ +%typemap(out) char ** { + /* %typemap(out) char ** */ + int i; + int len=0; + jstring temp_string; + const jclass clazz = jenv->FindClass("java/lang/String"); + + while ($1[len]) len++; + jresult = jenv->NewObjectArray(len, clazz, NULL); + /* exception checking omitted */ + + for (i=0; i<len; i++) { + temp_string = jenv->NewStringUTF(*result++); + jenv->SetObjectArrayElement(jresult, i, temp_string); + jenv->DeleteLocalRef(temp_string); + } +} + +/* These 3 typemaps tell SWIG what JNI and Java types to use */ +%typemap(jni) char ** "jobjectArray" +%typemap(jtype) char ** "String[]" +%typemap(jstype) char ** "String[]" +%typemap(javain) char ** "$javainput" +%typemap(javaout) char ** { + return $jnicall; + } + + + + +%typemap(in) void * { + /* %typemap(in) void * */ + $1 = jenv->GetDirectBufferAddress($input); +} + +/* These 3 typemaps tell SWIG what JNI and Java types to use */ +%typemap(jni) void * "jobject" +%typemap(jtype) void * "java.nio.ByteBuffer" +%typemap(jstype) void * "java.nio.ByteBuffer" +%typemap(javain) void * "$javainput" +%typemap(javaout) void * { + return $jnicall; + } + diff --git a/Utilities/GDAL/swig/include/ogr.i b/Utilities/GDAL/swig/include/ogr.i new file mode 100644 index 0000000000..50fa027738 --- /dev/null +++ b/Utilities/GDAL/swig/include/ogr.i @@ -0,0 +1,1319 @@ +/****************************************************************************** + * $Id: ogr.i,v 1.55 2006/04/11 12:48:52 ajolma Exp $ + * + * Name: ogr.i + * Project: GDAL Python Interface + * Purpose: OGR Core SWIG Interface declarations. + * Author: Howard Butler, hobu@iastate.edu + * + + * + * $Log: ogr.i,v $ + * Revision 1.55 2006/04/11 12:48:52 ajolma + * swig 1.3.29 _does_ have DISOWN for Perl + * + * Revision 1.54 2006/04/06 20:45:47 ajolma + * + * swig/Perl does not use *DISOWN, so I added another solution + * + * Revision 1.53 2006/04/02 18:34:33 fwarmerdam + * Added OFTTime and OFTDateTime. + * + * Revision 1.52 2006/02/15 04:19:51 fwarmerdam + * Added OFTDate. + * + * Revision 1.51 2006/02/02 21:09:24 collinsb + * Corrected wrong Java typemap filename + * + * Revision 1.50 2006/02/02 20:52:40 collinsb + * Added SWIG JAVA bindings + * + * Revision 1.49 2005/10/17 14:38:16 hobu + * Implemented a poor excuse for a GetDriver method on OGRDataSourceShadow + * + * Revision 1.48 2005/10/11 14:47:36 kruland + * Removed all the manual throws and changed to return OGRErr where appropriate. + * There are 4 methods which have had serious alterations: + * Layer.GetExtent() was changed to OGRErr GetExtent( double argout[4], int = 1); + * Geometry.ExportToWkt() was changed to OGRErr ExportToWkt( char **argout ); + * CreateGeometryFromWkb() and CreateGeometryFromWkt will return a NULL + * geometry object is the construction fails. This will need to be handled + * differently in a subsequent revision. + * + * Revision 1.47 2005/10/11 14:10:57 kruland + * Feature.SetGeomerty() should not throw but should return the OGRErr. + * + * Revision 1.46 2005/10/03 20:09:58 cfis + * Changed various methods to return bool instead of int. These changes make the methods more natural to work with in scripting languages. + * + * Revision 1.45 2005/09/26 05:02:13 cfis + * Added comments pointing out where parent objects are giving out references to child objects. + * + * Revision 1.44 2005/09/21 15:33:02 kruland + * - Added DISOWN to ReleaseResultSet + * - Added %newobject to GetSpatialFilter and GetOpenDS + * - Added kwargs feature to Open and OpenShared - they must have been + * dropped during a previous commit. + * + * Revision 1.43 2005/09/21 02:21:56 fwarmerdam + * added comment blocks + * + * Revision 1.42 2005/09/19 02:53:23 cfis + * The two versions of the method OGRFeatureShadow::GetFieldDefnRef were both marked with the %newobject feature. + * + * However, this is wrong. Neither return a newobject so this has been removed. + * + * Revision 1.41 2005/09/14 21:28:35 kruland + * OGRFeatureDefn::GetFieldDefn() returns an internal pointer, not a newobject. + * + * Revision 1.40 2005/09/13 16:10:00 kruland + * Import ogr_perl.i for SWIGPERL. + * Moved GetFieldTypeName from Geometry to FieldDefn. + * + * Revision 1.39 2005/09/07 01:12:49 kruland + * Have ogr.i include osr.i in order to have access to types defined in the osr + * module. + * Removed the typedef for OGRErr. The %include osr.i caused it to be double + * defined and caused warnings from swig. + * Fixed the %constant declarations for strings. + * + * Revision 1.38 2005/09/06 01:49:07 kruland + * Declare %feature("compactdefaultargs") so all bindings use it. + * Import gdal_typemaps.i if no other language specific file used. + * Added Geometry::GetFieldTypeName() binding. + * Moved Open, OpenShared, GetDriver, and GetDriverByName from python + * language file. + * + * Revision 1.37 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.36 2005/08/25 21:02:30 cfis + * Added check for SWIGRuby when defining open,openshared,GetDriverByName and GetDriver methods. + * + * Also moved all the renames into a preprocessor macro block because they interfere with the Ruby specific %rename directives. + * + * Revision 1.35 2005/08/22 19:00:50 kruland + * Attempt to make ogr library behave well using normal script memory + * management. + * - Implemented public destructor for DataSource, Feature, FeatureDefn, FieldDefn, + * Geometry + * - Stubbed Reference() and Dereference() for all classes as "pass" + * in python for backward compatibility + * - Implemented Destroy() and Release() for all classes in python + * as calls to destructor along with disowning the C ptr so the destructor + * is not called again. These methods are only for backward compatibility in + * python bindings. + * - Added %newobject to Layer.GetFeature() and Layer.GetNextFeature() + * - Use DISOWN typemap on Feature.SetGeometryDirectly() and + * Geometry.AddGeometryDirectly() because they assume ownership of the + * argument. + * - Removed %newobject from Geometry.GetGeometryRef(), GetOpenDS() because they + * return internal references. + * + * Revision 1.34 2005/08/10 16:49:43 hobu + * syntactic sugar to support the __iter__ protocol on Layer + * for Python. This allows us to (slowly) do for feature in layer and + * have it call GetNextFeature for us until we are done. + * + * Revision 1.33 2005/08/10 15:44:57 hobu + * Added some convenience properties for FieldDefn: + * width, type, precision, name, justify as shortcuts for the + * setters/getters + * + * Revision 1.32 2005/08/09 17:40:09 kruland + * Added support for ruby. + * + * Revision 1.31 2005/08/09 14:38:27 kruland + * Fixed the FeatureDefn constructor -- their decls don't have a return value. + * + * Revision 1.30 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.29 2005/08/05 20:32:11 kruland + * Pass bytecount into OGR_G_CreateFromWkb. + * + * Revision 1.28 2005/08/05 15:49:27 kruland + * Added __str__ to Geometry class python bindings. + * + * Revision 1.27 2005/06/22 18:42:33 kruland + * Don't apply a typemap for returning OGRErr. + * + * Revision 1.26 2005/03/14 21:33:33 hobu + * rename method names that are common to both gdal and ogr + * for the C# only + * + * Revision 1.25 2005/03/10 17:13:57 hobu + * #ifdefs for csharp + * + * Revision 1.24 2005/02/24 17:20:47 hobu + * move constants to %constants so they are available to + * all languages + * + * Revision 1.23 2005/02/24 16:15:53 hobu + * ifdef'd the %pythoncode, conditionally rename some methods + * if they conflict with existing "object" methods in C#. + * + * Revision 1.22 2005/02/22 18:44:34 hobu + * and the one in the Datasource constructor + * + * Revision 1.21 2005/02/22 18:43:31 hobu + * yank out debug refcount increments + * + * Revision 1.20 2005/02/22 18:24:34 hobu + * apply the double_4 typemap for Layer.GetExtent + * + * Revision 1.19 2005/02/22 15:33:37 kruland + * Removed duplicate defns of SetField that I introduced in previous revision. + * Added %appy to SetField which will call str() on second arg. + * + * Revision 1.18 2005/02/22 02:04:33 kruland + * Corrected decl of FieldDefn constructor. + * Implemented first cut at Feature.SetField() -- needs to accept any for value. + * Added constructor for FeatureDefn. + * Make Geometry.GetEnvelope return a 4-tuple. + * Implemented Geometry.Centroid() + * + * Revision 1.17 2005/02/21 23:09:33 hobu + * Added all of the Geometry and FieldDefn classes/methods + * + * Revision 1.16 2005/02/21 21:27:31 kruland + * Added AddPoint, AddGeometryDirectly, Destroy to Geometry. + * Mucked with some more newobject directives. + * + * Revision 1.15 2005/02/21 20:48:11 kruland + * Intermediate commit. Changed internal typenames so they no longer use + * those defined in gdal/ogr library. Removed newobject from Dataset function + * which return layers since they are owned by the dataset. Moved the + * Geometry factory methods so they are visible to the Geometry object + * constructor. + * + * Revision 1.14 2005/02/21 18:56:54 kruland + * Fix usage of the Geometry class. The factory methods were confused by + * returning voids instead of void*s. + * Renamed the internal type to OGRGeometryShadow to prevent confusion. + * Properly implemented Geometry.ExportToWkb() using the buffer typemaps. + * + * Revision 1.13 2005/02/21 18:00:44 hobu + * Started in on Geometry + * + * Revision 1.12 2005/02/21 16:53:30 kruland + * Changed name of SpatialReference shadow type. + * + * Revision 1.11 2005/02/21 16:52:39 hobu + * GetFieldAs* methods that take in string or int input for Feature + * + * Revision 1.10 2005/02/18 23:47:11 hobu + * Feature and FeatureDefn + * except for the field handling methods on Feature + * + * Revision 1.9 2005/02/18 22:03:51 hobu + * Finished up Layer + * + * Revision 1.8 2005/02/18 20:41:19 hobu + * it compiles and it doesn't blow up. IMO this is a + * good stopping point :) + * + * Revision 1.7 2005/02/18 18:42:07 kruland + * Added %feature("autodoc"); + * + * Revision 1.6 2005/02/18 18:28:16 kruland + * Rename OGRSpatialReferenceH type to SpatialReference to make the ogr and + * osr modules compatible. + * + * Revision 1.5 2005/02/18 18:01:34 hobu + * Started working on the geometry constructors with a lot + * of help from Kevin + * + * Revision 1.4 2005/02/17 00:01:37 hobu + * quick start on the datasource/driver stuff + * + * Revision 1.3 2005/02/16 21:55:02 hobu + * started the OGRDriver class stuff. + * CopyDataSource, CreateDataSource, and + * DS Open + * + * Revision 1.2 2005/02/16 20:02:57 hobu + * added constants + * + * Revision 1.1 2005/02/16 19:47:03 hobu + * skeleton OGR interface + * + * + * + * nmake /f makefile.vc swig_python + *D:\cvs\gdal\gdalautotest>d:\Python\debug\Python-2.4\PCbuild\python_d.exe run_all.py ogr +*/ + +%include "exception.i" + +%module ogr + +%feature("compactdefaultargs"); +%feature("autodoc"); + +typedef int OGRwkbByteOrder; +typedef int OGRwkbGeometryType; +typedef int OGRFieldType; +typedef int OGRJustification; + +%{ +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; +%} + +%constant wkb25Bit = wkb25DBit; +%constant wkbUnknown = 0; + +%constant wkbPoint = 1; +%constant wkbLineString = 2; +%constant wkbPolygon = 3; +%constant wkbMultiPoint = 4; +%constant wkbMultiLineString = 5; +%constant wkbMultiPolygon = 6; +%constant wkbGeometryCollection = 7; +%constant wkbNone = 100; +%constant wkbLinearRing = 101; +%constant wkbPoint25D = wkbPoint + wkb25DBit; +%constant wkbLineString25D = wkbLineString + wkb25DBit; +%constant wkbPolygon25D = wkbPolygon + wkb25DBit; +%constant wkbMultiPoint25D = wkbMultiPoint + wkb25DBit; +%constant wkbMultiLineString25D = wkbMultiLineString + wkb25DBit; +%constant wkbMultiPolygon25D = wkbMultiPolygon + wkb25DBit; +%constant wkbGeometryCollection25D = wkbGeometryCollection + wkb25DBit; + +%constant OFTInteger = 0; +%constant OFTIntegerList= 1; +%constant OFTReal = 2; +%constant OFTRealList = 3; +%constant OFTString = 4; +%constant OFTStringList = 5; +%constant OFTWideString = 6; +%constant OFTWideStringList = 7; +%constant OFTBinary = 8; +%constant OFTDate = 9; +%constant OFTTime = 10; +%constant OFTDateTime = 11; + +%constant OJUndefined = 0; +%constant OJLeft = 1; +%constant OJRight = 2; + +%constant wkbXDR = 0; +%constant wkbNDR = 1; + +%constant char *OLCRandomRead = "RandomRead"; +%constant char *OLCSequentialWrite = "SequentialWrite"; +%constant char *OLCRandomWrite = "RandomWrite"; +%constant char *OLCFastSpatialFilter = "FastSpatialFilter"; +%constant char *OLCFastFeatureCount = "FastFeatureCount"; +%constant char *OLCFastGetExtent = "FastGetExtent"; +%constant char *OLCCreateField = "CreateField"; +%constant char *OLCTransactions = "Transactions"; +%constant char *OLCDeleteFeature = "DeleteFeature"; +%constant char *OLCFastSetNextByIndex = "FastSetNextByIndex"; + +%constant char *ODsCCreateLayer = "CreateLayer"; +%constant char *ODsCDeleteLayer = "DeleteLayer"; + +%constant char *ODrCCreateDataSource = "CreateDataSource"; +%constant char *ODrCDeleteDataSource = "DeleteDataSource"; + +#if defined(SWIGPYTHON) +%include ogr_python.i +#elif defined(SWIGRUBY) +%include ogr_ruby.i +#elif defined(SWIGPHP4) +%include ogr_php.i +#elif defined(SWIGCSHARP) +%include ogr_csharp.i +#elif defined(SWIGPERL) +%include ogr_perl.i +#elif defined(SWIGJAVA) +%include ogr_java.i +#else +%include gdal_typemaps.i +#endif + +/* + * We need to import osr.i here so the ogr module knows about the + * wrapper for SpatialReference and CoordinateSystem from osr. + * These types are used in Geometry::Transform() among others. + * This was primarily a problem in the perl bindings because + * perl names things differently when using -proxy (default) argument + */ +%import osr.i + +/************************************************************************/ +/* OGRDriver */ +/************************************************************************/ + +%rename (Driver) OGRDriverShadow; + +class OGRDriverShadow { + OGRDriverShadow(); + ~OGRDriverShadow(); +public: +%extend { + +%immutable; + char const *name; +%mutable; + +%newobject CreateDataSource; +%feature( "kwargs" ) CreateDataSource; + OGRDataSourceShadow *CreateDataSource( const char *name, + char **options = 0 ) { + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } + +%newobject CopyDataSource; +%feature( "kwargs" ) CopyDataSource; + OGRDataSourceShadow *CopyDataSource( OGRDataSourceShadow* copy_ds, + const char* name, + char **options = 0 ) { + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } + +%newobject Open; +%feature( "kwargs" ) Open; + OGRDataSourceShadow *Open( const char* name, + int update=0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } + + int DeleteDataSource( const char *name ) { + return OGR_Dr_DeleteDataSource( self, name ); + } + + bool TestCapability (const char *cap) { + return OGR_Dr_TestCapability(self, cap); + } + + const char * GetName() { + return OGR_Dr_GetName( self ); + } + + +} /* %extend */ +}; /* class OGRDriverShadow */ + + +/************************************************************************/ +/* OGRDataSource */ +/************************************************************************/ + + +%rename (DataSource) OGRDataSourceShadow; + +class OGRDataSourceShadow { + OGRDataSourceShadow() { + } +public: +%extend { + +%immutable; + char const *name; +%mutable; + + ~OGRDataSourceShadow() { + OGRReleaseDataSource(self); + } + + int GetRefCount() { + return OGR_DS_GetRefCount(self); + } + + int GetSummaryRefCount() { + return OGR_DS_GetSummaryRefCount(self); + } + + int GetLayerCount() { + return OGR_DS_GetLayerCount(self); + } + + OGRDriverShadow * GetDriver() { + OGRDriverShadow* driver; + OGRDataSourceShadow* ds; + ds = (OGRDataSourceShadow*)OGROpen((const char *) OGR_DS_GetName(self),0,&driver); + OGRReleaseDataSource(ds); + return driver; + } + const char * GetName() { + return OGR_DS_GetName(self); + } + + OGRErr DeleteLayer(int index){ + return OGR_DS_DeleteLayer(self, index); + } + + /* Note that datasources own their layers */ + %feature( "kwargs" ) CreateLayer; + OGRLayerShadow *CreateLayer(const char* name, + OSRSpatialReferenceShadow* reference=NULL, + OGRwkbGeometryType geom_type=wkbUnknown, + char** options=0) { + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } + + %feature( "kwargs" ) CopyLayer; + OGRLayerShadow *CopyLayer(OGRLayerShadow *src_layer, + const char* new_name, + char** options=0) { + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } + + %feature( "kwargs" ) GetLayerByIndex; + OGRLayerShadow *GetLayerByIndex( int index=0) { + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayer(self, index); + return layer; + } + + OGRLayerShadow *GetLayerByName( const char* layer_name) { + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayerByName(self, layer_name); + return layer; + } + + bool TestCapability(const char * cap) { + return OGR_DS_TestCapability(self, cap); + } + + %newobject ExecuteSQL; + %feature( "kwargs" ) ExecuteSQL; + OGRLayerShadow *ExecuteSQL(const char* statement, + OGRGeometryShadow* geom=NULL, + const char* dialect="") { + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } + +%apply SWIGTYPE *DISOWN {OGRLayerShadow *layer}; + void ReleaseResultSet(OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +%clear OGRLayerShadow *layer; + +} /* %extend */ + + +}; /* class OGRDataSourceShadow */ + +/************************************************************************/ +/* OGRLayer */ +/************************************************************************/ + +%rename (Layer) OGRLayerShadow; +class OGRLayerShadow { + OGRLayerShadow(); + ~OGRLayerShadow(); +public: +%extend { + + int GetRefCount() { + return OGR_L_GetRefCount(self); + } + + void SetSpatialFilter(OGRGeometryShadow* filter) { + OGR_L_SetSpatialFilter (self, filter); + } + + void SetSpatialFilterRect( double minx, double miny, + double maxx, double maxy) { + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } + + OGRGeometryShadow *GetSpatialFilter() { + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } + + OGRErr SetAttributeFilter(char* filter_string) { + return OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + } + + void ResetReading() { + OGR_L_ResetReading(self); + } + + const char * GetName() { + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } + +%newobject GetFeature; + OGRFeatureShadow *GetFeature(long fid) { + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } + +%newobject GetNextFeature; + OGRFeatureShadow *GetNextFeature() { + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } + + OGRErr SetNextByIndex(long new_index) { + return OGR_L_SetNextByIndex(self, new_index); + } + + OGRErr SetFeature(OGRFeatureShadow *feature) { + return OGR_L_SetFeature(self, feature); + } + + + OGRErr CreateFeature(OGRFeatureShadow *feature) { + return OGR_L_CreateFeature(self, feature); + } + + OGRErr DeleteFeature(long fid) { + return OGR_L_DeleteFeature(self, fid); + } + + OGRErr SyncToDisk() { + return OGR_L_SyncToDisk(self); + } + + OGRFeatureDefnShadow *GetLayerDefn() { + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } + + %feature( "kwargs" ) GetFeatureCount; + int GetFeatureCount(int force=1) { + return OGR_L_GetFeatureCount(self, force); + } + + %feature( "kwargs" ) GetExtent; + OGRErr GetExtent(double argout[4], int force=1) { + return OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + } + + bool TestCapability(const char* cap) { + return OGR_L_TestCapability(self, cap); + } + + %feature( "kwargs" ) CreateField; + OGRErr CreateField(OGRFieldDefnShadow* field_def, int approx_ok = 1) { + return OGR_L_CreateField(self, field_def, approx_ok); + } + + OGRErr StartTransaction() { + return OGR_L_StartTransaction(self); + } + + OGRErr CommitTransaction() { + return OGR_L_CommitTransaction(self); + } + + OGRErr RollbackTransaction() { + return OGR_L_RollbackTransaction(self); + } + + OSRSpatialReferenceShadow *GetSpatialRef() { + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } + + GIntBig GetFeatureRead() { + return OGR_L_GetFeaturesRead(self); + } + +} /* %extend */ + + +}; /* class OGRLayerShadow */ + +/************************************************************************/ +/* OGRFeature */ +/************************************************************************/ + +%rename (Feature) OGRFeatureShadow; +class OGRFeatureShadow { + OGRFeatureShadow(); +public: +%extend { + + ~OGRFeatureShadow() { + OGR_F_Destroy(self); + } + + %feature("kwargs") OGRFeatureShadow; + OGRFeatureShadow( OGRFeatureDefnShadow *feature_def = 0 ) { + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } + + OGRFeatureDefnShadow *GetDefnRef() { + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } + + OGRErr SetGeometry(OGRGeometryShadow* geom) { + return OGR_F_SetGeometry(self, geom); + } + +/* The feature takes over owernship of the geometry. */ +%apply SWIGTYPE *DISOWN {OGRGeometryShadow *geom}; + OGRErr SetGeometryDirectly(OGRGeometryShadow* geom) { + return OGR_F_SetGeometryDirectly(self, geom); + } +%clear OGRGeometryShadow *geom; + + /* Feature owns its geometry */ + OGRGeometryShadow *GetGeometryRef() { + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } + + %newobject Clone; + OGRFeatureShadow *Clone() { + return (OGRFeatureShadow*) OGR_F_Clone(self); + } + + bool Equal(OGRFeatureShadow *feature) { + return OGR_F_Equal(self, feature); + } + + int GetFieldCount() { + return OGR_F_GetFieldCount(self); + } + + /* ---- GetFieldDefnRef --------------------- */ + OGRFieldDefnShadow *GetFieldDefnRef(int id) { + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } + + OGRFieldDefnShadow *GetFieldDefnRef(const char* name) { + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } + /* ------------------------------------------- */ + + /* ---- GetFieldAsString --------------------- */ + + const char* GetFieldAsString(int id) { + return (const char *) OGR_F_GetFieldAsString(self, id); + } + + const char* GetFieldAsString(const char* name) { + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } + /* ------------------------------------------- */ + + /* ---- GetFieldAsInteger -------------------- */ + + int GetFieldAsInteger(int id) { + return OGR_F_GetFieldAsInteger(self, id); + } + + int GetFieldAsInteger(const char* name) { + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } + /* ------------------------------------------- */ + + /* ---- GetFieldAsDouble --------------------- */ + + double GetFieldAsDouble(int id) { + return OGR_F_GetFieldAsDouble(self, id); + } + + double GetFieldAsDouble(const char* name) { + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } + /* ------------------------------------------- */ + + + + /* ---- IsFieldSet --------------------------- */ + bool IsFieldSet(int id) { + return OGR_F_IsFieldSet(self, id); + } + + bool IsFieldSet(const char* name) { + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } + /* ------------------------------------------- */ + + int GetFieldIndex(const char* name) { + return OGR_F_GetFieldIndex(self, name); + } + + int GetFID() { + return OGR_F_GetFID(self); + } + + OGRErr SetFID(int fid) { + return OGR_F_SetFID(self, fid); + } + + void DumpReadable() { + OGR_F_DumpReadable(self, NULL); + } + + void UnsetField(int id) { + OGR_F_UnsetField(self, id); + } + + + void UnsetField(const char* name) { + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } + + /* ---- SetField ----------------------------- */ + + %apply ( tostring argin ) { (const char* value) }; + void SetField(int id, const char* value) { + OGR_F_SetFieldString(self, id, value); + } + + void SetField(const char* name, const char* value) { + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } + %clear (const char* value ); + + /* ------------------------------------------- */ + + %feature("kwargs") SetFrom; + OGRErr SetFrom(OGRFeatureShadow *other, int forgiving=1) { + return OGR_F_SetFrom(self, other, forgiving); + } + + const char *GetStyleString() { + return (const char*) OGR_F_GetStyleString(self); + } + + void SetStyleString(const char* the_string) { + OGR_F_SetStyleString(self, the_string); + } + + /* ---- GetFieldType ------------------------- */ + OGRFieldType GetFieldType(int id) { + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } + + OGRFieldType GetFieldType(const char* name, const char* value) { + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } + /* ------------------------------------------- */ + +} /* %extend */ + + +}; /* class OGRFeatureShadow */ + +/************************************************************************/ +/* OGRFeatureDefn */ +/************************************************************************/ + +%rename (FeatureDefn) OGRFeatureDefnShadow; +class OGRFeatureDefnShadow { + OGRFeatureDefnShadow(); +public: +%extend { + + ~OGRFeatureDefnShadow() { + OGR_FD_Destroy(self); + } + + %feature("kwargs") OGRFeatureDefnShadow; + OGRFeatureDefnShadow(const char* name=NULL) { + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } + + const char* GetName(){ + return OGR_FD_GetName(self); + } + + int GetFieldCount(){ + return OGR_FD_GetFieldCount(self); + } + + /* FeatureDefns own their FieldDefns */ + OGRFieldDefnShadow* GetFieldDefn(int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } + + int GetFieldIndex(const char* name) { + return OGR_FD_GetFieldIndex(self, name); + } + + void AddFieldDefn(OGRFieldDefnShadow* defn) { + OGR_FD_AddFieldDefn(self, defn); + } + + OGRwkbGeometryType GetGeomType() { + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } + + void SetGeomType(OGRwkbGeometryType geom_type) { + OGR_FD_SetGeomType(self, geom_type); + } + + int GetReferenceCount(){ + return OGR_FD_GetReferenceCount(self); + } + +} /* %extend */ + + +}; /* class OGRFeatureDefnShadow */ + +/************************************************************************/ +/* OGRFieldDefn */ +/************************************************************************/ + +%rename (FieldDefn) OGRFieldDefnShadow; + +class OGRFieldDefnShadow { + OGRFieldDefnShadow(); +public: +%extend { + + ~OGRFieldDefnShadow() { + OGR_Fld_Destroy(self); + } + + %feature("kwargs") OGRFieldDefnShadow; + OGRFieldDefnShadow( const char* name="unnamed", + OGRFieldType field_type=OFTString) { + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } + + const char * GetName() { + return (const char *) OGR_Fld_GetNameRef(self); + } + + const char * GetNameRef() { + return (const char *) OGR_Fld_GetNameRef(self); + } + + void SetName( const char* name) { + OGR_Fld_SetName(self, name); + } + + OGRFieldType GetType() { + return OGR_Fld_GetType(self); + } + + void SetType(OGRFieldType type) { + OGR_Fld_SetType(self, type); + } + + OGRJustification GetJustify() { + return OGR_Fld_GetJustify(self); + } + + void SetJustify(OGRJustification justify) { + OGR_Fld_SetJustify(self, justify); + } + + int GetWidth () { + return OGR_Fld_GetWidth(self); + } + + void SetWidth (int width) { + OGR_Fld_SetWidth(self, width); + } + + int GetPrecision() { + return OGR_Fld_GetPrecision(self); + } + + void SetPrecision(int precision) { + OGR_Fld_SetPrecision(self, precision); + } + + const char * GetFieldTypeName(OGRFieldType type) { + return OGR_GetFieldTypeName(type); + } + +} /* %extend */ + + +}; /* class OGRFieldDefnShadow */ + + +/* -------------------------------------------------------------------- */ +/* Geometry factory methods. */ +/* -------------------------------------------------------------------- */ +%feature( "kwargs" ) CreateGeometryFromWkb; +%newobject CreateGeometryFromWkb; +%apply (int nLen, char *pBuf ) { (int len, char *bin_string)}; +%inline %{ + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + +%} +%clear (int len, char *bin_string); + +%feature( "kwargs" ) CreateGeometryFromWkt; +%apply (char **ignorechange) { (char **) }; +%newobject CreateGeometryFromWkt; +%inline %{ + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + +%} +%clear (char **); + +%newobject CreateGeometryFromGML; +%inline %{ + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + +%} + +/************************************************************************/ +/* OGRGeometry */ +/************************************************************************/ + +%rename (Geometry) OGRGeometryShadow; +class OGRGeometryShadow { + OGRGeometryShadow(); +public: +%extend { + + ~OGRGeometryShadow() { + OGR_G_DestroyGeometry( self ); + } + + %feature("kwargs") OGRGeometryShadow; + OGRGeometryShadow( OGRwkbGeometryType type = wkbUnknown, char *wkt = 0, int wkb= 0, char *wkb_buf = 0, char *gml = 0 ) { + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } + + OGRErr ExportToWkt( char** argout ) { + return OGR_G_ExportToWkt(self, argout); + } + + %feature("kwargs") ExportToWkb; + OGRErr ExportToWkb( int *nLen, char **pBuf, OGRwkbByteOrder byte_order=wkbXDR ) { + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } + + const char * ExportToGML() { + return (const char *) OGR_G_ExportToGML(self); + } + + %feature("kwargs") AddPoint; + void AddPoint(double x, double y, double z = 0) { + OGR_G_AddPoint( self, x, y, z ); + } + +/* The geometry now owns an inner geometry */ +%apply SWIGTYPE *DISOWN {OGRGeometryShadow* other}; + OGRErr AddGeometryDirectly( OGRGeometryShadow* other ) { + return OGR_G_AddGeometryDirectly( self, other ); + } +%clear OGRGeometryShadow* other; + + OGRErr AddGeometry( OGRGeometryShadow* other ) { + return OGR_G_AddGeometry( self, other ); + } + + %newobject Clone; + OGRGeometryShadow* Clone() { + return (OGRGeometryShadow*) OGR_G_Clone(self); + } + + OGRwkbGeometryType GetGeometryType() { + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } + + const char * GetGeometryName() { + return (const char *) OGR_G_GetGeometryName(self); + } + + double GetArea() { + return OGR_G_GetArea(self); + } + + int GetPointCount() { + return OGR_G_GetPointCount(self); + } + + %feature("kwargs") GetX; + double GetX(int point=0) { + return OGR_G_GetX(self, point); + } + + %feature("kwargs") GetY; + double GetY(int point=0) { + return OGR_G_GetY(self, point); + } + + %feature("kwargs") GetZ; + double GetZ(int point=0) { + return OGR_G_GetZ(self, point); + } + + int GetGeometryCount() { + return OGR_G_GetGeometryCount(self); + } + + %feature("kwargs") SetPoint; + void SetPoint(int point, double x, double y, double z=0) { + OGR_G_SetPoint(self, point, x, y, z); + } + + /* Geometries own their internal geometries */ + OGRGeometryShadow* GetGeometryRef(int geom) { + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } + + %newobject GetBoundary; + OGRGeometryShadow* GetBoundary() { + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } + + %newobject ConvexHull; + OGRGeometryShadow* ConvexHull() { + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } + + %newobject Buffer; + %feature("kwargs") Buffer; + OGRGeometryShadow* Buffer( double distance, int quadsecs=30 ) { + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } + + %newobject Intersection; + OGRGeometryShadow* Intersection( OGRGeometryShadow* other ) { + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } + + %newobject Union; + OGRGeometryShadow* Union( OGRGeometryShadow* other ) { + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } + + %newobject Difference; + OGRGeometryShadow* Difference( OGRGeometryShadow* other ) { + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } + + %newobject SymmetricDifference; + OGRGeometryShadow* SymmetricDifference( OGRGeometryShadow* other ) { + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } + + double Distance( OGRGeometryShadow* other) { + return OGR_G_Distance(self, other); + } + + void Empty () { + OGR_G_Empty(self); + } + + bool Intersect (OGRGeometryShadow* other) { + return OGR_G_Intersect(self, other); + } + + bool Equal (OGRGeometryShadow* other) { + return OGR_G_Equal(self, other); + } + + bool Disjoint(OGRGeometryShadow* other) { + return OGR_G_Disjoint(self, other); + } + + bool Touches (OGRGeometryShadow* other) { + return OGR_G_Touches(self, other); + } + + bool Crosses (OGRGeometryShadow* other) { + return OGR_G_Crosses(self, other); + } + + bool Within (OGRGeometryShadow* other) { + return OGR_G_Within(self, other); + } + + bool Contains (OGRGeometryShadow* other) { + return OGR_G_Contains(self, other); + } + + bool Overlaps (OGRGeometryShadow* other) { + return OGR_G_Overlaps(self, other); + } + + OGRErr TransformTo(OSRSpatialReferenceShadow* reference) { + return OGR_G_TransformTo(self, reference); + } + + OGRErr Transform(OSRCoordinateTransformationShadow* trans) { + return OGR_G_Transform(self, trans); + } + + OSRSpatialReferenceShadow* GetSpatialReference() { + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } + + void AssignSpatialReference(OSRSpatialReferenceShadow* reference) { + OGR_G_AssignSpatialReference(self, reference); + } + + void CloseRings() { + OGR_G_CloseRings(self); + } + + void FlattenTo2D() { + OGR_G_FlattenTo2D(self); + } + + void GetEnvelope(double argout[4]) { + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } + + %newobject Centroid; + OGRGeometryShadow* Centroid() { + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } + + int WkbSize() { + return OGR_G_WkbSize(self); + } + + int GetCoordinateDimension() { + return OGR_G_GetCoordinateDimension(self); + } + + int GetDimension() { + return OGR_G_GetDimension(self); + } + +} /* %extend */ + + +}; /* class OGRGeometryShadow */ + +/************************************************************************/ +/* Other misc functions. */ +/************************************************************************/ + +%{ +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} +%} + +int OGRGetDriverCount(); + +int OGRGetOpenDSCount(); + +OGRErr OGRSetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER); + +void OGRRegisterAll(); + +%inline %{ + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } +%} + +%newobject Open; +%feature( "kwargs" ) Open; +%inline %{ + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } +%} + +%newobject OpenShared; +%feature( "kwargs" ) OpenShared; +%inline %{ + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } +%} + +%inline %{ +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} +%} + diff --git a/Utilities/GDAL/swig/include/ogr_error_map.i b/Utilities/GDAL/swig/include/ogr_error_map.i new file mode 100644 index 0000000000..7ca2236e4c --- /dev/null +++ b/Utilities/GDAL/swig/include/ogr_error_map.i @@ -0,0 +1,47 @@ +/* + * $Id: ogr_error_map.i,v 1.2 2005/09/26 08:16:48 cfis Exp $ + * + * helper function to convert OGRError numbers into + * character strings. + * + * $Log: ogr_error_map.i,v $ + * Revision 1.2 2005/09/26 08:16:48 cfis + * Ruby does not seem to support the %fragment directive. + * + * Revision 1.1 2005/09/13 02:58:19 kruland + * Put the OGRErr to char * mapping in a file so multiple bindings can use it. + * + * + */ + +#ifdef SWIGRUBY +%header +#else +%fragment("OGRErrMessages","header") +#endif +%{ + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} +%} diff --git a/Utilities/GDAL/swig/include/osr.i b/Utilities/GDAL/swig/include/osr.i new file mode 100644 index 0000000000..be2516120d --- /dev/null +++ b/Utilities/GDAL/swig/include/osr.i @@ -0,0 +1,684 @@ +/****************************************************************************** + * $Id: osr.i,v 1.24 2006/02/02 21:09:24 collinsb Exp $ + * + * Name: osr.i + * Project: GDAL Python Interface + * Purpose: OSR Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: osr.i,v $ + * Revision 1.24 2006/02/02 21:09:24 collinsb + * Corrected wrong Java typemap filename + * + * Revision 1.23 2006/02/02 20:52:40 collinsb + * Added SWIG JAVA bindings + * + * Revision 1.22 2006/01/14 01:47:22 cfis + * Added private default constructors since SWIG 1.3.28 HEAD was incorrectly generating them. + * + * Revision 1.21 2005/09/06 01:43:06 kruland + * Include gdal_typemaps.i if no other file is specified. + * + * Revision 1.20 2005/09/02 21:42:42 kruland + * The compactdefaultargs feature should be turned on for all bindings not just + * python. + * + * Revision 1.19 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.18 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.17 2005/08/05 19:19:53 hobu + * OPTGetParameterInfo uses default as an argument. + * C# uses default as a keyword. + * C# wins. Rename the parameter name. + * + * Revision 1.16 2005/07/20 16:08:49 kruland + * Declare the double and char * consts correctly. And change all the decls + * to defer the the #defined values from the headers. + * + * Revision 1.15 2005/07/20 14:44:13 kruland + * Use correct name for OPTGetProjectionMethods(). + * + * Revision 1.14 2005/06/22 18:42:33 kruland + * Don't apply a typemap for returning OGRErr. + * + * Revision 1.13 2005/02/24 20:33:58 kruland + * Back to import gdal_typemaps.i to prevent confusion. + * + * Revision 1.12 2005/02/24 18:39:14 kruland + * Using the GetProjectionMethods() custom code from old interface for the + * python binding. Defined access to plain C-api for other bindings. + * Added GetWellKnownGeogCSAsWKT() global method. + * + * Revision 1.11 2005/02/24 17:53:37 kruland + * import the generic typemap.i file. + * + * Revision 1.10 2005/02/24 16:45:17 kruland + * Commented missing methods. + * Added first cut at a proxy for ProjectionMethods. + * + * Revision 1.9 2005/02/23 17:44:37 kruland + * Change SpatialReference constructor to have keyword argument "wkt". + * + * Revision 1.8 2005/02/20 19:46:04 kruland + * Use the new fixed size typemap for (double **) arguments in ExportToPCI and + * ExportToUSGS. + * + * Revision 1.7 2005/02/20 19:42:53 kruland + * Rename the Swig shadow classes so the names do not give the impression that + * they are any part of the GDAL/OSR apis. There were no bugs with the old + * names but they were confusing. + * + * Revision 1.6 2005/02/18 18:42:07 kruland + * Added %feature("autodoc"); + * + * Revision 1.5 2005/02/18 18:13:05 kruland + * Now using the THROW_OGR_ERROR tyepmap for all methods. Changed those + * which should return OGRErr to return OGRErr since the typemap is friendly + * to return arguments. + * + * Revision 1.4 2005/02/18 16:18:27 kruland + * Added %feature("compactdefaultargs") to fix problem with ImportFromPCI, + * ImportFromUSGS and the fact that %typemap (char**ignorechange) has no + * %typecheck. + * + * Fixed bug in new_CoordinateTransformation(). It wasn't returning a value. + * + * Revision 1.3 2005/02/17 21:12:06 kruland + * More complete implementation of SpatialReference and CoordinateTransformation. + * Satisfies the osr gdalautotests with 1 exception. + * + * Revision 1.2 2005/02/17 03:39:25 kruland + * Use %constant decls for the constants. + * + * Revision 1.1 2005/02/15 20:50:09 kruland + * Minimal SpatialReference Object to make gcore pretty much succeed. + * + * +*/ + +%module osr + +%feature("compactdefaultargs"); + +%constant char *SRS_PT_ALBERS_CONIC_EQUAL_AREA = SRS_PT_ALBERS_CONIC_EQUAL_AREA; +%constant char *SRS_PT_AZIMUTHAL_EQUIDISTANT = SRS_PT_AZIMUTHAL_EQUIDISTANT; +%constant char *SRS_PT_CASSINI_SOLDNER = SRS_PT_CASSINI_SOLDNER; +%constant char *SRS_PT_CYLINDRICAL_EQUAL_AREA = SRS_PT_CYLINDRICAL_EQUAL_AREA; +%constant char *SRS_PT_ECKERT_IV = SRS_PT_ECKERT_IV; +%constant char *SRS_PT_ECKERT_VI = SRS_PT_ECKERT_VI; +%constant char *SRS_PT_EQUIDISTANT_CONIC = SRS_PT_EQUIDISTANT_CONIC; +%constant char *SRS_PT_EQUIRECTANGULAR = SRS_PT_EQUIRECTANGULAR; +%constant char *SRS_PT_GALL_STEREOGRAPHIC = SRS_PT_GALL_STEREOGRAPHIC; +%constant char *SRS_PT_GNOMONIC = SRS_PT_GNOMONIC; +%constant char *SRS_PT_GOODE_HOMOLOSINE = SRS_PT_GOODE_HOMOLOSINE; +%constant char *SRS_PT_HOTINE_OBLIQUE_MERCATOR = SRS_PT_HOTINE_OBLIQUE_MERCATOR; +%constant char *SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN = SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN; +%constant char *SRS_PT_LABORDE_OBLIQUE_MERCATOR = SRS_PT_LABORDE_OBLIQUE_MERCATOR; +%constant char *SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP = SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP; +%constant char *SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP = SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP; +%constant char *SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM = SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM; +%constant char *SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA = SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA; +%constant char *SRS_PT_MERCATOR_1SP = SRS_PT_MERCATOR_1SP; +%constant char *SRS_PT_MERCATOR_2SP = SRS_PT_MERCATOR_2SP; +%constant char *SRS_PT_MILLER_CYLINDRICAL = SRS_PT_MILLER_CYLINDRICAL; +%constant char *SRS_PT_MOLLWEIDE = SRS_PT_MOLLWEIDE; +%constant char *SRS_PT_NEW_ZEALAND_MAP_GRID = SRS_PT_NEW_ZEALAND_MAP_GRID; +%constant char *SRS_PT_OBLIQUE_STEREOGRAPHIC = SRS_PT_OBLIQUE_STEREOGRAPHIC; +%constant char *SRS_PT_ORTHOGRAPHIC = SRS_PT_ORTHOGRAPHIC; +%constant char *SRS_PT_POLAR_STEREOGRAPHIC = SRS_PT_POLAR_STEREOGRAPHIC; +%constant char *SRS_PT_POLYCONIC = SRS_PT_POLYCONIC; +%constant char *SRS_PT_ROBINSON = SRS_PT_ROBINSON; +%constant char *SRS_PT_SINUSOIDAL = SRS_PT_SINUSOIDAL; +%constant char *SRS_PT_STEREOGRAPHIC = SRS_PT_STEREOGRAPHIC; +%constant char *SRS_PT_SWISS_OBLIQUE_CYLINDRICAL= SRS_PT_SWISS_OBLIQUE_CYLINDRICAL; +%constant char *SRS_PT_TRANSVERSE_MERCATOR = SRS_PT_TRANSVERSE_MERCATOR; +%constant char *SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED = SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED; +%constant char *SRS_PT_TRANSVERSE_MERCATOR_MI_22= SRS_PT_TRANSVERSE_MERCATOR_MI_22; +%constant char *SRS_PT_TRANSVERSE_MERCATOR_MI_23= SRS_PT_TRANSVERSE_MERCATOR_MI_23; +%constant char *SRS_PT_TRANSVERSE_MERCATOR_MI_24= SRS_PT_TRANSVERSE_MERCATOR_MI_24; +%constant char *SRS_PT_TRANSVERSE_MERCATOR_MI_25= SRS_PT_TRANSVERSE_MERCATOR_MI_25; +%constant char *SRS_PT_TUNISIA_MINING_GRID = SRS_PT_TUNISIA_MINING_GRID; +%constant char *SRS_PT_VANDERGRINTEN = SRS_PT_VANDERGRINTEN; +%constant char *SRS_PT_KROVAK = SRS_PT_KROVAK; + +%constant char *SRS_PP_CENTRAL_MERIDIAN = SRS_PP_CENTRAL_MERIDIAN; +%constant char *SRS_PP_SCALE_FACTOR = SRS_PP_SCALE_FACTOR; +%constant char *SRS_PP_STANDARD_PARALLEL_1 = SRS_PP_STANDARD_PARALLEL_1; +%constant char *SRS_PP_STANDARD_PARALLEL_2 = SRS_PP_STANDARD_PARALLEL_2; +%constant char *SRS_PP_PSEUDO_STD_PARALLEL_1 = SRS_PP_PSEUDO_STD_PARALLEL_1; +%constant char *SRS_PP_LONGITUDE_OF_CENTER = SRS_PP_LONGITUDE_OF_CENTER; +%constant char *SRS_PP_LATITUDE_OF_CENTER = SRS_PP_LATITUDE_OF_CENTER; +%constant char *SRS_PP_LONGITUDE_OF_ORIGIN = SRS_PP_LONGITUDE_OF_ORIGIN; +%constant char *SRS_PP_LATITUDE_OF_ORIGIN = SRS_PP_LATITUDE_OF_ORIGIN; +%constant char *SRS_PP_FALSE_EASTING = SRS_PP_FALSE_EASTING; +%constant char *SRS_PP_FALSE_NORTHING = SRS_PP_FALSE_NORTHING; +%constant char *SRS_PP_AZIMUTH = SRS_PP_AZIMUTH; +%constant char *SRS_PP_LONGITUDE_OF_POINT_1 = SRS_PP_LONGITUDE_OF_POINT_1; +%constant char *SRS_PP_LATITUDE_OF_POINT_1 = SRS_PP_LATITUDE_OF_POINT_1; +%constant char *SRS_PP_LONGITUDE_OF_POINT_2 = SRS_PP_LONGITUDE_OF_POINT_2; +%constant char *SRS_PP_LATITUDE_OF_POINT_2 = SRS_PP_LATITUDE_OF_POINT_2; +%constant char *SRS_PP_LONGITUDE_OF_POINT_3 = SRS_PP_LONGITUDE_OF_POINT_3; +%constant char *SRS_PP_LATITUDE_OF_POINT_3 = SRS_PP_LATITUDE_OF_POINT_3; +%constant char *SRS_PP_RECTIFIED_GRID_ANGLE = SRS_PP_RECTIFIED_GRID_ANGLE; +%constant char *SRS_PP_LANDSAT_NUMBER = SRS_PP_LANDSAT_NUMBER; +%constant char *SRS_PP_PATH_NUMBER = SRS_PP_PATH_NUMBER; +%constant char *SRS_PP_PERSPECTIVE_POINT_HEIGHT = SRS_PP_PERSPECTIVE_POINT_HEIGHT; +%constant char *SRS_PP_FIPSZONE = SRS_PP_FIPSZONE; +%constant char *SRS_PP_ZONE = SRS_PP_ZONE; + +%constant char *SRS_UL_METER = SRS_UL_METER; +%constant char *SRS_UL_FOOT = SRS_UL_FOOT; +%constant char *SRS_UL_FOOT_CONV = SRS_UL_FOOT_CONV; +%constant char *SRS_UL_US_FOOT = SRS_UL_US_FOOT; +%constant char *SRS_UL_US_FOOT_CONV = SRS_UL_US_FOOT_CONV; +%constant char *SRS_UL_NAUTICAL_MILE = SRS_UL_NAUTICAL_MILE; +%constant char *SRS_UL_NAUTICAL_MILE_CONV = SRS_UL_NAUTICAL_MILE_CONV; +%constant char *SRS_UL_LINK = SRS_UL_LINK; +%constant char *SRS_UL_LINK_CONV = SRS_UL_LINK_CONV; +%constant char *SRS_UL_CHAIN = SRS_UL_CHAIN; +%constant char *SRS_UL_CHAIN_CONV = SRS_UL_CHAIN_CONV; +%constant char *SRS_UL_ROD = SRS_UL_ROD; +%constant char *SRS_UL_ROD_CONV = SRS_UL_ROD_CONV; + +%constant char *SRS_DN_NAD27 = SRS_DN_NAD27; +%constant char *SRS_DN_NAD83 = SRS_DN_NAD83; +%constant char *SRS_DN_WGS72 = SRS_DN_WGS72; +%constant char *SRS_DN_WGS84 = SRS_DN_WGS84; + +%constant double SRS_WGS84_SEMIMAJOR = SRS_WGS84_SEMIMAJOR; +%constant double SRS_WGS84_INVFLATTENING = SRS_WGS84_INVFLATTENING; + +%{ +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + +%} + +typedef int OGRErr; + +#if defined(SWIGPYTHON) +%include osr_python.i +#elif defined(SWIGRUBY) +%include typemaps_ruby.i +#elif defined(SWIGPHP4) +%include typemaps_php.i +#elif defined(SWIGCSHARP) +%include typemaps_csharp.i +#elif defined(SWIGJAVA) +%include osr_java.i +#else +%include gdal_typemaps.i +#endif + +/****************************************************************************** + * + * Global methods + * + */ + +/************************************************************************/ +/* GetWellKnownGeogCSAsWKT() */ +/************************************************************************/ +%inline %{ +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} +%} + +/************************************************************************/ +/* GetProjectionMethods() */ +/************************************************************************/ +/* + * Python has it's own custom interface to GetProjectionMethods().which returns + * fairly complex strucutre. + * + * All other languages will have a more simplistic interface which is + * exactly the same as the C api. + * + */ +#if !defined(SWIGPYTHON) +%rename (GetProjectionMethods) OPTGetProjectionMethods; +char **OPTGetProjectionMethods(); + +%rename (GetProjectionMethodParameterList) OPTGetParameterList; +char **OPTGetParameterList( char *method, char **username ); + +%rename (GetProjectionMethodParamInfo) OPTGetParameterInfo; +void OPTGetParameterInfo( char *method, char *param, char **usrname, + char **type, double *defaultval ); +#endif + +/****************************************************************************** + * + * Spatial Reference Object. + * + */ + +%rename (SpatialReference) OSRSpatialReferenceShadow; +class OSRSpatialReferenceShadow { +private: + OSRSpatialReferenceShadow(); +public: +%extend { + +// NEEDED +// Reference +// Dereference +// SetAuthority +// SetGH +// SetGnomonic +// SetHOM +//SetHOM2PNO +// SetKrovak +// SetLAEA +// SetLCC +// SetLCCB +// SetLCC1SP +// SetMC +// SetMercator +// SetMollweide +// SetNZMG +// SetOS +// SetOrthographic +// SetPolyconic +// SetPS +// SetRobinson +// SetSinusoidal +// SetStereographic +// SetSOC +// SetTM +// SetTMSO +// SetTMG +// SetVDG + + + %feature("kwargs") OSRSpatialReferenceShadow; + OSRSpatialReferenceShadow( char const * wkt = "" ) { + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } + + ~OSRSpatialReferenceShadow() { + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } + +/* NEEDED */ +// Reference ? I don't think this are needed in script-land +// Dereference ? I don't think this are needed in script-land + +%newobject __str__; + char *__str__() { + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } + + int IsSame( OSRSpatialReferenceShadow *rhs ) { + return OSRIsSame( self, rhs ); + } + + int IsSameGeogCS( OSRSpatialReferenceShadow *rhs ) { + return OSRIsSameGeogCS( self, rhs ); + } + + int IsGeographic() { + return OSRIsGeographic(self); + } + + int IsProjected() { + return OSRIsProjected(self); + } + + const char *GetAttrValue( const char *name, int child = 0 ) { + return OSRGetAttrValue( self, name, child ); + } + +/* + const char *__getattr__( const char *name ) { + return OSRGetAttrValue( self, name, 0 ); + } +*/ + + OGRErr SetAttrValue( const char *name, const char *value ) { + return OSRSetAttrValue( self, name, value ); + } + +/* + OGRErr __setattr__( const char *name, const char *value ) { + return OSRSetAttrValue( self, name, value ); + } +*/ + + OGRErr SetAngularUnits( const char*name, double to_radians ) { + return OSRSetAngularUnits( self, name, to_radians ); + } + + double GetAngularUnits() { + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } + + OGRErr SetLinearUnits( const char*name, double to_meters ) { + return OSRSetAngularUnits( self, name, to_meters ); + } + + double GetLinearUnits() { + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } + + const char *GetLinearUnitsName() { + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } + + const char *GetAuthorityCode( const char *target_key ) { + return OSRGetAuthorityCode( self, target_key ); + } + + const char *GetAuthorityName( const char *target_key ) { + return OSRGetAuthorityName( self, target_key ); + } + + OGRErr SetUTM( int zone, int north =1 ) { + return OSRSetUTM( self, zone, north ); + } + + OGRErr SetStatePlane( int zone, int is_nad83 = 1, char const *unitsname = "", double units = 0.0 ) { + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } + + OGRErr AutoIdentifyEPSG() { + return OSRAutoIdentifyEPSG( self ); + } + + OGRErr SetProjection( char const *arg ) { + return OSRSetProjection( self, arg ); + } + + OGRErr SetProjParm( const char *name, double val ) { + return OSRSetProjParm( self, name, val ); + } + + double GetProjParm( const char *name, double default_val = 0.0 ) { + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } + + OGRErr SetNormProjParm( const char *name, double val ) { + return OSRSetNormProjParm( self, name, val ); + } + + double GetNormProjParm( const char *name, double default_val = 0.0 ) { + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } + + OGRErr SetACEA( double stdp1, double stdp2, double clat, double clong, double fe, double fn ) { + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } + + OGRErr SetAE( double clat, double clon, double fe, double fn ) { + return OSRSetAE( self, clat, clon, fe, fn ); + } + + OGRErr SetCS( double clat, double clong, double fe, double fn ) { + return OSRSetCS( self, clat, clong, fe, fn ); + } + + OGRErr SetBonne( double clat, double clong, double fe, double fn ) { + return OSRSetBonne( self, clat, clong, fe, fn ); + } + + OGRErr SetEC( double stdp1, double stdp2, double clat, double clong, double fe, double fn ) { + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } + + OGRErr SetEckertIV( double cm, double fe, double fn ) { + return OSRSetEckertIV( self, cm, fe, fn ); + } + + OGRErr SetEckertVI( double cm, double fe, double fn ) { + return OSRSetEckertVI( self, cm, fe, fn ); + } + + OGRErr SetEquirectangular( double clat, double clong, double fe, double fn ) { + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } + +%feature( "kwargs" ) SetGS; + OGRErr SetGS( double cm, double fe, double fn ) { + return OSRSetGS( self, cm, fe, fn ); + } + + OGRErr SetWellKnownGeogCS( const char *name ) { + return OSRSetWellKnownGeogCS( self, name ); + } + + OGRErr SetFromUserInput( const char *name ) { + return OSRSetFromUserInput( self, name ); + } + + OGRErr CopyGeogCSFrom( OSRSpatialReferenceShadow *rhs ) { + return OSRCopyGeogCSFrom( self, rhs ); + } + + OGRErr SetTOWGS84( double p1, double p2, double p3, + double p4 = 0.0, double p5 = 0.0, + double p6 = 0.0, double p7 = 0.0 ) { + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } + + OGRErr GetTOWGS84( double argout[7] ) { + return OSRGetTOWGS84( self, argout, 7 ); + } + + OGRErr SetGeogCS( const char * pszGeogName, + const char * pszDatumName, + const char * pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + const char * pszPMName = "Greenwich", + double dfPMOffset = 0.0, + const char * pszUnits = "degree", + double dfConvertToRadians = 0.0174532925199433 ) { + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } + + OGRErr SetProjCS( const char *name = "unnamed" ) { + return OSRSetProjCS( self, name ); + } + +%apply (char **ignorechange) { (char **) }; + OGRErr ImportFromWkt( char **ppszInput ) { + return OSRImportFromWkt( self, ppszInput ); + } +%clear (char **); + + OGRErr ImportFromProj4( char *ppszInput ) { + return OSRImportFromProj4( self, ppszInput ); + } + +%apply (char **ignorechange) { (char **) }; + OGRErr ImportFromESRI( char **ppszInput ) { + return OSRImportFromESRI( self, ppszInput ); + } +%clear (char **); + + OGRErr ImportFromEPSG( int arg ) { + return OSRImportFromEPSG(self, arg); + } + + OGRErr ImportFromPCI( char const *proj, char const *units = "METRE", + double argin[17] = 0 ) { + return OSRImportFromPCI( self, proj, units, argin ); + } + + OGRErr ImportFromUSGS( long proj_code, long zone = 0, + double argin[15] = 0, + long datum_code = 0 ) { + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } + + OGRErr ImportFromXML( char const *xmlString ) { + return OSRImportFromXML( self, xmlString ); + } + + OGRErr ExportToWkt( char **argout ) { + return OSRExportToWkt( self, argout ); + } + + OGRErr ExportToPrettyWkt( char **argout, int simplify = 0 ) { + return OSRExportToPrettyWkt( self, argout, simplify ); + } + + OGRErr ExportToProj4( char **argout ) { + return OSRExportToProj4( self, argout ); + } + +%apply (char **argout) { (char **) }; +%apply (double *argout[ANY]) { (double *parms[17] ) }; + OGRErr ExportToPCI( char **proj, char **units, double *parms[17] ) { + return OSRExportToPCI( self, proj, units, parms ); + } +%clear (char **); +%clear (double *parms[17]); + +%apply (long *OUTPUT) { (long*) }; +%apply (double *argout[ANY]) { (double *parms[15]) } + OGRErr ExportToUSGS( long *code, long *zone, double *parms[15], long *datum ) { + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +%clear (long*); +%clear (double *parms[15]); + + OGRErr ExportToXML( char **argout, const char *dialect = "" ) { + return OSRExportToXML( self, argout, dialect ); + } + +%newobject CloneGeogCS; + OSRSpatialReferenceShadow *CloneGeogCS() { + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } + +/* + * Commented out until the headers have changed to make OSRClone visible. +%newobject Clone; + OSRSpatialReferenceShadow *Clone() { + return (OSRSpatialReferenceShadow*) OSRClone(self); + } +*/ + + OGRErr Validate() { + return OSRValidate(self); + } + + OGRErr StripCTParms() { + return OSRStripCTParms(self); + } + + OGRErr FixupOrdering() { + return OSRFixupOrdering(self); + } + + OGRErr Fixup() { + return OSRFixup(self); + } + + OGRErr MorphToESRI() { + return OSRMorphToESRI(self); + } + + OGRErr MorphFromESRI() { + return OSRMorphFromESRI(self); + } + + +} /* %extend */ +}; + + +/****************************************************************************** + * + * CoordinateTransformation Object + * + */ + +// NEEDED +// Custom python __init__ which takes a tuple. +// TransformPoints which takes list of 3-tuples + +%rename (CoordinateTransformation) OSRCoordinateTransformationShadow; +class OSRCoordinateTransformationShadow { +private: + OSRCoordinateTransformationShadow(); +public: +%extend { + + OSRCoordinateTransformationShadow( OSRSpatialReferenceShadow *src, OSRSpatialReferenceShadow *dst ) { + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } + + ~OSRCoordinateTransformationShadow() { + OCTDestroyCoordinateTransformation( self ); + } + +// Need to apply argin typemap second so the numinputs=1 version gets applied +// instead of the numinputs=0 version from argout. +%apply (double argout[ANY]) {(double inout[3])}; +%apply (double argin[ANY]) {(double inout[3])}; + void TransformPoint( double inout[3] ) { + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +%clear (double inout[3]); + + void TransformPoint( double argout[3], double x, double y, double z = 0.0 ) { + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } + +} /*extend */ +}; diff --git a/Utilities/GDAL/swig/include/perl/gdal_perl.i b/Utilities/GDAL/swig/include/perl/gdal_perl.i new file mode 100644 index 0000000000..d387ce73db --- /dev/null +++ b/Utilities/GDAL/swig/include/perl/gdal_perl.i @@ -0,0 +1,37 @@ +/* + * $Id: gdal_perl.i,v 1.4 2005/09/16 19:17:46 kruland Exp $ + * + * perl specific code for gdal bindings. + */ + +/* + * $Log: gdal_perl.i,v $ + * Revision 1.4 2005/09/16 19:17:46 kruland + * Call UseExceptions on module init. + * + * Revision 1.3 2005/09/13 18:35:50 kruland + * Rename GetMetadata_Dict to GetMetadata and ignore GetMetadata_List. + * + * Revision 1.2 2005/09/13 17:36:28 kruland + * Whoops! import typemaps_perl.i. + * + * Revision 1.1 2005/09/13 16:08:45 kruland + * Added perl specific modifications for gdal and ogr. + * + * + */ + +%init %{ + /* gdal_perl.i %init code */ + UseExceptions(); + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } +%} + +%include cpl_exceptions.i + +%rename (GetMetadata) GetMetadata_Dict; +%ignore GetMetadata_List; + +%import typemaps_perl.i diff --git a/Utilities/GDAL/swig/include/perl/ogr_perl.i b/Utilities/GDAL/swig/include/perl/ogr_perl.i new file mode 100644 index 0000000000..d5a7460a41 --- /dev/null +++ b/Utilities/GDAL/swig/include/perl/ogr_perl.i @@ -0,0 +1,40 @@ +/* + * $Id: ogr_perl.i,v 1.4 2005/09/21 19:04:12 kruland Exp $ + * + * perl specific code for ogr bindings. + */ + +/* + * $Log: ogr_perl.i,v $ + * Revision 1.4 2005/09/21 19:04:12 kruland + * Need to %include cpl_exceptions.i + * + * Revision 1.3 2005/09/21 18:00:05 kruland + * Turn on UseExceptions in ogr init code. + * + * Revision 1.2 2005/09/13 17:36:28 kruland + * Whoops! import typemaps_perl.i. + * + * Revision 1.1 2005/09/13 16:08:45 kruland + * Added perl specific modifications for gdal and ogr. + * + * + */ + +%init %{ + + UseExceptions(); + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + +%} + +%include cpl_exceptions.i + +%rename (GetDriverCount) OGRGetDriverCount; +%rename (GetOpenDSCount) OGRGetOpenDSCount; +%rename (SetGenerate_DB2_V72_BYTE_ORDER) OGRSetGenerate_DB2_V72_BYTE_ORDER; +%rename (RegisterAll) OGRRegisterAll(); + +%import typemaps_perl.i diff --git a/Utilities/GDAL/swig/include/perl/typemaps_perl.i b/Utilities/GDAL/swig/include/perl/typemaps_perl.i new file mode 100644 index 0000000000..47042ebc0f --- /dev/null +++ b/Utilities/GDAL/swig/include/perl/typemaps_perl.i @@ -0,0 +1,667 @@ +/* + * $Id: typemaps_perl.i,v 1.12 2006/04/11 12:47:55 ajolma Exp $ + */ + +/* + * $Log: typemaps_perl.i,v $ + * Revision 1.12 2006/04/11 12:47:55 ajolma + * removed now deprecated "perl5," from typemaps + * + * Revision 1.11 2005/10/11 14:11:42 kruland + * Fix memory bug in typemap(out) char **options. The returned array of strings + * is owned by the dataset. + * + * Revision 1.10 2005/10/11 01:49:07 kruland + * Back out previous change. It introduced a memory leak. + * + * Revision 1.9 2005/10/03 20:28:51 kruland + * Fixed bug in %typemap(out) char **dict. + * + * Revision 1.8 2005/09/30 18:52:28 kruland + * Fixed typo. + * + * Revision 1.7 2005/09/29 14:00:19 kruland + * Fixed: %typemap(perl5,argout) (int *nGCPs, GDAL_GCP const **pGCPs ) + * Fixed: %typemap(perl5,in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) + * + * Revision 1.6 2005/09/27 14:32:01 kruland + * Fixed the in,numinputs=1 int nLen, char *pBuf typemap used by + * ReadRaster & WriteRaster (thanks Ari). + * + * Revision 1.5 2005/09/16 20:42:49 kruland + * Magical adjustments to some list length calls. + * + * Revision 1.4 2005/09/14 15:01:33 kruland + * Removed accidental debug message. + * + * Revision 1.3 2005/09/13 03:02:43 kruland + * Added OGRErr out typemap which uses ogr_error_map.i. + * + * Revision 1.2 2005/09/13 02:10:52 kruland + * Added Colormap typemaps. + * + * Revision 1.1 2005/09/06 01:40:26 kruland + * Perl typemaps. + * + */ + +/* + * Copyright Ari Jolma 2005. Based on typemaps_python.i + * You may distribute this file under the same terms as GDAL itself. + */ + +/* + * Include the typemaps from swig library for returning of + * standard types through arguments. + */ +%include "typemaps.i" + +%apply (double *OUTPUT) { double *argout }; + +/* + * double *val, int*hasval, is a special contrived typemap used for + * the RasterBand GetNoDataValue, GetMinimum, GetMaximum, GetOffset, GetScale methods. + * In the python bindings, the variable hasval is tested. If it is 0 (is, the value + * is not set in the raster band) then Py_None is returned. If is is != 0, then + * the value is coerced into a long and returned. + */ +%typemap(in,numinputs=0) (double *val, int *hasval) ( double tmpval, int tmphasval ) { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + $1 = &tmpval; + $2 = &tmphasval; +} +%typemap(argout) (double *val, int *hasval) { + /* %typemap(argout) (double *val, int *hasval) */ + $result = sv_newmortal(); + if ( *$2 ) + sv_setnv($result, *$1); + argvi++; +} +/* if the call to the fct failed, return an undef */ +%typemap(out) IF_FALSE_RETURN_NONE +{ + /* %typemap(out) IF_FALSE_RETURN_NONE */ +} +%typemap(ret) IF_FALSE_RETURN_NONE +{ + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + if ($1 == 0 ) { + /* this is currently used only in GDALGCPsToGeoTransform + this is probably a memory leak + ST(argvi-1) is at this point an array which needs to be destr + */ + ST(argvi-1) = sv_newmortal(); + } +} + +/* + * SWIG macro to define fixed length array typemaps + * defines three different typemaps. + * + * 1) For argument in. The wrapped function's prototype is: + * + * FunctionOfDouble3( double *vector ); + * + * The function assumes that vector points to three consecutive doubles. + * This can be wrapped using: + * + * %apply (double_3 argin) { (double *vector) }; + * FunctionOfDouble3( double *vector ); + * %clear (double *vector); + * + * Example: Dataset.SetGeoTransform(). + * + * 2) Functions which modify a fixed length array passed as + * an argument or return data in an array allocated by the + * caller. + * + * %apply (double_6 argout ) { (double *vector) }; + * GetVector6( double *vector ); + * %clear ( double *vector ); + * + * Example: Dataset.GetGeoTransform(). + * + * 3) Functions which take a double **. Through this argument it + * returns a pointer to a fixed size array allocated with CPLMalloc. + * + * %apply (double_17 *argoug) { (double **vector) }; + * ReturnVector17( double **vector ); + * %clear ( double **vector ); + * + * Example: SpatialReference.ExportToPCI(). + * + */ + +%fragment("CreateArrayFromDoubleArray","header") %{ +static SV * +CreateArrayFromDoubleArray( double *first, unsigned int size ) { + AV *av = (AV*)sv_2mortal((SV*)newAV()); + for( unsigned int i=0; i<size; i++ ) { + av_store(av,i,newSVnv(*first)); + ++first; + } + return newRV_noinc((SV*)av); +} +%} + +%typemap(in,numinputs=0) ( double argout[ANY]) (double argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double argout[ANY]) */ + $1 = argout; +} +%typemap(argout,fragment="CreateArrayFromDoubleArray") ( double argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + $result = CreateArrayFromDoubleArray( $1, $dim0 ); + argvi++; +} + +%typemap(in,numinputs=0) ( double *argout[ANY]) (double *argout) +{ + /* %typemap(in,numinputs=0) (double *argout[ANY]) */ + $1 = &argout; +} +%typemap(argout,fragment="CreateArrayFromDoubleArray") ( double *argout[ANY]) +{ + /* %typemap(argout) (double *argout[ANY]) */ + $result = CreateArrayFromDoubleArray( *$1, $dim0 ); + argvi++; +} +%typemap(freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*$1); +} +%typemap(in) (double argin[ANY]) (double argin[$dim0]) +{ + /* %typemap(in) (double argin[ANY]) */ + if (! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + $1 = argin; + AV *av = (AV*)(SvRV($input)); + int seq_size = av_len(av)+1; + if ( seq_size != $dim0 ) { + croak("argument array must have length %d",$dim0); + SWIG_fail; + } + for (unsigned int i=0; i<$dim0; i++) { + SV **sv = av_fetch(av, i, 0); + $1[i] = SvNV(*sv); + } +} + +/* + * Typemap for counted arrays of ints <- PySequence + */ +%typemap(in,numinputs=1) (int nList, int* pList) +{ + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + if (! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV($input)); + $1 = av_len(av)-1; + $2 = (int*) malloc($1*sizeof(int)); + for( int i = 0; i<$1; i++ ) { + SV **sv = av_fetch(av, i, 0); + $2[i] = SvIV(*sv); + } +} +%typemap(freearg) (int nList, int* pList) +{ + /* %typemap(freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} +%fragment("CreateArrayFromIntegerArray","header") %{ +static SV * +CreateArrayFromIntegerArray( double *first, unsigned int size ) { + AV *av = (AV*)sv_2mortal((SV*)newAV()); + for( unsigned int i=0; i<size; i++ ) { + av_store(av,i,newSViv(*first)); + ++first; + } + return newRV_noinc((SV*)av); +} +%} + +/* + * Typemap for buffers with length <-> AV + * Used in Band::ReadRaster() and Band::WriteRaster() + * + * This typemap has a typecheck also since the WriteRaster() + * methods are overloaded. + */ +%typemap(in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen = 0, char *pBuf = 0 ) +{ + /* %typemap(in,numinputs=0) (int *nLen, char **pBuf ) */ + $1 = &nLen; + $2 = &pBuf; +} +%typemap(argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + $result = sv_2mortal(newSVpv( *$2, *$1 )); + argvi++; +} +%typemap(freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *$1 ) { + free( *$2 ); + } +} +%typemap(in,numinputs=1) (int nLen, char *pBuf ) +{ + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + if (!SvPOK($input)) { + croak("buf argument has to be binary data"); + SWIG_fail; + } + STRLEN len = SvCUR($input); + $2 = SvPV_nolen($input); + $1 = len; +} + +/* + * Typemap argout of GDAL_GCP* used in Dataset::GetGCPs( ) + */ +%typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) (int nGCPs=0, GDAL_GCP *pGCPs=0 ) +{ + /* %typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + $1 = &nGCPs; + $2 = &pGCPs; +} +%typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) +{ + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + AV *dict = (AV*)sv_2mortal((SV*)newAV()); + for( int i = 0; i < *$1; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*$2)[i].dfGCPX, + (*$2)[i].dfGCPY, + (*$2)[i].dfGCPZ, + (*$2)[i].dfGCPPixel, + (*$2)[i].dfGCPLine, + (*$2)[i].pszInfo, + (*$2)[i].pszId ); + SV *sv = newSV(0); + SWIG_MakePtr( sv, (void*)o, $*2_descriptor, SWIG_SHADOW|SWIG_OWNER); + av_store(dict, i, sv); + } + $result = newRV_noinc((SV*)dict); + argvi++; +} +%typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) ( GDAL_GCP *tmpGCPList ) +{ + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV($input)); + $1 = av_len(av)+1; + tmpGCPList = (GDAL_GCP*) malloc($1*sizeof(GDAL_GCP)); + $2 = tmpGCPList; + for( int i = 0; i<$1; i++ ) { + SV **sv = av_fetch(av, i, 0); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( *sv, (void**)&item, SWIGTYPE_p_GDAL_GCP, 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList; + } +} +%typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) +{ + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if ($2) { + free( (void*) $2 ); + } +} + +/* + * Typemap for GDALColorEntry* <-> AV + * GDALColorEntry* may be a return value and both input and output param + */ +%typemap(out) GDALColorEntry* +{ + /* %typemap(out) GDALColorEntry* */ + if (result == NULL) + croak("GetColorEntry failed at index %i",result); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c1); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c2); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c3); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c4); +} +%typemap(in,numinputs=0) GDALColorEntry*(GDALColorEntry e) +{ + /* %typemap(in,numinputs=0) GDALColorEntry*(GDALColorEntry e) */ + $1 = &e; +} +%typemap(argout) GDALColorEntry* +{ + /* %typemap(argout) GDALColorEntry* */ + if (result == FALSE) + croak("GetColorEntryAsRGB failed at index %i",result); + argvi--; + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c1); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c2); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c3); + $result = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c4); +} +%typemap(argout) const GDALColorEntry* +{ + /* %typemap(argout) const GDALColorEntry* */ +} +%typemap(in,numinputs=1) const GDALColorEntry*(GDALColorEntry e) +{ + /* %typemap(in,numinputs=1) const GDALColorEntry*(GDALColorEntry e) */ + $1 = &e3; + if (! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV($input)); + int seq_size = av_len(av); + if ( seq_size != 3 ) { + croak("color entry argument array must have length 4 (it is %i)",seq_size+1); + SWIG_fail; + } + SV **sv = av_fetch(av, 0, 0); + $1->c1 = SvIV(*sv); + sv = av_fetch(av, 1, 0); + $1->c2 = SvIV(*sv); + sv = av_fetch(av, 2, 0); + $1->c3 = SvIV(*sv); + sv = av_fetch(av, 3, 0); + $1->c4 = SvIV(*sv); +} + +/* + * Typemap char ** <-> HV * + */ +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) +{ + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + $1 = (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVHV)) ? 1 : 0; +} +%typemap(in) char **dict +{ + /* %typemap(in) char **dict */ + HV *hv = (HV*)SvRV($input); + SV *sv; + char *key; + I32 klen; + $1 = NULL; + hv_iterinit(hv); + while(sv = hv_iternextsv(hv,&key,&klen)) { + $1 = CSLAddNameValue( $1, key, SvPV_nolen(sv) ); + } +} +%typemap(out) char **dict +{ + /* %typemap(out) char **dict */ + char **stringarray = $1; + HV *hv = (HV*)sv_2mortal((SV*)newHV()); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + hv_store(hv, keyptr, strlen(keyptr), newSVpv(valptr, strlen(valptr)), 0); + CPLFree( keyptr ); + } + stringarray++; + } + } + $result = newRV_noinc((SV*)hv); + argvi++; +} +%typemap(freearg) char **dict +{ + /* %typemap(freearg) char **dict */ + CSLDestroy( $1 ); +} + +/* + * Typemap char **options <-> AV + */ +%typemap(in) char **options +{ + /* %typemap(in) char **options */ + if ( ! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV($input)); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + $1 = CSLAddString( $1, pszItem ); + } +} +%typemap(freearg) char **options +{ + /* %typemap(freearg) char **options */ + CSLDestroy( $1 ); +} +%typemap(out) char **options +{ + /* %typemap(out) char ** -> ( string ) */ + AV* av = (AV*)sv_2mortal((SV*)newAV()); + char **stringarray = $1; + if ( stringarray != NULL ) { + for ( int i = 0; i < CSLCount( stringarray ); ++i, ++stringarray ) { + av_store(av, i, newSVpv(*stringarray, strlen(*stringarray))); + } + } + $result = newRV_noinc((SV*)av); + argvi++; +} + +/* + * Typemaps map mutable char ** arguments from AV. Does not + * return the modified argument + */ +%typemap(in) (char **ignorechange) ( char *val ) +{ + /* %typemap(in) (char **ignorechange) */ + val = SvPV_nolen($input); + $1 = &val; +} + +/* + * Typemap for char **argout. + */ +%typemap(in,numinputs=0) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in,numinputs=0) (char **argout) */ + $1 = &argout; +} +%typemap(argout) (char **argout) +{ + /* %typemap(argout) (char **argout) */ + $result = sv_newmortal(); + if ( $1 ) + sv_setpv($result, *$1); + argvi++; +} +%typemap(freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + if ( *$1 ) + CPLFree( *$1 ); +} + +/* + * Typemap for an optional POD argument. + * Declare function to take POD *. If the parameter + * is NULL then the function needs to define a default + * value. + */ +%typemap(in) (int *optional_int) ( int val ) +{ + /* %typemap(in) (int *optional_int) */ + if ( !SvOK($input) ) { + $1 = 0; + } + else { + val = SvIV($input); + $1 = ($1_type)&val; + } +} + +/* + * Typedef const char * <- Any object. + * + * Formats the object using str and returns the string representation + */ + +%typemap(in) (tostring argin) +{ + /* %typemap(in) (tostring argin) */ + $1 = SvPV_nolen( $input ); +} +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) +{ + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + $1 = 1; +} + +/* + * Typemap for CPLErr. + * This typemap will use the wrapper C-variable + * int UseExceptions to determine proper behavour for + * CPLErr return codes. + * If UseExceptions ==0, then return the rc. + * If UseExceptions ==1, then if rc >= CE_Failure, raise an exception. + */ +%typemap(out) CPLErr +{ + /* %typemap(out) CPLErr */ + $result = sv_2mortal(newSViv($1)); + argvi++; +} + +/* + * Typemap for OGRErr. + */ +%import "ogr_error_map.i" +%typemap(out,fragment="OGRErrMessages") OGRErr +{ + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } +} + +/* + * Typemaps for minixml: CPLXMLNode* input, CPLXMLNode *ret + */ + +%fragment("AVToXMLTree","header") %{ +/************************************************************************/ +/* AVToXMLTree() */ +/************************************************************************/ +static CPLXMLNode *AVToXMLTree( AV *av ) + +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = av_len(av) - 1; + if( nChildCount < 0 ) + { + croak("Error in input XMLTree."); + return NULL; + } + + nType = SvIV(*(av_fetch(av,0,0))); + pszText = SvPV_nolen(*(av_fetch(av,1,0))); + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = AVToXMLTree( (AV *)(*(av_fetch(av,iChild+2,0))) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} +%} + +%typemap(in,fragment="AVToXMLTree") (CPLXMLNode* xmlnode ) +{ + /* %typemap(in) (CPLXMLNode* xmlnode ) */ + if ( ! (SvROK($input) && (SvTYPE(SvRV($input))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV($input)); + $1 = AVToXMLTree( av ); + if ( !$1 ) SWIG_fail; +} +%typemap(freearg) (CPLXMLNode *xmlnode) +{ + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + if ( $1 ) CPLDestroyXMLNode( $1 ); +} + +%fragment("XMLTreeToAV","header") %{ +/************************************************************************/ +/* XMLTreeToAV() */ +/************************************************************************/ +static AV *XMLTreeToAV( CPLXMLNode *psTree ) +{ + AV *av; + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + av = (AV*)sv_2mortal((SV*)newAV()); + + av_store(av,0,newSViv((int) psTree->eType)); + av_store(av,1,newSVpv(psTree->pszValue, strlen(psTree->pszValue))); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + av_store(av, iChild, newRV_noinc((SV*)(XMLTreeToAV( psChild ))) ); + } + + return av; +} +%} + +%typemap(out,fragment="XMLTreeToAV") (CPLXMLNode*) +{ + /* %typemap(out) (CPLXMLNode*) */ + $result = newRV_noinc((SV*)XMLTreeToAV( $1 )); + argvi++; +} +%typemap(ret) (CPLXMLNode*) +{ + /* %typemap(ret) (CPLXMLNode*) */ + if ( $1 ) CPLDestroyXMLNode( $1 ); +} diff --git a/Utilities/GDAL/swig/include/php/gdal_php.i b/Utilities/GDAL/swig/include/php/gdal_php.i new file mode 100644 index 0000000000..841669dc39 --- /dev/null +++ b/Utilities/GDAL/swig/include/php/gdal_php.i @@ -0,0 +1,22 @@ +/* + * $Id: gdal_php.i,v 1.1 2005/09/02 16:19:23 kruland Exp $ + * + * php specific code for gdal bindings. + */ + +/* + * $Log: gdal_php.i,v $ + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%init %{ + if (GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } +%} + +%include typemaps_php.i diff --git a/Utilities/GDAL/swig/include/php/ogr_php.i b/Utilities/GDAL/swig/include/php/ogr_php.i new file mode 100644 index 0000000000..f72dfaadf2 --- /dev/null +++ b/Utilities/GDAL/swig/include/php/ogr_php.i @@ -0,0 +1,22 @@ +/* + * $Id: ogr_php.i,v 1.1 2005/09/02 16:19:23 kruland Exp $ + * + * php specific code for ogr bindings. + */ + +/* + * $Log: ogr_php.i,v $ + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%init %{ + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } +%} + +%include typemaps_php.i diff --git a/Utilities/GDAL/swig/include/php/typemaps_php.i b/Utilities/GDAL/swig/include/php/typemaps_php.i new file mode 100644 index 0000000000..6e1c31b197 --- /dev/null +++ b/Utilities/GDAL/swig/include/php/typemaps_php.i @@ -0,0 +1,453 @@ +/****************************************************************************** + * $Id: typemaps_php.i,v 1.7 2005/10/11 14:11:43 kruland Exp $ + * + * Name: typemaps_php.i + * Project: GDAL PHP Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * +*/ + +/* + * Include the typemaps from swig library for returning of + * standard types through arguments. + */ +%include "typemaps.i" + +%apply (double *OUTPUT) { double *argout }; + +/* + * double *val, int*hasval, is a special contrived typemap used for + * the RasterBand GetNoDataValue, GetMinimum, GetMaximum, GetOffset, GetScale methods. + * In the python bindings, the variable hasval is tested. If it is 0 (is, the value + * is not set in the raster band) then Py_None is returned. If is is != 0, then + * the value is coerced into a long and returned. + */ +%typemap(in,numinputs=0) (double *val, int*hasval) ( double tmpval, int tmphasval ) { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + $1 = &tmpval; + $2 = &tmphasval; +} +%typemap(argout) (double *val, int*hasval) { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*$2 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *$1 ); + } +} + +/* + * + * Define a simple return code typemap which checks if the return code from + * the wrapped method is non-zero. If non-zero, return None. Otherwise, + * return any argout or None. + * + * Applied like this: + * %apply (IF_ERR_RETURN_NONE) {CPLErr}; + * CPLErr function_to_wrap( ); + * %clear (CPLErr); + */ +%typemap(out) IF_FALSE_RETURN_NONE +{ + /* %typemap(out) IF_FALSE_RETURN_NONE */ + RETVAL_NULL(); +} +%typemap(ret) IF_FALSE_RETURN_NONE +{ + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + RETVAL_NULL(); +} + +/* + * Another output typemap which will raise an + * exception on error. If there is no error, + * and no other argout typemaps create a return value, + * then it will return 0. + */ +%fragment("OGRErrMessages","header") %{ +static char * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error 0: None"; + case 1: + return "OGR Error 1: Not enough data"; + case 2: + return "OGR Error 2: Unsupported geometry type"; + case 3: + return "OGR Error 3: Unsupported operation"; + case 4: + return "OGR Error 4: Corrupt data"; + case 5: + return "OGR Error 5: General Error"; + case 6: + return "OGR Error 6: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} +%} +%typemap(out) OGRErr +{ + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } +} +%typemap(ret,fragment="OGRErrMessages") OGRErr +{ + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); +} + +%fragment("CreateTupleFromDoubleArray","header") %{ + zval * + CreateTupleFromDoubleArray( double *first, unsigned int size ) { + zval *tmp; + MAKE_STD_ZVAL(tmp); + array_init(tmp); + for( unsigned int i=0; i<size; i++ ) { + add_next_index_double( tmp, *first ); + ++first; + } + return tmp; + } +%} + +%typemap(in,numinputs=0) ( double argout[ANY]) (double argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double argout[ANY]) */ + $1 = argout; +} +%typemap(argout,fragment="CreateTupleFromDoubleArray,t_output_helper") ( double argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( $1, $dim0 ); + t_output_helper( &$result, t ); +} +%typemap(in,numinputs=0) ( double *argout[ANY]) (double *argout) +{ + /* %typemap(in,numinputs=0) (double *argout[ANY]) */ + $1 = &argout; +} +%typemap(argout,fragment="CreateTupleFromDoubleArray,t_output_helper") ( double *argout[ANY]) +{ + /* %typemap(argout) (double *argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( *$1, $dim0 ); + t_output_helper( &$result, t); +} +%typemap(freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*$1); +} +%typemap(in) (double argin[ANY]) (double argin[$dim0]) +{ + /* %typemap(in) (double argin[ANY]) */ + $1 = argin; + for (unsigned int i=0; i<$dim0; i++) { + double val = 0.0; /* extract val from i-th position of $input */ + $1[i] = val; + } +} + +/* + * Typemap for counted arrays of ints <- PySequence + */ +%typemap(in,numinputs=1) (int nList, int* pList) +{ + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + zend_error(E_ERROR,"Typemap (in,numinputs=1) (int nList, int*pList) not properly defined"); + /* check if is List */ +// if ( !PySequence_Check($input) ) { +// PyErr_SetString(PyExc_TypeError, "not a sequence"); +// SWIG_fail; +// } +// $1 = PySequence_Size($input); +// $2 = (int*) malloc($1*sizeof(int)); +// for( int i = 0; i<$1; i++ ) { +// PyObject *o = PySequence_GetItem($input,i); +// if ( !PyArg_Parse(o,"i",&$2[i]) ) { +// SWIG_fail; +// } +// } +} +%typemap(freearg) (int nList, int* pList) +{ + /* %typemap(freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} + +/* + * Typemap for buffers with length <-> PyStrings + * Used in Band::ReadRaster() and Band::WriteRaster() + * + * This typemap has a typecheck also since the WriteRaster() + * methods are overloaded. + */ +%typemap(in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen = 0, char *pBuf = 0 ) +{ + /* %typemap(in,numinputs=0) (int *nLen, char **pBuf ) */ + $1 = &nLen; + $2 = &pBuf; +} +%typemap(argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + ZVAL_STRINGL( $result, *$2, *$1, 1 ); +} +%typemap(freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *$1 ) { + free( *$2 ); + } +} +%typemap(in,numinputs=1) (int nLen, char *pBuf ) +{ + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + convert_to_string_ex($input); + $2 = Z_STRVAL_PP($input); + $1 = Z_STRLEN_PP($input); +} +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) + (int nLen, char *pBuf) +{ + /* %typecheck(SWIG_TYPECHECK_POINTER) (int nLen, char *pBuf) */ + $1 = ($input)->type == IS_STRING; +} + +/* + * Typemap argout of GDAL_GCP* used in Dataset::GetGCPs( ) + */ +%typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) (int nGCPs=0, GDAL_GCP *pGCPs=0 ) +{ + /* %typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + $1 = &nGCPs; + $2 = &pGCPs; +} +%typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) +{ + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + zval *out; + MAKE_STD_ZVAL(out); + array_init(out); + for( int i = 0; i < *$1; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*$2)[i].dfGCPX, + (*$2)[i].dfGCPY, + (*$2)[i].dfGCPZ, + (*$2)[i].dfGCPPixel, + (*$2)[i].dfGCPLine, + (*$2)[i].pszInfo, + (*$2)[i].pszId ); + zval *t; + MAKE_STD_ZVAL(t); + SWIG_SetPointerZval(t,(void*)o,SWIGTYPE_p_GDAL_GCP,1); + add_next_index_zval(out,t); + } + $result = out; + zval_copy_ctor($result); +} +%typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) ( GDAL_GCP *tmpGCPList ) +{ + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ +} +%typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) +{ + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if ($2) { + free( (void*) $2 ); + } +} + +/* + * Typemap for GDALColorEntry* <-> tuple + */ +%typemap(out) GDALColorEntry* +{ + /* %typemap(out) GDALColorEntry* */ + array_init($result); + add_next_index_long($result,(*$1).c1); + add_next_index_long($result,(*$1).c2); + add_next_index_long($result,(*$1).c3); + add_next_index_long($result,(*$1).c4); +} + +%typemap(in) GDALColorEntry* +{ + /* %typemap(in) GDALColorEntry* */ + GDALColorEntry ce = {255,255,255,255}; + // Need to parse the array values from $input + $1 = &ce; +} + +/* + * Typemap char ** -> dict + */ +%typemap(out) char **dict +{ + /* %typemap(out) char **dict */ + char **stringarray = $1; + array_init($result); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + add_assoc_string($result,keyptr,(char*)valptr,1); + CPLFree( keyptr ); + } + stringarray++; + } + } +} + +/* + * Typemap char **<- dict. This typemap actually supports lists as well, + * Then each entry in the list must be a string and have the form: + * "name=value" so gdal can handle it. + */ +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) +{ + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + $1 = 0; //(PyMapping_Check($input) || PySequence_Check($input) ) ? 1 : 0; +} +%typemap(in) char **dict +{ + /* %typemap(in) char **dict */ + zend_error(E_ERROR,"Typemap (in) char **dict not properly defined"); +/* if ( PySequence_Check( $input ) ) { + int size = PySequence_Size($input); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem($input,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + $1 = CSLAddString( $1, pszItem ); + } + } +*/ +} +%typemap(freearg) char **dict +{ + /* %typemap(freearg) char **dict */ + CSLDestroy( $1 ); +} + +/* + * Typemap maps char** arguments from Python Sequence Object + */ +%typemap(in) char **options +{ + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size($input); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem($input,i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // $1 = CSLAddString( $1, pszItem ); + // } +} +%typemap(freearg) char **options +{ + /* %typemap(freearg) char **options */ + CSLDestroy( $1 ); +} +%typemap(out) char **options +{ + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = $1; + if ( stringarray == NULL ) { + RETVAL_NULL(); + } + else { + int len = CSLCount( stringarray ); + array_init($result); + for ( int i = 0; i < len; ++i, ++stringarray ) { + add_next_index_string( $result, *stringarray, 1 ); + } + } +} + +/* + * Typemaps map mutable char ** arguments from PyStrings. Does not + * return the modified argument + */ +%typemap(in) (char **ignorechange) ( char *val ) +{ + /* %typemap(in) (char **ignorechange) */ + convert_to_string_ex( $input ); + $1 = NULL; +} + +/* + * Typemap for char **argout. + */ +%typemap(in,numinputs=0) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in,numinputs=0) (char **argout) */ + $1 = &argout; +} +%typemap(argout,fragment="t_output_helper") (char **argout) +{ + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( $1 ) { + ZVAL_STRING(t,*$1,strlen(*$1)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&$result, t); +} +%typemap(freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + if ( *$1 ) + CPLFree( *$1 ); +} + +%typemap(in) (int *optional_int) ( $*1_ltype val ) +{ + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*$input) ) { + $1 = 0; + } + convert_to_long_ex($input); + val = ($*1_ltype) Z_LVAL_PP( $input ); + $1 = &val; +} +%typemap(typecheck,precedence=0) (int *optional_int) +{ + /* %typemap(typecheck,precedence=0) (int *optional_int) */ + $1 = (($input->type == IS_NONE) || $input->type == IS_LONG ) ? 1 : 0; +} + +/* + * Typedef const char * <- Any object. + * + * Formats the object using str and returns the string representation + */ + +%typemap(in) (tostring argin) +{ + /* %typemap(in) (tostring argin) */ + convert_to_string_ex($input); + $1 = Z_STRVAL_PP( $input ); +} +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) +{ + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + $1 = 1; +} + diff --git a/Utilities/GDAL/swig/include/python/gdal_python.i b/Utilities/GDAL/swig/include/python/gdal_python.i new file mode 100644 index 0000000000..e3e39c422e --- /dev/null +++ b/Utilities/GDAL/swig/include/python/gdal_python.i @@ -0,0 +1,136 @@ +/* + * $Id: gdal_python.i,v 1.4 2005/09/30 20:19:19 kruland Exp $ + * + * python specific code for gdal bindings. + */ + +/* + * $Log: gdal_python.i,v $ + * Revision 1.4 2005/09/30 20:19:19 kruland + * Moved cpl_exceptions.i code into gdal_python so the other languages can + * have a common mechanism. + * + * Revision 1.3 2005/09/13 03:05:05 kruland + * Exception generation code was moved to the cpl_exceptions.i file. + * + * Revision 1.2 2005/09/02 21:42:42 kruland + * The compactdefaultargs feature should be turned on for all bindings not just + * python. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%feature("autodoc"); + +%init %{ + /* gdal_python.i %init code */ + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } +%} + +%pythoncode %{ + from gdalconst import * +%} + +/* + * This was the cpl_exceptions.i code. But since python is the only one + * different (should support old method as well as new one) + * it was moved into this file. + */ +%{ +int bUseExceptions=0; + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} +%} + +%inline %{ +void UseExceptions() { + bUseExceptions = 1; + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + bUseExceptions = 0; + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} +%} + +%include exception.i + +%exception { + CPLErrorReset(); + $action + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } +} + + +%extend GDAL_GCP { +%pythoncode { + def __str__(self): + str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\ + % (self.Id, self.GCPPixel, self.GCPLine, + self.GCPX, self.GCPY, self.GCPZ, self.Info ) + return str + def serialize(self,with_Z=0): + base = [CXT_Element,'GCP'] + base.append([CXT_Attribute,'Id',[CXT_Text,self.Id]]) + pixval = '%0.15E' % self.GCPPixel + lineval = '%0.15E' % self.GCPLine + xval = '%0.15E' % self.GCPX + yval = '%0.15E' % self.GCPY + zval = '%0.15E' % self.GCPZ + base.append([CXT_Attribute,'Pixel',[CXT_Text,pixval]]) + base.append([CXT_Attribute,'Line',[CXT_Text,lineval]]) + base.append([CXT_Attribute,'X',[CXT_Text,xval]]) + base.append([CXT_Attribute,'Y',[CXT_Text,yval]]) + if with_Z: + base.append([CXT_Attribute,'Z',[CXT_Text,zval]]) + return base +} /* pythoncode */ +} + +%extend GDALRasterBandShadow { +%pythoncode { + def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None, + buf_xsize=None, buf_ysize=None, buf_obj=None): + import gdalnumeric + + return gdalnumeric.BandReadAsArray( self, xoff, yoff, + win_xsize, win_ysize, + buf_xsize, buf_ysize, buf_obj ) + + def WriteArray(self, array, xoff=0, yoff=0): + import gdalnumeric + + return gdalnumeric.BandWriteArray( self, array, xoff, yoff ) + +} +} + +%extend GDALMajorObjectShadow { +%pythoncode { + def GetMetadata( self, domain = '' ): + if domain[:4] == 'xml:': + return self.GetMetadata_List( domain ) + return self.GetMetadata_Dict( domain ) +} +} + +%import typemaps_python.i diff --git a/Utilities/GDAL/swig/include/python/ogr_python.i b/Utilities/GDAL/swig/include/python/ogr_python.i new file mode 100644 index 0000000000..bb38d20ffe --- /dev/null +++ b/Utilities/GDAL/swig/include/python/ogr_python.i @@ -0,0 +1,248 @@ +/* + * $Id: ogr_python.i,v 1.3 2005/10/16 20:39:56 hobu Exp $ + * + * python specific code for ogr bindings. + */ + +/* + * $Log: ogr_python.i,v $ + * Revision 1.3 2005/10/16 20:39:56 hobu + * fix a typo + * + * Revision 1.2 2005/09/06 01:51:42 kruland + * Removed GetDriverByName, GetDriver, Open, OpenShared because they are defined + * in ogr now. + * Removed %feature("compactdefaultargs") because it's defined in ogr.i now. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%feature("autodoc"); + +%init %{ + + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + +%} + +%rename (GetDriverCount) OGRGetDriverCount; +%rename (GetOpenDSCount) OGRGetOpenDSCount; +%rename (SetGenerate_DB2_V72_BYTE_ORDER) OGRSetGenerate_DB2_V72_BYTE_ORDER; +%rename (RegisterAll) OGRRegisterAll(); + +%extend OGRDataSourceShadow { + %pythoncode { + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def Release(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def Reference(self): + "For backwards compatibility only." + pass + + def Dereference(self): + "For backwards compatibility only." + pass + + def __len__(self): + """Returns the number of layers on the datasource""" + return self.GetLayerCount() + + def __getitem__(self, value): + """Support dictionary, list, and slice -like access to the datasource. +ds[0] would return the first layer on the datasource. +ds['aname'] would return the layer named "aname". +ds[0:4] would return a list of the first four layers.""" + import types + if isinstance(value, types.SliceType): + output = [] + for i in xrange(value.start,value.stop,step=value.step): + try: + output.append(self.GetLayer(i)) + except OGRError: #we're done because we're off the end + return output + return output + if isinstance(value, types.IntType): + if value > len(self)-1: + raise IndexError + return self.GetLayer(value) + elif isinstance(value,types.StringType): + return self.GetLayer(value) + else: + raise TypeError, 'Input %s is not of String or Int type' % type(value) + + def GetLayer(self,iLayer=0): + """Return the layer given an index or a name""" + import types + if isinstance(iLayer, types.StringType): + return self.GetLayerByName(iLayer) + elif isinstance(iLayer, types.IntType): + return self.GetLayerByIndex(iLayer) + else: + raise TypeError, "Input %s is not of String or Int type" % type(iLayer) +} +} + +%extend OGRLayerShadow { + %pythoncode { + def Reference(self): + "For backwards compatibility only." + pass + + def Dereference(self): + "For backwards compatibility only." + pass + + def __len__(self): + """Returns the number of features in the layer""" + return self.GetFeatureCount() + + def __getitem__(self, value): + """Support list and slice -like access to the layer. +layer[0] would return the first feature on the layer. +layer[0:4] would return a list of the first four features.""" + if isinstance(value, types.SliceType): + output = [] + if value.stop == sys.maxint: + #for an unending slice, sys.maxint is used + #We need to stop before that or GDAL will write an + ##error to stdout + stop = len(self) - 1 + else: + stop = value.stop + for i in xrange(value.start,stop,step=value.step): + feature = self.GetFeature(i) + if feature: + output.append(feature) + else: + return output + return output + if isinstance(value, types.IntType): + if value > len(self)-1: + raise IndexError + return self.GetFeature(value) + else: + raise TypeError,"Input %s is not of IntType or SliceType" % type(value) + + def CreateFields(fields): + """Create a list of fields on the Layer""" + for i in fields: + self.CreateField(i) + + def __iter__(self): + return self + + def next(self): + feature = self.GetNextFeature() + if not feature: + raise StopIteration + else: + return feature + } + +} + +%extend OGRFeatureShadow { + %pythoncode { + def Reference(self): + pass + + def Dereference(self): + pass + + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def __cmp__(self, other): + """Compares a feature to another for equality""" + return self.Equal(other) + + def __copy__(self): + return self.Clone() + + def __getattr__(self, name): + """Returns the values of fields by the given name""" + try: + names = [] + for i in range(self.GetFieldCount()): + names.append(self.GetFieldDefnRef_ByID(i).GetName()) + if name in names: + return self.GetField(name) + else: + raise + except: + raise AttributeError, name + def GetField(self, fld_index): + import types + if isinstance(fld_index, types.StringType): + fld_index = self.GetFieldIndex(fld_index) + if (fld_index < 0) or (fld_index > self.GetFieldCount()): + raise ValueError, "Illegal field requested in GetField()" + if not (self.IsFieldSet(fld_index)): + return None + fld_type = self.GetFieldType(fld_index) + if fld_type == OFTInteger: + return self.GetFieldAsInteger(fld_index) + if fld_type == OFTReal: + return self.GetFieldAsDouble(fld_index) + if fld_type == OFTString: + return self.GetFieldAsString(fld_index) + +} + +} + +%extend OGRGeometryShadow { +%pythoncode { + def Destroy(self): + self.__del__() + self.thisown = 0 + + def __str__(self): + return self.ExportToWkt() +} +} + +%extend OGRFieldDefnShadow { +%pythoncode { + width = property(GetWidth, SetWidth) + type = property(GetType, SetType) + precision = property(GetPrecision, SetPrecision) + name = property(GetName, SetName) + justify = property(GetJustify, SetJustify) +} +} + +%extend OGRFeatureDefnShadow { +%pythoncode { + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 +} +} + +%extend OGRFieldDefnShadow { +%pythoncode { + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 +} +} + +%import typemaps_python.i diff --git a/Utilities/GDAL/swig/include/python/osr_python.i b/Utilities/GDAL/swig/include/python/osr_python.i new file mode 100644 index 0000000000..9de8f4d8a4 --- /dev/null +++ b/Utilities/GDAL/swig/include/python/osr_python.i @@ -0,0 +1,82 @@ +/* + * $Id: osr_python.i,v 1.2 2005/09/02 21:42:42 kruland Exp $ + * + * python specific code for ogr bindings. + */ + +/* + * $Log: osr_python.i,v $ + * Revision 1.2 2005/09/02 21:42:42 kruland + * The compactdefaultargs feature should be turned on for all bindings not just + * python. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +%feature("autodoc"); + +%{ +static PyObject * +py_OPTGetProjectionMethods(PyObject *self, PyObject *args) { + + PyObject *py_MList; + char **papszMethods; + int iMethod; + + self = self; + args = args; + + papszMethods = OPTGetProjectionMethods(); + py_MList = PyList_New(CSLCount(papszMethods)); + + for( iMethod = 0; papszMethods[iMethod] != NULL; iMethod++ ) + { + char *pszUserMethodName; + char **papszParameters; + PyObject *py_PList; + int iParam; + + papszParameters = OPTGetParameterList( papszMethods[iMethod], + &pszUserMethodName ); + if( papszParameters == NULL ) + return NULL; + + py_PList = PyList_New(CSLCount(papszParameters)); + for( iParam = 0; papszParameters[iParam] != NULL; iParam++ ) + { + char *pszType; + char *pszUserParamName; + double dfDefault; + + OPTGetParameterInfo( papszMethods[iMethod], + papszParameters[iParam], + &pszUserParamName, + &pszType, &dfDefault ); + PyList_SetItem(py_PList, iParam, + Py_BuildValue("(sssd)", + papszParameters[iParam], + pszUserParamName, + pszType, dfDefault )); + } + + CSLDestroy( papszParameters ); + + PyList_SetItem(py_MList, iMethod, + Py_BuildValue("(ssO)", + papszMethods[iMethod], + pszUserMethodName, + py_PList)); + } + + CSLDestroy( papszMethods ); + + return py_MList; +} +%} +%native(GetProjectionMethods) py_OPTGetProjectionMethods; + +%include typemaps_python.i diff --git a/Utilities/GDAL/swig/include/python/typemaps_python.i b/Utilities/GDAL/swig/include/python/typemaps_python.i new file mode 100644 index 0000000000..73ddae3c2e --- /dev/null +++ b/Utilities/GDAL/swig/include/python/typemaps_python.i @@ -0,0 +1,844 @@ +/****************************************************************************** + * $Id: typemaps_python.i,v 1.43 2005/10/11 15:20:28 kruland Exp $ + * + * Name: typemaps_python.i + * Project: GDAL Python Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Kevin Ruland, kruland@ku.edu + * + + * + * $Log: typemaps_python.i,v $ + * Revision 1.43 2005/10/11 15:20:28 kruland + * Removed the unused IF_ERROR_RETURN_NONE typemap. + * Removed the unnecessary $result=0 from typemaps. These lines were to correct + * a bug in SWIG versions <= 1.3.24. + * + * Revision 1.42 2005/10/11 14:11:43 kruland + * Fix memory bug in typemap(out) char **options. The returned array of strings + * is owned by the dataset. + * + * Revision 1.41 2005/10/03 20:13:33 kruland + * Clean up the CPLErr typemap to account for the new-er %exception code. + * + * Revision 1.40 2005/09/29 14:02:23 kruland + * Fixed memcpy in %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs) + * + * Revision 1.39 2005/09/13 02:58:41 kruland + * Use the ogr_error_map.i include file. + * + * Revision 1.38 2005/09/13 02:10:19 kruland + * Make fixes to the in ColorMap typemap. Possible problems by using + * references to temporaries. + * + * Revision 1.37 2005/09/02 15:24:38 kruland + * Remove old and confusing comment which is no longer required. + * + * Revision 1.36 2005/08/08 17:07:16 kruland + * Added python typemaps for CPLXMLNode* in and return for the ParseXMLString + * and SerializeXMLTree methods. + * + * Revision 1.35 2005/08/06 20:51:58 kruland + * Instead of using double_## defines and SWIG macros, use typemaps with + * [ANY] specified and use $dim0 to extract the dimension. This makes the + * code quite a bit more readable. + * + * Revision 1.34 2005/08/04 20:47:24 kruland + * Added a new binding to support RasterBand::GetNoDataValue(), GetMaximum(), GetMinimum(), + * GetOffset(), GetScale() returning None when the attribute is not set. + * + * Revision 1.33 2005/07/15 20:28:16 kruland + * It seems that in Python 2.3 (maybe 2.4 as well), sequence objects (lists) are also + * mapping objects (dicts). Fortunately, dicts are not lists. So, in the in char **dict + * typemap, we need to first test if the arg is a sequence then test for mapping. + * + * Revision 1.32 2005/07/15 19:01:45 kruland + * Typemap out char **options needs to return a list instead of tuple to satisfy + * the gdalautotests. + * + * Revision 1.31 2005/07/15 18:34:59 kruland + * Revised the char **<-dict in mapping. It now allows either dictionaries, + * or sequences of strings. Added a typecheck so overloading works. This + * typemap is only used in SetMetadata. + * + * Revision 1.30 2005/07/15 17:08:00 kruland + * - Initialize the local pointer variables in + * (in,numinputs=0)(int *nLen,char**pBuf) argout typemap. + * - Fix the freearg typemap for int *nLen,char **pBuf. + * - Initialize the local pointer variables in + * (in,numinputs=0)(int*nGCPs, GDAL_GCP*pGCPs) argout typemap. + * - Fix the ret CPLErr typemap for the not using exceptions case. + * The use exception case is probably still broken. + * + * Revision 1.29 2005/07/15 15:08:19 kruland + * - Use the method SWIG_ConvertPtr instead of the #define'd name + * SWIG_Python_ConvertPtr. The other name is available in older versions of swig. + * - Use PyInt_FromLong instead of SWIG_From_int. + * - In all the typemaps which use t_output_helper, implement code which forces + * initialization of $result to 0 at the beginning of the wrapper. + * + * Revision 1.28 2005/06/22 18:46:22 kruland + * Be consistant about using 'python' in %typemap decls. + * Removed references to 'python' in the %typemap comment strings to improve greps. + * Use $result instead of resultobj. + * Renamed type for OGRErr out typemap to OGRErr instead of THROW_OGR_ERROR. + * First cut at CPLErr out typemap which uses the bUseExceptions flag. + * + * Revision 1.27 2005/02/24 18:37:20 kruland + * Moved the c# typemaps to its own file. + * + * Revision 1.26 2005/02/24 17:35:15 hobu + * add the python name to the THROW_OGR_ERROR typemap + * + * Revision 1.25 2005/02/24 16:36:31 kruland + * Added IF_FALSE_RETURN_NONE typemap for GCPsToGeoTransform method. + * Changed GCPs typemaps to use new object rather than raw tuple. + * Added out typemap for char **s. Currently used in osr.GetProjectionMethods. + * + * Revision 1.24 2005/02/24 16:13:57 hobu + * freearg patch for tostring argin typemap + * Added dummy typemaps (just copied the python ones) + * for the typemaps used in OGR for C# + * + * Revision 1.23 2005/02/23 21:01:10 hobu + * swap the decref with the asstring in the + * tostring argin typemap + * + * Revision 1.22 2005/02/23 17:45:35 kruland + * Change the optional_int macro to perform a cast to support the integer + * typedefs such as GDALDataType. + * + * Revision 1.21 2005/02/22 15:36:17 kruland + * Added ARRAY_TYPEMAP(4) for ogr.Geometry.GetEnvelope(). + * Added a char* typemap (tostring argin), which calls str() on its argument + * to coerce into a string representation. + * + * Revision 1.20 2005/02/21 19:03:17 kruland + * Use Py_XDECREF() in the argout buffer typemap. + * Added a convienence fragment for constructing python sequences from integer + * arrays. + * + * Revision 1.19 2005/02/20 19:43:33 kruland + * Implement another argout typemap for fixed length double arrays. + * + * Revision 1.18 2005/02/18 19:34:08 hobu + * typo in OGRErrMessages + * + * Revision 1.17 2005/02/18 17:59:20 kruland + * Added nicely worded OGR exception mapping mechanism. + * + * Revision 1.16 2005/02/18 17:28:07 kruland + * Fixed bugs in THROW_OGR_ERROR typemap. When no error is found, and no + * argouts, return None. + * Fixed bug in IF_ERR_RETURN_NONE typemap to return None if there are no + * argouts to return. + * + * Revision 1.15 2005/02/18 16:54:35 kruland + * Removed IGNORE_RC exception macro. + * Removed fragments.i %include because it's not included in swig 1.3.24. + * Defined out typemap IF_ERR_RETURN_NONE. + * Defined out typemap THROW_OGR_ERROR. (untested). + * + * Revision 1.14 2005/02/17 21:14:48 kruland + * Use swig library's typemaps.i and fragments.i to support returning + * multiple argument values as a tuple. Use this in all the custom + * argout typemaps. + * + * Revision 1.13 2005/02/17 17:27:13 kruland + * Changed the handling of fixed size double arrays to make it fit more + * naturally with GDAL/OSR usage. Declare as typedef double * double_17; + * If used as return argument use: function ( ... double_17 argout ... ); + * If used as value argument use: function (... double_17 argin ... ); + * + * Revision 1.12 2005/02/17 03:42:10 kruland + * Added macro to define typemaps for optional arguments to functions. + * The optional argument must be coded as a pointer in the function decl. + * The function must properly interpret a null pointer as default. + * + * Revision 1.11 2005/02/16 17:49:40 kruland + * Added in typemap for Lists of GCPs. + * Added 'python' to all the freearg typemaps too. + * + * Revision 1.10 2005/02/16 17:18:03 hobu + * put "python" name on the typemaps that are specific + * to python + * + * Revision 1.9 2005/02/16 16:53:45 kruland + * Minor comment change. + * + * Revision 1.8 2005/02/15 20:53:11 kruland + * Added typemap(in) char ** from PyString which allows the pointer (to char*) + * to change but assumes the contents do not change. + * + * Revision 1.7 2005/02/15 19:49:42 kruland + * Added typemaps for arbitrary char* buffers with length. + * + * Revision 1.6 2005/02/15 17:05:13 kruland + * Use CPLParseNameValue instead of strchr() in typemap(out) char **dict. + * + * Revision 1.5 2005/02/15 16:52:41 kruland + * Added a swig macro for handling fixed length double array arguments. Used + * for Band::ComputeMinMax( double[2] ), and Dataset::?etGeoTransform() methods. + * + * Revision 1.4 2005/02/15 06:00:28 kruland + * Fixed critical bug in %typemap(in) std::vector<double>. Used incorrect python + * parse call. + * Removed some stray cout's. + * Gave the "argument" to the %typemap(out) char** mapping. This makes it easier + * to control its application. + * + * Revision 1.3 2005/02/14 23:56:02 hobu + * Added log info and C99-style comments + * + * +*/ + +/* + * The typemaps defined here use the code fragment called: + * t_out_helper which is defined in the pytuplehlp.swg file. + * The *.swg library files are considered "swig internal". + * fortunately, pytuplehlp.swg is included by typemaps.i + * which we need anyway. + */ + +/* + * Include the typemaps from swig library for returning of + * standard types through arguments. + */ +%include "typemaps.i" + +%apply (double *OUTPUT) { double *argout }; + +/* + * double *val, int*hasval, is a special contrived typemap used for + * the RasterBand GetNoDataValue, GetMinimum, GetMaximum, GetOffset, GetScale methods. + * In the python bindings, the variable hasval is tested. If it is 0 (is, the value + * is not set in the raster band) then Py_None is returned. If is is != 0, then + * the value is coerced into a long and returned. + */ +%typemap(python,in,numinputs=0) (double *val, int*hasval) ( double tmpval, int tmphasval ) { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + $1 = &tmpval; + $2 = &tmphasval; +} +%typemap(python,argout) (double *val, int*hasval) { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*$2 ) { + Py_INCREF(Py_None); + r = Py_None; + $result = t_output_helper($result,r); + } + else { + r = PyFloat_FromDouble( *$1 ); + $result = t_output_helper($result,r); + } +} + +/* + * + * Define a simple return code typemap which checks if the return code from + * the wrapped method is non-zero. If zero, return None. Otherwise, + * return any argout or None. + * + * Applied like this: + * %apply (IF_FALSE_RETURN_NONE) {int}; + * int function_to_wrap( ); + * %clear (int); + */ +/* + * The out typemap prevents the default typemap for output integers from + * applying. + */ +%typemap(python,out) IF_FALSE_RETURN_NONE "/*%typemap(out) IF_FALSE_RETURN_NONE */" +%typemap(python,ret) IF_FALSE_RETURN_NONE +{ + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + if ($1 == 0 ) { + Py_XDECREF( $result ); + $result = Py_None; + Py_INCREF($result); + } + if ($result == 0) { + $result = Py_None; + Py_INCREF($result); + } +} + +%import "ogr_error_map.i" + +%typemap(python, out,fragment="OGRErrMessages") OGRErr +{ + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } +} +%typemap(python, ret) OGRErr +{ + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } +} + +%fragment("CreateTupleFromDoubleArray","header") %{ +static PyObject * +CreateTupleFromDoubleArray( double *first, unsigned int size ) { + PyObject *out = PyTuple_New( size ); + for( unsigned int i=0; i<size; i++ ) { + PyObject *val = PyFloat_FromDouble( *first ); + ++first; + PyTuple_SetItem( out, i, val ); + } + return out; +} +%} + +%typemap(python,in,numinputs=0) ( double argout[ANY]) (double argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double argout[ANY]) */ + $1 = argout; +} +%typemap(python,argout,fragment="t_output_helper,CreateTupleFromDoubleArray") ( double argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( $1, $dim0 ); + $result = t_output_helper($result,out); +} + +%typemap(python,in,numinputs=0) ( double *argout[ANY]) (double *argout) +{ + /* %typemap(in,numinputs=0) (double *argout[ANY]) */ + $1 = &argout; +} +%typemap(python,argout,fragment="t_output_helper,CreateTupleFromDoubleArray") ( double *argout[ANY]) +{ + /* %typemap(argout) (double *argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( *$1, $dim0 ); + $result = t_output_helper($result,out); +} +%typemap(python,freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*$1); +} +%typemap(python,in) (double argin[ANY]) (double argin[$dim0]) +{ + /* %typemap(in) (double argin[ANY]) */ + $1 = argin; + if (! PySequence_Check($input) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + int seq_size = PySequence_Size($input); + if ( seq_size != $dim0 ) { + PyErr_SetString(PyExc_TypeError, "sequence must have length ##size"); + SWIG_fail; + } + for (unsigned int i=0; i<$dim0; i++) { + PyObject *o = PySequence_GetItem($input,i); + double val; + PyArg_Parse(o, "d", &val ); + $1[i] = val; + } +} + +/* + * Typemap for counted arrays of ints <- PySequence + */ +%typemap(python,in,numinputs=1) (int nList, int* pList) +{ + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + /* check if is List */ + if ( !PySequence_Check($input) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + $1 = PySequence_Size($input); + $2 = (int*) malloc($1*sizeof(int)); + for( int i = 0; i<$1; i++ ) { + PyObject *o = PySequence_GetItem($input,i); + if ( !PyArg_Parse(o,"i",&$2[i]) ) { + SWIG_fail; + } + } +} +%typemap(python,freearg) (int nList, int* pList) +{ + /* %typemap(freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} +%fragment("CreateTupleFromIntegerArray","header") %{ +static PyObject * +CreateTupleFromDoubleArray( int *first, unsigned int size ) { + PyObject *out = PyTuple_New( size ); + for( unsigned int i=0; i<size; i++ ) { + PyObject *val = PyInt_FromInt( *first ); + ++first; + PyTuple_SetItem( out, i, val ); + } + return out; +} +%} + +/* + * Typemap for buffers with length <-> PyStrings + * Used in Band::ReadRaster() and Band::WriteRaster() + * + * This typemap has a typecheck also since the WriteRaster() + * methods are overloaded. + */ +%typemap(python,in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen = 0, char *pBuf = 0 ) +{ + /* %typemap(in,numinputs=0) (int *nLen, char **pBuf ) */ + $1 = &nLen; + $2 = &pBuf; +} +%typemap(python,argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + Py_XDECREF($result); + $result = PyString_FromStringAndSize( *$2, *$1 ); +} +%typemap(python,freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *$1 ) { + free( *$2 ); + } +} +%typemap(python,in,numinputs=1) (int nLen, char *pBuf ) +{ + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + PyString_AsStringAndSize($input, &$2, &$1 ); +} +%typemap(python,typecheck,precedence=SWIG_TYPECHECK_POINTER) + (int nLen, char *pBuf) +{ + /* %typecheck(SWIG_TYPECHECK_POINTER) (int nLen, char *pBuf) */ + $1 = (PyString_Check($input)) ? 1 : 0; +} + +/* + * Typemap argout of GDAL_GCP* used in Dataset::GetGCPs( ) + */ +%typemap(python,in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) (int nGCPs=0, GDAL_GCP *pGCPs=0 ) +{ + /* %typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + $1 = &nGCPs; + $2 = &pGCPs; +} +%typemap(python,argout) (int *nGCPs, GDAL_GCP const **pGCPs ) +{ + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + PyObject *dict = PyTuple_New( *$1 ); + for( int i = 0; i < *$1; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*$2)[i].dfGCPX, + (*$2)[i].dfGCPY, + (*$2)[i].dfGCPZ, + (*$2)[i].dfGCPPixel, + (*$2)[i].dfGCPLine, + (*$2)[i].pszInfo, + (*$2)[i].pszId ); + + PyTuple_SetItem(dict, i, + SWIG_NewPointerObj((void*)o,SWIGTYPE_p_GDAL_GCP,1) ); + } + Py_DECREF($result); + $result = dict; +} +%typemap(python,in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) ( GDAL_GCP *tmpGCPList ) +{ + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + /* check if is List */ + if ( !PySequence_Check($input) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + $1 = PySequence_Size($input); + tmpGCPList = (GDAL_GCP*) malloc($1*sizeof(GDAL_GCP)); + $2 = tmpGCPList; + for( int i = 0; i<$1; i++ ) { + PyObject *o = PySequence_GetItem($input,i); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( o, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList; + } +} +%typemap(python,freearg) (int nGCPs, GDAL_GCP const *pGCPs ) +{ + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if ($2) { + free( (void*) $2 ); + } +} + +/* + * Typemap for GDALColorEntry* <-> tuple + */ +%typemap(python,out) GDALColorEntry* +{ + /* %typemap(out) GDALColorEntry* */ + $result = Py_BuildValue( "(hhhh)", (*$1).c1,(*$1).c2,(*$1).c3,(*$1).c4); +} + +%typemap(python,in) GDALColorEntry* (GDALColorEntry ce) +{ + /* %typemap(in) GDALColorEntry* */ + ce.c4 = 255; + int size = PySequence_Size($input); + if ( size > 4 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too long"); + SWIG_fail; + } + if ( size < 3 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too short"); + SWIG_fail; + } + PyArg_ParseTuple( $input,"hhh|h", &ce.c1, &ce.c2, &ce.c3, &ce.c4 ); + $1 = &ce; +} + +/* + * Typemap char ** -> dict + */ +%typemap(python,out) char **dict +{ + /* %typemap(out) char **dict */ + char **stringarray = $1; + $result = PyDict_New(); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + PyObject *nm = PyString_FromString( keyptr ); + PyObject *val = PyString_FromString( valptr ); + PyDict_SetItem($result, nm, val ); + CPLFree( keyptr ); + } + stringarray++; + } + } +} + +/* + * Typemap char **<- dict. This typemap actually supports lists as well, + * Then each entry in the list must be a string and have the form: + * "name=value" so gdal can handle it. + */ +%typemap(python,typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) +{ + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + $1 = (PyMapping_Check($input) || PySequence_Check($input) ) ? 1 : 0; +} +%typemap(python,in) char **dict +{ + /* %typemap(in) char **dict */ + $1 = NULL; + if ( PySequence_Check( $input ) ) { + int size = PySequence_Size($input); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem($input,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + $1 = CSLAddString( $1, pszItem ); + } + } + else if ( PyMapping_Check( $input ) ) { + /* We need to use the dictionary form. */ + int size = PyMapping_Length( $input ); + if ( size > 0 ) { + PyObject *item_list = PyMapping_Items( $input ); + for( int i=0; i<size; i++ ) { + PyObject *it = PySequence_GetItem( item_list, i ); + char *nm; + char *val; + PyArg_ParseTuple( it, "ss", &nm, &val ); + $1 = CSLAddNameValue( $1, nm, val ); + } + } + } + else { + PyErr_SetString(PyExc_TypeError,"Argument must be dictionary or sequence of strings"); + SWIG_fail; + } +} +%typemap(python,freearg) char **dict +{ + /* %typemap(freearg) char **dict */ + CSLDestroy( $1 ); +} + +/* + * Typemap maps char** arguments from Python Sequence Object + */ +%typemap(python,in) char **options +{ + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check($input)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size($input); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem($input,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + $1 = CSLAddString( $1, pszItem ); + } +} +%typemap(python,freearg) char **options +{ + /* %typemap(freearg) char **options */ + CSLDestroy( $1 ); +} +/* + * Typemap converts an array of strings into a list of strings + * with the assumption that the called object maintains ownership of the + * array of strings. + */ +%typemap(python,out) char **options +{ + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = $1; + if ( stringarray == NULL ) { + $result = Py_None; + Py_INCREF( $result ); + } + else { + int len = CSLCount( stringarray ); + $result = PyList_New( len ); + for ( int i = 0; i < len; ++i, ++stringarray ) { + PyObject *o = PyString_FromString( *stringarray ); + PyList_SetItem($result, i, o ); + } + } +} + +/* + * Typemaps map mutable char ** arguments from PyStrings. Does not + * return the modified argument + */ +%typemap(python,in) (char **ignorechange) ( char *val ) +{ + /* %typemap(in) (char **ignorechange) */ + PyArg_Parse( $input, "s", &val ); + $1 = &val; +} + +/* + * Typemap for char **argout. + */ +%typemap(python,in,numinputs=0) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in,numinputs=0) (char **argout) */ + $1 = &argout; +} +%typemap(python,argout,fragment="t_output_helper") (char **argout) +{ + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( $1 ) { + o = PyString_FromString( *$1 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + $result = t_output_helper($result, o); +} +%typemap(python,freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + if ( *$1 ) + CPLFree( *$1 ); +} + +/* + * Typemap for an optional POD argument. + * Declare function to take POD *. If the parameter + * is NULL then the function needs to define a default + * value. + */ +%define OPTIONAL_POD(type,argstring) +%typemap(python,in) (type *optional_##type) ( type val ) +{ + /* %typemap(in) (type *optional_##type) */ + if ( $input == Py_None ) { + $1 = 0; + } + else if ( PyArg_Parse( $input, #argstring ,&val ) ) { + $1 = ($1_type) &val; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } +} +%typemap(python,typecheck,precedence=0) (type *optional_##type) +{ + /* %typemap(typecheck,precedence=0) (type *optionalInt) */ + $1 = (($input==Py_None) || my_PyCheck_##type($input)) ? 1 : 0; +} +%enddef + +OPTIONAL_POD(int,i); + +/* + * Typedef const char * <- Any object. + * + * Formats the object using str and returns the string representation + */ + +%typemap(python,in) (tostring argin) (PyObject *str) +{ + /* %typemap(in) (tostring argin) */ + str = PyObject_Str( $input ); + if ( str == 0 ) { + PyErr_SetString( PyExc_RuntimeError, "Unable to format argument as string"); + SWIG_fail; + } + + $1 = PyString_AsString(str); +} +%typemap(python,freearg)(tostring argin) +{ + /* %typemap(freearg) (tostring argin) */ + Py_DECREF(str$argnum); +} +%typemap(python,typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) +{ + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + $1 = 1; +} + +/* + * Typemap for CPLErr. + * This typemap will use the wrapper C-variable + * int UseExceptions to determine proper behavour for + * CPLErr return codes. + * If UseExceptions ==0, then return the rc. + * If UseExceptions ==1, then if rc >= CE_Failure, raise an exception. + */ +%typemap(python,ret) CPLErr +{ + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( $result == 0 ) { + /* No other return values set so return ErrorCode */ + $result = PyInt_FromLong($1); + } + } +} + +/* + * Typemaps for minixml: CPLXMLNode* input, CPLXMLNode *ret + */ + +%fragment("PyListToXMLTree","header") %{ +/************************************************************************/ +/* PyListToXMLTree() */ +/************************************************************************/ +static CPLXMLNode *PyListToXMLTree( PyObject *pyList ) + +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = PyList_Size(pyList) - 2; + if( nChildCount < 0 ) + { + PyErr_SetString(PyExc_TypeError,"Error in input XMLTree." ); + return NULL; + } + + PyArg_Parse( PyList_GET_ITEM(pyList,0), "i", &nType ); + PyArg_Parse( PyList_GET_ITEM(pyList,1), "s", &pszText ); + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = PyListToXMLTree( PyList_GET_ITEM(pyList,iChild+2) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} +%} + +%typemap(python,in,fragment="PyListToXMLTree") (CPLXMLNode* xmlnode ) +{ + /* %typemap(python,in) (CPLXMLNode* xmlnode ) */ + $1 = PyListToXMLTree( $input ); + if ( !$1 ) SWIG_fail; +} +%typemap(python,freearg) (CPLXMLNode *xmlnode) +{ + /* %typemap(python,freearg) (CPLXMLNode *xmlnode) */ + if ( $1 ) CPLDestroyXMLNode( $1 ); +} + +%fragment("XMLTreeToPyList","header") %{ +/************************************************************************/ +/* XMLTreeToPyList() */ +/************************************************************************/ +static PyObject *XMLTreeToPyList( CPLXMLNode *psTree ) +{ + PyObject *pyList; + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + pyList = PyList_New(nChildCount+2); + + PyList_SetItem( pyList, 0, Py_BuildValue( "i", (int) psTree->eType ) ); + PyList_SetItem( pyList, 1, Py_BuildValue( "s", psTree->pszValue ) ); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + PyList_SetItem( pyList, iChild, XMLTreeToPyList( psChild ) ); + } + + return pyList; +} +%} + +%typemap(python,out,fragment="XMLTreeToPyList") (CPLXMLNode*) +{ + /* %typemap(python,out) (CPLXMLNode*) */ + $result = XMLTreeToPyList( $1 ); +} +%typemap(python,ret) (CPLXMLNode*) +{ + /* %typemap(python,ret) (CPLXMLNode*) */ + if ( $1 ) CPLDestroyXMLNode( $1 ); +} diff --git a/Utilities/GDAL/swig/include/ruby/gdal_ruby.i b/Utilities/GDAL/swig/include/ruby/gdal_ruby.i new file mode 100644 index 0000000000..2dc5972bba --- /dev/null +++ b/Utilities/GDAL/swig/include/ruby/gdal_ruby.i @@ -0,0 +1,143 @@ +/* + * $Id: gdal_ruby.i,v 1.2 2005/09/26 08:18:55 cfis Exp $ + * + * ruby specific code for gdal bindings. + */ + +/* + * $Log: gdal_ruby.i,v $ + * Revision 1.2 2005/09/26 08:18:55 cfis + * Copied over code from the Python version of gdal_ruby.i. Will have to port the code to Ruby. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + + +%init %{ + /* gdal_ruby.i %init code */ + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } +%} + +%include "cpl_exceptions.i"; + + +%header %{ + +static CPLXMLNode *RubyArrayToXMLTree(VALUE rubyArray) +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = RARRAY(rubyArray)->len - 2; + if( nChildCount < 0 ) + { + rb_raise(rb_eRuntimeError, "Error in input XMLTree, child count is less than zero."); + } + + VALUE item1 = rb_ary_entry(rubyArray, 0); + nType = NUM2INT(item1); + + VALUE item2 = rb_ary_entry(rubyArray, 1); + pszText = StringValuePtr(item2); + + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = RubyArrayToXMLTree( rb_ary_entry(rubyArray,iChild+2) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} + +static VALUE XMLTreeToRubyArray( CPLXMLNode *psTree ) +{ + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + VALUE rubyArray = rb_ary_new2(nChildCount+2); + + rb_ary_store(rubyArray, 0, INT2NUM((int) psTree->eType)); + rb_ary_store(rubyArray, 1, rb_str_new2(psTree->pszValue)); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + rb_ary_store(rubyArray, iChild, XMLTreeToRubyArray(psChild)); + } + + return rubyArray; +} +%} + + +/*%extend GDAL_GCP { +%pythoncode { + def __str__(self): + str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\ + % (self.Id, self.GCPPixel, self.GCPLine, + self.GCPX, self.GCPY, self.GCPZ, self.Info ) + return str + def serialize(self,with_Z=0): + base = [CXT_Element,'GCP'] + base.append([CXT_Attribute,'Id',[CXT_Text,self.Id]]) + pixval = '%0.15E' % self.GCPPixel + lineval = '%0.15E' % self.GCPLine + xval = '%0.15E' % self.GCPX + yval = '%0.15E' % self.GCPY + zval = '%0.15E' % self.GCPZ + base.append([CXT_Attribute,'Pixel',[CXT_Text,pixval]]) + base.append([CXT_Attribute,'Line',[CXT_Text,lineval]]) + base.append([CXT_Attribute,'X',[CXT_Text,xval]]) + base.append([CXT_Attribute,'Y',[CXT_Text,yval]]) + if with_Z: + base.append([CXT_Attribute,'Z',[CXT_Text,zval]]) + return base +} +} + +%extend GDALRasterBandShadow { +%pythoncode { + def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None, + buf_xsize=None, buf_ysize=None, buf_obj=None): + import gdalnumeric + + return gdalnumeric.BandReadAsArray( self, xoff, yoff, + win_xsize, win_ysize, + buf_xsize, buf_ysize, buf_obj ) + + def WriteArray(self, array, xoff=0, yoff=0): + import gdalnumeric + + return gdalnumeric.BandWriteArray( self, array, xoff, yoff ) + +} +} + +%extend GDALMajorObjectShadow { +%pythoncode { + def GetMetadata( self, domain = '' ): + if domain[:4] == 'xml:': + return self.GetMetadata_List( domain ) + return self.GetMetadata_Dict( domain ) +} +} +*/ + +%import typemaps_ruby.i + diff --git a/Utilities/GDAL/swig/include/ruby/ogr_ruby.i b/Utilities/GDAL/swig/include/ruby/ogr_ruby.i new file mode 100644 index 0000000000..93ce482ed5 --- /dev/null +++ b/Utilities/GDAL/swig/include/ruby/ogr_ruby.i @@ -0,0 +1,218 @@ +/* + * $Id: ogr_ruby.i,v 1.4 2006/01/17 04:42:16 cfis Exp $ + * + * ruby specific code for ogr bindings. + */ + +/* + * $Log: ogr_ruby.i,v $ + * Revision 1.4 2006/01/17 04:42:16 cfis + * Added some renames that are not covered by -autorename since they start with the text OGR. + * + * Revision 1.3 2005/09/26 08:18:21 cfis + * Moved renames to typemaps_ruby.i. Now %include typemaps_ruby.i instead of %import (we want to inline the code). + * + * Revision 1.2 2005/09/18 07:34:58 cfis + * Added support for exceptions, removed some outdated code. + * + * Revision 1.1 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + */ + +/* Include default Ruby typemaps */ +%include typemaps_ruby.i + +/* Include exception handling code */ +%include cpl_exceptions.i + +/* Setup a few renames */ +%rename(get_driver_count) OGRGetDriverCount; +%rename(get_open_dscount) OGRGetOpenDSCount; +%rename(set_generate_db2_v72_byte_order) OGRSetGenerate_DB2_V72_BYTE_ORDER; +%rename(register_all) OGRRegisterAll; + + +%init %{ + + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + + /* Setup exception handling */ + UseExceptions(); +%} + +/* Replace GetLayerByIndex and GetLayerByName by GetLayer */ +%ignore OGRDataSourceShadow::GetLayerByIndex; +%ignore OGRDataSourceShadow::GetLayerByName; + +%extend OGRDataSourceShadow { + + OGRLayerShadow *GetLayer(VALUE whichLayer) { + // get field index + switch (TYPE(whichLayer)) { + case T_STRING: { + char* name = StringValuePtr(whichLayer); + return OGR_DS_GetLayerByName(self, name); + break; + } + case T_FIXNUM: { + int index = NUM2INT(whichLayer); + return OGR_DS_GetLayer(self, index); + break; + } + default: + SWIG_exception(SWIG_TypeError, "Value must be a string or integer."); + } + } + + /* Override the way that ReleaseResultSet is handled - we + want to apply a typemap that unlinks the layer from + its underlying C++ object since this method destroys + the C++ object */ +// %typemap(freearg) OGRLayerShadow *layer { + /* %typemap(freearg) OGRLayerShadow *layer */ +// DATA_PTR(argv[0]) = 0; +// } + // void ReleaseResultSet(OGRLayerShadow *layer) { + // OGR_DS_ReleaseResultSet(self, layer); +// } +} + +/* Extend the layers class by adding support for ruby enumerable mixin. */ +%mixin OGRLayerShadow "Enumerable"; + +/* Replace GetNextFeature by each */ +%ignore OGRDataSourceShadow::GetLayerByIndex; + +%extend OGRLayerShadow { + /*~OGRLayerShadow () { + FreeResultSet(); + } + + %typemap(in) OGRDatasourceShadow *ds { + SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN); + rb_iv_set($input, "__swigtype__", self); + } + void ReleaseResultSet(OGRDatasourceShadow *ds, OGRLayerShadow *layer) { + OGR_DS_ReleaseResultSet(self, layer); + } +*/ + %newobject OGRLayerShadow::each; + void each() { + OGRFeatureShadow* feature = NULL; + + while (feature = (OGRFeatureShadow*) OGR_L_GetNextFeature(self)) + { + /* Convert the pointer to a Ruby object. Note we set the flag + to one manually to show this is a new object */ + VALUE object = SWIG_NewPointerObj((void *) feature, $descriptor(OGRFeatureShadow *), SWIG_POINTER_OWN); + + /* Now invoke the block specified for this method. */ + rb_yield(object); + } + } +} + +%extend OGRFeatureShadow { + VALUE GetField(VALUE object) { + VALUE result; + + int index; + + // get field index + switch (TYPE(object)) { + case T_STRING: + index = OGR_F_GetFieldIndex(self, StringValuePtr(object)); + break; + case T_FIXNUM: + index = NUM2INT(object); + break; + default: + SWIG_exception(SWIG_TypeError, "Value must be a string or integer."); + } + + int count = OGR_F_GetFieldCount(self); + + if (index < 0 || index > count) { + SWIG_exception(SWIG_IndexError, "Illegal field requested."); + } + + // is the field unset? + if (!OGR_F_IsFieldSet(self, index)) { + result = Qnil; + return result; + } + + // get field type + OGRFieldType field_type = (OGRFieldType) OGR_Fld_GetType(OGR_F_GetFieldDefnRef( self, index)); + + switch (field_type) { + case OFTInteger: { + const int value = OGR_F_GetFieldAsInteger(self, index); + result = INT2NUM(value); + break; + } + + case OFTIntegerList: { + int len = 0; + const int* list = OGR_F_GetFieldAsIntegerList(self, index, &len); + + result = rb_ary_new2(len); + + for ( int i = 0; i < len; ++i, ++list ) { + VALUE item = INT2NUM(*list); + rb_ary_store(result, item, i); + } + break; + } + + case OFTReal: { + const double value = OGR_F_GetFieldAsDouble(self, index); + return rb_float_new(value); + break; + } + + case OFTRealList: { + int len = 0; + const double* list = OGR_F_GetFieldAsDoubleList(self, index, &len); + + result = rb_ary_new2(len); + + for ( int i = 0; i < len; ++i, ++list ) { + VALUE item = rb_float_new(*list); + rb_ary_store(result, item, i); + } + break; + } + + case OFTString: { + const char* value = (const char *) OGR_F_GetFieldAsString(self, index); + return rb_str_new2(value); + break; + } + + case OFTStringList: +/* int len3 = 0; + const char** string_list = OGR_F_GetFieldAsStringList(self, index, &len); + + result = rb_ary_new2(len3); + + for ( int i = 0; i < len; ++i, ++string_list ) { + VALUE item = rb_str_new2(*string_list); + rb_ary_store(result, item, i); + }*/ + result = Qnil; + break; + default: + SWIG_exception(SWIG_TypeError, "Unsupported field type."); + } + + return result; + } +} + + diff --git a/Utilities/GDAL/swig/include/ruby/osr_ruby.i b/Utilities/GDAL/swig/include/ruby/osr_ruby.i new file mode 100644 index 0000000000..694624f822 --- /dev/null +++ b/Utilities/GDAL/swig/include/ruby/osr_ruby.i @@ -0,0 +1,62 @@ +/* +%{ +static PyObject * +py_OPTGetProjectionMethods(PyObject *self, PyObject *args) { + + PyObject *py_MList; + char **papszMethods; + int iMethod; + + self = self; + args = args; + + papszMethods = OPTGetProjectionMethods(); + py_MList = PyList_New(CSLCount(papszMethods)); + + for( iMethod = 0; papszMethods[iMethod] != NULL; iMethod++ ) + { + char *pszUserMethodName; + char **papszParameters; + PyObject *py_PList; + int iParam; + + papszParameters = OPTGetParameterList( papszMethods[iMethod], + &pszUserMethodName ); + if( papszParameters == NULL ) + return NULL; + + py_PList = PyList_New(CSLCount(papszParameters)); + for( iParam = 0; papszParameters[iParam] != NULL; iParam++ ) + { + char *pszType; + char *pszUserParamName; + double dfDefault; + + OPTGetParameterInfo( papszMethods[iMethod], + papszParameters[iParam], + &pszUserParamName, + &pszType, &dfDefault ); + PyList_SetItem(py_PList, iParam, + Py_BuildValue("(sssd)", + papszParameters[iParam], + pszUserParamName, + pszType, dfDefault )); + } + + CSLDestroy( papszParameters ); + + PyList_SetItem(py_MList, iMethod, + Py_BuildValue("(ssO)", + papszMethods[iMethod], + pszUserMethodName, + py_PList)); + } + + CSLDestroy( papszMethods ); + + return py_MList; +} +%} +%native(GetProjectionMethods) py_OPTGetProjectionMethods; +*/ +%include typemaps_ruby.i diff --git a/Utilities/GDAL/swig/include/ruby/typemaps_ruby.i b/Utilities/GDAL/swig/include/ruby/typemaps_ruby.i new file mode 100644 index 0000000000..bf5ae39605 --- /dev/null +++ b/Utilities/GDAL/swig/include/ruby/typemaps_ruby.i @@ -0,0 +1,747 @@ + +/****************************************************************************** + * $Id: typemaps_ruby.i,v 1.9 2006/01/17 04:41:26 cfis Exp $ + * + * Name: typemaps_ruby.i + * Project: GDAL Ruby Interface + * Purpose: GDAL Core SWIG Interface declarations. + * Author: Charles F. I. Savage + * + + * + * $Log: typemaps_ruby.i,v $ + * Revision 1.9 2006/01/17 04:41:26 cfis + * Removed dependency on renames.i - instead use new swig -autorename directive. Also fix a memory issue with hex_to_binary. + * + * Revision 1.8 2006/01/16 08:06:23 cfis + * Added typemaps to support CPLHexToBinary and CPLHexToBinary + * + * Revision 1.7 2006/01/14 21:45:26 cfis + * Updated type maps that fix issue with returning an array of results. + * + * Revision 1.6 2006/01/14 19:55:47 cfis + * Fixed an error in accessing items in a pointer to an array of doubles. + * + * Revision 1.5 2006/01/14 02:34:05 cfis + * Updated typemaps that compile with SWIG 1.3.28 head. + * + * Revision 1.4 2005/10/11 14:11:43 kruland + * Fix memory bug in typemap(out) char **options. The returned array of strings + * is owned by the dataset. + * + * Revision 1.3 2005/10/02 19:03:45 cfis + * Changed $source (which is deprecated) to $1 in "out" and "ret" typemaps. + * + * Revision 1.2 2005/10/01 08:09:21 cfis + * Added additional gdal typemaps. Also removed CPLErr 'ret' typemaps since they are not necessary since the Ruby bindings always raises exceptions on errors. + * + * Revision 1.1 2005/09/26 08:20:19 cfis + * Significantly updated typemaps for Ruby - resynced with the Python typemaps file. + * + * Revision 1.5 2005/09/02 16:19:23 kruland + * Major reorganization to accomodate multiple language bindings. + * Each language binding can define renames and supplemental code without + * having to have a lot of conditionals in the main interface definition files. + * + * Revision 1.4 2005/08/25 21:00:55 cfis + * Added note saying that SWIG 1.3.26 or higher is required because the bindings need the SWIGTYPE *DISOWN typemap. + * + * Revision 1.3 2005/08/21 23:52:08 cfis + * The Layer each method was not correctly setting the owernship flag for returned objects. This has now been fixed and commented. + * + * Revision 1.2 2005/08/20 20:50:13 cfis + * Added GetLayer method that maps to either GetLayerByName or GetLayerByIndex. Also commented out Open and OpenShared as DataSouce class static methods. + * + * Revision 1.1 2005/08/09 17:40:09 kruland + * Added support for ruby. + * + */ + +/* !NOTE! - The Ruby bindings require SWIG-1.3.26 or above. Earlier versions + do not work because they did not include support for the WWIGTYPE *DISOWN + typemap which is crucial for supporting the AddGeometryDirectly and + SetGeometryDirectly methods. + + These typemaps were ported from typemaps_python.i. For more information + please refer to that file and to the README.typemaps file */ + +%include typemaps.i +%include ogr_error_map.i + + + +%apply (double *OUTPUT) { double *argout }; + +/* + * double *val, int *hasval, is a special contrived typemap used for + * the RasterBand GetNoDataValue, GetMinimum, GetMaximum, GetOffset, GetScale methods. + * In the Ruby bindings, the variable hasval is tested. If it is 0 (is, the value + * is not set in the raster band) then Py_None is returned. If is is != 0, then + * the value is coerced into a long and returned. + */ +%typemap(in,numinputs=0) (double *val, int *hasval) (double tmpval, int tmphasval) { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + $1 = &tmpval; + $2 = &tmphasval; +} + +%typemap(argout) (double *val, int *hasval) { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*$2 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*$1); + } + + $result = SWIG_AppendOutput($result, argOut); +} + +/* Define a simple return code typemap which checks if the return code from + * the wrapped method is non-zero. If non-zero, return None. Otherwise, + * return any argout or None. + * + * Applied like this: + * %apply (IF_ERR_RETURN_NONE) {CPLErr}; + * CPLErr function_to_wrap( ); + * %clear (CPLErr); */ + +%typemap(out) IF_ERR_RETURN_NONE +{ + /* %typemap(out) IF_ERR_RETURN_NONE */ + /* result = Qnil; */ +} + +%typemap(out) IF_FALSE_RETURN_NONE +{ + /* %typemap(out) IF_FALSE_RETURN_NONE */ + if ($1 == 0 ) { + $result = Qnil; + } +} + +/* -------- OGR Error Handling --------------- */ +%typemap(out) OGRErr +{ + /* %typemap(out) OGRErr */ + if ($1 != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } +} + +%typemap(ret) OGRErr +{ + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } +} + +/* ------------- Array <-> Fixed Length Double Array ----------------------*/ +%typemap(in) (double argin[ANY]) (double temp[$dim0]) +{ + /* %typemap(in) (double argin[ANY]) (double temp[$dim0]) */ + /* Make sure this is an array. */ + Check_Type($input, T_ARRAY); + + /* Get the length */ + int seq_size = RARRAY($input)->len; + + if ( seq_size != $dim0 ) { + rb_raise(rb_eRangeError, "sequence must have length %i.", seq_size); + } + + for( int i = 0; i<$dim0; i++ ) { + /* Get the Ruby Object */ + VALUE item = rb_ary_entry($input,i); + + /* Convert to double and store in array*/ + temp[i] = NUM2DBL(item); + } + + /* Set argument $1 equal to the temp array */ + $1 = temp; +} + + +%typemap(in,numinputs=0) (double argout[ANY]) (double argout[$dim0]) +{ + /* %typemap(in,numinputs=0) (double argout[ANY]) */ + $1 = argout; +} + +%typemap(argout) (double argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<$dim0; i++) + { + VALUE value = rb_float_new(($1)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + $result = SWIG_AppendOutput($result, outArr); +} + +%typemap(in,numinputs=0) (double *argout[ANY]) (double *argout) +{ + /* %typemap(in,numinputs=0) (double *argout[ANY]) */ + $1 = &argout; +} + +%typemap(argout) (double *argout[ANY]) +{ + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<$dim0; i++) + { + /* $1 is a pointer to an array, so first dereference the array, + then specify the index. */ + VALUE value = rb_float_new((*$1)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + $result = SWIG_AppendOutput($result, outArr); +} + +%typemap(freearg) (double *argout[ANY]) +{ + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*$1); +} + +/* ------------- Ruby Array <-> integer Array ----------------------*/ +%typemap(in,numinputs=1) (int nList, int* pList) +{ + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + + /* Make sure this is an array. */ + Check_Type($input, T_ARRAY); + + /* Get the length */ + $1 = RARRAY($input)->len; + + /* Allocate space for the C array. */ + $2 = (int*) malloc($1*sizeof(int)); + + for( int i = 0; i<$1; i++ ) { + /* Get the Ruby Object */ + VALUE item = rb_ary_entry($input,i); + /* Conver to an integer */ + $2[i] = NUM2INT(item); + } +} + +%typemap(freearg) (int nList, int* pList) +{ + /* %typemap(freearg) (int nList, int* pList) */ + if ($2) { + free((void*) $2); + } +} + +/* ------------- Ruby String <-> char ** with lengths ----------------------*/ +%typemap(in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen = 0, char *pBuf = 0 ) +{ + /* %typemap(in,numinputs=0) (int *nLen, char **pBuf ) ( int nLen = 0, char *pBuf = 0 ) */ + $1 = &nLen; + $2 = &pBuf; +} + +%typemap(argout) (int *nLen, char **pBuf ) +{ + /* %typemap(argout) (int *nLen, char **pBuf ) */ + $result = rb_str_new(*$2, *$1); +} + +%typemap(freearg) (int *nLen, char **pBuf ) +{ + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *$2 ) { + free( *$2 ); + } +} + +/* ------------- Ruby String <-> char * ----------------------*/ +%typemap(in) (int nLen, char *pBuf ) = (int LENGTH, char *STRING); + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) + (int nLen, char *pBuf) +{ + /* %typecheck(ruby,typecheck,precedence=SWIG_TYPECHECK_POINTER) (int nLen, char *pBuf) */ + $1 = (TYPE($input) == T_STRING) ? 1: 0; +} + + + +/* --------- GDAL_GCP used in Dataset::GetGCPs( ) ----------- */ +%typemap(in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) (int nGCPs=0, GDAL_GCP *pGCPs=0 ) +{ + /* %typemap( in,numinputs=0) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + $1 = &nGCPs; + $2 = &pGCPs; +} + +%typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) +{ + /* %typemap( argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + +/* $result = rb_ary_new2(*$1); + + for( int i = 0; i < *$1; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*$2)[i].dfGCPX, + (*$2)[i].dfGCPY, + (*$2)[i].dfGCPZ, + (*$2)[i].dfGCPPixel, + (*$2)[i].dfGCPLine, + (*$2)[i].pszInfo, + (*$2)[i].pszId ); + + rb_ary_store($result, i, + SWIG_NewPointerObj((void*)o, SWIGTYPE_p_GDAL_GCP,1)); + }*/ +} + +%typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) ( GDAL_GCP *tmpGCPList ) +{ + /* %typemap( in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + + /* Check if is a list */ + Check_Type($input, T_ARRAY); + + $1 = RARRAY($input)->len; + tmpGCPList = (GDAL_GCP*) malloc($1*sizeof(GDAL_GCP)); + $2 = tmpGCPList; + + for( int i = 0; i<$1; i++ ) { + VALUE rubyItem = rb_ary_entry($input,i); + GDAL_GCP *item = 0; + + SWIG_ConvertPtr( rubyItem, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + + if (!item) { + rb_raise(rb_eRuntimeError, "GDAL_GCP item cannot be nil"); + } + + memcpy( (void*) item, (void*) tmpGCPList, sizeof( GDAL_GCP ) ); + ++tmpGCPList; + } +} + +%typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) +{ + /* %typemap( freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if ($2) { + free( (void*) $2 ); + } +} + +/* ----------- Typemap for GDALColorEntry* <-> tuple -------------- */ +/*%typemap(out) GDALColorEntry* +{*/ + /* %typemap( out) GDALColorEntry* */ + + /* $result = Py_BuildValue( "(hhhh)", (*$1).c1,(*$1).c2,(*$1).c3,(*$1).c4); +} + +%typemap(in) GDALColorEntry* (GDALColorEntry ce) +{*/ + /* %typemap(in) GDALColorEntry* */ +/* ce.c4 = 255; + + int size = PySequence_Size($input); + + if ( size > 4 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too long"); + SWIG_fail; + } + + if ( size < 3 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too short"); + SWIG_fail; + } + + PyArg_ParseTuple( $input,"hhh|h", &ce.c1, &ce.c2, &ce.c3, &ce.c4 ); + $1 = &ce; +} +*/ + + +/* ------------- Ruby Hash <-> char ** ---------------------- + * Used to convert a native dictionary/hash type into name value pairs. */ + +/* Hash -> char** */ +%typemap(in) char **dict +{ + /* %typemap(in) char **dict */ + + $1 = NULL; + + /* is the provided object an array or a hash? */ + if ( TYPE($input) == T_ARRAY) { + /* get the size of the array */ + int size = RARRAY($input)->len; + + for (int i = 0; i < size; i++) { + /* get the ruby object */ + VALUE value = rb_ary_entry($input, i); + + /* Convert the value to a string via ruby duck typing + * (i.e., the object might not actually be a string) + */ + char *pszItem = StringValuePtr(value); + $1 = CSLAddString( $1, pszItem ); + } + } + + else if ( TYPE($input) == T_HASH) { + /* This is a hash - get the size by calling via the ruby method */ + int size = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL)); + + if ( size > 0 ) { + /* Get the keys by caling via ruby */ + VALUE keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL); + + for( int i=0; i<size; i++ ) { + /* Get the key and value as ruby objects */ + VALUE key = rb_ary_entry(keys_arr, i); + VALUE value = rb_hash_aref($input, key); + + /* Convert the key and value to strings via ruby duck typing + * (i.e., the objects might not actually be strings) + */ + char *nm = StringValuePtr(key); + char *val = StringValuePtr(value); + + /* Add the value */ + $1 = CSLAddNameValue( $1, nm, val ); + } + } + } + else { + rb_raise(rb_eTypeError, "Argument must be dictionary or sequence of strings"); + } +} + +/* char** --> Hash */ +%typemap(out) char **dict +{ + /* %typemap(out) char **dict */ + + /* Get a pointer to the c array */ + char **stringarray = $1; + + /* Create a new hash table, this will be returned to Ruby. */ + $result = rb_hash_new(); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + /* Get the key and value */ + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + + if ( valptr != 0 ) { + /* Convert the key and value to Ruby strings */ + VALUE nm = rb_str_new2( keyptr ); + VALUE val = rb_str_new2( valptr ); + /* Save the key, value pair to the hash table. */ + rb_hash_aset($result, nm, val); + CPLFree( keyptr ); + } + stringarray++; + } + } +} + +/* + * Typemap char **<- dict. This typemap actually supports lists as well, + * Then each entry in the list must be a string and have the form: + * "name=value" so gdal can handle it. + */ +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) +{ + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) */ + $1 = ((TYPE($input) == T_HASH) || (TYPE($input) == T_ARRAY)) ? 1 : 0; +} + + +%typemap(freearg) char **dict +{ + /* %typemap(freearg) char **dict */ + CSLDestroy( $1 ); +} + + +/* ------------- Ruby Array <-> array of char* ------------*/ + + +/* Typemap maps char** arguments from Ruby Array */ +%typemap(in) char **options +{ + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type($input, T_ARRAY); + + int size = RARRAY($input)->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry($input, i); + char *pszItem = StringValuePtr(item); + $1 = CSLAddString( $1, pszItem ); + } +} + +%typemap(out) char **options +{ + /* %typemap(out) char **options */ + + char **stringarray = $1; + if ( stringarray == NULL ) { + $result = Qnil; + } + else { + int len = CSLCount( stringarray ); + $result = rb_ary_new2( len ); + for ( int i = 0; i < len; ++i, ++stringarray ) { + VALUE nm = rb_str_new2( *stringarray ); + rb_ary_push($result, nm); + } + } +} + +%typemap(freearg) char **options +{ + /* %typemap(freearg) char **options */ + + CSLDestroy( $1 ); +} + +/* + * Typemaps map mutable char ** arguments from Ruby Strings. Does not + * return the modified argument + */ +%typemap(in) char ** ( char *val=0 ) +{ + /* %typemap(in) char ** ( char *val=0 ) */ + + val = StringValuePtr($input); + $1 = &val; +} + +%apply char** {char **ignorechange}; + + +/* ------------- Ruby String <- char ** no lengths ------------------*/ +%typemap(in,numinputs=0) (char **argout) ( char *argout=0 ) +{ + /* %typemap(in,numinputs=0) (char **argout) ( char *argout=0 ) */ + $1 = &argout; +} + +%typemap(argout,fragment="output_helper") char **argout +{ + /* %typemap(argout) (char **argout) */ + VALUE outArg; + if ( $1 ) { + outArg = rb_str_new2( *$1 ); + } + else { + outArg = Qnil; + } + + $result = SWIG_AppendOutput($result, outArg); +} + +%typemap(freearg) (char **argout) +{ + /* %typemap(freearg) (char **argout) */ + + if ( *$1 ) + CPLFree( *$1 ); +} + +/* ------------- POD Typemaps ----------------------*/ + +/* + * Typemap for an optional POD argument. + * Declare function to take POD *. If the parameter + * is NULL then the function needs to define a default + * value. + */ +/*%define OPTIONAL_POD(type,argstring) +%typemap(in) (type *optional_##type) ( type val ) +{ +*/ + /* %typemap(in) (type *optional_##type) */ +/* if ( $input == Qnil ) { + $1 = 0; + } + else if ( PyArg_Parse( $input, #argstring ,&val ) ) { + $1 = ($1_type) &val; + } + else { + rb_raise(rb_eRuntimeError, "Invalid Parameter"); + } +}*/ + + +/*%typemap(typecheck,precedence=0) (type *optional_##type) +{ +*/ + /* %typemap(typecheck,precedence=0) (type *optionalInt) */ + /* $1 = (($input==Py_None) || my_PyCheck_##type($input)) ? 1 : 0; +} +%enddef*/ + + +//OPTIONAL_POD(int,i); + +/* -------- const char * <- Any object ------------ */ + +/* Formats the object using str and returns the string representation */ + +%typemap(in) (tostring argin) (VALUE rubyString) +{ + /* %typemap( in) (tostring argin) */ + + $1 = StringValuePtr($input); +} + + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) +{ + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + $1 = 1; +} + + +/* ------------- Ruby Exception <- CPLErr ----------------------*/ +%typemap(out) CPLErr +{ + /* %typemap(out) CPLErr */ + $result = ($1_type)LONG2NUM($1); +} + +/* ----------- Ruby Arrays <------> XML Trees Helper Methods --------------- */ + +%typemap(in) (CPLXMLNode* xmlnode ) +{ + /* %typemap(in) (CPLXMLNode* xmlnode ) */ + $1 = RubyArrayToXMLTree($input); + + if ( !$1 ) { + rb_raise(rb_eRuntimeError, "Could not convert Ruby Array to XML tree."); + } +} + +%typemap(freearg) (CPLXMLNode *xmlnode) +{ + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + + if ( $1 ) { + CPLDestroyXMLNode( $1 ); + } +} + + +%typemap(out,fragment="XMLTreeToPyList") (CPLXMLNode*) +{ + /* %typemap(out) (CPLXMLNode*) */ + + $result = XMLTreeToRubyArray($1); +} + +%typemap(ret) (CPLXMLNode*) +{ + /* %typemap(ret) (CPLXMLNode*) */ + if ( $1 ) { + CPLDestroyXMLNode( $1 ); + } +} + + +%apply char* {tostring argin} +%apply int* {int* optional_int}; + +%typemap(in) GDALDataType, CPLErr, GDALPaletteInterp, GDALAccess, + GDALResampleAlg, GDALColorInterp, OGRwkbGeometryType, OGRFieldType, + OGRJustification, OGRwkbByteOrder +{ + /* %typemap(in) CPLErr */ + $1 = ($1_type) NUM2INT($input); +} + +%typemap(out) SWIGTYPE* ParentReference { + /* %typemap(out) SWIGTYPE* ParentReference */ + + /* There parent C++ object (self) owns the returned C++ object (result). + If the parent goes out of scope it will free the child, invalidating + the scripting language object that represents the child. To prevent + that create a reference from the child to the parent, thereby telling + the garabage collector not to GC the parent.*/ + + $result = SWIG_NewPointerObj((void *) $1, $1_descriptor,$owner); + rb_iv_set($result, "swig_parent_reference", self); +} + + +/*%typemap(freearg) SWIGTYPE* ParentReference { + /* %typemap(freearg) SWIGTYPE* ParentReference */ + + /* Subtract 2, 1 for self and 1 since argv is 0-based */ + //rb_iv_set(argv[$argnum-2], "swig_parent_reference", self); +//}*/ + + +/* ----------- GByte --------------- */ +/* Tread byte arrays as char arrays */ + +%typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (int nBytes, const GByte *pabyData) + (int res, GByte *buf = 0, size_t size = 0, int alloc = 0) { + + /*%typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (int nBytes, const GByte *pabyData) */ + + res = SWIG_AsCharPtrAndSize($input, (char**)&buf, &size, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "(GByte*, int)", $symname, $argnum); + } + $1 = ($1_ltype) size - 1; + $2 = ($2_ltype) buf; +} + +%typemap(freearg) (int nBytes, const GByte *pabyData) { + /* %typemap(freearg) (int nBytes, const GByte *pabyData) */ + CPLFree(result); +} + + +%typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (const char *pszHex, int *pnBytes) + (int res, char *buf = 0, int size = 0, int alloc = 0) { + + /*% typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (const char *pszHex, int *pnBytes) */ + $2 = &size; + res = SWIG_AsCharPtr($input, &buf, &alloc); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } + $1 = buf; +} + + +%typemap(argout) (const char *pszHex, int *pnBytes) { + /* %typemap(argout) (const char *pszHex, int *pnBytes) */ + $result = SWIG_FromCharPtrAndSize((char*)result, (size_t)*$2); + CPLFree(result); +} + +%typemap(out) GByte* { + /* %typemap(out) GByte* */ + + /* Stops insertion of default type map. */ +} \ No newline at end of file diff --git a/Utilities/GDAL/swig/java/GNUmakefile b/Utilities/GDAL/swig/java/GNUmakefile new file mode 100644 index 0000000000..d8777f45b2 --- /dev/null +++ b/Utilities/GDAL/swig/java/GNUmakefile @@ -0,0 +1,55 @@ + + +include ../../GDALmake.opt +include java.opt + +all: build + +BINDING = java +include ../SWIGmake.base + +SHORT_NAME = $(subst _wrap,,$*) +SWIGARGS += -outdir "org/gdal/$(SHORT_NAME)" -package "org.gdal.$(SHORT_NAME)" + +EXTRA_DIST = org + +.PHONY: makedir +makedir: + mkdir -p org/gdal/gdal + mkdir -p org/gdal/gdalconst + mkdir -p org/gdal/ogr + mkdir -p org/gdal/osr + + +JAVA_MODULES = libgdaljni.so libogrjni.so libgdalconstjni.so libosrjni.so + +clean: + -rm -f ${JAVA_MODULES} + -rm *.o *.lo + +veryclean: clean + -rm -f ${WRAPPERS} + -rm -rf ${EXTRA_DIST} + +generate: makedir ${WRAPPERS} + +build: generate ${JAVA_MODULES} + cp ./.libs/*.so ./ + ant + +install: generate + @echo "No installation to be done" + + +$(JAVA_MODULES): lib%jni.so: %_wrap.o + $(LD) -shared $(LDFLAGS) $(CONFIG_LIBS) $< -o $@ + +%.o: %.cpp + $(CXX) -fPIC $(CFLAGS) $(GDAL_INCLUDE) $(JAVA_INCLUDE) -c $< + +%.o: %.cxx + $(CXX) -fPIC $(CFLAGS) $(GDAL_INCLUDE) $(JAVA_INCLUDE) -c $< + +%.o: %.c + $(CC) -fPIC $(CFLAGS) $(GDAL_INCLUDE) $(JAVA_INCLUDE) -c $< + diff --git a/Utilities/GDAL/swig/java/apps/GDALtest.java b/Utilities/GDAL/swig/java/apps/GDALtest.java new file mode 100644 index 0000000000..50bd98f40a --- /dev/null +++ b/Utilities/GDAL/swig/java/apps/GDALtest.java @@ -0,0 +1,336 @@ +/****************************************************************************** + * $Id: GDALtest.java,v 1.1 2006/02/08 19:39:03 collinsb Exp $ + * + * Name: GDALtest.java + * Project: GDAL SWIG Interface + * Purpose: Sample Java application showing some basic loading of raster data + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: GDALtest.java,v $ + * Revision 1.1 2006/02/08 19:39:03 collinsb + * Initial version + * + * +*/ + + +import java.awt.BorderLayout; +import java.awt.color.ColorSpace; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BandedSampleModel; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferShort; +import java.awt.image.Raster; +import java.awt.image.SampleModel; +import java.awt.image.WritableRaster; +import java.io.File; +import java.nio.ByteBuffer; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import org.gdal.gdal.Band; +import org.gdal.gdal.Dataset; +import org.gdal.gdal.Driver; +import org.gdal.gdal.GCP; +import org.gdal.gdal.gdal; +import org.gdal.gdalconst.gdalconst; +import org.gdal.gdalconst.gdalconstConstants; + +public class GDALtest extends JFrame implements ActionListener{ + + BufferedImage image = null; + JLabel canvas = null; + JButton load = null; + + static { + System.out.println("GDAL init..."); + gdal.AllRegister(); + int count = gdal.GetDriverCount(); + System.out.println(count + " available Drivers"); + for (int i = 0; i < count; i++) { + try { + Driver driver = gdal.GetDriver(i); + System.out.println(" " + driver.getShortName() + " : " + + driver.getLongName()); + } catch (Exception e) { + System.err.println("Error loading driver " + i); + } + } + } + + public GDALtest() { + load = new JButton("Load Image"); + load.addActionListener(this); + + canvas = new JLabel(); + canvas.setSize(1024, 768); + + this.getContentPane().setLayout(new BorderLayout()); + this.getContentPane().add(load, BorderLayout.NORTH); + this.getContentPane().add(canvas, BorderLayout.SOUTH); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + this.setSize(1024, 768); + this.show(); + } + + public void setImage(BufferedImage image) { + ImageIcon icon = new ImageIcon(image); + + if(this.canvas != null) { + canvas.setIcon(icon); + } + } + + public BufferedImage openFile(File f) { + Dataset poDataset = null; + try { + poDataset = (Dataset) gdal.Open(f.getAbsolutePath(), + gdalconst.GA_ReadOnly); + if (poDataset == null) { + System.out.println("The image could not be read."); + printLastError(); + return null; + } + } catch(Exception e) { + System.err.println("Exception caught."); + System.err.println(e.getMessage()); + e.printStackTrace(); + return null; + } + double[] adfGeoTransform = new double[6]; + + System.out.println("Driver: " + poDataset.GetDriver().GetDescription()); + + System.out.println("Size is: " + poDataset.getRasterXSize() + "x" + + poDataset.getRasterYSize() + " bands:" + + poDataset.getRasterCount()); + + if (poDataset.GetProjectionRef() != null) + System.out.println("Projection is `" + poDataset.GetProjectionRef() + + "'"); + + Hashtable dict = poDataset.GetMetadata_Dict(""); + Enumeration keys = dict.keys(); + System.out.println(dict.size() + " items of metadata found (via Hashtable dict):"); + while(keys.hasMoreElements()) { + String key = (String)keys.nextElement(); + System.out.println(" :" + key + ":==:" + dict.get(key) + ":"); + } + + Vector list = poDataset.GetMetadata_List(""); + Enumeration enumerate = list.elements(); + System.out.println(list.size() + " items of metadata found (via Vector list):"); + while(enumerate.hasMoreElements()) { + String s = (String)enumerate.nextElement(); + System.out.println(" " + s); + } + + Vector GCPs = new Vector(); + poDataset.GetGCPs(GCPs); + System.out.println("Got " + GCPs.size() + " GCPs"); + Enumeration e = GCPs.elements(); + while(e.hasMoreElements()) { + GCP gcp = (GCP)e.nextElement(); + System.out.println(" x:" + gcp.getGCPX() + + " y:" + gcp.getGCPY() + + " z:" + gcp.getGCPZ() + + " pixel:" + gcp.getGCPPixel() + + " line:" + gcp.getGCPLine() + + " line:" + gcp.getInfo()); + } + + + poDataset.GetGeoTransform(adfGeoTransform); + { + System.out.println("Origin = (" + adfGeoTransform[0] + ", " + + adfGeoTransform[3] + ")"); + + System.out.println("Pixel Size = (" + adfGeoTransform[1] + ", " + + adfGeoTransform[5] + ")"); + } + + Band poBand = null; + double[] adfMinMax = new double[2]; + Double[] max = new Double[1]; + Double[] min = new Double[1]; + + int bandCount = poDataset.getRasterCount(); + ByteBuffer[] bands = new ByteBuffer[bandCount]; + int[] banks = new int[bandCount]; + int[] offsets = new int[bandCount]; + + int xsize = 1024;//poDataset.getRasterXSize(); + int ysize = 1024;//poDataset.getRasterYSize(); + int pixels = xsize * ysize; + int buf_type = 0, buf_size = 0; + + for(int band = 0; band < bandCount; band++) { + /* Bands are not 0-base indexed, so we must add 1 */ + poBand = poDataset.GetRasterBand(band+1); + + buf_type = poBand.getDataType(); + buf_size = pixels * gdal.GetDataTypeSize(buf_type) / 8; + + System.out.println(" Data Type = " + + gdal.GetDataTypeName(poBand.getDataType())); + System.out.println(" ColorInterp = " + + gdal.GetColorInterpretationName(poBand + .GetRasterColorInterpretation())); + + System.out.println("Band size is: " + poBand.getXSize() + "x" + + poBand.getYSize()); + + poBand.GetMinimum(min); + poBand.GetMaximum(max); + if(min[0] != null || max[0] != null) { + System.out.println(" Min=" + min[0] + " Max=" + + max[0]); + } else { + System.out.println(" No Min/Max values stored in raster."); + } + + if (poBand.GetOverviewCount() > 0) { + System.out.println("Band has " + poBand.GetOverviewCount() + + " overviews."); + } + + if (poBand.GetRasterColorTable() != null) { + System.out.println("Band has a color table with " + + poBand.GetRasterColorTable().GetCount() + " entries."); + for(int i = 0; i < poBand.GetRasterColorTable().GetCount(); i++) { + System.out.println(" " + i + ": " + + poBand.GetRasterColorTable().GetColorEntry(i)); + } + } + + System.out.println("Allocating ByteBuffer of size: " + buf_size); + + ByteBuffer data = ByteBuffer.allocateDirect(buf_size); + + int returnVal = 0; + try { + returnVal = poBand.ReadRaster_Direct(0, 0, poBand.getXSize(), + poBand.getYSize(), xsize, ysize, + buf_type, data); + } catch(Exception ex) { + System.err.println("Could not read raster data."); + System.err.println(ex.getMessage()); + ex.printStackTrace(); + return null; + } + if(returnVal == gdalconstConstants.CE_None) { + bands[band] = data; + } else { + printLastError(); + } + banks[band] = band; + offsets[band] = 0; + } + + DataBuffer imgBuffer = null; + SampleModel sampleModel = null; + int data_type = 0, buffer_type = 0; + + if(buf_type == gdalconstConstants.GDT_Byte) { + byte[][] bytes = new byte[bandCount][]; + for(int i = 0; i < bandCount; i++) { + bytes[i] = new byte[pixels]; + bands[i].get(bytes[i]); + } + imgBuffer = new DataBufferByte(bytes, pixels); + buffer_type = DataBuffer.TYPE_BYTE; + sampleModel = new BandedSampleModel(buffer_type, + xsize, ysize, xsize, banks, offsets); + data_type = (poBand.GetRasterColorInterpretation() == + gdalconstConstants.GCI_PaletteIndex)? + BufferedImage.TYPE_BYTE_INDEXED : BufferedImage.TYPE_BYTE_GRAY; + } else if(buf_type == gdalconstConstants.GDT_Int16) { + short[][] shorts = new short[bandCount][]; + for(int i = 0; i < bandCount; i++) { + shorts[i] = new short[pixels]; + bands[i].asShortBuffer().get(shorts[i]); + } + imgBuffer = new DataBufferShort(shorts, pixels); + buffer_type = DataBuffer.TYPE_USHORT; + sampleModel = new BandedSampleModel(buffer_type, + xsize, ysize, xsize, banks, offsets); + data_type = BufferedImage.TYPE_USHORT_GRAY; + } else if(buf_type == gdalconstConstants.GDT_Int32) { + int[][] ints = new int[bandCount][]; + for(int i = 0; i < bandCount; i++) { + ints[i] = new int[pixels]; + bands[i].asIntBuffer().get(ints[i]); + } + imgBuffer = new DataBufferInt(ints, pixels); + buffer_type = DataBuffer.TYPE_INT; + sampleModel = new BandedSampleModel(buffer_type, + xsize, ysize, xsize, banks, offsets); + data_type = BufferedImage.TYPE_CUSTOM; + } + + WritableRaster raster = Raster.createWritableRaster(sampleModel, imgBuffer, null); + BufferedImage img = null; + ColorModel cm = null; + + if(poBand.GetRasterColorInterpretation() == + gdalconstConstants.GCI_PaletteIndex) { + data_type = BufferedImage.TYPE_BYTE_INDEXED; + cm = poBand.GetRasterColorTable().getIndexColorModel( + gdal.GetDataTypeSize(buf_type)); + img = new BufferedImage(cm, raster, true, null); + } else { + ColorSpace cs = null; + if(bandCount > 2){ + cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + cm = new ComponentColorModel(cs, false, false, + ColorModel.OPAQUE, buffer_type); + img = new BufferedImage(cm, raster, true, null); + } else { + img = new BufferedImage(xsize, ysize, + data_type); + img.setData(raster); + } + } + return img; + } + + public void printLastError() { + System.out.println("Last error: " + gdal.GetLastErrorMsg()); + System.out.println("Last error no: " + gdal.GetLastErrorNo()); + System.out.println("Last error type: " + gdal.GetLastErrorType()); + } + + public void actionPerformed(ActionEvent arg0) { + System.out.println("Loading file chooser..."); + JFileChooser chooser = new JFileChooser(); + int result = chooser.showOpenDialog(this); + if(result == JFileChooser.APPROVE_OPTION) { + /* open the image! */ + BufferedImage tmpImage = openFile(chooser.getSelectedFile()); + setImage(tmpImage); + } + } + + /** + * @param args + */ + public static void main(String[] args) { + new GDALtest(); + } + +} diff --git a/Utilities/GDAL/swig/java/apps/gdalinfo.java b/Utilities/GDAL/swig/java/apps/gdalinfo.java new file mode 100644 index 0000000000..4677d5627a --- /dev/null +++ b/Utilities/GDAL/swig/java/apps/gdalinfo.java @@ -0,0 +1,458 @@ +/****************************************************************************** + * $Id: gdalinfo.java,v 1.1 2006/02/02 21:04:35 collinsb Exp $ + * + * Name: gdalinfo.java + * Project: GDAL SWIG Interface + * Purpose: Java port of gdalinfo application + * Author: Benjamin Collins, The MITRE Corporation + * + * + * $Log: gdalinfo.java,v $ + * Revision 1.1 2006/02/02 21:04:35 collinsb + * Expand support for SWIG Java bindings + * + * + * +*/ + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +import org.gdal.gdal.Band; +import org.gdal.gdal.ColorTable; +import org.gdal.gdal.Dataset; +import org.gdal.gdal.Driver; +import org.gdal.gdal.GCP; +import org.gdal.gdal.gdal; +import org.gdal.gdalconst.gdalconstConstants; +import org.gdal.osr.CoordinateTransformation; +import org.gdal.osr.SpatialReference; + +public class gdalinfo { + + /************************************************************************/ + /* Usage() */ + /************************************************************************/ + + public static void Usage() + + { + System.out + .println("Usage: gdalinfo [--help-general] [-mm] [-nogcp] [-nomd] " + + "datasetname"); + System.exit(1); + } + + /************************************************************************/ + /* main() */ + /************************************************************************/ + + public static void main(String[] args) { + { + Dataset hDataset; + Band hBand; + int i, iBand; + double[] adfGeoTransform = new double[6]; + Driver hDriver; + Hashtable papszMetadata; + boolean bComputeMinMax = false, bSample = false; + boolean bShowGCPs = true, bShowMetadata = true; + boolean bStats = false; + String pszFilename = null; + + gdal.AllRegister(); + + if (args.length < 1) { + Usage(); + System.exit(0); + } + + /* -------------------------------------------------------------------- */ + /* Parse arguments. */ + /* -------------------------------------------------------------------- */ + for (i = 0; i < args.length; i++) { + if (args[i].equals("-mm")) + bComputeMinMax = true; + else if (args[i].equals("-stats")) + bStats = true; + else if (args[i].equals("-sample")) + bSample = true; + else if (args[i].equals("-nogcp")) + bShowGCPs = false; + else if (args[i].equals("-nomd")) + bShowMetadata = false; + else if (args[i].startsWith("-")) + Usage(); + else if (pszFilename == null) + pszFilename = args[i]; + else + Usage(); + } + + if (pszFilename == null) + Usage(); + + /* -------------------------------------------------------------------- */ + /* Open dataset. */ + /* -------------------------------------------------------------------- */ + hDataset = gdal.Open(pszFilename, gdalconstConstants.GA_ReadOnly); + + if (hDataset == null) { + System.err + .println("GDALOpen failed - " + gdal.GetLastErrorNo()); + System.err.println(gdal.GetLastErrorMsg()); + + //gdal.DumpOpenDatasets( stderr ); + + //gdal.DestroyDriverManager(); + + //gdal.DumpSharedList( null ); + + System.exit(1); + } + + /* -------------------------------------------------------------------- */ + /* Report general info. */ + /* -------------------------------------------------------------------- */ + hDriver = hDataset.GetDriver(); + System.out.println("Driver: " + hDriver.getShortName() + "/" + + hDriver.getLongName()); + + System.out.println("Size is " + hDataset.getRasterXSize() + ", " + + hDataset.getRasterYSize()); + + /* -------------------------------------------------------------------- */ + /* Report projection. */ + /* -------------------------------------------------------------------- */ + if (hDataset.GetProjectionRef() != null) { + SpatialReference hSRS; + String pszProjection; + + pszProjection = hDataset.GetProjectionRef(); + + hSRS = new SpatialReference(pszProjection); + if (hSRS != null) { + String[] pszPrettyWkt = new String[1]; + + hSRS.ExportToPrettyWkt(pszPrettyWkt, 0); + System.out.println("Coordinate System is:"); + System.out.println(pszPrettyWkt[0]); + //gdal.CPLFree( pszPrettyWkt ); + } else + System.out.println("Coordinate System is `" + + hDataset.GetProjectionRef() + "'"); + + hSRS.delete(); + } + + /* -------------------------------------------------------------------- */ + /* Report Geotransform. */ + /* -------------------------------------------------------------------- */ + hDataset.GetGeoTransform(adfGeoTransform); + { + if (adfGeoTransform[2] == 0.0 && adfGeoTransform[4] == 0.0) { + System.out.println("Origin = (" + adfGeoTransform[0] + "," + + adfGeoTransform[3] + ")"); + + System.out.println("Pixel Size = (" + adfGeoTransform[1] + + "," + adfGeoTransform[5] + ")"); + } else + System.out.println("GeoTransform ="); + System.out.println(" " + adfGeoTransform[0] + ", " + + adfGeoTransform[1] + ", " + adfGeoTransform[2]); + System.out.println(" " + adfGeoTransform[3] + ", " + + adfGeoTransform[4] + ", " + adfGeoTransform[5]); + } + + /* -------------------------------------------------------------------- */ + /* Report GCPs. */ + /* -------------------------------------------------------------------- */ + if (bShowGCPs && hDataset.GetGCPCount() > 0) { + System.out.println("GCP Projection = " + + hDataset.GetGCPProjection()); + + int count = 0; + Vector GCPs = new Vector(); + hDataset.GetGCPs(GCPs); + + Enumeration e = GCPs.elements(); + while (e.hasMoreElements()) { + GCP gcp = (GCP) e.nextElement(); + System.out.println("GCP[" + (count++) + "]: Id=" + + gcp.getId() + ", Info=" + gcp.getInfo()); + System.out.println(" (" + gcp.getGCPPixel() + "," + + gcp.getGCPLine() + ") (" + gcp.getGCPX() + "," + + gcp.getGCPY() + "," + gcp.getGCPZ() + ")"); + } + + } + + /* -------------------------------------------------------------------- */ + /* Report metadata. */ + /* -------------------------------------------------------------------- */ + papszMetadata = hDataset.GetMetadata_Dict(""); + if (bShowMetadata && papszMetadata.size() > 0) { + Enumeration keys = papszMetadata.keys(); + System.out.println("Metadata:"); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + System.out.println(" " + key + "=" + + papszMetadata.get(key)); + } + } + + /* -------------------------------------------------------------------- */ + /* Report subdatasets. */ + /* -------------------------------------------------------------------- */ + papszMetadata = hDataset.GetMetadata_Dict("SUBDATASETS"); + if (papszMetadata.size() > 0) { + System.out.println("Subdatasets:"); + Enumeration keys = papszMetadata.keys(); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + System.out.println(" " + key + "=" + + papszMetadata.get(key)); + } + } + + /* -------------------------------------------------------------------- */ + /* Report corners. */ + /* -------------------------------------------------------------------- */ + System.out.println("Corner Coordinates:\n"); + GDALInfoReportCorner(hDataset, "Upper Left", 0.0, 0.0); + GDALInfoReportCorner(hDataset, "Lower Left", 0.0, hDataset + .getRasterYSize()); + GDALInfoReportCorner(hDataset, "Upper Right", hDataset + .getRasterXSize(), 0.0); + GDALInfoReportCorner(hDataset, "Lower Right", hDataset + .getRasterXSize(), hDataset.getRasterYSize()); + GDALInfoReportCorner(hDataset, "Center", + hDataset.getRasterXSize() / 2.0, + hDataset.getRasterYSize() / 2.0); + + /* ==================================================================== */ + /* Loop over bands. */ + /* ==================================================================== */ + for (iBand = 0; iBand < hDataset.getRasterCount(); iBand++) { + Double[] pass1 = new Double[1], pass2 = new Double[1]; + double[] adfCMinMax = new double[2]; + ColorTable hTable; + + hBand = hDataset.GetRasterBand(iBand + 1); + + /*if( bSample ) + { + float[] afSample = new float[10000]; + int nCount; + + nCount = hBand.GetRandomRasterSample( 10000, afSample ); + System.out.println( "Got " + nCount + " samples." ); + }*/ + + System.out.println("Band " + + (iBand+1) + + " Type=" + + gdal.GetDataTypeName(hBand.getDataType()) + + ", ColorInterp=" + + gdal.GetColorInterpretationName(hBand + .GetRasterColorInterpretation())); + + String hBandDesc = hBand.GetDescription(); + if (hBandDesc != null && hBandDesc.length() > 0) + System.out.println(" Description = " + hBandDesc); + + hBand.GetMinimum(pass1); + hBand.GetMaximum(pass2); + if(pass1[0] != null || pass2[0] != null || bComputeMinMax) { + System.out.println(" Min=" + pass1[0] + " Max=" + + pass2[0]); + } + if (bComputeMinMax) { + hBand.ComputeRasterMinMax(adfCMinMax, 0); + System.out.println(" Computed Min/Max=" + adfCMinMax[0] + + "," + adfCMinMax[1]); + } + + /*eErr = hBand.GetRasterStatistics( hBand, false, bStats, + dfMin, dfMax, dfMean, dfStdDev ); + if( eErr == CE_None ) + { + System.out.println( " Minimum=%.3f, Maximum=%.3f, Mean=%.3f, StdDev=%.3f\n", + dfMin, dfMax, dfMean, dfStdDev ); + }*/ + + hBand.GetNoDataValue(pass1); + if(pass1[0] != null) + { + System.out.println(" NoData Value=" + pass1[0]); + } + + if (hBand.GetOverviewCount() > 0) { + int iOverview; + + System.out.println(" Overviews: "); + for (iOverview = 0; iOverview < hBand.GetOverviewCount(); iOverview++) { + Band hOverview; + + if (iOverview != 0) + System.out.print(", "); + + hOverview = hBand.GetOverview(iOverview); + System.out.print(hOverview.getXSize() + "x" + + hOverview.getYSize()); + } + System.out.println(""); + } + + /*if( GDALHasArbitraryOverviews( hBand ) ) + { + System.out.println( " Overviews: arbitrary\n" ); + }*/ + + /*if( strlen(GDALGetRasterUnitType(hBand)) > 0 ) + { + System.out.println( " Unit Type: %s\n", GDALGetRasterUnitType(hBand) ); + }*/ + + /*if( GDALGetRasterCategoryNames(hBand) != null ) + { + String[][] papszCategories = GDALGetRasterCategoryNames(hBand); + int i; + + System.out.println( " Categories:\n" ); + for( i = 0; papszCategories[i] != null; i++ ) + System.out.println( " %3d: %s\n", i, papszCategories[i] ); + }*/ + + hBand.GetScale(pass1); + if(pass1[0] != null) { + System.out.print(" Offset: " + pass1[0]); + } + hBand.GetOffset(pass1); + if(pass1[0] != null) { + System.out.println(", Scale:" + pass1[0]); + } + + papszMetadata = hBand.GetMetadata_Dict(""); + if( bShowMetadata && papszMetadata.size() > 0 ) { + Enumeration keys = papszMetadata.keys(); + System.out.println("Metadata:"); + while (keys.hasMoreElements()) { + String key = (String) keys.nextElement(); + System.out.println(" " + key + "=" + + papszMetadata.get(key)); + } + } + + if (hBand.GetRasterColorInterpretation() == gdalconstConstants.GCI_PaletteIndex + && (hTable = hBand.GetRasterColorTable()) != null) { + int count; + + System.out.println(" Color Table (" + + gdal.GetPaletteInterpretationName(hTable + .GetPaletteInterpretation()) + " with " + + hTable.GetCount() + " entries)"); + + for (count = 0; count < hTable.GetCount(); count++) { + System.out.println(" " + count + ": " + + hTable.GetColorEntry(count)); + } + } + } + + hDataset.delete(); + + //CSLDestroy( argv ); + + //GDALDumpOpenDatasets( stderr ); + + //gdal.DestroyDriverManager(); + + //CPLDumpSharedList( null ); + //CPLCleanupTLS(); + + System.exit(0); + } + } + + /************************************************************************/ + /* GDALInfoReportCorner() */ + /************************************************************************/ + + static boolean GDALInfoReportCorner(Dataset hDataset, String corner_name, + double x, double y) + + { + double dfGeoX, dfGeoY; + String pszProjection; + double[] adfGeoTransform = new double[6]; + CoordinateTransformation hTransform = null; + + System.out.print(corner_name + " "); + + /* -------------------------------------------------------------------- */ + /* Transform the point into georeferenced coordinates. */ + /* -------------------------------------------------------------------- */ + hDataset.GetGeoTransform(adfGeoTransform); + { + pszProjection = hDataset.GetProjectionRef(); + + dfGeoX = adfGeoTransform[0] + adfGeoTransform[1] * x + + adfGeoTransform[2] * y; + dfGeoY = adfGeoTransform[3] + adfGeoTransform[4] * x + + adfGeoTransform[5] * y; + } + + if (adfGeoTransform[0] == 0 && adfGeoTransform[1] == 0 + && adfGeoTransform[2] == 0 && adfGeoTransform[3] == 0 + && adfGeoTransform[4] == 0 && adfGeoTransform[5] == 0) { + System.out.println("(" + x + "," + y + ")"); + return false; + } + + /* -------------------------------------------------------------------- */ + /* Report the georeferenced coordinates. */ + /* -------------------------------------------------------------------- */ + System.out.print("(" + dfGeoX + "," + dfGeoY + ") "); + + /* -------------------------------------------------------------------- */ + /* Setup transformation to lat/long. */ + /* -------------------------------------------------------------------- */ + if (pszProjection != null && pszProjection.length() > 0) { + SpatialReference hProj, hLatLong = null; + + hProj = new SpatialReference(pszProjection); + if (hProj != null) + hLatLong = hProj.CloneGeogCS(); + + if (hLatLong != null) { + //CPLPushErrorHandler( gdalconstConstants.CPLQuietErrorHandler ); + hTransform = new CoordinateTransformation(hProj, hLatLong); + //CPLPopErrorHandler(); + hLatLong.delete(); + } + + if (hProj != null) + hProj.delete(); + } + + /* -------------------------------------------------------------------- */ + /* Transform to latlong and report. */ + /* -------------------------------------------------------------------- */ + if (hTransform != null) { + double[] transPoint = new double[3]; + hTransform.TransformPoint(transPoint, dfGeoX, dfGeoY, 0); + System.out.print("(" + gdal.DecToDMS(transPoint[0], "Long", 2)); + System.out + .print("," + gdal.DecToDMS(transPoint[1], "Lat", 2) + ")"); + } + + if (hTransform != null) + hTransform.delete(); + + System.out.println(""); + + return true; + } +} diff --git a/Utilities/GDAL/swig/java/build.xml b/Utilities/GDAL/swig/java/build.xml new file mode 100644 index 0000000000..2fc48c885c --- /dev/null +++ b/Utilities/GDAL/swig/java/build.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<project name="gdal" default="archive"> + + <description>Builds the Java SWIG bindings-proxy classes for GDAL/OGR</description> + + <target name="compile" description="Compile the source files."> + <mkdir dir="build/classes"/> + <javac srcdir="org" destdir="build/classes" + debug="on" source="1.4" target="1.4" + includeantruntime="false" deprecation="true"> + </javac> + <echo>compilation complete</echo> + </target> + + <target name="archive" depends="compile" description="Build a jar."> + <jar destfile="gdal.jar"> + <fileset dir="build/classes"> + <include name="**/*.class"/> + </fileset> + </jar> + </target> + + <target name="clean" description="Cleans up old files."> + <delete dir="build"/> + </target> + +</project> diff --git a/Utilities/GDAL/swig/java/const/makefile.vc b/Utilities/GDAL/swig/java/const/makefile.vc new file mode 100644 index 0000000000..4af736abdb --- /dev/null +++ b/Utilities/GDAL/swig/java/const/makefile.vc @@ -0,0 +1,18 @@ +OBJ = gdalconst_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt +!INCLUDE ..\java.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + +.cpp.obj: + $(CC) $(CFLAGS) $(JAVA_INCLUDE) /c $*.cpp + diff --git a/Utilities/GDAL/swig/java/gdal/makefile.vc b/Utilities/GDAL/swig/java/gdal/makefile.vc new file mode 100644 index 0000000000..1cdcfb5951 --- /dev/null +++ b/Utilities/GDAL/swig/java/gdal/makefile.vc @@ -0,0 +1,19 @@ +OBJ = gdal_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt +!INCLUDE ..\java.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + +.cpp.obj: + $(CC) $(CFLAGS) $(JAVA_INCLUDE) /c $*.cpp + + diff --git a/Utilities/GDAL/swig/java/gdal_wrap.cpp b/Utilities/GDAL/swig/java/gdal_wrap.cpp new file mode 100644 index 0000000000..720ae19e3c --- /dev/null +++ b/Utilities/GDAL/swig/java/gdal_wrap.cpp @@ -0,0 +1,4485 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTELC__) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + jenv->ExceptionClear(); + excep = jenv->FindClass(except_ptr->java_exception); + if (excep) + jenv->ThrowNew(excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + + + +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) + + +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input); +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input); +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz); + + +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input); +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz); + + +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input); +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz); + + +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input); +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz); + + +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input); +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input); +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz); + + +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input); +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input); +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz); + + +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input); +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz); + + +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input); +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input); +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz); + + +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input); +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz); + + +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input); +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz); + + +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input); +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input); +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz); + + +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input); +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input); +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz); + + +#else + + +/* bool[] support */ +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetBooleanArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new bool[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = ((*jarr)[i] != 0); + return 1; +} + +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jboolean)carr[i]; + jenv->ReleaseBooleanArrayElements(input, jarr, 0); +} + +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz) { + jboolean *arr; + int i; + jbooleanArray jresult = jenv->NewBooleanArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetBooleanArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jboolean)result[i]; + jenv->ReleaseBooleanArrayElements(jresult, arr, 0); + return jresult; +} + + +/* signed char[] support */ +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetByteArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new signed char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (signed char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jbyte)carr[i]; + jenv->ReleaseByteArrayElements(input, jarr, 0); +} + +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) { + jbyte *arr; + int i; + jbyteArray jresult = jenv->NewByteArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetByteArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jbyte)result[i]; + jenv->ReleaseByteArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned char[] support */ +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* short[] support */ +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned short[] support */ +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* int[] support */ +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned int[] support */ +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* long[] support */ +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned long[] support */ +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* jlong[] support */ +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new jlong[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (jlong)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* float[] support */ +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetFloatArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new float[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (float)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jfloat)carr[i]; + jenv->ReleaseFloatArrayElements(input, jarr, 0); +} + +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) { + jfloat *arr; + int i; + jfloatArray jresult = jenv->NewFloatArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetFloatArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jfloat)result[i]; + jenv->ReleaseFloatArrayElements(jresult, arr, 0); + return jresult; +} + + +/* double[] support */ +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetDoubleArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new double[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (double)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jdouble)carr[i]; + jenv->ReleaseDoubleArrayElements(input, jarr, 0); +} + +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { + jdouble *arr; + int i; + jdoubleArray jresult = jenv->NewDoubleArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetDoubleArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jdouble)result[i]; + jenv->ReleaseDoubleArrayElements(jresult, arr, 0); + return jresult; +} + + +#endif + + + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + + +static char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){ + return GDALGetDescription( self ); + } +static void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){ + GDALSetDescription( self, pszNewDesc ); + } +static char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static char **GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){ + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){ + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } +static GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *name,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){ + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } +static GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *name,GDALDatasetShadow *src,int strict=1,char **options=0){ + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } +static int GDALDriverShadow_Delete(GDALDriverShadow *self,char const *name){ + return GDALDeleteDataset( self, name ); + } + +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} + +static GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){ + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } +static void delete_GDAL_GCP(GDAL_GCP *self){ + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } + + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + +static void delete_GDALDatasetShadow(GDALDatasetShadow *self){ + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } +static GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){ + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } +static GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){ + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } +static char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){ + return GDALSetProjection( self, prj ); + } +static void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6]){ + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } +static CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){ + return GDALSetGeoTransform( self, argin ); + } +static int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0){ + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +static int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){ + return GDALGetGCPCount( self ); + } +static char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){ + return GDALGetGCPProjection( self ); + } +static void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){ + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } +static CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){ + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } +static void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){ + GDALFlushCache( self ); + } +static CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){ + return GDALAddBand( self, datatype, options ); + } +static CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } + +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} + + +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} + +static GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){ + return GDALGetRasterColorInterpretation( self ); + } +static CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){ + return GDALSetRasterColorInterpretation( self, val ); + } +static void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterNoDataValue( self, hasval ); + } +static CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){ + return GDALSetRasterNoDataValue( self, d ); + } +static void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMinimum( self, hasval ); + } +static void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMaximum( self, hasval ); + } +static void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterOffset( self, hasval ); + } +static void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterScale( self, hasval ); + } +static int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){ + return GDALGetOverviewCount( self ); + } +static GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){ + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } +static int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){ + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +static void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){ + GDALComputeRasterMinMax( self, approx_ok, argout ); + } +static CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){ + return GDALFillRaster( self, real_fill, imag_fill ); + } +static CPLErr GDALRasterBandShadow_ReadRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_len,char **buf,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +static CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +static void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){ + GDALFlushRasterCache( self ); + } +static GDALColorTable *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){ + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } +static int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTable *arg){ + return GDALSetRasterColorTable( self, arg ); + } +static CPLErr GDALRasterBandShadow_ReadRaster_Direct(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_xsize,int buf_ysize,GDALDataType buf_type,void *buf){ + + return GDALRasterIO( self, GF_Read, xoff, yoff, xsize, ysize, + buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + +} +static CPLErr GDALRasterBandShadow_WriteRaster_Direct(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_xsize,int buf_ysize,GDALDataType buf_type,void *buf){ + + return GDALRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + +} + +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} + + +int GetDriverCount() { + return GDALGetDriverCount(); +} + + +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} + + +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} + + +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} + + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Debug(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return ; + } + } + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + Debug((char const *)arg1,(char const *)arg2); + + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Error(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2, jstring jarg3) { + CPLErr arg1 = (CPLErr) CE_Failure ; + int arg2 = (int) 0 ; + char *arg3 = (char *) "error" ; + + (void)jenv; + (void)jcls; + arg1 = (CPLErr)jarg1; + arg2 = (int)jarg2; + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return ; + } + } + Error(arg1,arg2,(char const *)arg3); + + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_PushErrorHandler_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jint jresult = 0 ; + char *arg1 = (char *) "CPLQuietErrorHandler" ; + CPLErr result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (CPLErr)PushErrorHandler((char const *)arg1); + + jresult = (jint)result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_PushErrorHandler_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1) { + CPLErrorHandler arg1 ; + CPLErrorHandler *argp1 ; + + (void)jenv; + (void)jcls; + argp1 = *(CPLErrorHandler **)(void *)&jarg1; + if (!argp1) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null CPLErrorHandler"); + return ; + } + arg1 = *argp1; + CPLPushErrorHandler(arg1); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_PopErrorHandler(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + CPLPopErrorHandler(); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_ErrorReset(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + CPLErrorReset(); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetLastErrorNo(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)CPLGetLastErrorNo(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetLastErrorType(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + result = (CPLErr)CPLGetLastErrorType(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GetLastErrorMsg(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *)CPLGetLastErrorMsg(); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_PushFinderLocation(JNIEnv *jenv, jclass jcls, jstring jarg1) { + char *arg1 = (char *) 0 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return ; + } + } + CPLPushFinderLocation((char const *)arg1); + + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_PopFinderLocation(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + CPLPopFinderLocation(); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_FinderClean(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + CPLFinderClean(); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_FindFile(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) { + jstring jresult = 0 ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char *)CPLFindFile((char const *)arg1,(char const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_SetConfigOption(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return ; + } + } + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + CPLSetConfigOption((char const *)arg1,(char const *)arg2); + + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GetConfigOption(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) { + jstring jresult = 0 ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char *)CPLGetConfigOption((char const *)arg1,(char const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_CPLBinaryToHex(JNIEnv *jenv, jclass jcls, jint jarg1, jlong jarg2) { + jstring jresult = 0 ; + int arg1 ; + GByte *arg2 = (GByte *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + arg2 = *(GByte **)(void *)&jarg2; + result = (char *)CPLBinaryToHex(arg1,(GByte const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_CPLHexToBinary(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int *arg2 = (int *) 0 ; + GByte *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = *(int **)(void *)&jarg2; + result = (GByte *)CPLHexToBinary((char const *)arg1,arg2); + + *(GByte **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1GetDescription(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + result = (char *)GDALMajorObjectShadow_GetDescription(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1SetDescription(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDALMajorObjectShadow_SetDescription(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jobject JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1GetMetadata_1Dict(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jobject jresult = 0 ; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char **)GDALMajorObjectShadow_GetMetadata_Dict(arg1,(char const *)arg2); + + { + /* %typemap(out) char ** -> to hash */ + /* Convert a char array to a Hashtable */ + char **stringarray = result; + const jclass hashtable = jenv->FindClass("java/util/Hashtable"); + const jmethodID constructor = jenv->GetMethodID(hashtable, "<init>", "()V"); + const jmethodID put = jenv->GetMethodID(hashtable, "put", + "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + jresult = jenv->NewObject(hashtable, constructor); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + /*printf("working on pair: %s\n", *stringarray);*/ + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + jstring name = jenv->NewStringUTF(keyptr); + jstring value = jenv->NewStringUTF(valptr); + jenv->CallObjectMethod(jresult, put, name, value); + CPLFree( keyptr ); + } + stringarray++; + } + } + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jobject JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1GetMetadata_1List(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jobject jresult = 0 ; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char **)GDALMajorObjectShadow_GetMetadata_List(arg1,(char const *)arg2); + + { + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = result; + const jclass vector = jenv->FindClass("java/util/Vector"); + const jmethodID constructor = jenv->GetMethodID(vector, "<init>", "()V"); + const jmethodID add = jenv->GetMethodID(vector, "add", "(Ljava/lang/Object;)Z"); + + jresult = jenv->NewObject(vector, constructor); + if ( stringarray != NULL ) { + while(*stringarray != NULL) { + /*printf("working on string %s\n", *stringarray);*/ + jstring value = (jstring)jenv->NewStringUTF(*stringarray); + jenv->CallBooleanMethod(jresult, add, value); + stringarray++; + } + } + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1SetMetadata_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2, jstring jarg3) { + jint jresult = 0 ; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + { + /* %typemap(in) char **dict */ + /* Convert the Hashtable to a char array */ + arg2 = NULL; + if(jarg2 != 0) { + const jclass hashtable = jenv->FindClass("java/util/Hashtable"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID get = jenv->GetMethodID(hashtable, "get", + "(Ljava/lang/Object;)Ljava/lang/Object;"); + const jmethodID keys = jenv->GetMethodID(hashtable, "keys", + "()Ljava/lang/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "getNextElement", "()Ljava/lang/Object;"); + for (jobject keyset = jenv->CallObjectMethod(jarg2, keys); + jenv->CallBooleanMethod(keyset, hasMoreElements) == JNI_TRUE;) { + jstring key = (jstring)jenv->CallObjectMethod(keyset, getNextElement); + jstring value = (jstring)jenv->CallObjectMethod(jarg2, get, key); + const char *keyptr = jenv->GetStringUTFChars(key, 0); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg2 = CSLAddNameValue(arg2, keyptr, valptr); + jenv->ReleaseStringUTFChars(key, keyptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_0(arg1,arg2,(char const *)arg3); + + jresult = (jint)result; + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_MajorObject_1SetMetadata_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3) { + jint jresult = 0 ; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALMajorObjectShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_1(arg1,arg2,(char const *)arg3); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1ShortName_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + result = (char *)GDALDriverShadow_ShortName_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1LongName_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + result = (char *)GDALDriverShadow_LongName_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1HelpTopic_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + result = (char *)GDALDriverShadow_HelpTopic_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1Create(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jobject jarg7) { + jlong jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 = (int) 1 ; + GDALDataType arg6 = (GDALDataType) GDT_Byte ; + char **arg7 = (char **) 0 ; + GDALDatasetShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + arg6 = (GDALDataType)jarg6; + { + /* %typemap(in) char **options */ + arg7 = NULL; + if(jarg7 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg7, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg7 = CSLAddString(arg7, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (GDALDatasetShadow *)GDALDriverShadow_Create(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + + *(GDALDatasetShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1CreateCopy(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jlong jarg3, jint jarg4, jobject jarg5) { + jlong jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + GDALDatasetShadow *arg3 = (GDALDatasetShadow *) 0 ; + int arg4 = (int) 1 ; + char **arg5 = (char **) 0 ; + GDALDatasetShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = *(GDALDatasetShadow **)(void *)&jarg3; + arg4 = (int)jarg4; + { + /* %typemap(in) char **options */ + arg5 = NULL; + if(jarg5 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg5, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg5 = CSLAddString(arg5, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (GDALDatasetShadow *)GDALDriverShadow_CreateCopy(arg1,(char const *)arg2,arg3,arg4,arg5); + + *(GDALDatasetShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Driver_1Delete(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (int)GDALDriverShadow_Delete(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPX_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPX_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPX_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPX_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPY_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPY_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPY_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPY_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPZ_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPZ_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPZ_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPZ_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPPixel_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPPixel_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPPixel_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPLine_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPLine_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1GCPLine_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPLine_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1Info_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_Info_set(arg1,arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1Info_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_Info_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1Id_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_Id_set(arg1,arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GCP_1Id_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_Id_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_new_1GCP(JNIEnv *jenv, jclass jcls, jdouble jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5, jstring jarg6, jstring jarg7) { + jlong jresult = 0 ; + double arg1 = (double) 0.0 ; + double arg2 = (double) 0.0 ; + double arg3 = (double) 0.0 ; + double arg4 = (double) 0.0 ; + double arg5 = (double) 0.0 ; + char *arg6 = (char *) "" ; + char *arg7 = (char *) "" ; + GDAL_GCP *result; + + (void)jenv; + (void)jcls; + arg1 = (double)jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + { + arg6 = 0; + if (jarg6) { + arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0); + if (!arg6) return 0; + } + } + { + arg7 = 0; + if (jarg7) { + arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0); + if (!arg7) return 0; + } + } + result = (GDAL_GCP *)new_GDAL_GCP(arg1,arg2,arg3,arg4,arg5,(char const *)arg6,(char const *)arg7); + + *(GDAL_GCP **)(void *)&jresult = result; + { + if (arg6) jenv->ReleaseStringUTFChars(jarg6, arg6); + } + { + if (arg7) jenv->ReleaseStringUTFChars(jarg7, arg7); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_delete_1GCP(JNIEnv *jenv, jclass jcls, jlong jarg1) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + delete_GDAL_GCP(arg1); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPX_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPX_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPX_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPX_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPY_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPY_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPY_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPY_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPZ_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPZ_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPZ_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPZ_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPPixel_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPPixel_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPPixel_set(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPLine_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_GCPLine_get(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1GCPLine_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_GCPLine_set(arg1,arg2); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1Info_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_Info_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1Info_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_Info_set(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1Id_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_Id_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1Id_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_Id_set(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1GCPX(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_get_GCPX(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1GCPX(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_set_GCPX(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1GCPY(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_get_GCPY(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1GCPY(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_set_GCPY(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1GCPZ(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_get_GCPZ(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1GCPZ(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_set_GCPZ(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1GCPPixel(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_get_GCPPixel(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1GCPPixel(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_set_GCPPixel(arg1,arg2); + +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1GCPLine(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (double)GDAL_GCP_get_GCPLine(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1GCPLine(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + arg2 = (double)jarg2; + GDAL_GCP_set_GCPLine(arg1,arg2); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1Info(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_get_Info(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1Info(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_set_Info(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1get_1Id(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + result = (char *)GDAL_GCP_get_Id(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_GDAL_1GCP_1set_1Id(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDAL_GCP **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + GDAL_GCP_set_Id(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_GCPsToGeoTransform(JNIEnv *jenv, jclass jcls, jint jarg1, jlong jarg2, jdoubleArray jarg3, jint jarg4) { + jlong jresult = 0 ; + int arg1 ; + GDAL_GCP *arg2 = (GDAL_GCP *) 0 ; + double *arg3 ; + int arg4 = (int) 1 ; + FALSE_IS_ERR result; + jdouble *jarr3 ; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + arg2 = *(GDAL_GCP **)(void *)&jarg2; + if (jarg3 && jenv->GetArrayLength(jarg3) != 6) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return 0; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr3, &arg3, jarg3)) return 0; + arg4 = (int)jarg4; + result = GDALGCPsToGeoTransform(arg1,(GDAL_GCP const *)arg2,arg3,arg4); + + { + /* %typemap(out) IF_FALSE_RETURN_NONE */ + jresult = 0; + } + SWIG_JavaArrayArgoutDouble(jenv, jarr3, arg3, jarg3); + delete [] arg3; + { + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1RasterXSize_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (int)GDALDatasetShadow_RasterXSize_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1RasterYSize_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (int)GDALDatasetShadow_RasterYSize_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1RasterCount_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (int)GDALDatasetShadow_RasterCount_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_delete_1Dataset(JNIEnv *jenv, jclass jcls, jlong jarg1) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + delete_GDALDatasetShadow(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetDriver(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDriverShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (GDALDriverShadow *)GDALDatasetShadow_GetDriver(arg1); + + *(GDALDriverShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetRasterBand(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (GDALRasterBandShadow *)GDALDatasetShadow_GetRasterBand(arg1,arg2); + + *(GDALRasterBandShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetProjection(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (char *)GDALDatasetShadow_GetProjection(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetProjectionRef(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (char *)GDALDatasetShadow_GetProjectionRef(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1SetProjection(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (CPLErr)GDALDatasetShadow_SetProjection(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetGeoTransform(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 6) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return ; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return ; + GDALDatasetShadow_GetGeoTransform(arg1,arg2); + + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1SetGeoTransform(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + CPLErr result; + jboolean isCopy2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + { + /* %typemap(in) (double argin[ANY]) */ + arg2 = (double *)jenv->GetDoubleArrayElements(jarg2, &isCopy2); + } + result = (CPLErr)GDALDatasetShadow_SetGeoTransform(arg1,arg2); + + jresult = (jint)result; + { + /* %typemap(argout) (double argin[ANY]) */ + } + { + /* %typemap(in) (double argin[ANY]) */ + if(isCopy2 == JNI_TRUE) { + jenv->ReleaseDoubleArrayElements(jarg2, (jdouble *)arg2, 0); + } + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1BuildOverviews(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jintArray jarg3) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) "NEAREST" ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + /* %typemap(in) (int nList, int* pList) */ + /* check if is List */ + arg3 = jenv->GetArrayLength(jarg3); + arg4 = (int *)jenv->GetIntArrayElements(jarg3, NULL); + } + result = (int)GDALDatasetShadow_BuildOverviews(arg1,(char const *)arg2,arg3,arg4); + + jresult = (jint)result; + { + /* %typemap(argout) (int nList, int* pList) */ + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetGCPCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (int)GDALDatasetShadow_GetGCPCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetGCPProjection(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + result = (char *)GDALDatasetShadow_GetGCPProjection(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1GetGCPs(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg2) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int *arg2 = (int *) 0 ; + GDAL_GCP **arg3 = (GDAL_GCP **) 0 ; + int nGCPs2 = 0 ; + GDAL_GCP *pGCPs2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=1) (int *nGCPs2, GDAL_GCP const **pGCPs2 ) */ + arg2 = &nGCPs2; + arg3 = &pGCPs2; + } + GDALDatasetShadow_GetGCPs(arg1,arg2,(GDAL_GCP const **)arg3); + + { + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + const jclass GCPClass = jenv->FindClass("org/gdal/gdal/GCP"); + const jclass vectorClass = jenv->FindClass("java/util/Vector"); + const jmethodID add = jenv->GetMethodID(vectorClass, "add", "(Ljava/lang/Object;)Z"); + const jmethodID GCPcon = jenv->GetMethodID(GCPClass, "<init>", + "(DDDDDLjava/lang/String;Ljava/lang/String;)V"); + + for( int i = 0; i < *arg2; i++ ) { + jobject GCPobj = jenv->NewObject(GCPClass, GCPcon, + (*arg3)[i].dfGCPX, + (*arg3)[i].dfGCPY, + (*arg3)[i].dfGCPZ, + (*arg3)[i].dfGCPPixel, + (*arg3)[i].dfGCPLine, + (*arg3)[i].pszInfo, + (*arg3)[i].pszId ); + + jenv->CallBooleanMethod(jarg2, add, GCPobj); + } + //jresult = jarg2; + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1SetGCPs(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jlong jarg3, jstring jarg4) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDAL_GCP *arg3 = (GDAL_GCP *) 0 ; + char *arg4 = (char *) 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = *(GDAL_GCP **)(void *)&jarg3; + { + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + } + result = (CPLErr)GDALDatasetShadow_SetGCPs(arg1,arg2,(GDAL_GCP const *)arg3,(char const *)arg4); + + jresult = (jint)result; + { + if (arg4) jenv->ReleaseStringUTFChars(jarg4, arg4); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1FlushCache(JNIEnv *jenv, jclass jcls, jlong jarg1) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + GDALDatasetShadow_FlushCache(arg1); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1AddBand(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jobject jarg3) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDataType arg2 = (GDALDataType) GDT_Byte ; + char **arg3 = (char **) 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + arg2 = (GDALDataType)jarg2; + { + /* %typemap(in) char **options */ + arg3 = NULL; + if(jarg3 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg3, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg3 = CSLAddString(arg3, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (CPLErr)GDALDatasetShadow_AddBand(arg1,arg2,arg3); + + jresult = (jint)result; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Dataset_1WriteRaster(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jcharArray jarg6, jintArray jarg8, jintArray jarg9, jintArray jarg10, jintArray jarg11) { + jint jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + GDALDataType *arg10 = (GDALDataType *) 0 ; + int arg11 = (int) 0 ; + int *arg12 = (int *) 0 ; + CPLErr result; + jboolean isCopy6 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + { + /* %typemap(in) (int nLen, char *pBuf ) */ + arg6 = jenv->GetArrayLength(jarg6); + arg7 = (char *)jenv->GetCharArrayElements(jarg6, &isCopy6); + } + { + /* %typemap(in) (int *optional_##int) */ + arg8 = (int *)jarg8; + } + { + /* %typemap(in) (int *optional_##int) */ + arg9 = (int *)jarg9; + } + { + /* %typemap(in) (int *optional_##int) */ + arg10 = (GDALDataType *)jarg10; + } + { + /* %typemap(in) (int nList, int* pList) */ + /* check if is List */ + arg11 = jenv->GetArrayLength(jarg11); + arg12 = (int *)jenv->GetIntArrayElements(jarg11, NULL); + } + result = (CPLErr)GDALDatasetShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + + jresult = (jint)result; + { + /* %typemap(argout) (int nLen, char *pBuf ) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(argout) (int nList, int* pList) */ + } + { + /* %typemap(freearg) (int nLen, char *pBuf ) */ + /* This calls JNI_ABORT, so any modifications will not be passed back + into the Java caller + */ + if(isCopy6 == JNI_TRUE) { + jenv->ReleaseCharArrayElements(jarg6, (jchar *)arg7, 0); + } + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1XSize_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (int)GDALRasterBandShadow_XSize_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1YSize_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (int)GDALRasterBandShadow_YSize_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1DataType_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALDataType result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (GDALDataType)GDALRasterBandShadow_DataType_get(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetRasterColorInterpretation(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (GDALColorInterp)GDALRasterBandShadow_GetRasterColorInterpretation(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1SetRasterColorInterpretation(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp arg2 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (GDALColorInterp)jarg2; + result = (CPLErr)GDALRasterBandShadow_SetRasterColorInterpretation(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetNoDataValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + if(jenv->GetArrayLength(jarg2) < 1) { + return ; + } + } + GDALRasterBandShadow_GetNoDataValue(arg1,arg2,arg3); + + { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*arg3) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval2); + jenv->SetObjectArrayElement(jarg2, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement(jarg2, (jsize)0, 0); + } + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1SetNoDataValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + result = (CPLErr)GDALRasterBandShadow_SetNoDataValue(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetMinimum(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + if(jenv->GetArrayLength(jarg2) < 1) { + return ; + } + } + GDALRasterBandShadow_GetMinimum(arg1,arg2,arg3); + + { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*arg3) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval2); + jenv->SetObjectArrayElement(jarg2, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement(jarg2, (jsize)0, 0); + } + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetMaximum(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + if(jenv->GetArrayLength(jarg2) < 1) { + return ; + } + } + GDALRasterBandShadow_GetMaximum(arg1,arg2,arg3); + + { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*arg3) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval2); + jenv->SetObjectArrayElement(jarg2, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement(jarg2, (jsize)0, 0); + } + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetOffset(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + if(jenv->GetArrayLength(jarg2) < 1) { + return ; + } + } + GDALRasterBandShadow_GetOffset(arg1,arg2,arg3); + + { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*arg3) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval2); + jenv->SetObjectArrayElement(jarg2, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement(jarg2, (jsize)0, 0); + } + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetScale(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + if(jenv->GetArrayLength(jarg2) < 1) { + return ; + } + } + GDALRasterBandShadow_GetScale(arg1,arg2,arg3); + + { + /* %typemap(argout) (double *val, int*hasval) */ + const jclass Double = jenv->FindClass("java/lang/Double"); + const jmethodID ctor = jenv->GetMethodID(Double, "<init>", + "(D)V"); + if(*arg3) { + jobject dbl = jenv->NewObject(Double, ctor, tmpval2); + jenv->SetObjectArrayElement(jarg2, (jsize)0, dbl); + } else { + jenv->SetObjectArrayElement(jarg2, (jsize)0, 0); + } + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetOverviewCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (int)GDALRasterBandShadow_GetOverviewCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetOverview(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (GDALRasterBandShadow *)GDALRasterBandShadow_GetOverview(arg1,arg2); + + *(GDALRasterBandShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1Checksum(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jintArray jarg4, jintArray jarg5) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 = (int) 0 ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + { + /* %typemap(in) (int *optional_##int) */ + arg4 = (int *)jarg4; + } + { + /* %typemap(in) (int *optional_##int) */ + arg5 = (int *)jarg5; + } + result = (int)GDALRasterBandShadow_Checksum(arg1,arg2,arg3,arg4,arg5); + + jresult = (jint)result; + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1ComputeRasterMinMax(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2, jint jarg3) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 0 ; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 2) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return ; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return ; + arg3 = (int)jarg3; + GDALRasterBandShadow_ComputeRasterMinMax(arg1,arg2,arg3); + + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1Fill(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + double arg3 = (double) 0.0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + result = (CPLErr)GDALRasterBandShadow_Fill(arg1,arg2,arg3); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1ReadRaster(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jobjectArray jarg6, jintArray jarg8, jintArray jarg9, jintArray jarg10) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 = (int *) 0 ; + char **arg7 = (char **) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + int nLen6 ; + char *pBuf6 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + { + /* %typemap(in) (int *nLen6, char **pBuf6 ) */ + arg6 = &nLen6; + arg7 = &pBuf6; + } + { + /* %typemap(in) (int *optional_##int) */ + arg8 = (int *)jarg8; + } + { + /* %typemap(in) (int *optional_##int) */ + arg9 = (int *)jarg9; + } + { + /* %typemap(in) (int *optional_##int) */ + arg10 = (int *)jarg10; + } + result = (CPLErr)GDALRasterBandShadow_ReadRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + jresult = (jint)result; + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + /* make sure that the passed array is at lease length 1 */ + if(jenv->GetArrayLength(jarg6) >= 1) { + jcharArray charArray = jenv->NewCharArray(nLen6); + jenv->SetCharArrayRegion(charArray, (jsize)0, (jsize)nLen6, (jchar*)pBuf6); + jenv->SetObjectArrayElement(jarg6,0,charArray); + } + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( arg6 ) { + free( *arg7 ); + } + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1WriteRaster(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jcharArray jarg6, jintArray jarg8, jintArray jarg9, jintArray jarg10) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + jboolean isCopy6 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + { + /* %typemap(in) (int nLen, char *pBuf ) */ + arg6 = jenv->GetArrayLength(jarg6); + arg7 = (char *)jenv->GetCharArrayElements(jarg6, &isCopy6); + } + { + /* %typemap(in) (int *optional_##int) */ + arg8 = (int *)jarg8; + } + { + /* %typemap(in) (int *optional_##int) */ + arg9 = (int *)jarg9; + } + { + /* %typemap(in) (int *optional_##int) */ + arg10 = (int *)jarg10; + } + result = (CPLErr)GDALRasterBandShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + jresult = (jint)result; + { + /* %typemap(argout) (int nLen, char *pBuf ) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(in) (int *optional_##int) */ + } + { + /* %typemap(freearg) (int nLen, char *pBuf ) */ + /* This calls JNI_ABORT, so any modifications will not be passed back + into the Java caller + */ + if(isCopy6 == JNI_TRUE) { + jenv->ReleaseCharArrayElements(jarg6, (jchar *)arg7, 0); + } + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_Band_1FlushCache(JNIEnv *jenv, jclass jcls, jlong jarg1) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + GDALRasterBandShadow_FlushCache(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Band_1GetRasterColorTable(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + result = (GDALColorTable *)GDALRasterBandShadow_GetRasterColorTable(arg1); + + *(GDALColorTable **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1SetRasterColorTable(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *arg2 = (GDALColorTable *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = *(GDALColorTable **)(void *)&jarg2; + result = (int)GDALRasterBandShadow_SetRasterColorTable(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1ReadRaster_1Direct(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jint jarg7, jint jarg8, jobject jarg9) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + GDALDataType arg8 ; + void *arg9 = (void *) 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + arg6 = (int)jarg6; + arg7 = (int)jarg7; + arg8 = (GDALDataType)jarg8; + { + /* %typemap(in) void * */ + arg9 = jenv->GetDirectBufferAddress(jarg9); + } + result = (CPLErr)GDALRasterBandShadow_ReadRaster_Direct(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_Band_1WriteRaster_1Direct(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jint jarg7, jint jarg8, jobject jarg9) { + jint jresult = 0 ; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + int arg7 ; + GDALDataType arg8 ; + void *arg9 = (void *) 0 ; + CPLErr result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALRasterBandShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + arg4 = (int)jarg4; + arg5 = (int)jarg5; + arg6 = (int)jarg6; + arg7 = (int)jarg7; + arg8 = (GDALDataType)jarg8; + { + /* %typemap(in) void * */ + arg9 = jenv->GetDirectBufferAddress(jarg9); + } + result = (CPLErr)GDALRasterBandShadow_WriteRaster_Direct(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_new_1ColorTable(JNIEnv *jenv, jclass jcls, jint jarg1) { + jlong jresult = 0 ; + GDALPaletteInterp arg1 = (GDALPaletteInterp) GPI_RGB ; + GDALColorTable *result; + + (void)jenv; + (void)jcls; + arg1 = (GDALPaletteInterp)jarg1; + result = (GDALColorTable *)new GDALColorTable(arg1); + + *(GDALColorTable **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_delete_1ColorTable(JNIEnv *jenv, jclass jcls, jlong jarg1) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + delete arg1; + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1Clone(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALColorTable *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + result = (GDALColorTable *)((GDALColorTable const *)arg1)->Clone(); + + *(GDALColorTable **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1GetPaletteInterpretation(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALPaletteInterp result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + result = (GDALPaletteInterp)((GDALColorTable const *)arg1)->GetPaletteInterpretation(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1GetCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + result = (int)((GDALColorTable const *)arg1)->GetColorEntryCount(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jobject JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1GetColorEntry(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jobject jresult = 0 ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (GDALColorEntry *)(arg1)->GetColorEntry(arg2); + + { + /* %typemap(out) (GDALColorEntry *) */ + const jclass Color = jenv->FindClass("java/awt/Color"); + const jmethodID ccon = jenv->GetMethodID(Color, "<init>", + "(IIII)V"); + jresult = jenv->NewObject(Color, ccon, result->c1, result->c2, result->c3, result->c4); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1GetColorEntryAsRGB(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jobject jarg3) { + jint jresult = 0 ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + int result; + GDALColorEntry tmp3 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + arg2 = (int)jarg2; + { + /* %typemap(in) (GDALColorEntry *) (GDALColorEntry tmp3) */ + arg3 = NULL; + float *colorptr = 0; + const jclass Color = jenv->FindClass("java/awt/Color"); + const jmethodID colors = jenv->GetMethodID(Color, "getRGBComponents", + "([F)[F"); + + jfloatArray colorArr = jenv->NewFloatArray(4); + colorArr = (jfloatArray)jenv->CallObjectMethod(jarg3, colors, colorArr); + + colorptr = (float *)jenv->GetFloatArrayElements(colorArr, 0); + tmp3.c1 = (short)(colorptr[0] * 255); + tmp3.c2 = (short)(colorptr[1] * 255); + tmp3.c3 = (short)(colorptr[2] * 255); + tmp3.c4 = (short)(colorptr[3] * 255); + /*printf( " %d, %d, %d, %d\n", + tmp3.c1, tmp3.c2, tmp3.c3, tmp3.c4 );*/ + arg3 = &tmp3; + } + result = (int)((GDALColorTable const *)arg1)->GetColorEntryAsRGB(arg2,arg3); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_ColorTable_1SetColorEntry(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jobject jarg3) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + GDALColorEntry tmp3 ; + + (void)jenv; + (void)jcls; + arg1 = *(GDALColorTable **)(void *)&jarg1; + arg2 = (int)jarg2; + { + /* %typemap(in) (GDALColorEntry *) (GDALColorEntry tmp3) */ + arg3 = NULL; + float *colorptr = 0; + const jclass Color = jenv->FindClass("java/awt/Color"); + const jmethodID colors = jenv->GetMethodID(Color, "getRGBComponents", + "([F)[F"); + + jfloatArray colorArr = jenv->NewFloatArray(4); + colorArr = (jfloatArray)jenv->CallObjectMethod(jarg3, colors, colorArr); + + colorptr = (float *)jenv->GetFloatArrayElements(colorArr, 0); + tmp3.c1 = (short)(colorptr[0] * 255); + tmp3.c2 = (short)(colorptr[1] * 255); + tmp3.c3 = (short)(colorptr[2] * 255); + tmp3.c4 = (short)(colorptr[3] * 255); + /*printf( " %d, %d, %d, %d\n", + tmp3.c1, tmp3.c2, tmp3.c3, tmp3.c4 );*/ + arg3 = &tmp3; + } + (arg1)->SetColorEntry(arg2,(GDALColorEntry const *)arg3); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_AllRegister(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + GDALAllRegister(); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetCacheMax(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)GDALGetCacheMax(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_gdal_gdalJNI_SetCacheMax(JNIEnv *jenv, jclass jcls, jint jarg1) { + int arg1 ; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + GDALSetCacheMax(arg1); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetCacheUsed(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)GDALGetCacheUsed(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetDataTypeSize(JNIEnv *jenv, jclass jcls, jint jarg1) { + jint jresult = 0 ; + GDALDataType arg1 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = (GDALDataType)jarg1; + result = (int)GDALGetDataTypeSize(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_DataTypeIsComplex(JNIEnv *jenv, jclass jcls, jint jarg1) { + jint jresult = 0 ; + GDALDataType arg1 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = (GDALDataType)jarg1; + result = (int)GDALDataTypeIsComplex(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GetDataTypeName(JNIEnv *jenv, jclass jcls, jint jarg1) { + jstring jresult = 0 ; + GDALDataType arg1 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = (GDALDataType)jarg1; + result = (char *)GDALGetDataTypeName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetDataTypeByName(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jint jresult = 0 ; + char *arg1 = (char *) 0 ; + GDALDataType result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (GDALDataType)GDALGetDataTypeByName((char const *)arg1); + + jresult = (jint)result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GetColorInterpretationName(JNIEnv *jenv, jclass jcls, jint jarg1) { + jstring jresult = 0 ; + GDALColorInterp arg1 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = (GDALColorInterp)jarg1; + result = (char *)GDALGetColorInterpretationName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_GetPaletteInterpretationName(JNIEnv *jenv, jclass jcls, jint jarg1) { + jstring jresult = 0 ; + GDALPaletteInterp arg1 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = (GDALPaletteInterp)jarg1; + result = (char *)GDALGetPaletteInterpretationName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_DecToDMS(JNIEnv *jenv, jclass jcls, jdouble jarg1, jstring jarg2, jint jarg3) { + jstring jresult = 0 ; + double arg1 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 2 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = (double)jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (int)jarg3; + result = (char *)GDALDecToDMS(arg1,(char const *)arg2,arg3); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_PackedDMSToDec(JNIEnv *jenv, jclass jcls, jdouble jarg1) { + jdouble jresult = 0 ; + double arg1 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = (double)jarg1; + result = (double)GDALPackedDMSToDec(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_gdal_gdalJNI_DecToPackedDMS(JNIEnv *jenv, jclass jcls, jdouble jarg1) { + jdouble jresult = 0 ; + double arg1 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = (double)jarg1; + result = (double)GDALDecToPackedDMS(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_ParseXMLString(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + CPLXMLNode *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (CPLXMLNode *)CPLParseXMLString(arg1); + + *(CPLXMLNode **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdal_gdalJNI_SerializeXMLTree(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + CPLXMLNode *arg1 = (CPLXMLNode *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(CPLXMLNode **)(void *)&jarg1; + result = (char *)CPLSerializeXMLTree(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdal_gdalJNI_GetDriverCount(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)GetDriverCount(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_GetDriverByName(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + GDALDriverShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (GDALDriverShadow *)GetDriverByName((char const *)arg1); + + *(GDALDriverShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_GetDriver(JNIEnv *jenv, jclass jcls, jint jarg1) { + jlong jresult = 0 ; + int arg1 ; + GDALDriverShadow *result; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + result = (GDALDriverShadow *)GetDriver(arg1); + + *(GDALDriverShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_Open(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = (GDALAccess)jarg2; + result = (GDALDatasetShadow *)Open((char const *)arg1,arg2); + + *(GDALDatasetShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_OpenShared(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = (GDALAccess)jarg2; + result = (GDALDatasetShadow *)OpenShared((char const *)arg1,arg2); + + *(GDALDatasetShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_AutoCreateWarpedVRT(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3, jint jarg4, jdouble jarg5) { + jlong jresult = 0 ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + GDALResampleAlg arg4 = (GDALResampleAlg) GRA_NearestNeighbour ; + double arg5 = (double) 0.0 ; + GDALDatasetShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(GDALDatasetShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + arg4 = (GDALResampleAlg)jarg4; + arg5 = (double)jarg5; + result = (GDALDatasetShadow *)AutoCreateWarpedVRT(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + + *(GDALDatasetShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_SWIGDriverUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong baseptr = 0; + (void)jenv; + (void)jcls; + *(GDALMajorObjectShadow **)(void *)&baseptr = *(GDALDriverShadow **)(void *)&jarg1; + return baseptr; +} + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_SWIGDatasetUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong baseptr = 0; + (void)jenv; + (void)jcls; + *(GDALMajorObjectShadow **)(void *)&baseptr = *(GDALDatasetShadow **)(void *)&jarg1; + return baseptr; +} + +JNIEXPORT jlong JNICALL Java_org_gdal_gdal_gdalJNI_SWIGBandUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong baseptr = 0; + (void)jenv; + (void)jcls; + *(GDALMajorObjectShadow **)(void *)&baseptr = *(GDALRasterBandShadow **)(void *)&jarg1; + return baseptr; +} + +#ifdef __cplusplus +} +#endif + diff --git a/Utilities/GDAL/swig/java/gdalconst_wrap.c b/Utilities/GDAL/swig/java/gdalconst_wrap.c new file mode 100644 index 0000000000..32c8944e4b --- /dev/null +++ b/Utilities/GDAL/swig/java/gdalconst_wrap.c @@ -0,0 +1,1680 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTELC__) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + (*jenv)->ExceptionClear(jenv); + excep = (*jenv)->FindClass(jenv, except_ptr->java_exception); + if (excep) + (*jenv)->ThrowNew(jenv, excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) + + +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input); +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz); + + +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input); +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz); + + +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input); +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz); + + +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input); +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input); +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz); + + +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input); +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input); +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz); + + +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input); +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz); + + +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input); +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input); +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz); + + +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input); +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz); + + +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input); +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz); + + +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input); +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input); +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz); + + +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input); +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input); +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz); + + +#else + + +/* signed char[] support */ +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetByteArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (signed char*) calloc(sz, sizeof(signed char)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (signed char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jbyte)carr[i]; + (*jenv)->ReleaseByteArrayElements(jenv, input, jarr, 0); +} + +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) { + jbyte *arr; + int i; + jbyteArray jresult = (*jenv)->NewByteArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetByteArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jbyte)result[i]; + (*jenv)->ReleaseByteArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned char[] support */ +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned char*) calloc(sz, sizeof(unsigned char)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + (*jenv)->ReleaseShortArrayElements(jenv, input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = (*jenv)->NewShortArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + (*jenv)->ReleaseShortArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* short[] support */ +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (short*) calloc(sz, sizeof(short)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + (*jenv)->ReleaseShortArrayElements(jenv, input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = (*jenv)->NewShortArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + (*jenv)->ReleaseShortArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned short[] support */ +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned short*) calloc(sz, sizeof(unsigned short)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* int[] support */ +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (int*) calloc(sz, sizeof(int)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned int[] support */ +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned int*) calloc(sz, sizeof(unsigned int)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* long[] support */ +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (long*) calloc(sz, sizeof(long)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned long[] support */ +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned long*) calloc(sz, sizeof(unsigned long)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* jlong[] support */ +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (jlong*) calloc(sz, sizeof(jlong)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (jlong)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* float[] support */ +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetFloatArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (float*) calloc(sz, sizeof(float)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (float)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jfloat)carr[i]; + (*jenv)->ReleaseFloatArrayElements(jenv, input, jarr, 0); +} + +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) { + jfloat *arr; + int i; + jfloatArray jresult = (*jenv)->NewFloatArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetFloatArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jfloat)result[i]; + (*jenv)->ReleaseFloatArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* double[] support */ +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetDoubleArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (double*) calloc(sz, sizeof(double)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (double)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) { + int i; + jsize sz = (*jenv)->GetArrayLength(jenv, input); + for (i=0; i<sz; i++) + jarr[i] = (jdouble)carr[i]; + (*jenv)->ReleaseDoubleArrayElements(jenv, input, jarr, 0); +} + +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { + jdouble *arr; + int i; + jdoubleArray jresult = (*jenv)->NewDoubleArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetDoubleArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jdouble)result[i]; + (*jenv)->ReleaseDoubleArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +#endif + + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Unknown_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Unknown; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Byte_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Byte; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1UInt16_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_UInt16; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Int16_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Int16; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1UInt32_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_UInt32; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Int32_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Int32; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Float32_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Float32; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1Float64_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_Float64; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1CInt16_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_CInt16; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1CInt32_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_CInt32; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1CFloat32_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_CFloat32; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1CFloat64_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_CFloat64; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GDT_1TypeCount_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GDT_TypeCount; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GA_1ReadOnly_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GA_ReadOnly; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GA_1Update_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GA_Update; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GF_1Read_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GF_Read; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GF_1Write_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GF_Write; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1Undefined_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_Undefined; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1GrayIndex_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_GrayIndex; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1PaletteIndex_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_PaletteIndex; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1RedBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_RedBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1GreenBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_GreenBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1BlueBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_BlueBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1AlphaBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_AlphaBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1HueBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_HueBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1SaturationBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_SaturationBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1LightnessBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_LightnessBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1CyanBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_CyanBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1MagentaBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_MagentaBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1YellowBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_YellowBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GCI_1BlackBand_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GCI_BlackBand; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GRA_1NearestNeighbour_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GRA_NearestNeighbour; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GRA_1Bilinear_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GRA_Bilinear; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GRA_1Cubic_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GRA_Cubic; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GRA_1CubicSpline_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GRA_CubicSpline; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GPI_1Gray_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GPI_Gray; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GPI_1RGB_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GPI_RGB; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GPI_1CMYK_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GPI_CMYK; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_GPI_1HLS_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) GPI_HLS; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CXT_1Element_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CXT_Element; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CXT_1Text_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CXT_Text; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CXT_1Attribute_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CXT_Attribute; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CXT_1Comment_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CXT_Comment; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CXT_1Literal_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CXT_Literal; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CE_1None_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CE_None; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CE_1Debug_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CE_Debug; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CE_1Warning_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CE_Warning; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CE_1Failure_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CE_Failure; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CE_1Fatal_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CE_Fatal; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1None_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_None; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1AppDefined_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_AppDefined; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1OutOfMemory_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_OutOfMemory; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1FileIO_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_FileIO; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1OpenFailed_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_OpenFailed; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1IllegalArg_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_IllegalArg; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1NotSupported_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_NotSupported; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1AssertionFailed_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_AssertionFailed; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1NoWriteAccess_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_NoWriteAccess; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLE_1UserInterrupt_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLE_UserInterrupt; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1LONGNAME_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_LONGNAME"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1HELPTOPIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_HELPTOPIC"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1MIMETYPE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_MIMETYPE"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1EXTENSION_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_EXTENSION"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1CREATIONOPTIONLIST_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_CREATIONOPTIONLIST"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DMD_1CREATIONDATATYPES_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DMD_CREATIONDATATYPES"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DCAP_1CREATE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DCAP_CREATE"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_gdalconst_gdalconstJNI_DCAP_1CREATECOPY_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "GDAL_DCAP_CREATECOPY"; + + { + if(result) jresult = (*jenv)->NewStringUTF(jenv, result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLES_1BackslashQuotable_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLES_BackslashQuotable; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLES_1XML_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLES_XML; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLES_1URL_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLES_URL; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLES_1SQL_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLES_SQL; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_gdalconst_gdalconstJNI_CPLES_1CSV_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) CPLES_CSV; + + jresult = (jint)result; + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/Utilities/GDAL/swig/java/java.opt b/Utilities/GDAL/swig/java/java.opt new file mode 100644 index 0000000000..1c50230da5 --- /dev/null +++ b/Utilities/GDAL/swig/java/java.opt @@ -0,0 +1,9 @@ +# +# Java Stuff +JAVA_HOME = "/usr/java/j2sdk1.4.2_10" +JAVADOC=$(JAVA_HOME)\bin\javadoc +JAVAC=$(JAVA_HOME)\bin\javac +JAVA=$(JAVA_HOME)\bin\java +JAR=$(JAVA_HOME)\bin\jar +JAVA_INCLUDE=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux + diff --git a/Utilities/GDAL/swig/java/makefile.vc b/Utilities/GDAL/swig/java/makefile.vc new file mode 100644 index 0000000000..61237478ba --- /dev/null +++ b/Utilities/GDAL/swig/java/makefile.vc @@ -0,0 +1,66 @@ +GDAL_ROOT = ..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +!IFDEF DLLBUILD +GDALLIB = $(GDAL_ROOT)\gdal_i.lib +!ELSE +GDALLIB = $(GDAL_ROOT)\gdal.lib +!ENDIF + +OBJ = gdal_wrap.obj gdalconst_wrap.obj ogr_wrap.obj osr_wrap.obj + +all: ogr_dir gdal_dir const_dir osr_dir + ant + + +ogr_dir: + cd ogr + $(MAKE) /f makefile.vc + cd .. + link ogr_wrap.obj $(GDALLIB) /out:ogrjni.dll /DLL + +gdal_dir: + cd gdal + $(MAKE) /f makefile.vc + cd .. + link gdal_wrap.obj $(GDALLIB) /out:gdaljni.dll /DLL + +const_dir: + cd const + $(MAKE) /f makefile.vc + cd .. + link gdalconst_wrap.obj $(GDALLIB) /out:gdalconstjni.dll /DLL + +osr_dir: + cd osr + $(MAKE) /f makefile.vc + cd .. + link osr_wrap.obj $(GDALLIB) /out:osrjni.dll /DLL + + +clean: + rmdir /s /q org + cd gdal + $(MAKE) /f makefile.vc clean + cd .. + cd ogr + $(MAKE) /f makefile.vc clean + cd .. + cd const + $(MAKE) /f makefile.vc clean + cd .. + cd osr + $(MAKE) /f makefile.vc clean + cd .. + -del gdal.lib + -del *.dll + -del *.obj + -del *.exp + -del *.ilk + -del *.pdb + -del *.tlb + -del *.snk + -del *.cs + -del *.cpp + -del *.lib diff --git a/Utilities/GDAL/swig/java/ogr/makefile.vc b/Utilities/GDAL/swig/java/ogr/makefile.vc new file mode 100644 index 0000000000..2aecc7c9bb --- /dev/null +++ b/Utilities/GDAL/swig/java/ogr/makefile.vc @@ -0,0 +1,17 @@ +OBJ = ogr_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt +!INCLUDE ..\java.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + +.cpp.obj: + $(CC) $(CFLAGS) $(JAVA_INCLUDE) /c $*.cpp diff --git a/Utilities/GDAL/swig/java/ogr_wrap.cpp b/Utilities/GDAL/swig/java/ogr_wrap.cpp new file mode 100644 index 0000000000..1180ae78b1 --- /dev/null +++ b/Utilities/GDAL/swig/java/ogr_wrap.cpp @@ -0,0 +1,5449 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTELC__) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + jenv->ExceptionClear(); + excep = jenv->FindClass(except_ptr->java_exception); + if (excep) + jenv->ThrowNew(excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#define SWIG_MemoryError 1 +#define SWIG_IOError 2 +#define SWIG_RuntimeError 3 +#define SWIG_IndexError 4 +#define SWIG_TypeError 5 +#define SWIG_DivisionByZero 6 +#define SWIG_OverflowError 7 +#define SWIG_SyntaxError 8 +#define SWIG_ValueError 9 +#define SWIG_SystemError 10 +#define SWIG_UnknownError 99 + + +SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { + SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_JavaOutOfMemoryError; + break; + case SWIG_IOError: + exception_code = SWIG_JavaIOException; + break; + case SWIG_SystemError: + case SWIG_RuntimeError: + exception_code = SWIG_JavaRuntimeException; + break; + case SWIG_OverflowError: + case SWIG_IndexError: + exception_code = SWIG_JavaIndexOutOfBoundsException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_JavaArithmeticException; + break; + case SWIG_SyntaxError: + case SWIG_ValueError: + case SWIG_TypeError: + exception_code = SWIG_JavaIllegalArgumentException; + break; + case SWIG_UnknownError: + default: + exception_code = SWIG_JavaUnknownError; + break; + } + SWIG_JavaThrowException(jenv, exception_code, msg); +} + + +#include <stdexcept> + + +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; + + +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) + + +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input); +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input); +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz); + + +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input); +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz); + + +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input); +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz); + + +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input); +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz); + + +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input); +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input); +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz); + + +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input); +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input); +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz); + + +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input); +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz); + + +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input); +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input); +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz); + + +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input); +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz); + + +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input); +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz); + + +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input); +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input); +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz); + + +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input); +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input); +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz); + + +#else + + +/* bool[] support */ +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetBooleanArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new bool[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = ((*jarr)[i] != 0); + return 1; +} + +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jboolean)carr[i]; + jenv->ReleaseBooleanArrayElements(input, jarr, 0); +} + +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz) { + jboolean *arr; + int i; + jbooleanArray jresult = jenv->NewBooleanArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetBooleanArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jboolean)result[i]; + jenv->ReleaseBooleanArrayElements(jresult, arr, 0); + return jresult; +} + + +/* signed char[] support */ +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetByteArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new signed char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (signed char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jbyte)carr[i]; + jenv->ReleaseByteArrayElements(input, jarr, 0); +} + +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) { + jbyte *arr; + int i; + jbyteArray jresult = jenv->NewByteArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetByteArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jbyte)result[i]; + jenv->ReleaseByteArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned char[] support */ +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* short[] support */ +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned short[] support */ +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* int[] support */ +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned int[] support */ +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* long[] support */ +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned long[] support */ +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* jlong[] support */ +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new jlong[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (jlong)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* float[] support */ +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetFloatArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new float[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (float)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jfloat)carr[i]; + jenv->ReleaseFloatArrayElements(input, jarr, 0); +} + +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) { + jfloat *arr; + int i; + jfloatArray jresult = jenv->NewFloatArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetFloatArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jfloat)result[i]; + jenv->ReleaseFloatArrayElements(jresult, arr, 0); + return jresult; +} + + +/* double[] support */ +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetDoubleArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new double[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (double)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jdouble)carr[i]; + jenv->ReleaseDoubleArrayElements(input, jarr, 0); +} + +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { + jdouble *arr; + int i; + jdoubleArray jresult = jenv->NewDoubleArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetDoubleArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jdouble)result[i]; + jenv->ReleaseDoubleArrayElements(jresult, arr, 0); + return jresult; +} + + +#endif + +static OGRDataSourceShadow *OGRDriverShadow_CreateDataSource(OGRDriverShadow *self,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } +static OGRDataSourceShadow *OGRDriverShadow_CopyDataSource(OGRDriverShadow *self,OGRDataSourceShadow *copy_ds,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } +static OGRDataSourceShadow *OGRDriverShadow_Open(OGRDriverShadow *self,char const *name,int update=0){ + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } +static int OGRDriverShadow_DeleteDataSource(OGRDriverShadow *self,char const *name){ + return OGR_Dr_DeleteDataSource( self, name ); + } +static bool OGRDriverShadow_TestCapability(OGRDriverShadow *self,char const *cap){ + return OGR_Dr_TestCapability(self, cap); + } +static char const *OGRDriverShadow_GetName(OGRDriverShadow *self){ + return OGR_Dr_GetName( self ); + } +static void delete_OGRDataSourceShadow(OGRDataSourceShadow *self){ + OGRReleaseDataSource(self); + } +static int OGRDataSourceShadow_GetRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetRefCount(self); + } +static int OGRDataSourceShadow_GetSummaryRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetSummaryRefCount(self); + } +static int OGRDataSourceShadow_GetLayerCount(OGRDataSourceShadow *self){ + return OGR_DS_GetLayerCount(self); + } +static OGRDriverShadow *OGRDataSourceShadow_GetDriver(OGRDataSourceShadow *self){ + OGRDriverShadow* driver; + OGRDataSourceShadow* ds; + ds = (OGRDataSourceShadow*)OGROpen((const char *) OGR_DS_GetName(self),0,&driver); + OGRReleaseDataSource(ds); + return driver; + } +static char const *OGRDataSourceShadow_GetName(OGRDataSourceShadow *self){ + return OGR_DS_GetName(self); + } +static OGRErr OGRDataSourceShadow_DeleteLayer(OGRDataSourceShadow *self,int index){ + return OGR_DS_DeleteLayer(self, index); + } + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error %d: None"; + case 1: + return "OGR Error %d: Not enough data"; + case 2: + return "OGR Error %d: Unsupported geometry type"; + case 3: + return "OGR Error %d: Unsupported operation"; + case 4: + return "OGR Error %d: Corrupt data"; + case 5: + return "OGR Error %d: General Error"; + case 6: + return "OGR Error %d: Unsupported SRS"; + default: + return "OGR Error %d: Unknown"; + } +} + +static OGRLayerShadow *OGRDataSourceShadow_CreateLayer(OGRDataSourceShadow *self,char const *name,OSRSpatialReferenceShadow *reference=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_CopyLayer(OGRDataSourceShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByIndex(OGRDataSourceShadow *self,int index=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayer(self, index); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByName(OGRDataSourceShadow *self,char const *layer_name){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayerByName(self, layer_name); + return layer; + } +static bool OGRDataSourceShadow_TestCapability(OGRDataSourceShadow *self,char const *cap){ + return OGR_DS_TestCapability(self, cap); + } +static OGRLayerShadow *OGRDataSourceShadow_ExecuteSQL(OGRDataSourceShadow *self,char const *statement,OGRGeometryShadow *geom=NULL,char const *dialect=""){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } +static void OGRDataSourceShadow_ReleaseResultSet(OGRDataSourceShadow *self,OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +static int OGRLayerShadow_GetRefCount(OGRLayerShadow *self){ + return OGR_L_GetRefCount(self); + } +static void OGRLayerShadow_SetSpatialFilter(OGRLayerShadow *self,OGRGeometryShadow *filter){ + OGR_L_SetSpatialFilter (self, filter); + } +static void OGRLayerShadow_SetSpatialFilterRect(OGRLayerShadow *self,double minx,double miny,double maxx,double maxy){ + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } +static OGRGeometryShadow *OGRLayerShadow_GetSpatialFilter(OGRLayerShadow *self){ + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } +static OGRErr OGRLayerShadow_SetAttributeFilter(OGRLayerShadow *self,char *filter_string){ + return OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + } +static void OGRLayerShadow_ResetReading(OGRLayerShadow *self){ + OGR_L_ResetReading(self); + } +static char const *OGRLayerShadow_GetName(OGRLayerShadow *self){ + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } +static OGRFeatureShadow *OGRLayerShadow_GetFeature(OGRLayerShadow *self,long fid){ + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } +static OGRFeatureShadow *OGRLayerShadow_GetNextFeature(OGRLayerShadow *self){ + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } +static OGRErr OGRLayerShadow_SetNextByIndex(OGRLayerShadow *self,long new_index){ + return OGR_L_SetNextByIndex(self, new_index); + } +static OGRErr OGRLayerShadow_SetFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_SetFeature(self, feature); + } +static OGRErr OGRLayerShadow_CreateFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_CreateFeature(self, feature); + } +static OGRErr OGRLayerShadow_DeleteFeature(OGRLayerShadow *self,long fid){ + return OGR_L_DeleteFeature(self, fid); + } +static OGRErr OGRLayerShadow_SyncToDisk(OGRLayerShadow *self){ + return OGR_L_SyncToDisk(self); + } +static OGRFeatureDefnShadow *OGRLayerShadow_GetLayerDefn(OGRLayerShadow *self){ + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } +static int OGRLayerShadow_GetFeatureCount(OGRLayerShadow *self,int force=1){ + return OGR_L_GetFeatureCount(self, force); + } +static OGRErr OGRLayerShadow_GetExtent(OGRLayerShadow *self,double argout[4],int force=1){ + return OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + } +static bool OGRLayerShadow_TestCapability(OGRLayerShadow *self,char const *cap){ + return OGR_L_TestCapability(self, cap); + } +static OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){ + return OGR_L_CreateField(self, field_def, approx_ok); + } +static OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){ + return OGR_L_StartTransaction(self); + } +static OGRErr OGRLayerShadow_CommitTransaction(OGRLayerShadow *self){ + return OGR_L_CommitTransaction(self); + } +static OGRErr OGRLayerShadow_RollbackTransaction(OGRLayerShadow *self){ + return OGR_L_RollbackTransaction(self); + } +static OSRSpatialReferenceShadow *OGRLayerShadow_GetSpatialRef(OGRLayerShadow *self){ + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } +static GIntBig OGRLayerShadow_GetFeatureRead(OGRLayerShadow *self){ + return OGR_L_GetFeaturesRead(self); + } +static void delete_OGRFeatureShadow(OGRFeatureShadow *self){ + OGR_F_Destroy(self); + } +static OGRFeatureShadow *new_OGRFeatureShadow(OGRFeatureDefnShadow *feature_def=0){ + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } +static OGRFeatureDefnShadow *OGRFeatureShadow_GetDefnRef(OGRFeatureShadow *self){ + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } +static OGRErr OGRFeatureShadow_SetGeometry(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometry(self, geom); + } +static OGRErr OGRFeatureShadow_SetGeometryDirectly(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometryDirectly(self, geom); + } +static OGRGeometryShadow *OGRFeatureShadow_GetGeometryRef(OGRFeatureShadow *self){ + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } +static OGRFeatureShadow *OGRFeatureShadow_Clone(OGRFeatureShadow *self){ + return (OGRFeatureShadow*) OGR_F_Clone(self); + } +static bool OGRFeatureShadow_Equal(OGRFeatureShadow *self,OGRFeatureShadow *feature){ + return OGR_F_Equal(self, feature); + } +static int OGRFeatureShadow_GetFieldCount(OGRFeatureShadow *self){ + return OGR_F_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_0(OGRFeatureShadow *self,int id){ + return (const char *) OGR_F_GetFieldAsString(self, id); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsInteger(self, id); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsDouble(self, id); + } +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } +static bool OGRFeatureShadow_IsFieldSet__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_IsFieldSet(self, id); + } +static bool OGRFeatureShadow_IsFieldSet__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldIndex(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldIndex(self, name); + } +static int OGRFeatureShadow_GetFID(OGRFeatureShadow *self){ + return OGR_F_GetFID(self); + } +static OGRErr OGRFeatureShadow_SetFID(OGRFeatureShadow *self,int fid){ + return OGR_F_SetFID(self, fid); + } +static void OGRFeatureShadow_DumpReadable(OGRFeatureShadow *self){ + OGR_F_DumpReadable(self, NULL); + } +static void OGRFeatureShadow_UnsetField__SWIG_0(OGRFeatureShadow *self,int id){ + OGR_F_UnsetField(self, id); + } +static void OGRFeatureShadow_UnsetField__SWIG_1(OGRFeatureShadow *self,char const *name){ + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } +static void OGRFeatureShadow_SetField__SWIG_0(OGRFeatureShadow *self,int id,char const *value){ + OGR_F_SetFieldString(self, id, value); + } +static void OGRFeatureShadow_SetField__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } +static OGRErr OGRFeatureShadow_SetFrom(OGRFeatureShadow *self,OGRFeatureShadow *other,int forgiving=1){ + return OGR_F_SetFrom(self, other, forgiving); + } +static char const *OGRFeatureShadow_GetStyleString(OGRFeatureShadow *self){ + return (const char*) OGR_F_GetStyleString(self); + } +static void OGRFeatureShadow_SetStyleString(OGRFeatureShadow *self,char const *the_string){ + OGR_F_SetStyleString(self, the_string); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } +static void delete_OGRFeatureDefnShadow(OGRFeatureDefnShadow *self){ + OGR_FD_Destroy(self); + } +static OGRFeatureDefnShadow *new_OGRFeatureDefnShadow(char const *name=NULL){ + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } +static char const *OGRFeatureDefnShadow_GetName(OGRFeatureDefnShadow *self){ + return OGR_FD_GetName(self); + } +static int OGRFeatureDefnShadow_GetFieldCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureDefnShadow_GetFieldDefn(OGRFeatureDefnShadow *self,int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } +static int OGRFeatureDefnShadow_GetFieldIndex(OGRFeatureDefnShadow *self,char const *name){ + return OGR_FD_GetFieldIndex(self, name); + } +static void OGRFeatureDefnShadow_AddFieldDefn(OGRFeatureDefnShadow *self,OGRFieldDefnShadow *defn){ + OGR_FD_AddFieldDefn(self, defn); + } +static OGRwkbGeometryType OGRFeatureDefnShadow_GetGeomType(OGRFeatureDefnShadow *self){ + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } +static void OGRFeatureDefnShadow_SetGeomType(OGRFeatureDefnShadow *self,OGRwkbGeometryType geom_type){ + OGR_FD_SetGeomType(self, geom_type); + } +static int OGRFeatureDefnShadow_GetReferenceCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetReferenceCount(self); + } +static void delete_OGRFieldDefnShadow(OGRFieldDefnShadow *self){ + OGR_Fld_Destroy(self); + } +static OGRFieldDefnShadow *new_OGRFieldDefnShadow(char const *name="unnamed",OGRFieldType field_type=OFTString){ + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } +static char const *OGRFieldDefnShadow_GetName(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static char const *OGRFieldDefnShadow_GetNameRef(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static void OGRFieldDefnShadow_SetName(OGRFieldDefnShadow *self,char const *name){ + OGR_Fld_SetName(self, name); + } +static OGRFieldType OGRFieldDefnShadow_GetType(OGRFieldDefnShadow *self){ + return OGR_Fld_GetType(self); + } +static void OGRFieldDefnShadow_SetType(OGRFieldDefnShadow *self,OGRFieldType type){ + OGR_Fld_SetType(self, type); + } +static OGRJustification OGRFieldDefnShadow_GetJustify(OGRFieldDefnShadow *self){ + return OGR_Fld_GetJustify(self); + } +static void OGRFieldDefnShadow_SetJustify(OGRFieldDefnShadow *self,OGRJustification justify){ + OGR_Fld_SetJustify(self, justify); + } +static int OGRFieldDefnShadow_GetWidth(OGRFieldDefnShadow *self){ + return OGR_Fld_GetWidth(self); + } +static void OGRFieldDefnShadow_SetWidth(OGRFieldDefnShadow *self,int width){ + OGR_Fld_SetWidth(self, width); + } +static int OGRFieldDefnShadow_GetPrecision(OGRFieldDefnShadow *self){ + return OGR_Fld_GetPrecision(self); + } +static void OGRFieldDefnShadow_SetPrecision(OGRFieldDefnShadow *self,int precision){ + OGR_Fld_SetPrecision(self, precision); + } +static char const *OGRFieldDefnShadow_GetFieldTypeName(OGRFieldDefnShadow *self,OGRFieldType type){ + return OGR_GetFieldTypeName(type); + } + + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + + +static void delete_OGRGeometryShadow(OGRGeometryShadow *self){ + OGR_G_DestroyGeometry( self ); + } +static OGRGeometryShadow *new_OGRGeometryShadow(OGRwkbGeometryType type=wkbUnknown,char *wkt=0,int wkb=0,char *wkb_buf=0,char *gml=0){ + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } +static OGRErr OGRGeometryShadow_ExportToWkt(OGRGeometryShadow *self,char **argout){ + return OGR_G_ExportToWkt(self, argout); + } +static OGRErr OGRGeometryShadow_ExportToWkb(OGRGeometryShadow *self,int *nLen,char **pBuf,OGRwkbByteOrder byte_order=wkbXDR){ + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } +static char const *OGRGeometryShadow_ExportToGML(OGRGeometryShadow *self){ + return (const char *) OGR_G_ExportToGML(self); + } +static void OGRGeometryShadow_AddPoint(OGRGeometryShadow *self,double x,double y,double z=0){ + OGR_G_AddPoint( self, x, y, z ); + } +static OGRErr OGRGeometryShadow_AddGeometryDirectly(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometryDirectly( self, other ); + } +static OGRErr OGRGeometryShadow_AddGeometry(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometry( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Clone(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_Clone(self); + } +static OGRwkbGeometryType OGRGeometryShadow_GetGeometryType(OGRGeometryShadow *self){ + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } +static char const *OGRGeometryShadow_GetGeometryName(OGRGeometryShadow *self){ + return (const char *) OGR_G_GetGeometryName(self); + } +static double OGRGeometryShadow_GetArea(OGRGeometryShadow *self){ + return OGR_G_GetArea(self); + } +static int OGRGeometryShadow_GetPointCount(OGRGeometryShadow *self){ + return OGR_G_GetPointCount(self); + } +static double OGRGeometryShadow_GetX(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetX(self, point); + } +static double OGRGeometryShadow_GetY(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetY(self, point); + } +static double OGRGeometryShadow_GetZ(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetZ(self, point); + } +static int OGRGeometryShadow_GetGeometryCount(OGRGeometryShadow *self){ + return OGR_G_GetGeometryCount(self); + } +static void OGRGeometryShadow_SetPoint(OGRGeometryShadow *self,int point,double x,double y,double z=0){ + OGR_G_SetPoint(self, point, x, y, z); + } +static OGRGeometryShadow *OGRGeometryShadow_GetGeometryRef(OGRGeometryShadow *self,int geom){ + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } +static OGRGeometryShadow *OGRGeometryShadow_GetBoundary(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } +static OGRGeometryShadow *OGRGeometryShadow_ConvexHull(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } +static OGRGeometryShadow *OGRGeometryShadow_Buffer(OGRGeometryShadow *self,double distance,int quadsecs=30){ + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } +static OGRGeometryShadow *OGRGeometryShadow_Intersection(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Union(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Difference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_SymmetricDifference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } +static double OGRGeometryShadow_Distance(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Distance(self, other); + } +static void OGRGeometryShadow_Empty(OGRGeometryShadow *self){ + OGR_G_Empty(self); + } +static bool OGRGeometryShadow_Intersect(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Intersect(self, other); + } +static bool OGRGeometryShadow_Equal(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Equal(self, other); + } +static bool OGRGeometryShadow_Disjoint(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Disjoint(self, other); + } +static bool OGRGeometryShadow_Touches(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Touches(self, other); + } +static bool OGRGeometryShadow_Crosses(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Crosses(self, other); + } +static bool OGRGeometryShadow_Within(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Within(self, other); + } +static bool OGRGeometryShadow_Contains(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Contains(self, other); + } +static bool OGRGeometryShadow_Overlaps(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Overlaps(self, other); + } +static OGRErr OGRGeometryShadow_TransformTo(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + return OGR_G_TransformTo(self, reference); + } +static OGRErr OGRGeometryShadow_Transform(OGRGeometryShadow *self,OSRCoordinateTransformationShadow *trans){ + return OGR_G_Transform(self, trans); + } +static OSRSpatialReferenceShadow *OGRGeometryShadow_GetSpatialReference(OGRGeometryShadow *self){ + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } +static void OGRGeometryShadow_AssignSpatialReference(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + OGR_G_AssignSpatialReference(self, reference); + } +static void OGRGeometryShadow_CloseRings(OGRGeometryShadow *self){ + OGR_G_CloseRings(self); + } +static void OGRGeometryShadow_FlattenTo2D(OGRGeometryShadow *self){ + OGR_G_FlattenTo2D(self); + } +static void OGRGeometryShadow_GetEnvelope(OGRGeometryShadow *self,double argout[4]){ + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } +static OGRGeometryShadow *OGRGeometryShadow_Centroid(OGRGeometryShadow *self){ + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } +static int OGRGeometryShadow_WkbSize(OGRGeometryShadow *self){ + return OGR_G_WkbSize(self); + } +static int OGRGeometryShadow_GetCoordinateDimension(OGRGeometryShadow *self){ + return OGR_G_GetCoordinateDimension(self); + } +static int OGRGeometryShadow_GetDimension(OGRGeometryShadow *self){ + return OGR_G_GetDimension(self); + } + +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + + + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } + + + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } + + + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } + + +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} + + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkb25Bit_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbUnknown_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 0; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbPoint_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 1; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbLineString_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 2; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbPolygon_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 3; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiPoint_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 4; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiLineString_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 5; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiPolygon_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 6; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbGeometryCollection_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 7; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbNone_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 100; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbLinearRing_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 101; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbPoint25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbPoint+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbLineString25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbLineString+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbPolygon25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbPolygon+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiPoint25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbMultiPoint+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiLineString25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbMultiLineString+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbMultiPolygon25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbMultiPolygon+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbGeometryCollection25D_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) wkbGeometryCollection+wkb25DBit; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTInteger_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 0; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTIntegerList_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 1; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTReal_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 2; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTRealList_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 3; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTString_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 4; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTStringList_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 5; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTWideString_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 6; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTWideStringList_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 7; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTBinary_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 8; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OFTDate_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 8; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OJUndefined_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 0; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OJLeft_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 1; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_OJRight_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 2; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbXDR_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 0; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_wkbNDR_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int) 1; + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCRandomRead_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "RandomRead"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCSequentialWrite_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SequentialWrite"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCRandomWrite_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "RandomWrite"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCFastSpatialFilter_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "FastSpatialFilter"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCFastFeatureCount_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "FastFeatureCount"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCFastGetExtent_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "FastGetExtent"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCCreateField_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "CreateField"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCTransactions_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "Transactions"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCDeleteFeature_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "DeleteFeature"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_OLCFastSetNextByIndex_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "FastSetNextByIndex"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_ODsCCreateLayer_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "CreateLayer"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_ODsCDeleteLayer_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "DeleteLayer"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_ODrCCreateDataSource_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "CreateDataSource"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_ODrCDeleteDataSource_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "DeleteDataSource"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1name_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + result = (char *)OGRDriverShadow_name_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1CreateDataSource(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jobject jarg3) { + jlong jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + /* %typemap(in) char **options */ + arg3 = NULL; + if(jarg3 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg3, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg3 = CSLAddString(arg3, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CreateDataSource(arg1,(char const *)arg2,arg3); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1CopyDataSource(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4) { + jlong jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + OGRDataSourceShadow *arg2 = (OGRDataSourceShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + arg2 = *(OGRDataSourceShadow **)(void *)&jarg2; + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + { + /* %typemap(in) char **options */ + arg4 = NULL; + if(jarg4 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg4, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg4 = CSLAddString(arg4, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CopyDataSource(arg1,arg2,(char const *)arg3,arg4); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1Open(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jint jarg3) { + jlong jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (int)jarg3; + result = (OGRDataSourceShadow *)OGRDriverShadow_Open(arg1,(char const *)arg2,arg3); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1DeleteDataSource(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (int)OGRDriverShadow_DeleteDataSource(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1TestCapability(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jboolean jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (bool)OGRDriverShadow_TestCapability(arg1,(char const *)arg2); + + jresult = (jboolean)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Driver_1GetName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDriverShadow **)(void *)&jarg1; + result = (char *)OGRDriverShadow_GetName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1name_1get(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (char *)OGRDataSourceShadow_name_get(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_delete_1DataSource(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + delete_OGRDataSourceShadow(arg1); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetRefCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (int)OGRDataSourceShadow_GetRefCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetSummaryRefCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (int)OGRDataSourceShadow_GetSummaryRefCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetLayerCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (int)OGRDataSourceShadow_GetLayerCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetDriver(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRDriverShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (OGRDriverShadow *)OGRDataSourceShadow_GetDriver(arg1); + + *(OGRDriverShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + result = (char *)OGRDataSourceShadow_GetName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1DeleteLayer(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRErr)OGRDataSourceShadow_DeleteLayer(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1CreateLayer(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jlong jarg3, jint jarg4, jobject jarg5) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRwkbGeometryType arg4 = (OGRwkbGeometryType) wkbUnknown ; + char **arg5 = (char **) 0 ; + OGRLayerShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = *(OSRSpatialReferenceShadow **)(void *)&jarg3; + arg4 = (OGRwkbGeometryType)jarg4; + { + /* %typemap(in) char **options */ + arg5 = NULL; + if(jarg5 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg5, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg5 = CSLAddString(arg5, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CreateLayer(arg1,(char const *)arg2,arg3,arg4,arg5); + + *(OGRLayerShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1CopyLayer(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jstring jarg3, jobject jarg4) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRLayerShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + arg2 = *(OGRLayerShadow **)(void *)&jarg2; + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + { + /* %typemap(in) char **options */ + arg4 = NULL; + if(jarg4 != 0) { + const jclass vector = jenv->FindClass("java/util/Vector"); + const jclass enumeration = jenv->FindClass("java/util/Enumeration"); + const jmethodID elements = jenv->GetMethodID(vector, "elements", + "()Ljava/util/Enumeration;"); + const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, + "hasMoreElements", "()Z"); + const jmethodID getNextElement = jenv->GetMethodID(enumeration, + "nextElement", "()Ljava/lang/Object;"); + if(vector == NULL || enumeration == NULL || elements == NULL || + hasMoreElements == NULL || getNextElement == NULL) { + fprintf(stderr, "Could not load (options **) jni types.\n"); + return 0; + } + for (jobject keys = jenv->CallObjectMethod(jarg4, elements); + jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) { + jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement); + const char *valptr = jenv->GetStringUTFChars(value, 0); + arg4 = CSLAddString(arg4, valptr); + jenv->ReleaseStringUTFChars(value, valptr); + } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CopyLayer(arg1,arg2,(char const *)arg3,arg4); + + *(OGRLayerShadow **)(void *)&jresult = result; + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetLayerByIndex(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 = (int) 0 ; + OGRLayerShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByIndex(arg1,arg2); + + *(OGRLayerShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1GetLayerByName(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRLayerShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByName(arg1,(char const *)arg2); + + *(OGRLayerShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1TestCapability(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jboolean jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (bool)OGRDataSourceShadow_TestCapability(arg1,(char const *)arg2); + + jresult = (jboolean)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1ExecuteSQL(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jlong jarg3, jstring jarg4) { + jlong jresult = 0 ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRGeometryShadow *arg3 = (OGRGeometryShadow *) NULL ; + char *arg4 = (char *) "" ; + OGRLayerShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = *(OGRGeometryShadow **)(void *)&jarg3; + { + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_ExecuteSQL(arg1,(char const *)arg2,arg3,(char const *)arg4); + + *(OGRLayerShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg4) jenv->ReleaseStringUTFChars(jarg4, arg4); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_DataSource_1ReleaseResultSet(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRDataSourceShadow **)(void *)&jarg1; + arg2 = *(OGRLayerShadow **)(void *)&jarg2; + OGRDataSourceShadow_ReleaseResultSet(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetRefCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (int)OGRLayerShadow_GetRefCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SetSpatialFilter(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + OGRLayerShadow_SetSpatialFilter(arg1,arg2); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SetSpatialFilterRect(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + OGRLayerShadow_SetSpatialFilterRect(arg1,arg2,arg3,arg4,arg5); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetSpatialFilter(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRLayerShadow_GetSpatialFilter(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SetAttributeFilter(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OGRLayerShadow_SetAttributeFilter(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1ResetReading(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + OGRLayerShadow_ResetReading(arg1); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (char *)OGRLayerShadow_GetName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetFeature(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRFeatureShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = (long)jarg2; + result = (OGRFeatureShadow *)OGRLayerShadow_GetFeature(arg1,arg2); + + *(OGRFeatureShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetNextFeature(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRFeatureShadow *)OGRLayerShadow_GetNextFeature(arg1); + + *(OGRFeatureShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SetNextByIndex(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = (long)jarg2; + result = (OGRErr)OGRLayerShadow_SetNextByIndex(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SetFeature(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = *(OGRFeatureShadow **)(void *)&jarg2; + result = (OGRErr)OGRLayerShadow_SetFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1CreateFeature(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = *(OGRFeatureShadow **)(void *)&jarg2; + result = (OGRErr)OGRLayerShadow_CreateFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1DeleteFeature(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = (long)jarg2; + result = (OGRErr)OGRLayerShadow_DeleteFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1SyncToDisk(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRErr)OGRLayerShadow_SyncToDisk(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetLayerDefn(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureDefnShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRFeatureDefnShadow *)OGRLayerShadow_GetLayerDefn(arg1); + + *(OGRFeatureDefnShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetFeatureCount(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int arg2 = (int) 1 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (int)OGRLayerShadow_GetFeatureCount(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetExtent(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2, jint jarg3) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 4) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return 0; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return 0; + arg3 = (int)jarg3; + result = (OGRErr)OGRLayerShadow_GetExtent(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1TestCapability(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jboolean jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (bool)OGRLayerShadow_TestCapability(arg1,(char const *)arg2); + + jresult = (jboolean)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1CreateField(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jint jarg3) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + arg2 = *(OGRFieldDefnShadow **)(void *)&jarg2; + arg3 = (int)jarg3; + result = (OGRErr)OGRLayerShadow_CreateField(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1StartTransaction(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRErr)OGRLayerShadow_StartTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1CommitTransaction(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRErr)OGRLayerShadow_CommitTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1RollbackTransaction(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OGRErr)OGRLayerShadow_RollbackTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetSpatialRef(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OSRSpatialReferenceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = (OSRSpatialReferenceShadow *)OGRLayerShadow_GetSpatialRef(arg1); + + *(OSRSpatialReferenceShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Layer_1GetFeatureRead(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + GIntBig result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRLayerShadow **)(void *)&jarg1; + result = OGRLayerShadow_GetFeatureRead(arg1); + + *(GIntBig **)(void *)&jresult = new GIntBig((GIntBig &)result); + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_delete_1Feature(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + delete_OGRFeatureShadow(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_new_1Feature(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFeatureShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + result = (OGRFeatureShadow *)new_OGRFeatureShadow(arg1); + + *(OGRFeatureShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetDefnRef(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureDefnShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (OGRFeatureDefnShadow *)OGRFeatureShadow_GetDefnRef(arg1); + + *(OGRFeatureDefnShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetGeometry(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetGeometryDirectly(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRErr)OGRFeatureShadow_SetGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetGeometryRef(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRFeatureShadow_GetGeometryRef(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1Clone(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (OGRFeatureShadow *)OGRFeatureShadow_Clone(arg1); + + *(OGRFeatureShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1Equal(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = *(OGRFeatureShadow **)(void *)&jarg2; + result = (bool)OGRFeatureShadow_Equal(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (int)OGRFeatureShadow_GetFieldCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldDefnRef_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_0(arg1,arg2); + + *(OGRFieldDefnShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldDefnRef_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jlong jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRFieldDefnShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_1(arg1,(char const *)arg2); + + *(OGRFieldDefnShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsString_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jstring jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_0(arg1,arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsString_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jstring jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_1(arg1,(char const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsInteger_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_0(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsInteger_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_1(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsDouble_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jdouble jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_0(arg1,arg2); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldAsDouble_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jdouble jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_1(arg1,(char const *)arg2); + + jresult = (jdouble)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1IsFieldSet_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jboolean jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_0(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1IsFieldSet_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jboolean jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_1(arg1,(char const *)arg2); + + jresult = (jboolean)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldIndex(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (int)OGRFeatureShadow_GetFieldIndex(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFID(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (int)OGRFeatureShadow_GetFID(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetFID(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRErr)OGRFeatureShadow_SetFID(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1DumpReadable(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + OGRFeatureShadow_DumpReadable(arg1); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1UnsetField_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + OGRFeatureShadow_UnsetField__SWIG_0(arg1,arg2); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1UnsetField_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + OGRFeatureShadow_UnsetField__SWIG_1(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetField_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jstring jarg3) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + { + /* %typemap(in) (tostring argin) */ + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + } + OGRFeatureShadow_SetField__SWIG_0(arg1,arg2,(char const *)arg3); + + { + /* %typemap(in) (tostring argin) */ + jenv->ReleaseStringUTFChars(jarg3, (char*)arg3); + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetField_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + { + /* %typemap(in) (tostring argin) */ + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + } + OGRFeatureShadow_SetField__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(in) (tostring argin) */ + jenv->ReleaseStringUTFChars(jarg3, (char*)arg3); + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetFrom(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jint jarg3) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = *(OGRFeatureShadow **)(void *)&jarg2; + arg3 = (int)jarg3; + result = (OGRErr)OGRFeatureShadow_SetFrom(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetStyleString(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + result = (char *)OGRFeatureShadow_GetStyleString(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1SetStyleString(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + OGRFeatureShadow_SetStyleString(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldType_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldType result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_0(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Feature_1GetFieldType_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3) { + jint jresult = 0 ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRFieldType result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_delete_1FeatureDefn(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + delete_OGRFeatureDefnShadow(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_new_1FeatureDefn(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) NULL ; + OGRFeatureDefnShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (OGRFeatureDefnShadow *)new_OGRFeatureDefnShadow((char const *)arg1); + + *(OGRFeatureDefnShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + result = (char *)OGRFeatureDefnShadow_GetName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetFieldCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + result = (int)OGRFeatureDefnShadow_GetFieldCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetFieldDefn(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRFieldDefnShadow *)OGRFeatureDefnShadow_GetFieldDefn(arg1,arg2); + + *(OGRFieldDefnShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetFieldIndex(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (int)OGRFeatureDefnShadow_GetFieldIndex(arg1,(char const *)arg2); + + jresult = (jint)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1AddFieldDefn(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + arg2 = *(OGRFieldDefnShadow **)(void *)&jarg2; + OGRFeatureDefnShadow_AddFieldDefn(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetGeomType(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + result = (OGRwkbGeometryType)OGRFeatureDefnShadow_GetGeomType(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1SetGeomType(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + arg2 = (OGRwkbGeometryType)jarg2; + OGRFeatureDefnShadow_SetGeomType(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FeatureDefn_1GetReferenceCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFeatureDefnShadow **)(void *)&jarg1; + result = (int)OGRFeatureDefnShadow_GetReferenceCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_delete_1FieldDefn(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + delete_OGRFieldDefnShadow(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_new_1FieldDefn(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) "unnamed" ; + OGRFieldType arg2 = (OGRFieldType) OFTString ; + OGRFieldDefnShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = (OGRFieldType)jarg2; + result = (OGRFieldDefnShadow *)new_OGRFieldDefnShadow((char const *)arg1,arg2); + + *(OGRFieldDefnShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (char *)OGRFieldDefnShadow_GetName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetNameRef(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (char *)OGRFieldDefnShadow_GetNameRef(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1SetName(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + OGRFieldDefnShadow_SetName(arg1,(char const *)arg2); + + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetFieldType(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (OGRFieldType)OGRFieldDefnShadow_GetType(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1SetType(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + arg2 = (OGRFieldType)jarg2; + OGRFieldDefnShadow_SetType(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetJustify(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (OGRJustification)OGRFieldDefnShadow_GetJustify(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1SetJustify(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + arg2 = (OGRJustification)jarg2; + OGRFieldDefnShadow_SetJustify(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetWidth(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (int)OGRFieldDefnShadow_GetWidth(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1SetWidth(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + OGRFieldDefnShadow_SetWidth(arg1,arg2); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetPrecision(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + result = (int)OGRFieldDefnShadow_GetPrecision(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1SetPrecision(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + OGRFieldDefnShadow_SetPrecision(arg1,arg2); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_FieldDefn_1GetFieldTypeName(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jstring jresult = 0 ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRFieldDefnShadow **)(void *)&jarg1; + arg2 = (OGRFieldType)jarg2; + result = (char *)OGRFieldDefnShadow_GetFieldTypeName(arg1,arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_CreateGeometryFromWkb(JNIEnv *jenv, jclass jcls, jcharArray jarg1, jlong jarg3) { + jlong jresult = 0 ; + int arg1 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + jboolean isCopy1 ; + + (void)jenv; + (void)jcls; + { + /* %typemap(in) (int nLen, char *pBuf ) */ + arg1 = jenv->GetArrayLength(jarg1); + arg2 = (char *)jenv->GetCharArrayElements(jarg1, &isCopy1); + } + arg3 = *(OSRSpatialReferenceShadow **)(void *)&jarg3; + result = (OGRGeometryShadow *)CreateGeometryFromWkb(arg1,arg2,arg3); + + *(OGRGeometryShadow **)(void *)&jresult = result; + { + /* %typemap(argout) (int nLen, char *pBuf ) */ + } + { + /* %typemap(freearg) (int nLen, char *pBuf ) */ + /* This calls JNI_ABORT, so any modifications will not be passed back + into the Java caller + */ + if(isCopy1 == JNI_TRUE) { + jenv->ReleaseCharArrayElements(jarg1, (jchar *)arg2, 0); + } + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_CreateGeometryFromWkt(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2) { + jlong jresult = 0 ; + char **arg1 = (char **) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + char *val1 ; + + (void)jenv; + (void)jcls; + { + /* %typemap(in) (char **ignorechange) */ + val1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + arg1 = &val1; + } + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (OGRGeometryShadow *)CreateGeometryFromWkt(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + { + /* %typemap(freearg) (char **ignorechange) */ + jenv->ReleaseStringUTFChars(jarg1, val1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_CreateGeometryFromGML(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (OGRGeometryShadow *)CreateGeometryFromGML((char const *)arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_delete_1Geometry(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + delete_OGRGeometryShadow(arg1); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_new_1Geometry(JNIEnv *jenv, jclass jcls, jint jarg1, jstring jarg2, jint jarg3, jstring jarg4, jstring jarg5) { + jlong jresult = 0 ; + OGRwkbGeometryType arg1 = (OGRwkbGeometryType) wkbUnknown ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = (OGRwkbGeometryType)jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (int)jarg3; + { + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + } + { + arg5 = 0; + if (jarg5) { + arg5 = (char *)jenv->GetStringUTFChars(jarg5, 0); + if (!arg5) return 0; + } + } + result = (OGRGeometryShadow *)new_OGRGeometryShadow(arg1,arg2,arg3,arg4,arg5); + + *(OGRGeometryShadow **)(void *)&jresult = result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg4) jenv->ReleaseStringUTFChars(jarg4, arg4); + } + { + if (arg5) jenv->ReleaseStringUTFChars(jarg5, arg5); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1ExportToWkt(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + result = (OGRErr)OGRGeometryShadow_ExportToWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1ExportToWkb(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2, jint jarg4) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int *arg2 = (int *) 0 ; + char **arg3 = (char **) 0 ; + OGRwkbByteOrder arg4 = (OGRwkbByteOrder) wkbXDR ; + OGRErr result; + int nLen2 ; + char *pBuf2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + { + /* %typemap(in) (int *nLen2, char **pBuf2 ) */ + arg2 = &nLen2; + arg3 = &pBuf2; + } + arg4 = (OGRwkbByteOrder)jarg4; + result = (OGRErr)OGRGeometryShadow_ExportToWkb(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + /* make sure that the passed array is at lease length 1 */ + if(jenv->GetArrayLength(jarg2) >= 1) { + jcharArray charArray = jenv->NewCharArray(nLen2); + jenv->SetCharArrayRegion(charArray, (jsize)0, (jsize)nLen2, (jchar*)pBuf2); + jenv->SetObjectArrayElement(jarg2,0,charArray); + } + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( arg2 ) { + free( *arg3 ); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1ExportToGML(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (char *)OGRGeometryShadow_ExportToGML(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1AddPoint(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 = (double) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + OGRGeometryShadow_AddPoint(arg1,arg2,arg3,arg4); + +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1AddGeometryDirectly(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRErr)OGRGeometryShadow_AddGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1AddGeometry(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRErr)OGRGeometryShadow_AddGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Clone(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRGeometryShadow_Clone(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetGeometryType(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRwkbGeometryType result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OGRwkbGeometryType)OGRGeometryShadow_GetGeometryType(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetGeometryName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (char *)OGRGeometryShadow_GetGeometryName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetArea(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (double)OGRGeometryShadow_GetArea(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetPointCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (int)OGRGeometryShadow_GetPointCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetX(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jdouble jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (double)OGRGeometryShadow_GetX(arg1,arg2); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetY(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jdouble jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (double)OGRGeometryShadow_GetY(arg1,arg2); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetZ(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jdouble jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (double)OGRGeometryShadow_GetZ(arg1,arg2); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetGeometryCount(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (int)OGRGeometryShadow_GetGeometryCount(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1SetPoint(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + OGRGeometryShadow_SetPoint(arg1,arg2,arg3,arg4,arg5); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetGeometryRef(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRGeometryShadow *)OGRGeometryShadow_GetGeometryRef(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetBoundary(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRGeometryShadow_GetBoundary(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1ConvexHull(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRGeometryShadow_ConvexHull(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Buffer(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jint jarg3) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + int arg3 = (int) 30 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (int)jarg3; + result = (OGRGeometryShadow *)OGRGeometryShadow_Buffer(arg1,arg2,arg3); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Intersection(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRGeometryShadow *)OGRGeometryShadow_Intersection(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Union(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRGeometryShadow *)OGRGeometryShadow_Union(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Difference(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRGeometryShadow *)OGRGeometryShadow_Difference(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1SymmetricDifference(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (OGRGeometryShadow *)OGRGeometryShadow_SymmetricDifference(arg1,arg2); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Distance(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jdouble jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (double)OGRGeometryShadow_Distance(arg1,arg2); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Empty(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + OGRGeometryShadow_Empty(arg1); + +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Intersect(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Intersect(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Equal(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Equal(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Disjoint(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Disjoint(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Touches(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Touches(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Crosses(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Crosses(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Within(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Within(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Contains(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Contains(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jboolean JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Overlaps(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jboolean jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OGRGeometryShadow **)(void *)&jarg2; + result = (bool)OGRGeometryShadow_Overlaps(arg1,arg2); + + jresult = (jboolean)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1TransformTo(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (OGRErr)OGRGeometryShadow_TransformTo(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Transform(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRCoordinateTransformationShadow *arg2 = (OSRCoordinateTransformationShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OSRCoordinateTransformationShadow **)(void *)&jarg2; + result = (OGRErr)OGRGeometryShadow_Transform(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetSpatialReference(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OSRSpatialReferenceShadow *)OGRGeometryShadow_GetSpatialReference(arg1); + + *(OSRSpatialReferenceShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1AssignSpatialReference(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + OGRGeometryShadow_AssignSpatialReference(arg1,arg2); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1CloseRings(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + OGRGeometryShadow_CloseRings(arg1); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1FlattenTo2D(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + OGRGeometryShadow_FlattenTo2D(arg1); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetEnvelope(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double *arg2 ; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 4) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return ; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return ; + OGRGeometryShadow_GetEnvelope(arg1,arg2); + + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1Centroid(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (OGRGeometryShadow *)OGRGeometryShadow_Centroid(arg1); + + *(OGRGeometryShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1WkbSize(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (int)OGRGeometryShadow_WkbSize(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetCoordinateDimension(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (int)OGRGeometryShadow_GetCoordinateDimension(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_Geometry_1GetDimension(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OGRGeometryShadow **)(void *)&jarg1; + result = (int)OGRGeometryShadow_GetDimension(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_GetDriverCount(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)OGRGetDriverCount(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_GetOpenDSCount(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)OGRGetOpenDSCount(); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_ogr_ogrJNI_SetGenerate_1DB2_1V72_1BYTE_1ORDER(JNIEnv *jenv, jclass jcls, jint jarg1) { + jint jresult = 0 ; + int arg1 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + result = (OGRErr)OGRSetGenerate_DB2_V72_BYTE_ORDER(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_ogr_ogrJNI_RegisterAll(JNIEnv *jenv, jclass jcls) { + (void)jenv; + (void)jcls; + OGRRegisterAll(); + +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_GetOpenDS(JNIEnv *jenv, jclass jcls, jint jarg1) { + jlong jresult = 0 ; + int arg1 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + result = (OGRDataSourceShadow *)GetOpenDS(arg1); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_Open(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = (int)jarg2; + result = (OGRDataSourceShadow *)Open((char const *)arg1,arg2); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_OpenShared(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + arg2 = (int)jarg2; + result = (OGRDataSourceShadow *)OpenShared((char const *)arg1,arg2); + + *(OGRDataSourceShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_GetDriverByName(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) 0 ; + OGRDriverShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (OGRDriverShadow *)GetDriverByName((char const *)arg1); + + *(OGRDriverShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_ogr_ogrJNI_GetDriver(JNIEnv *jenv, jclass jcls, jint jarg1) { + jlong jresult = 0 ; + int arg1 ; + OGRDriverShadow *result; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + result = (OGRDriverShadow *)GetDriver(arg1); + + *(OGRDriverShadow **)(void *)&jresult = result; + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/Band.java b/Utilities/GDAL/swig/java/org/gdal/gdal/Band.java new file mode 100644 index 0000000000..16b6081272 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/Band.java @@ -0,0 +1,126 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class Band extends MajorObject { + private long swigCPtr; + + protected Band(long cPtr, boolean cMemoryOwn) { + super(gdalJNI.SWIGBandUpcast(cPtr), cMemoryOwn); + swigCPtr = cPtr; + } + + protected static long getCPtr(Band obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + throw new UnsupportedOperationException("C++ destructor does not have public access"); + } + swigCPtr = 0; + super.delete(); + } + + public int getXSize() { + return gdalJNI.Band_XSize_get(swigCPtr); + } + + public int getYSize() { + return gdalJNI.Band_YSize_get(swigCPtr); + } + + public int getDataType() { + return gdalJNI.Band_DataType_get(swigCPtr); + } + + public int GetRasterColorInterpretation() { + return gdalJNI.Band_GetRasterColorInterpretation(swigCPtr); + } + + public int SetRasterColorInterpretation(int val) { + return gdalJNI.Band_SetRasterColorInterpretation(swigCPtr, val); + } + + public void GetNoDataValue(Double[] val) { + gdalJNI.Band_GetNoDataValue(swigCPtr, val); + } + + public int SetNoDataValue(double d) { + return gdalJNI.Band_SetNoDataValue(swigCPtr, d); + } + + public void GetMinimum(Double[] val) { + gdalJNI.Band_GetMinimum(swigCPtr, val); + } + + public void GetMaximum(Double[] val) { + gdalJNI.Band_GetMaximum(swigCPtr, val); + } + + public void GetOffset(Double[] val) { + gdalJNI.Band_GetOffset(swigCPtr, val); + } + + public void GetScale(Double[] val) { + gdalJNI.Band_GetScale(swigCPtr, val); + } + + public int GetOverviewCount() { + return gdalJNI.Band_GetOverviewCount(swigCPtr); + } + + public Band GetOverview(int i) { + long cPtr = gdalJNI.Band_GetOverview(swigCPtr, i); + return (cPtr == 0) ? null : new Band(cPtr, false); + } + + public int Checksum(int xoff, int yoff, int[] xsize, int[] ysize) { + return gdalJNI.Band_Checksum(swigCPtr, xoff, yoff, xsize, ysize); + } + + public void ComputeRasterMinMax(double[] argout, int approx_ok) { + gdalJNI.Band_ComputeRasterMinMax(swigCPtr, argout, approx_ok); + } + + public int Fill(double real_fill, double imag_fill) { + return gdalJNI.Band_Fill(swigCPtr, real_fill, imag_fill); + } + + public int ReadRaster(int xoff, int yoff, int xsize, int ysize, char[][] buf_len, int[] buf_xsize, int[] buf_ysize, int[] buf_type) { + return gdalJNI.Band_ReadRaster(swigCPtr, xoff, yoff, xsize, ysize, buf_len, buf_xsize, buf_ysize, buf_type); + } + + public int WriteRaster(int xoff, int yoff, int xsize, int ysize, char[] buf_len, int[] buf_xsize, int[] buf_ysize, int[] buf_type) { + return gdalJNI.Band_WriteRaster(swigCPtr, xoff, yoff, xsize, ysize, buf_len, buf_xsize, buf_ysize, buf_type); + } + + public void FlushCache() { + gdalJNI.Band_FlushCache(swigCPtr); + } + + public ColorTable GetRasterColorTable() { + long cPtr = gdalJNI.Band_GetRasterColorTable(swigCPtr); + return (cPtr == 0) ? null : new ColorTable(cPtr, false); + } + + public int SetRasterColorTable(ColorTable arg) { + return gdalJNI.Band_SetRasterColorTable(swigCPtr, ColorTable.getCPtr(arg)); + } + + public int ReadRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer buf) { + return gdalJNI.Band_ReadRaster_Direct(swigCPtr, xoff, yoff, xsize, ysize, buf_xsize, buf_ysize, buf_type, buf); + } + + public int WriteRaster_Direct(int xoff, int yoff, int xsize, int ysize, int buf_xsize, int buf_ysize, int buf_type, java.nio.ByteBuffer buf) { + return gdalJNI.Band_WriteRaster_Direct(swigCPtr, xoff, yoff, xsize, ysize, buf_xsize, buf_ysize, buf_type, buf); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/ColorTable.java b/Utilities/GDAL/swig/java/org/gdal/gdal/ColorTable.java new file mode 100644 index 0000000000..7aca63ff00 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/ColorTable.java @@ -0,0 +1,89 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +/* imports for getIndexColorModel */ +import java.awt.image.IndexColorModel; +import java.awt.Color; + +public class ColorTable { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected ColorTable(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(ColorTable obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + gdalJNI.delete_ColorTable(swigCPtr); + } + swigCPtr = 0; + } + +/* convienance method */ + public IndexColorModel getIndexColorModel(int bits) { + int size = GetCount(); + byte[] reds = new byte[size]; + byte[] greens = new byte[size]; + byte[] blues = new byte[size]; + byte[] alphas = new byte[size]; + + Color entry = null; + for(int i = 0; i < size; i++) { + entry = GetColorEntry(i); + reds[i] = (byte)entry.getRed(); + greens[i] = (byte)entry.getGreen(); + blues[i] = (byte)entry.getBlue(); + byte alpha = (byte)entry.getAlpha(); + alphas[i] = (alpha != -1) ? alpha : 0; + } + return new IndexColorModel(bits, size, reds, greens, blues, alphas); + } + + public ColorTable(int arg0) { + this(gdalJNI.new_ColorTable(arg0), true); + } + + public ColorTable Clone() { + long cPtr = gdalJNI.ColorTable_Clone(swigCPtr); + return (cPtr == 0) ? null : new ColorTable(cPtr, false); + } + + public int GetPaletteInterpretation() { + return gdalJNI.ColorTable_GetPaletteInterpretation(swigCPtr); + } + + public int GetCount() { + return gdalJNI.ColorTable_GetCount(swigCPtr); + } + + public java.awt.Color GetColorEntry(int arg0) { + return gdalJNI.ColorTable_GetColorEntry(swigCPtr, arg0); + } + + public int GetColorEntryAsRGB(int arg0, java.awt.Color arg1) { + return gdalJNI.ColorTable_GetColorEntryAsRGB(swigCPtr, arg0, arg1); + } + + public void SetColorEntry(int arg0, java.awt.Color arg1) { + gdalJNI.ColorTable_SetColorEntry(swigCPtr, arg0, arg1); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/Dataset.java b/Utilities/GDAL/swig/java/org/gdal/gdal/Dataset.java new file mode 100644 index 0000000000..b739e3ddf4 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/Dataset.java @@ -0,0 +1,110 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class Dataset extends MajorObject { + private long swigCPtr; + + protected Dataset(long cPtr, boolean cMemoryOwn) { + super(gdalJNI.SWIGDatasetUpcast(cPtr), cMemoryOwn); + swigCPtr = cPtr; + } + + protected static long getCPtr(Dataset obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + gdalJNI.delete_Dataset(swigCPtr); + } + swigCPtr = 0; + super.delete(); + } + + public int getRasterXSize() { + return gdalJNI.Dataset_RasterXSize_get(swigCPtr); + } + + public int getRasterYSize() { + return gdalJNI.Dataset_RasterYSize_get(swigCPtr); + } + + public int getRasterCount() { + return gdalJNI.Dataset_RasterCount_get(swigCPtr); + } + + public Driver GetDriver() { + long cPtr = gdalJNI.Dataset_GetDriver(swigCPtr); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + + public Band GetRasterBand(int nBand) { + long cPtr = gdalJNI.Dataset_GetRasterBand(swigCPtr, nBand); + return (cPtr == 0) ? null : new Band(cPtr, false); + } + + public String GetProjection() { + return gdalJNI.Dataset_GetProjection(swigCPtr); + } + + public String GetProjectionRef() { + return gdalJNI.Dataset_GetProjectionRef(swigCPtr); + } + + public int SetProjection(String prj) { + return gdalJNI.Dataset_SetProjection(swigCPtr, prj); + } + + public void GetGeoTransform(double[] argout) { + gdalJNI.Dataset_GetGeoTransform(swigCPtr, argout); + } + + public int SetGeoTransform(double[] argin) { + return gdalJNI.Dataset_SetGeoTransform(swigCPtr, argin); + } + + public int BuildOverviews(String resampling, int[] overviewlist) { + return gdalJNI.Dataset_BuildOverviews(swigCPtr, resampling, overviewlist); + } + + public int GetGCPCount() { + return gdalJNI.Dataset_GetGCPCount(swigCPtr); + } + + public String GetGCPProjection() { + return gdalJNI.Dataset_GetGCPProjection(swigCPtr); + } + + public void GetGCPs(java.util.Vector nGCPs) { + gdalJNI.Dataset_GetGCPs(swigCPtr, nGCPs); + } + + public int SetGCPs(int nGCPs, GCP pGCPs, String pszGCPProjection) { + return gdalJNI.Dataset_SetGCPs(swigCPtr, nGCPs, GCP.getCPtr(pGCPs), pszGCPProjection); + } + + public void FlushCache() { + gdalJNI.Dataset_FlushCache(swigCPtr); + } + + public int AddBand(int datatype, java.util.Vector options) { + return gdalJNI.Dataset_AddBand(swigCPtr, datatype, options); + } + + public int WriteRaster(int xoff, int yoff, int xsize, int ysize, char[] buf_len, int[] buf_xsize, int[] buf_ysize, int[] buf_type, int[] band_list) { + return gdalJNI.Dataset_WriteRaster(swigCPtr, xoff, yoff, xsize, ysize, buf_len, buf_xsize, buf_ysize, buf_type, band_list); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/Driver.java b/Utilities/GDAL/swig/java/org/gdal/gdal/Driver.java new file mode 100644 index 0000000000..820da0fa7f --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/Driver.java @@ -0,0 +1,58 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class Driver extends MajorObject { + private long swigCPtr; + + protected Driver(long cPtr, boolean cMemoryOwn) { + super(gdalJNI.SWIGDriverUpcast(cPtr), cMemoryOwn); + swigCPtr = cPtr; + } + + protected static long getCPtr(Driver obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + throw new UnsupportedOperationException("C++ destructor does not have public access"); + } + swigCPtr = 0; + super.delete(); + } + + public String getShortName() { + return gdalJNI.Driver_ShortName_get(swigCPtr); + } + + public String getLongName() { + return gdalJNI.Driver_LongName_get(swigCPtr); + } + + public String getHelpTopic() { + return gdalJNI.Driver_HelpTopic_get(swigCPtr); + } + + public Dataset Create(String name, int xsize, int ysize, int bands, int eType, java.util.Vector options) { + long cPtr = gdalJNI.Driver_Create(swigCPtr, name, xsize, ysize, bands, eType, options); + return (cPtr == 0) ? null : new Dataset(cPtr, true); + } + + public Dataset CreateCopy(String name, Dataset src, int strict, java.util.Vector options) { + long cPtr = gdalJNI.Driver_CreateCopy(swigCPtr, name, Dataset.getCPtr(src), strict, options); + return (cPtr == 0) ? null : new Dataset(cPtr, true); + } + + public int Delete(String name) { + return gdalJNI.Driver_Delete(swigCPtr, name); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/GCP.java b/Utilities/GDAL/swig/java/org/gdal/gdal/GCP.java new file mode 100644 index 0000000000..530b566e07 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/GCP.java @@ -0,0 +1,96 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class GCP { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected GCP(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(GCP obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + gdalJNI.delete_GCP(swigCPtr); + } + swigCPtr = 0; + } + + public void setGCPX(double value) { + gdalJNI.GCP_GCPX_set(swigCPtr, value); + } + + public double getGCPX() { + return gdalJNI.GCP_GCPX_get(swigCPtr); + } + + public void setGCPY(double value) { + gdalJNI.GCP_GCPY_set(swigCPtr, value); + } + + public double getGCPY() { + return gdalJNI.GCP_GCPY_get(swigCPtr); + } + + public void setGCPZ(double value) { + gdalJNI.GCP_GCPZ_set(swigCPtr, value); + } + + public double getGCPZ() { + return gdalJNI.GCP_GCPZ_get(swigCPtr); + } + + public void setGCPPixel(double value) { + gdalJNI.GCP_GCPPixel_set(swigCPtr, value); + } + + public double getGCPPixel() { + return gdalJNI.GCP_GCPPixel_get(swigCPtr); + } + + public void setGCPLine(double value) { + gdalJNI.GCP_GCPLine_set(swigCPtr, value); + } + + public double getGCPLine() { + return gdalJNI.GCP_GCPLine_get(swigCPtr); + } + + public void setInfo(String value) { + gdalJNI.GCP_Info_set(swigCPtr, value); + } + + public String getInfo() { + return gdalJNI.GCP_Info_get(swigCPtr); + } + + public void setId(String value) { + gdalJNI.GCP_Id_set(swigCPtr, value); + } + + public String getId() { + return gdalJNI.GCP_Id_get(swigCPtr); + } + + public GCP(double x, double y, double z, double pixel, double line, String info, String id) { + this(gdalJNI.new_GCP(x, y, z, pixel, line, info, id), true); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/MajorObject.java b/Utilities/GDAL/swig/java/org/gdal/gdal/MajorObject.java new file mode 100644 index 0000000000..2dc0b48f83 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/MajorObject.java @@ -0,0 +1,56 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class MajorObject { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected MajorObject(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(MajorObject obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + throw new UnsupportedOperationException("C++ destructor does not have public access"); + } + swigCPtr = 0; + } + + public String GetDescription() { + return gdalJNI.MajorObject_GetDescription(swigCPtr); + } + + public void SetDescription(String pszNewDesc) { + gdalJNI.MajorObject_SetDescription(swigCPtr, pszNewDesc); + } + + public java.util.Hashtable GetMetadata_Dict(String pszDomain) { + return gdalJNI.MajorObject_GetMetadata_Dict(swigCPtr, pszDomain); + } + + public java.util.Vector GetMetadata_List(String pszDomain) { + return gdalJNI.MajorObject_GetMetadata_List(swigCPtr, pszDomain); + } + + public int SetMetadata(java.util.Hashtable papszMetadata, String pszDomain) { + return gdalJNI.MajorObject_SetMetadata__SWIG_0(swigCPtr, papszMetadata, pszDomain); + } + + public int SetMetadata(String pszMetadataString, String pszDomain) { + return gdalJNI.MajorObject_SetMetadata__SWIG_1(swigCPtr, pszMetadataString, pszDomain); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLErrorHandler.java b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLErrorHandler.java new file mode 100644 index 0000000000..7c7cab4d83 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLErrorHandler.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class SWIGTYPE_p_CPLErrorHandler { + private long swigCPtr; + + protected SWIGTYPE_p_CPLErrorHandler(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_CPLErrorHandler() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_CPLErrorHandler obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLXMLNode.java b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLXMLNode.java new file mode 100644 index 0000000000..b49fc180e7 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_CPLXMLNode.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class SWIGTYPE_p_CPLXMLNode { + private long swigCPtr; + + protected SWIGTYPE_p_CPLXMLNode(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_CPLXMLNode() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_CPLXMLNode obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_FALSE_IS_ERR.java b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_FALSE_IS_ERR.java new file mode 100644 index 0000000000..6afad4d66d --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_FALSE_IS_ERR.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class SWIGTYPE_p_FALSE_IS_ERR { + private long swigCPtr; + + protected SWIGTYPE_p_FALSE_IS_ERR(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_FALSE_IS_ERR() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_FALSE_IS_ERR obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_GByte.java b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_GByte.java new file mode 100644 index 0000000000..dba533c640 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_GByte.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class SWIGTYPE_p_GByte { + private long swigCPtr; + + protected SWIGTYPE_p_GByte(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_GByte() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_GByte obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_int.java b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_int.java new file mode 100644 index 0000000000..f905a6aca8 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/SWIGTYPE_p_int.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class SWIGTYPE_p_int { + private long swigCPtr; + + protected SWIGTYPE_p_int(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_int() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_int obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/gdal.java b/Utilities/GDAL/swig/java/org/gdal/gdal/gdal.java new file mode 100644 index 0000000000..cfa197a732 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/gdal.java @@ -0,0 +1,287 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +public class gdal { + public static void Debug(String msg_class, String message) { + gdalJNI.Debug(msg_class, message); + } + + public static void Error(int msg_class, int err_code, String msg) { + gdalJNI.Error(msg_class, err_code, msg); + } + + public static int PushErrorHandler(String pszCallbackName) { + return gdalJNI.PushErrorHandler__SWIG_0(pszCallbackName); + } + + public static void PushErrorHandler(SWIGTYPE_p_CPLErrorHandler arg0) { + gdalJNI.PushErrorHandler__SWIG_1(SWIGTYPE_p_CPLErrorHandler.getCPtr(arg0)); + } + + public static void PopErrorHandler() { + gdalJNI.PopErrorHandler(); + } + + public static void ErrorReset() { + gdalJNI.ErrorReset(); + } + + public static int GetLastErrorNo() { + return gdalJNI.GetLastErrorNo(); + } + + public static int GetLastErrorType() { + return gdalJNI.GetLastErrorType(); + } + + public static String GetLastErrorMsg() { + return gdalJNI.GetLastErrorMsg(); + } + + public static void PushFinderLocation(String arg0) { + gdalJNI.PushFinderLocation(arg0); + } + + public static void PopFinderLocation() { + gdalJNI.PopFinderLocation(); + } + + public static void FinderClean() { + gdalJNI.FinderClean(); + } + + public static String FindFile(String arg0, String arg1) { + return gdalJNI.FindFile(arg0, arg1); + } + + public static void SetConfigOption(String arg0, String arg1) { + gdalJNI.SetConfigOption(arg0, arg1); + } + + public static String GetConfigOption(String arg0, String arg1) { + return gdalJNI.GetConfigOption(arg0, arg1); + } + + public static String CPLBinaryToHex(int nBytes, SWIGTYPE_p_GByte pabyData) { + return gdalJNI.CPLBinaryToHex(nBytes, SWIGTYPE_p_GByte.getCPtr(pabyData)); + } + + public static SWIGTYPE_p_GByte CPLHexToBinary(String pszHex, SWIGTYPE_p_int pnBytes) { + long cPtr = gdalJNI.CPLHexToBinary(pszHex, SWIGTYPE_p_int.getCPtr(pnBytes)); + return (cPtr == 0) ? null : new SWIGTYPE_p_GByte(cPtr, false); + } + + public static double GDAL_GCP_GCPX_get(GCP h) { + return gdalJNI.GDAL_GCP_GCPX_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_GCPX_set(GCP h, double val) { + gdalJNI.GDAL_GCP_GCPX_set(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_GCPY_get(GCP h) { + return gdalJNI.GDAL_GCP_GCPY_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_GCPY_set(GCP h, double val) { + gdalJNI.GDAL_GCP_GCPY_set(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_GCPZ_get(GCP h) { + return gdalJNI.GDAL_GCP_GCPZ_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_GCPZ_set(GCP h, double val) { + gdalJNI.GDAL_GCP_GCPZ_set(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_GCPPixel_get(GCP h) { + return gdalJNI.GDAL_GCP_GCPPixel_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_GCPPixel_set(GCP h, double val) { + gdalJNI.GDAL_GCP_GCPPixel_set(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_GCPLine_get(GCP h) { + return gdalJNI.GDAL_GCP_GCPLine_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_GCPLine_set(GCP h, double val) { + gdalJNI.GDAL_GCP_GCPLine_set(GCP.getCPtr(h), val); + } + + public static String GDAL_GCP_Info_get(GCP h) { + return gdalJNI.GDAL_GCP_Info_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_Info_set(GCP h, String val) { + gdalJNI.GDAL_GCP_Info_set(GCP.getCPtr(h), val); + } + + public static String GDAL_GCP_Id_get(GCP h) { + return gdalJNI.GDAL_GCP_Id_get(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_Id_set(GCP h, String val) { + gdalJNI.GDAL_GCP_Id_set(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_get_GCPX(GCP h) { + return gdalJNI.GDAL_GCP_get_GCPX(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_GCPX(GCP h, double val) { + gdalJNI.GDAL_GCP_set_GCPX(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_get_GCPY(GCP h) { + return gdalJNI.GDAL_GCP_get_GCPY(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_GCPY(GCP h, double val) { + gdalJNI.GDAL_GCP_set_GCPY(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_get_GCPZ(GCP h) { + return gdalJNI.GDAL_GCP_get_GCPZ(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_GCPZ(GCP h, double val) { + gdalJNI.GDAL_GCP_set_GCPZ(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_get_GCPPixel(GCP h) { + return gdalJNI.GDAL_GCP_get_GCPPixel(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_GCPPixel(GCP h, double val) { + gdalJNI.GDAL_GCP_set_GCPPixel(GCP.getCPtr(h), val); + } + + public static double GDAL_GCP_get_GCPLine(GCP h) { + return gdalJNI.GDAL_GCP_get_GCPLine(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_GCPLine(GCP h, double val) { + gdalJNI.GDAL_GCP_set_GCPLine(GCP.getCPtr(h), val); + } + + public static String GDAL_GCP_get_Info(GCP h) { + return gdalJNI.GDAL_GCP_get_Info(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_Info(GCP h, String val) { + gdalJNI.GDAL_GCP_set_Info(GCP.getCPtr(h), val); + } + + public static String GDAL_GCP_get_Id(GCP h) { + return gdalJNI.GDAL_GCP_get_Id(GCP.getCPtr(h)); + } + + public static void GDAL_GCP_set_Id(GCP h, String val) { + gdalJNI.GDAL_GCP_set_Id(GCP.getCPtr(h), val); + } + + public static SWIGTYPE_p_FALSE_IS_ERR GCPsToGeoTransform(int nGCPs, GCP pGCPs, double[] argout, int bApproxOK) { + return new SWIGTYPE_p_FALSE_IS_ERR(gdalJNI.GCPsToGeoTransform(nGCPs, GCP.getCPtr(pGCPs), argout, bApproxOK), true); + } + + public static void AllRegister() { + gdalJNI.AllRegister(); + } + + public static int GetCacheMax() { + return gdalJNI.GetCacheMax(); + } + + public static void SetCacheMax(int nBytes) { + gdalJNI.SetCacheMax(nBytes); + } + + public static int GetCacheUsed() { + return gdalJNI.GetCacheUsed(); + } + + public static int GetDataTypeSize(int arg0) { + return gdalJNI.GetDataTypeSize(arg0); + } + + public static int DataTypeIsComplex(int arg0) { + return gdalJNI.DataTypeIsComplex(arg0); + } + + public static String GetDataTypeName(int arg0) { + return gdalJNI.GetDataTypeName(arg0); + } + + public static int GetDataTypeByName(String arg0) { + return gdalJNI.GetDataTypeByName(arg0); + } + + public static String GetColorInterpretationName(int arg0) { + return gdalJNI.GetColorInterpretationName(arg0); + } + + public static String GetPaletteInterpretationName(int arg0) { + return gdalJNI.GetPaletteInterpretationName(arg0); + } + + public static String DecToDMS(double arg0, String arg1, int arg2) { + return gdalJNI.DecToDMS(arg0, arg1, arg2); + } + + public static double PackedDMSToDec(double arg0) { + return gdalJNI.PackedDMSToDec(arg0); + } + + public static double DecToPackedDMS(double arg0) { + return gdalJNI.DecToPackedDMS(arg0); + } + + public static SWIGTYPE_p_CPLXMLNode ParseXMLString(String arg0) { + long cPtr = gdalJNI.ParseXMLString(arg0); + return (cPtr == 0) ? null : new SWIGTYPE_p_CPLXMLNode(cPtr, false); + } + + public static String SerializeXMLTree(SWIGTYPE_p_CPLXMLNode xmlnode) { + return gdalJNI.SerializeXMLTree(SWIGTYPE_p_CPLXMLNode.getCPtr(xmlnode)); + } + + public static int GetDriverCount() { + return gdalJNI.GetDriverCount(); + } + + public static Driver GetDriverByName(String name) { + long cPtr = gdalJNI.GetDriverByName(name); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + + public static Driver GetDriver(int i) { + long cPtr = gdalJNI.GetDriver(i); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + + public static Dataset Open(String name, int eAccess) { + long cPtr = gdalJNI.Open(name, eAccess); + return (cPtr == 0) ? null : new Dataset(cPtr, true); + } + + public static Dataset OpenShared(String name, int eAccess) { + long cPtr = gdalJNI.OpenShared(name, eAccess); + return (cPtr == 0) ? null : new Dataset(cPtr, true); + } + + public static Dataset AutoCreateWarpedVRT(Dataset src_ds, String src_wkt, String dst_wkt, int eResampleAlg, double maxerror) { + long cPtr = gdalJNI.AutoCreateWarpedVRT(Dataset.getCPtr(src_ds), src_wkt, dst_wkt, eResampleAlg, maxerror); + return (cPtr == 0) ? null : new Dataset(cPtr, true); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdal/gdalJNI.java b/Utilities/GDAL/swig/java/org/gdal/gdal/gdalJNI.java new file mode 100644 index 0000000000..2c739409f7 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdal/gdalJNI.java @@ -0,0 +1,178 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdal; + +class gdalJNI { + + private static boolean available = false; + + static { + try { + System.loadLibrary("gdaljni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } + + public final static native void Debug(String jarg1, String jarg2); + public final static native void Error(int jarg1, int jarg2, String jarg3); + public final static native int PushErrorHandler__SWIG_0(String jarg1); + public final static native void PushErrorHandler__SWIG_1(long jarg1); + public final static native void PopErrorHandler(); + public final static native void ErrorReset(); + public final static native int GetLastErrorNo(); + public final static native int GetLastErrorType(); + public final static native String GetLastErrorMsg(); + public final static native void PushFinderLocation(String jarg1); + public final static native void PopFinderLocation(); + public final static native void FinderClean(); + public final static native String FindFile(String jarg1, String jarg2); + public final static native void SetConfigOption(String jarg1, String jarg2); + public final static native String GetConfigOption(String jarg1, String jarg2); + public final static native String CPLBinaryToHex(int jarg1, long jarg2); + public final static native long CPLHexToBinary(String jarg1, long jarg2); + public final static native String MajorObject_GetDescription(long jarg1); + public final static native void MajorObject_SetDescription(long jarg1, String jarg2); + public final static native java.util.Hashtable MajorObject_GetMetadata_Dict(long jarg1, String jarg2); + public final static native java.util.Vector MajorObject_GetMetadata_List(long jarg1, String jarg2); + public final static native int MajorObject_SetMetadata__SWIG_0(long jarg1, java.util.Hashtable jarg2, String jarg3); + public final static native int MajorObject_SetMetadata__SWIG_1(long jarg1, String jarg2, String jarg3); + public final static native String Driver_ShortName_get(long jarg1); + public final static native String Driver_LongName_get(long jarg1); + public final static native String Driver_HelpTopic_get(long jarg1); + public final static native long Driver_Create(long jarg1, String jarg2, int jarg3, int jarg4, int jarg5, int jarg6, java.util.Vector jarg7); + public final static native long Driver_CreateCopy(long jarg1, String jarg2, long jarg3, int jarg4, java.util.Vector jarg5); + public final static native int Driver_Delete(long jarg1, String jarg2); + public final static native void GCP_GCPX_set(long jarg1, double jarg2); + public final static native double GCP_GCPX_get(long jarg1); + public final static native void GCP_GCPY_set(long jarg1, double jarg2); + public final static native double GCP_GCPY_get(long jarg1); + public final static native void GCP_GCPZ_set(long jarg1, double jarg2); + public final static native double GCP_GCPZ_get(long jarg1); + public final static native void GCP_GCPPixel_set(long jarg1, double jarg2); + public final static native double GCP_GCPPixel_get(long jarg1); + public final static native void GCP_GCPLine_set(long jarg1, double jarg2); + public final static native double GCP_GCPLine_get(long jarg1); + public final static native void GCP_Info_set(long jarg1, String jarg2); + public final static native String GCP_Info_get(long jarg1); + public final static native void GCP_Id_set(long jarg1, String jarg2); + public final static native String GCP_Id_get(long jarg1); + public final static native long new_GCP(double jarg1, double jarg2, double jarg3, double jarg4, double jarg5, String jarg6, String jarg7); + public final static native void delete_GCP(long jarg1); + public final static native double GDAL_GCP_GCPX_get(long jarg1); + public final static native void GDAL_GCP_GCPX_set(long jarg1, double jarg2); + public final static native double GDAL_GCP_GCPY_get(long jarg1); + public final static native void GDAL_GCP_GCPY_set(long jarg1, double jarg2); + public final static native double GDAL_GCP_GCPZ_get(long jarg1); + public final static native void GDAL_GCP_GCPZ_set(long jarg1, double jarg2); + public final static native double GDAL_GCP_GCPPixel_get(long jarg1); + public final static native void GDAL_GCP_GCPPixel_set(long jarg1, double jarg2); + public final static native double GDAL_GCP_GCPLine_get(long jarg1); + public final static native void GDAL_GCP_GCPLine_set(long jarg1, double jarg2); + public final static native String GDAL_GCP_Info_get(long jarg1); + public final static native void GDAL_GCP_Info_set(long jarg1, String jarg2); + public final static native String GDAL_GCP_Id_get(long jarg1); + public final static native void GDAL_GCP_Id_set(long jarg1, String jarg2); + public final static native double GDAL_GCP_get_GCPX(long jarg1); + public final static native void GDAL_GCP_set_GCPX(long jarg1, double jarg2); + public final static native double GDAL_GCP_get_GCPY(long jarg1); + public final static native void GDAL_GCP_set_GCPY(long jarg1, double jarg2); + public final static native double GDAL_GCP_get_GCPZ(long jarg1); + public final static native void GDAL_GCP_set_GCPZ(long jarg1, double jarg2); + public final static native double GDAL_GCP_get_GCPPixel(long jarg1); + public final static native void GDAL_GCP_set_GCPPixel(long jarg1, double jarg2); + public final static native double GDAL_GCP_get_GCPLine(long jarg1); + public final static native void GDAL_GCP_set_GCPLine(long jarg1, double jarg2); + public final static native String GDAL_GCP_get_Info(long jarg1); + public final static native void GDAL_GCP_set_Info(long jarg1, String jarg2); + public final static native String GDAL_GCP_get_Id(long jarg1); + public final static native void GDAL_GCP_set_Id(long jarg1, String jarg2); + public final static native long GCPsToGeoTransform(int jarg1, long jarg2, double[] jarg3, int jarg4); + public final static native int Dataset_RasterXSize_get(long jarg1); + public final static native int Dataset_RasterYSize_get(long jarg1); + public final static native int Dataset_RasterCount_get(long jarg1); + public final static native void delete_Dataset(long jarg1); + public final static native long Dataset_GetDriver(long jarg1); + public final static native long Dataset_GetRasterBand(long jarg1, int jarg2); + public final static native String Dataset_GetProjection(long jarg1); + public final static native String Dataset_GetProjectionRef(long jarg1); + public final static native int Dataset_SetProjection(long jarg1, String jarg2); + public final static native void Dataset_GetGeoTransform(long jarg1, double[] jarg2); + public final static native int Dataset_SetGeoTransform(long jarg1, double[] jarg2); + public final static native int Dataset_BuildOverviews(long jarg1, String jarg2, int[] jarg3); + public final static native int Dataset_GetGCPCount(long jarg1); + public final static native String Dataset_GetGCPProjection(long jarg1); + public final static native void Dataset_GetGCPs(long jarg1, java.util.Vector jarg2); + public final static native int Dataset_SetGCPs(long jarg1, int jarg2, long jarg3, String jarg4); + public final static native void Dataset_FlushCache(long jarg1); + public final static native int Dataset_AddBand(long jarg1, int jarg2, java.util.Vector jarg3); + public final static native int Dataset_WriteRaster(long jarg1, int jarg2, int jarg3, int jarg4, int jarg5, char[] jarg6, int[] jarg8, int[] jarg9, int[] jarg10, int[] jarg11); + public final static native int Band_XSize_get(long jarg1); + public final static native int Band_YSize_get(long jarg1); + public final static native int Band_DataType_get(long jarg1); + public final static native int Band_GetRasterColorInterpretation(long jarg1); + public final static native int Band_SetRasterColorInterpretation(long jarg1, int jarg2); + public final static native void Band_GetNoDataValue(long jarg1, Double[] jarg2); + public final static native int Band_SetNoDataValue(long jarg1, double jarg2); + public final static native void Band_GetMinimum(long jarg1, Double[] jarg2); + public final static native void Band_GetMaximum(long jarg1, Double[] jarg2); + public final static native void Band_GetOffset(long jarg1, Double[] jarg2); + public final static native void Band_GetScale(long jarg1, Double[] jarg2); + public final static native int Band_GetOverviewCount(long jarg1); + public final static native long Band_GetOverview(long jarg1, int jarg2); + public final static native int Band_Checksum(long jarg1, int jarg2, int jarg3, int[] jarg4, int[] jarg5); + public final static native void Band_ComputeRasterMinMax(long jarg1, double[] jarg2, int jarg3); + public final static native int Band_Fill(long jarg1, double jarg2, double jarg3); + public final static native int Band_ReadRaster(long jarg1, int jarg2, int jarg3, int jarg4, int jarg5, char[][] jarg6, int[] jarg8, int[] jarg9, int[] jarg10); + public final static native int Band_WriteRaster(long jarg1, int jarg2, int jarg3, int jarg4, int jarg5, char[] jarg6, int[] jarg8, int[] jarg9, int[] jarg10); + public final static native void Band_FlushCache(long jarg1); + public final static native long Band_GetRasterColorTable(long jarg1); + public final static native int Band_SetRasterColorTable(long jarg1, long jarg2); + public final static native int Band_ReadRaster_Direct(long jarg1, int jarg2, int jarg3, int jarg4, int jarg5, int jarg6, int jarg7, int jarg8, java.nio.ByteBuffer jarg9); + public final static native int Band_WriteRaster_Direct(long jarg1, int jarg2, int jarg3, int jarg4, int jarg5, int jarg6, int jarg7, int jarg8, java.nio.ByteBuffer jarg9); + public final static native long new_ColorTable(int jarg1); + public final static native void delete_ColorTable(long jarg1); + public final static native long ColorTable_Clone(long jarg1); + public final static native int ColorTable_GetPaletteInterpretation(long jarg1); + public final static native int ColorTable_GetCount(long jarg1); + public final static native java.awt.Color ColorTable_GetColorEntry(long jarg1, int jarg2); + public final static native int ColorTable_GetColorEntryAsRGB(long jarg1, int jarg2, java.awt.Color jarg3); + public final static native void ColorTable_SetColorEntry(long jarg1, int jarg2, java.awt.Color jarg3); + public final static native void AllRegister(); + public final static native int GetCacheMax(); + public final static native void SetCacheMax(int jarg1); + public final static native int GetCacheUsed(); + public final static native int GetDataTypeSize(int jarg1); + public final static native int DataTypeIsComplex(int jarg1); + public final static native String GetDataTypeName(int jarg1); + public final static native int GetDataTypeByName(String jarg1); + public final static native String GetColorInterpretationName(int jarg1); + public final static native String GetPaletteInterpretationName(int jarg1); + public final static native String DecToDMS(double jarg1, String jarg2, int jarg3); + public final static native double PackedDMSToDec(double jarg1); + public final static native double DecToPackedDMS(double jarg1); + public final static native long ParseXMLString(String jarg1); + public final static native String SerializeXMLTree(long jarg1); + public final static native int GetDriverCount(); + public final static native long GetDriverByName(String jarg1); + public final static native long GetDriver(int jarg1); + public final static native long Open(String jarg1, int jarg2); + public final static native long OpenShared(String jarg1, int jarg2); + public final static native long AutoCreateWarpedVRT(long jarg1, String jarg2, String jarg3, int jarg4, double jarg5); + public final static native long SWIGDriverUpcast(long jarg1); + public final static native long SWIGDatasetUpcast(long jarg1); + public final static native long SWIGBandUpcast(long jarg1); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconst.java b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconst.java new file mode 100644 index 0000000000..f701bc8989 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconst.java @@ -0,0 +1,12 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdalconst; + +public class gdalconst implements gdalconstConstants { +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstConstants.java b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstConstants.java new file mode 100644 index 0000000000..d8cf4a4a2c --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstConstants.java @@ -0,0 +1,84 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdalconst; + +public interface gdalconstConstants { + public final static int GDT_Unknown = gdalconstJNI.GDT_Unknown_get(); + public final static int GDT_Byte = gdalconstJNI.GDT_Byte_get(); + public final static int GDT_UInt16 = gdalconstJNI.GDT_UInt16_get(); + public final static int GDT_Int16 = gdalconstJNI.GDT_Int16_get(); + public final static int GDT_UInt32 = gdalconstJNI.GDT_UInt32_get(); + public final static int GDT_Int32 = gdalconstJNI.GDT_Int32_get(); + public final static int GDT_Float32 = gdalconstJNI.GDT_Float32_get(); + public final static int GDT_Float64 = gdalconstJNI.GDT_Float64_get(); + public final static int GDT_CInt16 = gdalconstJNI.GDT_CInt16_get(); + public final static int GDT_CInt32 = gdalconstJNI.GDT_CInt32_get(); + public final static int GDT_CFloat32 = gdalconstJNI.GDT_CFloat32_get(); + public final static int GDT_CFloat64 = gdalconstJNI.GDT_CFloat64_get(); + public final static int GDT_TypeCount = gdalconstJNI.GDT_TypeCount_get(); + public final static int GA_ReadOnly = gdalconstJNI.GA_ReadOnly_get(); + public final static int GA_Update = gdalconstJNI.GA_Update_get(); + public final static int GF_Read = gdalconstJNI.GF_Read_get(); + public final static int GF_Write = gdalconstJNI.GF_Write_get(); + public final static int GCI_Undefined = gdalconstJNI.GCI_Undefined_get(); + public final static int GCI_GrayIndex = gdalconstJNI.GCI_GrayIndex_get(); + public final static int GCI_PaletteIndex = gdalconstJNI.GCI_PaletteIndex_get(); + public final static int GCI_RedBand = gdalconstJNI.GCI_RedBand_get(); + public final static int GCI_GreenBand = gdalconstJNI.GCI_GreenBand_get(); + public final static int GCI_BlueBand = gdalconstJNI.GCI_BlueBand_get(); + public final static int GCI_AlphaBand = gdalconstJNI.GCI_AlphaBand_get(); + public final static int GCI_HueBand = gdalconstJNI.GCI_HueBand_get(); + public final static int GCI_SaturationBand = gdalconstJNI.GCI_SaturationBand_get(); + public final static int GCI_LightnessBand = gdalconstJNI.GCI_LightnessBand_get(); + public final static int GCI_CyanBand = gdalconstJNI.GCI_CyanBand_get(); + public final static int GCI_MagentaBand = gdalconstJNI.GCI_MagentaBand_get(); + public final static int GCI_YellowBand = gdalconstJNI.GCI_YellowBand_get(); + public final static int GCI_BlackBand = gdalconstJNI.GCI_BlackBand_get(); + public final static int GRA_NearestNeighbour = gdalconstJNI.GRA_NearestNeighbour_get(); + public final static int GRA_Bilinear = gdalconstJNI.GRA_Bilinear_get(); + public final static int GRA_Cubic = gdalconstJNI.GRA_Cubic_get(); + public final static int GRA_CubicSpline = gdalconstJNI.GRA_CubicSpline_get(); + public final static int GPI_Gray = gdalconstJNI.GPI_Gray_get(); + public final static int GPI_RGB = gdalconstJNI.GPI_RGB_get(); + public final static int GPI_CMYK = gdalconstJNI.GPI_CMYK_get(); + public final static int GPI_HLS = gdalconstJNI.GPI_HLS_get(); + public final static int CXT_Element = gdalconstJNI.CXT_Element_get(); + public final static int CXT_Text = gdalconstJNI.CXT_Text_get(); + public final static int CXT_Attribute = gdalconstJNI.CXT_Attribute_get(); + public final static int CXT_Comment = gdalconstJNI.CXT_Comment_get(); + public final static int CXT_Literal = gdalconstJNI.CXT_Literal_get(); + public final static int CE_None = gdalconstJNI.CE_None_get(); + public final static int CE_Debug = gdalconstJNI.CE_Debug_get(); + public final static int CE_Warning = gdalconstJNI.CE_Warning_get(); + public final static int CE_Failure = gdalconstJNI.CE_Failure_get(); + public final static int CE_Fatal = gdalconstJNI.CE_Fatal_get(); + public final static int CPLE_None = gdalconstJNI.CPLE_None_get(); + public final static int CPLE_AppDefined = gdalconstJNI.CPLE_AppDefined_get(); + public final static int CPLE_OutOfMemory = gdalconstJNI.CPLE_OutOfMemory_get(); + public final static int CPLE_FileIO = gdalconstJNI.CPLE_FileIO_get(); + public final static int CPLE_OpenFailed = gdalconstJNI.CPLE_OpenFailed_get(); + public final static int CPLE_IllegalArg = gdalconstJNI.CPLE_IllegalArg_get(); + public final static int CPLE_NotSupported = gdalconstJNI.CPLE_NotSupported_get(); + public final static int CPLE_AssertionFailed = gdalconstJNI.CPLE_AssertionFailed_get(); + public final static int CPLE_NoWriteAccess = gdalconstJNI.CPLE_NoWriteAccess_get(); + public final static int CPLE_UserInterrupt = gdalconstJNI.CPLE_UserInterrupt_get(); + public final static String DMD_LONGNAME = gdalconstJNI.DMD_LONGNAME_get(); + public final static String DMD_HELPTOPIC = gdalconstJNI.DMD_HELPTOPIC_get(); + public final static String DMD_MIMETYPE = gdalconstJNI.DMD_MIMETYPE_get(); + public final static String DMD_EXTENSION = gdalconstJNI.DMD_EXTENSION_get(); + public final static String DMD_CREATIONOPTIONLIST = gdalconstJNI.DMD_CREATIONOPTIONLIST_get(); + public final static String DMD_CREATIONDATATYPES = gdalconstJNI.DMD_CREATIONDATATYPES_get(); + public final static String DCAP_CREATE = gdalconstJNI.DCAP_CREATE_get(); + public final static String DCAP_CREATECOPY = gdalconstJNI.DCAP_CREATECOPY_get(); + public final static int CPLES_BackslashQuotable = gdalconstJNI.CPLES_BackslashQuotable_get(); + public final static int CPLES_XML = gdalconstJNI.CPLES_XML_get(); + public final static int CPLES_URL = gdalconstJNI.CPLES_URL_get(); + public final static int CPLES_SQL = gdalconstJNI.CPLES_SQL_get(); + public final static int CPLES_CSV = gdalconstJNI.CPLES_CSV_get(); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstJNI.java b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstJNI.java new file mode 100644 index 0000000000..c8d60deea6 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/gdalconst/gdalconstJNI.java @@ -0,0 +1,102 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.gdalconst; + +class gdalconstJNI { + + private static boolean available = false; + + static { + try { + System.loadLibrary("gdalconstjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } + + public final static native int GDT_Unknown_get(); + public final static native int GDT_Byte_get(); + public final static native int GDT_UInt16_get(); + public final static native int GDT_Int16_get(); + public final static native int GDT_UInt32_get(); + public final static native int GDT_Int32_get(); + public final static native int GDT_Float32_get(); + public final static native int GDT_Float64_get(); + public final static native int GDT_CInt16_get(); + public final static native int GDT_CInt32_get(); + public final static native int GDT_CFloat32_get(); + public final static native int GDT_CFloat64_get(); + public final static native int GDT_TypeCount_get(); + public final static native int GA_ReadOnly_get(); + public final static native int GA_Update_get(); + public final static native int GF_Read_get(); + public final static native int GF_Write_get(); + public final static native int GCI_Undefined_get(); + public final static native int GCI_GrayIndex_get(); + public final static native int GCI_PaletteIndex_get(); + public final static native int GCI_RedBand_get(); + public final static native int GCI_GreenBand_get(); + public final static native int GCI_BlueBand_get(); + public final static native int GCI_AlphaBand_get(); + public final static native int GCI_HueBand_get(); + public final static native int GCI_SaturationBand_get(); + public final static native int GCI_LightnessBand_get(); + public final static native int GCI_CyanBand_get(); + public final static native int GCI_MagentaBand_get(); + public final static native int GCI_YellowBand_get(); + public final static native int GCI_BlackBand_get(); + public final static native int GRA_NearestNeighbour_get(); + public final static native int GRA_Bilinear_get(); + public final static native int GRA_Cubic_get(); + public final static native int GRA_CubicSpline_get(); + public final static native int GPI_Gray_get(); + public final static native int GPI_RGB_get(); + public final static native int GPI_CMYK_get(); + public final static native int GPI_HLS_get(); + public final static native int CXT_Element_get(); + public final static native int CXT_Text_get(); + public final static native int CXT_Attribute_get(); + public final static native int CXT_Comment_get(); + public final static native int CXT_Literal_get(); + public final static native int CE_None_get(); + public final static native int CE_Debug_get(); + public final static native int CE_Warning_get(); + public final static native int CE_Failure_get(); + public final static native int CE_Fatal_get(); + public final static native int CPLE_None_get(); + public final static native int CPLE_AppDefined_get(); + public final static native int CPLE_OutOfMemory_get(); + public final static native int CPLE_FileIO_get(); + public final static native int CPLE_OpenFailed_get(); + public final static native int CPLE_IllegalArg_get(); + public final static native int CPLE_NotSupported_get(); + public final static native int CPLE_AssertionFailed_get(); + public final static native int CPLE_NoWriteAccess_get(); + public final static native int CPLE_UserInterrupt_get(); + public final static native String DMD_LONGNAME_get(); + public final static native String DMD_HELPTOPIC_get(); + public final static native String DMD_MIMETYPE_get(); + public final static native String DMD_EXTENSION_get(); + public final static native String DMD_CREATIONOPTIONLIST_get(); + public final static native String DMD_CREATIONDATATYPES_get(); + public final static native String DCAP_CREATE_get(); + public final static native String DCAP_CREATECOPY_get(); + public final static native int CPLES_BackslashQuotable_get(); + public final static native int CPLES_XML_get(); + public final static native int CPLES_URL_get(); + public final static native int CPLES_SQL_get(); + public final static native int CPLES_CSV_get(); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/DataSource.java b/Utilities/GDAL/swig/java/org/gdal/ogr/DataSource.java new file mode 100644 index 0000000000..d7bd7179fe --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/DataSource.java @@ -0,0 +1,100 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +import org.gdal.osr.SpatialReference; + +public class DataSource { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected DataSource(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(DataSource obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + ogrJNI.delete_DataSource(swigCPtr); + } + swigCPtr = 0; + } + + public String getName() { + return ogrJNI.DataSource_name_get(swigCPtr); + } + + public int GetRefCount() { + return ogrJNI.DataSource_GetRefCount(swigCPtr); + } + + public int GetSummaryRefCount() { + return ogrJNI.DataSource_GetSummaryRefCount(swigCPtr); + } + + public int GetLayerCount() { + return ogrJNI.DataSource_GetLayerCount(swigCPtr); + } + + public Driver GetDriver() { + long cPtr = ogrJNI.DataSource_GetDriver(swigCPtr); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + + public String GetName() { + return ogrJNI.DataSource_GetName(swigCPtr); + } + + public int DeleteLayer(int index) { + return ogrJNI.DataSource_DeleteLayer(swigCPtr, index); + } + + public Layer CreateLayer(String name, SpatialReference reference, int geom_type, java.util.Vector options) { + long cPtr = ogrJNI.DataSource_CreateLayer(swigCPtr, name, SpatialReference.getCPtr(reference), geom_type, options); + return (cPtr == 0) ? null : new Layer(cPtr, false); + } + + public Layer CopyLayer(Layer src_layer, String new_name, java.util.Vector options) { + long cPtr = ogrJNI.DataSource_CopyLayer(swigCPtr, Layer.getCPtr(src_layer), new_name, options); + return (cPtr == 0) ? null : new Layer(cPtr, false); + } + + public Layer GetLayerByIndex(int index) { + long cPtr = ogrJNI.DataSource_GetLayerByIndex(swigCPtr, index); + return (cPtr == 0) ? null : new Layer(cPtr, false); + } + + public Layer GetLayerByName(String layer_name) { + long cPtr = ogrJNI.DataSource_GetLayerByName(swigCPtr, layer_name); + return (cPtr == 0) ? null : new Layer(cPtr, false); + } + + public boolean TestCapability(String cap) { + return ogrJNI.DataSource_TestCapability(swigCPtr, cap); + } + + public Layer ExecuteSQL(String statement, Geometry geom, String dialect) { + long cPtr = ogrJNI.DataSource_ExecuteSQL(swigCPtr, statement, Geometry.getCPtr(geom), dialect); + return (cPtr == 0) ? null : new Layer(cPtr, true); + } + + public void ReleaseResultSet(Layer layer) { + ogrJNI.DataSource_ReleaseResultSet(swigCPtr, Layer.getCPtr(layer)); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/Driver.java b/Utilities/GDAL/swig/java/org/gdal/ogr/Driver.java new file mode 100644 index 0000000000..4a9e97183f --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/Driver.java @@ -0,0 +1,63 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +public class Driver { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected Driver(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(Driver obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + throw new UnsupportedOperationException("C++ destructor does not have public access"); + } + swigCPtr = 0; + } + + public String getName() { + return ogrJNI.Driver_name_get(swigCPtr); + } + + public DataSource CreateDataSource(String name, java.util.Vector options) { + long cPtr = ogrJNI.Driver_CreateDataSource(swigCPtr, name, options); + return (cPtr == 0) ? null : new DataSource(cPtr, true); + } + + public DataSource CopyDataSource(DataSource copy_ds, String name, java.util.Vector options) { + long cPtr = ogrJNI.Driver_CopyDataSource(swigCPtr, DataSource.getCPtr(copy_ds), name, options); + return (cPtr == 0) ? null : new DataSource(cPtr, true); + } + + public DataSource Open(String name, int update) { + long cPtr = ogrJNI.Driver_Open(swigCPtr, name, update); + return (cPtr == 0) ? null : new DataSource(cPtr, true); + } + + public int DeleteDataSource(String name) { + return ogrJNI.Driver_DeleteDataSource(swigCPtr, name); + } + + public boolean TestCapability(String cap) { + return ogrJNI.Driver_TestCapability(swigCPtr, cap); + } + + public String GetName() { + return ogrJNI.Driver_GetName(swigCPtr); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/Feature.java b/Utilities/GDAL/swig/java/org/gdal/ogr/Feature.java new file mode 100644 index 0000000000..0e2be3472e --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/Feature.java @@ -0,0 +1,165 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +public class Feature { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected Feature(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(Feature obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + ogrJNI.delete_Feature(swigCPtr); + } + swigCPtr = 0; + } + + public Feature(FeatureDefn feature_def) { + this(ogrJNI.new_Feature(FeatureDefn.getCPtr(feature_def)), true); + } + + public FeatureDefn GetDefnRef() { + long cPtr = ogrJNI.Feature_GetDefnRef(swigCPtr); + return (cPtr == 0) ? null : new FeatureDefn(cPtr, false); + } + + public int SetGeometry(Geometry geom) { + return ogrJNI.Feature_SetGeometry(swigCPtr, Geometry.getCPtr(geom)); + } + + public int SetGeometryDirectly(Geometry geom) { + return ogrJNI.Feature_SetGeometryDirectly(swigCPtr, Geometry.getCPtr(geom)); + } + + public Geometry GetGeometryRef() { + long cPtr = ogrJNI.Feature_GetGeometryRef(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, false); + } + + public Feature Clone() { + long cPtr = ogrJNI.Feature_Clone(swigCPtr); + return (cPtr == 0) ? null : new Feature(cPtr, true); + } + + public boolean Equal(Feature feature) { + return ogrJNI.Feature_Equal(swigCPtr, Feature.getCPtr(feature)); + } + + public int GetFieldCount() { + return ogrJNI.Feature_GetFieldCount(swigCPtr); + } + + public FieldDefn GetFieldDefnRef(int id) { + long cPtr = ogrJNI.Feature_GetFieldDefnRef__SWIG_0(swigCPtr, id); + return (cPtr == 0) ? null : new FieldDefn(cPtr, false); + } + + public FieldDefn GetFieldDefnRef(String name) { + long cPtr = ogrJNI.Feature_GetFieldDefnRef__SWIG_1(swigCPtr, name); + return (cPtr == 0) ? null : new FieldDefn(cPtr, false); + } + + public String GetFieldAsString(int id) { + return ogrJNI.Feature_GetFieldAsString__SWIG_0(swigCPtr, id); + } + + public String GetFieldAsString(String name) { + return ogrJNI.Feature_GetFieldAsString__SWIG_1(swigCPtr, name); + } + + public int GetFieldAsInteger(int id) { + return ogrJNI.Feature_GetFieldAsInteger__SWIG_0(swigCPtr, id); + } + + public int GetFieldAsInteger(String name) { + return ogrJNI.Feature_GetFieldAsInteger__SWIG_1(swigCPtr, name); + } + + public double GetFieldAsDouble(int id) { + return ogrJNI.Feature_GetFieldAsDouble__SWIG_0(swigCPtr, id); + } + + public double GetFieldAsDouble(String name) { + return ogrJNI.Feature_GetFieldAsDouble__SWIG_1(swigCPtr, name); + } + + public boolean IsFieldSet(int id) { + return ogrJNI.Feature_IsFieldSet__SWIG_0(swigCPtr, id); + } + + public boolean IsFieldSet(String name) { + return ogrJNI.Feature_IsFieldSet__SWIG_1(swigCPtr, name); + } + + public int GetFieldIndex(String name) { + return ogrJNI.Feature_GetFieldIndex(swigCPtr, name); + } + + public int GetFID() { + return ogrJNI.Feature_GetFID(swigCPtr); + } + + public int SetFID(int fid) { + return ogrJNI.Feature_SetFID(swigCPtr, fid); + } + + public void DumpReadable() { + ogrJNI.Feature_DumpReadable(swigCPtr); + } + + public void UnsetField(int id) { + ogrJNI.Feature_UnsetField__SWIG_0(swigCPtr, id); + } + + public void UnsetField(String name) { + ogrJNI.Feature_UnsetField__SWIG_1(swigCPtr, name); + } + + public void SetField(int id, String value) { + ogrJNI.Feature_SetField__SWIG_0(swigCPtr, id, value); + } + + public void SetField(String name, String value) { + ogrJNI.Feature_SetField__SWIG_1(swigCPtr, name, value); + } + + public int SetFrom(Feature other, int forgiving) { + return ogrJNI.Feature_SetFrom(swigCPtr, Feature.getCPtr(other), forgiving); + } + + public String GetStyleString() { + return ogrJNI.Feature_GetStyleString(swigCPtr); + } + + public void SetStyleString(String the_string) { + ogrJNI.Feature_SetStyleString(swigCPtr, the_string); + } + + public int GetFieldType(int id) { + return ogrJNI.Feature_GetFieldType__SWIG_0(swigCPtr, id); + } + + public int GetFieldType(String name, String value) { + return ogrJNI.Feature_GetFieldType__SWIG_1(swigCPtr, name, value); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/FeatureDefn.java b/Utilities/GDAL/swig/java/org/gdal/ogr/FeatureDefn.java new file mode 100644 index 0000000000..617a18b0e2 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/FeatureDefn.java @@ -0,0 +1,73 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +public class FeatureDefn { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected FeatureDefn(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(FeatureDefn obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + ogrJNI.delete_FeatureDefn(swigCPtr); + } + swigCPtr = 0; + } + + public FeatureDefn(String name) { + this(ogrJNI.new_FeatureDefn(name), true); + } + + public String GetName() { + return ogrJNI.FeatureDefn_GetName(swigCPtr); + } + + public int GetFieldCount() { + return ogrJNI.FeatureDefn_GetFieldCount(swigCPtr); + } + + public FieldDefn GetFieldDefn(int i) { + long cPtr = ogrJNI.FeatureDefn_GetFieldDefn(swigCPtr, i); + return (cPtr == 0) ? null : new FieldDefn(cPtr, false); + } + + public int GetFieldIndex(String name) { + return ogrJNI.FeatureDefn_GetFieldIndex(swigCPtr, name); + } + + public void AddFieldDefn(FieldDefn defn) { + ogrJNI.FeatureDefn_AddFieldDefn(swigCPtr, FieldDefn.getCPtr(defn)); + } + + public int GetGeomType() { + return ogrJNI.FeatureDefn_GetGeomType(swigCPtr); + } + + public void SetGeomType(int geom_type) { + ogrJNI.FeatureDefn_SetGeomType(swigCPtr, geom_type); + } + + public int GetReferenceCount() { + return ogrJNI.FeatureDefn_GetReferenceCount(swigCPtr); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/FieldDefn.java b/Utilities/GDAL/swig/java/org/gdal/ogr/FieldDefn.java new file mode 100644 index 0000000000..aae8d248c5 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/FieldDefn.java @@ -0,0 +1,88 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +public class FieldDefn { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected FieldDefn(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(FieldDefn obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + ogrJNI.delete_FieldDefn(swigCPtr); + } + swigCPtr = 0; + } + + public FieldDefn(String name, int field_type) { + this(ogrJNI.new_FieldDefn(name, field_type), true); + } + + public String GetName() { + return ogrJNI.FieldDefn_GetName(swigCPtr); + } + + public String GetNameRef() { + return ogrJNI.FieldDefn_GetNameRef(swigCPtr); + } + + public void SetName(String name) { + ogrJNI.FieldDefn_SetName(swigCPtr, name); + } + + public int GetFieldType() { + return ogrJNI.FieldDefn_GetFieldType(swigCPtr); + } + + public void SetType(int type) { + ogrJNI.FieldDefn_SetType(swigCPtr, type); + } + + public int GetJustify() { + return ogrJNI.FieldDefn_GetJustify(swigCPtr); + } + + public void SetJustify(int justify) { + ogrJNI.FieldDefn_SetJustify(swigCPtr, justify); + } + + public int GetWidth() { + return ogrJNI.FieldDefn_GetWidth(swigCPtr); + } + + public void SetWidth(int width) { + ogrJNI.FieldDefn_SetWidth(swigCPtr, width); + } + + public int GetPrecision() { + return ogrJNI.FieldDefn_GetPrecision(swigCPtr); + } + + public void SetPrecision(int precision) { + ogrJNI.FieldDefn_SetPrecision(swigCPtr, precision); + } + + public String GetFieldTypeName(int type) { + return ogrJNI.FieldDefn_GetFieldTypeName(swigCPtr, type); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/Geometry.java b/Utilities/GDAL/swig/java/org/gdal/ogr/Geometry.java new file mode 100644 index 0000000000..6ddcf40e45 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/Geometry.java @@ -0,0 +1,234 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +import org.gdal.osr.SpatialReference; +import org.gdal.osr.CoordinateTransformation; + +public class Geometry { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected Geometry(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(Geometry obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + ogrJNI.delete_Geometry(swigCPtr); + } + swigCPtr = 0; + } + + public Geometry(int type, String wkt, int wkb, String wkb_buf, String gml) { + this(ogrJNI.new_Geometry(type, wkt, wkb, wkb_buf, gml), true); + } + + public int ExportToWkt(String[] argout) { + return ogrJNI.Geometry_ExportToWkt(swigCPtr, argout); + } + + public int ExportToWkb(char[][] nLen, int byte_order) { + return ogrJNI.Geometry_ExportToWkb(swigCPtr, nLen, byte_order); + } + + public String ExportToGML() { + return ogrJNI.Geometry_ExportToGML(swigCPtr); + } + + public void AddPoint(double x, double y, double z) { + ogrJNI.Geometry_AddPoint(swigCPtr, x, y, z); + } + + public int AddGeometryDirectly(Geometry other) { + return ogrJNI.Geometry_AddGeometryDirectly(swigCPtr, Geometry.getCPtr(other)); + } + + public int AddGeometry(Geometry other) { + return ogrJNI.Geometry_AddGeometry(swigCPtr, Geometry.getCPtr(other)); + } + + public Geometry Clone() { + long cPtr = ogrJNI.Geometry_Clone(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public int GetGeometryType() { + return ogrJNI.Geometry_GetGeometryType(swigCPtr); + } + + public String GetGeometryName() { + return ogrJNI.Geometry_GetGeometryName(swigCPtr); + } + + public double GetArea() { + return ogrJNI.Geometry_GetArea(swigCPtr); + } + + public int GetPointCount() { + return ogrJNI.Geometry_GetPointCount(swigCPtr); + } + + public double GetX(int point) { + return ogrJNI.Geometry_GetX(swigCPtr, point); + } + + public double GetY(int point) { + return ogrJNI.Geometry_GetY(swigCPtr, point); + } + + public double GetZ(int point) { + return ogrJNI.Geometry_GetZ(swigCPtr, point); + } + + public int GetGeometryCount() { + return ogrJNI.Geometry_GetGeometryCount(swigCPtr); + } + + public void SetPoint(int point, double x, double y, double z) { + ogrJNI.Geometry_SetPoint(swigCPtr, point, x, y, z); + } + + public Geometry GetGeometryRef(int geom) { + long cPtr = ogrJNI.Geometry_GetGeometryRef(swigCPtr, geom); + return (cPtr == 0) ? null : new Geometry(cPtr, false); + } + + public Geometry GetBoundary() { + long cPtr = ogrJNI.Geometry_GetBoundary(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry ConvexHull() { + long cPtr = ogrJNI.Geometry_ConvexHull(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry Buffer(double distance, int quadsecs) { + long cPtr = ogrJNI.Geometry_Buffer(swigCPtr, distance, quadsecs); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry Intersection(Geometry other) { + long cPtr = ogrJNI.Geometry_Intersection(swigCPtr, Geometry.getCPtr(other)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry Union(Geometry other) { + long cPtr = ogrJNI.Geometry_Union(swigCPtr, Geometry.getCPtr(other)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry Difference(Geometry other) { + long cPtr = ogrJNI.Geometry_Difference(swigCPtr, Geometry.getCPtr(other)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public Geometry SymmetricDifference(Geometry other) { + long cPtr = ogrJNI.Geometry_SymmetricDifference(swigCPtr, Geometry.getCPtr(other)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public double Distance(Geometry other) { + return ogrJNI.Geometry_Distance(swigCPtr, Geometry.getCPtr(other)); + } + + public void Empty() { + ogrJNI.Geometry_Empty(swigCPtr); + } + + public boolean Intersect(Geometry other) { + return ogrJNI.Geometry_Intersect(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Equal(Geometry other) { + return ogrJNI.Geometry_Equal(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Disjoint(Geometry other) { + return ogrJNI.Geometry_Disjoint(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Touches(Geometry other) { + return ogrJNI.Geometry_Touches(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Crosses(Geometry other) { + return ogrJNI.Geometry_Crosses(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Within(Geometry other) { + return ogrJNI.Geometry_Within(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Contains(Geometry other) { + return ogrJNI.Geometry_Contains(swigCPtr, Geometry.getCPtr(other)); + } + + public boolean Overlaps(Geometry other) { + return ogrJNI.Geometry_Overlaps(swigCPtr, Geometry.getCPtr(other)); + } + + public int TransformTo(SpatialReference reference) { + return ogrJNI.Geometry_TransformTo(swigCPtr, SpatialReference.getCPtr(reference)); + } + + public int Transform(CoordinateTransformation trans) { + return ogrJNI.Geometry_Transform(swigCPtr, CoordinateTransformation.getCPtr(trans)); + } + + public SpatialReference GetSpatialReference() { + long cPtr = ogrJNI.Geometry_GetSpatialReference(swigCPtr); + return (cPtr == 0) ? null : new SpatialReference(cPtr, false); + } + + public void AssignSpatialReference(SpatialReference reference) { + ogrJNI.Geometry_AssignSpatialReference(swigCPtr, SpatialReference.getCPtr(reference)); + } + + public void CloseRings() { + ogrJNI.Geometry_CloseRings(swigCPtr); + } + + public void FlattenTo2D() { + ogrJNI.Geometry_FlattenTo2D(swigCPtr); + } + + public void GetEnvelope(double[] argout) { + ogrJNI.Geometry_GetEnvelope(swigCPtr, argout); + } + + public Geometry Centroid() { + long cPtr = ogrJNI.Geometry_Centroid(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public int WkbSize() { + return ogrJNI.Geometry_WkbSize(swigCPtr); + } + + public int GetCoordinateDimension() { + return ogrJNI.Geometry_GetCoordinateDimension(swigCPtr); + } + + public int GetDimension() { + return ogrJNI.Geometry_GetDimension(swigCPtr); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/Layer.java b/Utilities/GDAL/swig/java/org/gdal/ogr/Layer.java new file mode 100644 index 0000000000..31afc60f47 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/Layer.java @@ -0,0 +1,135 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +import org.gdal.osr.SpatialReference; + +public class Layer { + private long swigCPtr; + protected boolean swigCMemOwn; + + protected Layer(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + protected static long getCPtr(Layer obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + throw new UnsupportedOperationException("C++ destructor does not have public access"); + } + swigCPtr = 0; + } + + public int GetRefCount() { + return ogrJNI.Layer_GetRefCount(swigCPtr); + } + + public void SetSpatialFilter(Geometry filter) { + ogrJNI.Layer_SetSpatialFilter(swigCPtr, Geometry.getCPtr(filter)); + } + + public void SetSpatialFilterRect(double minx, double miny, double maxx, double maxy) { + ogrJNI.Layer_SetSpatialFilterRect(swigCPtr, minx, miny, maxx, maxy); + } + + public Geometry GetSpatialFilter() { + long cPtr = ogrJNI.Layer_GetSpatialFilter(swigCPtr); + return (cPtr == 0) ? null : new Geometry(cPtr, false); + } + + public int SetAttributeFilter(String filter_string) { + return ogrJNI.Layer_SetAttributeFilter(swigCPtr, filter_string); + } + + public void ResetReading() { + ogrJNI.Layer_ResetReading(swigCPtr); + } + + public String GetName() { + return ogrJNI.Layer_GetName(swigCPtr); + } + + public Feature GetFeature(int fid) { + long cPtr = ogrJNI.Layer_GetFeature(swigCPtr, fid); + return (cPtr == 0) ? null : new Feature(cPtr, true); + } + + public Feature GetNextFeature() { + long cPtr = ogrJNI.Layer_GetNextFeature(swigCPtr); + return (cPtr == 0) ? null : new Feature(cPtr, true); + } + + public int SetNextByIndex(int new_index) { + return ogrJNI.Layer_SetNextByIndex(swigCPtr, new_index); + } + + public int SetFeature(Feature feature) { + return ogrJNI.Layer_SetFeature(swigCPtr, Feature.getCPtr(feature)); + } + + public int CreateFeature(Feature feature) { + return ogrJNI.Layer_CreateFeature(swigCPtr, Feature.getCPtr(feature)); + } + + public int DeleteFeature(int fid) { + return ogrJNI.Layer_DeleteFeature(swigCPtr, fid); + } + + public int SyncToDisk() { + return ogrJNI.Layer_SyncToDisk(swigCPtr); + } + + public FeatureDefn GetLayerDefn() { + long cPtr = ogrJNI.Layer_GetLayerDefn(swigCPtr); + return (cPtr == 0) ? null : new FeatureDefn(cPtr, false); + } + + public int GetFeatureCount(int force) { + return ogrJNI.Layer_GetFeatureCount(swigCPtr, force); + } + + public int GetExtent(double[] argout, int force) { + return ogrJNI.Layer_GetExtent(swigCPtr, argout, force); + } + + public boolean TestCapability(String cap) { + return ogrJNI.Layer_TestCapability(swigCPtr, cap); + } + + public int CreateField(FieldDefn field_def, int approx_ok) { + return ogrJNI.Layer_CreateField(swigCPtr, FieldDefn.getCPtr(field_def), approx_ok); + } + + public int StartTransaction() { + return ogrJNI.Layer_StartTransaction(swigCPtr); + } + + public int CommitTransaction() { + return ogrJNI.Layer_CommitTransaction(swigCPtr); + } + + public int RollbackTransaction() { + return ogrJNI.Layer_RollbackTransaction(swigCPtr); + } + + public SpatialReference GetSpatialRef() { + long cPtr = ogrJNI.Layer_GetSpatialRef(swigCPtr); + return (cPtr == 0) ? null : new SpatialReference(cPtr, false); + } + + public SWIGTYPE_p_GIntBig GetFeatureRead() { + return new SWIGTYPE_p_GIntBig(ogrJNI.Layer_GetFeatureRead(swigCPtr), true); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/SWIGTYPE_p_GIntBig.java b/Utilities/GDAL/swig/java/org/gdal/ogr/SWIGTYPE_p_GIntBig.java new file mode 100644 index 0000000000..0e3814ee29 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/SWIGTYPE_p_GIntBig.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +public class SWIGTYPE_p_GIntBig { + private long swigCPtr; + + protected SWIGTYPE_p_GIntBig(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_GIntBig() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_GIntBig obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/ogr.java b/Utilities/GDAL/swig/java/org/gdal/ogr/ogr.java new file mode 100644 index 0000000000..3e8744caab --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/ogr.java @@ -0,0 +1,70 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +import org.gdal.osr.SpatialReference; + +public class ogr implements ogrConstants { + public static Geometry CreateGeometryFromWkb(char[] len, SpatialReference reference) { + long cPtr = ogrJNI.CreateGeometryFromWkb(len, SpatialReference.getCPtr(reference)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public static Geometry CreateGeometryFromWkt(String val, SpatialReference reference) { + long cPtr = ogrJNI.CreateGeometryFromWkt(val, SpatialReference.getCPtr(reference)); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public static Geometry CreateGeometryFromGML(String input_string) { + long cPtr = ogrJNI.CreateGeometryFromGML(input_string); + return (cPtr == 0) ? null : new Geometry(cPtr, true); + } + + public static int GetDriverCount() { + return ogrJNI.GetDriverCount(); + } + + public static int GetOpenDSCount() { + return ogrJNI.GetOpenDSCount(); + } + + public static int SetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER) { + return ogrJNI.SetGenerate_DB2_V72_BYTE_ORDER(bGenerate_DB2_V72_BYTE_ORDER); + } + + public static void RegisterAll() { + ogrJNI.RegisterAll(); + } + + public static DataSource GetOpenDS(int ds_number) { + long cPtr = ogrJNI.GetOpenDS(ds_number); + return (cPtr == 0) ? null : new DataSource(cPtr, false); + } + + public static DataSource Open(String filename, int update) { + long cPtr = ogrJNI.Open(filename, update); + return (cPtr == 0) ? null : new DataSource(cPtr, true); + } + + public static DataSource OpenShared(String filename, int update) { + long cPtr = ogrJNI.OpenShared(filename, update); + return (cPtr == 0) ? null : new DataSource(cPtr, true); + } + + public static Driver GetDriverByName(String name) { + long cPtr = ogrJNI.GetDriverByName(name); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + + public static Driver GetDriver(int driver_number) { + long cPtr = ogrJNI.GetDriver(driver_number); + return (cPtr == 0) ? null : new Driver(cPtr, false); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/ogrConstants.java b/Utilities/GDAL/swig/java/org/gdal/ogr/ogrConstants.java new file mode 100644 index 0000000000..74a94ca767 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/ogrConstants.java @@ -0,0 +1,61 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +import org.gdal.osr.SpatialReference; + +public interface ogrConstants { + public final static int wkb25Bit = ogrJNI.wkb25Bit_get(); + public final static int wkbUnknown = ogrJNI.wkbUnknown_get(); + public final static int wkbPoint = ogrJNI.wkbPoint_get(); + public final static int wkbLineString = ogrJNI.wkbLineString_get(); + public final static int wkbPolygon = ogrJNI.wkbPolygon_get(); + public final static int wkbMultiPoint = ogrJNI.wkbMultiPoint_get(); + public final static int wkbMultiLineString = ogrJNI.wkbMultiLineString_get(); + public final static int wkbMultiPolygon = ogrJNI.wkbMultiPolygon_get(); + public final static int wkbGeometryCollection = ogrJNI.wkbGeometryCollection_get(); + public final static int wkbNone = ogrJNI.wkbNone_get(); + public final static int wkbLinearRing = ogrJNI.wkbLinearRing_get(); + public final static int wkbPoint25D = ogrJNI.wkbPoint25D_get(); + public final static int wkbLineString25D = ogrJNI.wkbLineString25D_get(); + public final static int wkbPolygon25D = ogrJNI.wkbPolygon25D_get(); + public final static int wkbMultiPoint25D = ogrJNI.wkbMultiPoint25D_get(); + public final static int wkbMultiLineString25D = ogrJNI.wkbMultiLineString25D_get(); + public final static int wkbMultiPolygon25D = ogrJNI.wkbMultiPolygon25D_get(); + public final static int wkbGeometryCollection25D = ogrJNI.wkbGeometryCollection25D_get(); + public final static int OFTInteger = ogrJNI.OFTInteger_get(); + public final static int OFTIntegerList = ogrJNI.OFTIntegerList_get(); + public final static int OFTReal = ogrJNI.OFTReal_get(); + public final static int OFTRealList = ogrJNI.OFTRealList_get(); + public final static int OFTString = ogrJNI.OFTString_get(); + public final static int OFTStringList = ogrJNI.OFTStringList_get(); + public final static int OFTWideString = ogrJNI.OFTWideString_get(); + public final static int OFTWideStringList = ogrJNI.OFTWideStringList_get(); + public final static int OFTBinary = ogrJNI.OFTBinary_get(); + public final static int OFTDate = ogrJNI.OFTDate_get(); + public final static int OJUndefined = ogrJNI.OJUndefined_get(); + public final static int OJLeft = ogrJNI.OJLeft_get(); + public final static int OJRight = ogrJNI.OJRight_get(); + public final static int wkbXDR = ogrJNI.wkbXDR_get(); + public final static int wkbNDR = ogrJNI.wkbNDR_get(); + public final static String OLCRandomRead = ogrJNI.OLCRandomRead_get(); + public final static String OLCSequentialWrite = ogrJNI.OLCSequentialWrite_get(); + public final static String OLCRandomWrite = ogrJNI.OLCRandomWrite_get(); + public final static String OLCFastSpatialFilter = ogrJNI.OLCFastSpatialFilter_get(); + public final static String OLCFastFeatureCount = ogrJNI.OLCFastFeatureCount_get(); + public final static String OLCFastGetExtent = ogrJNI.OLCFastGetExtent_get(); + public final static String OLCCreateField = ogrJNI.OLCCreateField_get(); + public final static String OLCTransactions = ogrJNI.OLCTransactions_get(); + public final static String OLCDeleteFeature = ogrJNI.OLCDeleteFeature_get(); + public final static String OLCFastSetNextByIndex = ogrJNI.OLCFastSetNextByIndex_get(); + public final static String ODsCCreateLayer = ogrJNI.ODsCCreateLayer_get(); + public final static String ODsCDeleteLayer = ogrJNI.ODsCDeleteLayer_get(); + public final static String ODrCCreateDataSource = ogrJNI.ODrCCreateDataSource_get(); + public final static String ODrCDeleteDataSource = ogrJNI.ODrCDeleteDataSource_get(); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/ogr/ogrJNI.java b/Utilities/GDAL/swig/java/org/gdal/ogr/ogrJNI.java new file mode 100644 index 0000000000..e35469ded2 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/ogr/ogrJNI.java @@ -0,0 +1,238 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.ogr; + +class ogrJNI { + public final static native int wkb25Bit_get(); + public final static native int wkbUnknown_get(); + public final static native int wkbPoint_get(); + public final static native int wkbLineString_get(); + public final static native int wkbPolygon_get(); + public final static native int wkbMultiPoint_get(); + public final static native int wkbMultiLineString_get(); + public final static native int wkbMultiPolygon_get(); + public final static native int wkbGeometryCollection_get(); + public final static native int wkbNone_get(); + public final static native int wkbLinearRing_get(); + public final static native int wkbPoint25D_get(); + public final static native int wkbLineString25D_get(); + public final static native int wkbPolygon25D_get(); + public final static native int wkbMultiPoint25D_get(); + public final static native int wkbMultiLineString25D_get(); + public final static native int wkbMultiPolygon25D_get(); + public final static native int wkbGeometryCollection25D_get(); + public final static native int OFTInteger_get(); + public final static native int OFTIntegerList_get(); + public final static native int OFTReal_get(); + public final static native int OFTRealList_get(); + public final static native int OFTString_get(); + public final static native int OFTStringList_get(); + public final static native int OFTWideString_get(); + public final static native int OFTWideStringList_get(); + public final static native int OFTBinary_get(); + public final static native int OFTDate_get(); + public final static native int OJUndefined_get(); + public final static native int OJLeft_get(); + public final static native int OJRight_get(); + public final static native int wkbXDR_get(); + public final static native int wkbNDR_get(); + public final static native String OLCRandomRead_get(); + public final static native String OLCSequentialWrite_get(); + public final static native String OLCRandomWrite_get(); + public final static native String OLCFastSpatialFilter_get(); + public final static native String OLCFastFeatureCount_get(); + public final static native String OLCFastGetExtent_get(); + public final static native String OLCCreateField_get(); + public final static native String OLCTransactions_get(); + public final static native String OLCDeleteFeature_get(); + public final static native String OLCFastSetNextByIndex_get(); + public final static native String ODsCCreateLayer_get(); + public final static native String ODsCDeleteLayer_get(); + public final static native String ODrCCreateDataSource_get(); + public final static native String ODrCDeleteDataSource_get(); + + private static boolean available = false; + + static { + try { + System.loadLibrary("ogrjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } + + public final static native String Driver_name_get(long jarg1); + public final static native long Driver_CreateDataSource(long jarg1, String jarg2, java.util.Vector jarg3); + public final static native long Driver_CopyDataSource(long jarg1, long jarg2, String jarg3, java.util.Vector jarg4); + public final static native long Driver_Open(long jarg1, String jarg2, int jarg3); + public final static native int Driver_DeleteDataSource(long jarg1, String jarg2); + public final static native boolean Driver_TestCapability(long jarg1, String jarg2); + public final static native String Driver_GetName(long jarg1); + public final static native String DataSource_name_get(long jarg1); + public final static native void delete_DataSource(long jarg1); + public final static native int DataSource_GetRefCount(long jarg1); + public final static native int DataSource_GetSummaryRefCount(long jarg1); + public final static native int DataSource_GetLayerCount(long jarg1); + public final static native long DataSource_GetDriver(long jarg1); + public final static native String DataSource_GetName(long jarg1); + public final static native int DataSource_DeleteLayer(long jarg1, int jarg2); + public final static native long DataSource_CreateLayer(long jarg1, String jarg2, long jarg3, int jarg4, java.util.Vector jarg5); + public final static native long DataSource_CopyLayer(long jarg1, long jarg2, String jarg3, java.util.Vector jarg4); + public final static native long DataSource_GetLayerByIndex(long jarg1, int jarg2); + public final static native long DataSource_GetLayerByName(long jarg1, String jarg2); + public final static native boolean DataSource_TestCapability(long jarg1, String jarg2); + public final static native long DataSource_ExecuteSQL(long jarg1, String jarg2, long jarg3, String jarg4); + public final static native void DataSource_ReleaseResultSet(long jarg1, long jarg2); + public final static native int Layer_GetRefCount(long jarg1); + public final static native void Layer_SetSpatialFilter(long jarg1, long jarg2); + public final static native void Layer_SetSpatialFilterRect(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5); + public final static native long Layer_GetSpatialFilter(long jarg1); + public final static native int Layer_SetAttributeFilter(long jarg1, String jarg2); + public final static native void Layer_ResetReading(long jarg1); + public final static native String Layer_GetName(long jarg1); + public final static native long Layer_GetFeature(long jarg1, int jarg2); + public final static native long Layer_GetNextFeature(long jarg1); + public final static native int Layer_SetNextByIndex(long jarg1, int jarg2); + public final static native int Layer_SetFeature(long jarg1, long jarg2); + public final static native int Layer_CreateFeature(long jarg1, long jarg2); + public final static native int Layer_DeleteFeature(long jarg1, int jarg2); + public final static native int Layer_SyncToDisk(long jarg1); + public final static native long Layer_GetLayerDefn(long jarg1); + public final static native int Layer_GetFeatureCount(long jarg1, int jarg2); + public final static native int Layer_GetExtent(long jarg1, double[] jarg2, int jarg3); + public final static native boolean Layer_TestCapability(long jarg1, String jarg2); + public final static native int Layer_CreateField(long jarg1, long jarg2, int jarg3); + public final static native int Layer_StartTransaction(long jarg1); + public final static native int Layer_CommitTransaction(long jarg1); + public final static native int Layer_RollbackTransaction(long jarg1); + public final static native long Layer_GetSpatialRef(long jarg1); + public final static native long Layer_GetFeatureRead(long jarg1); + public final static native void delete_Feature(long jarg1); + public final static native long new_Feature(long jarg1); + public final static native long Feature_GetDefnRef(long jarg1); + public final static native int Feature_SetGeometry(long jarg1, long jarg2); + public final static native int Feature_SetGeometryDirectly(long jarg1, long jarg2); + public final static native long Feature_GetGeometryRef(long jarg1); + public final static native long Feature_Clone(long jarg1); + public final static native boolean Feature_Equal(long jarg1, long jarg2); + public final static native int Feature_GetFieldCount(long jarg1); + public final static native long Feature_GetFieldDefnRef__SWIG_0(long jarg1, int jarg2); + public final static native long Feature_GetFieldDefnRef__SWIG_1(long jarg1, String jarg2); + public final static native String Feature_GetFieldAsString__SWIG_0(long jarg1, int jarg2); + public final static native String Feature_GetFieldAsString__SWIG_1(long jarg1, String jarg2); + public final static native int Feature_GetFieldAsInteger__SWIG_0(long jarg1, int jarg2); + public final static native int Feature_GetFieldAsInteger__SWIG_1(long jarg1, String jarg2); + public final static native double Feature_GetFieldAsDouble__SWIG_0(long jarg1, int jarg2); + public final static native double Feature_GetFieldAsDouble__SWIG_1(long jarg1, String jarg2); + public final static native boolean Feature_IsFieldSet__SWIG_0(long jarg1, int jarg2); + public final static native boolean Feature_IsFieldSet__SWIG_1(long jarg1, String jarg2); + public final static native int Feature_GetFieldIndex(long jarg1, String jarg2); + public final static native int Feature_GetFID(long jarg1); + public final static native int Feature_SetFID(long jarg1, int jarg2); + public final static native void Feature_DumpReadable(long jarg1); + public final static native void Feature_UnsetField__SWIG_0(long jarg1, int jarg2); + public final static native void Feature_UnsetField__SWIG_1(long jarg1, String jarg2); + public final static native void Feature_SetField__SWIG_0(long jarg1, int jarg2, String jarg3); + public final static native void Feature_SetField__SWIG_1(long jarg1, String jarg2, String jarg3); + public final static native int Feature_SetFrom(long jarg1, long jarg2, int jarg3); + public final static native String Feature_GetStyleString(long jarg1); + public final static native void Feature_SetStyleString(long jarg1, String jarg2); + public final static native int Feature_GetFieldType__SWIG_0(long jarg1, int jarg2); + public final static native int Feature_GetFieldType__SWIG_1(long jarg1, String jarg2, String jarg3); + public final static native void delete_FeatureDefn(long jarg1); + public final static native long new_FeatureDefn(String jarg1); + public final static native String FeatureDefn_GetName(long jarg1); + public final static native int FeatureDefn_GetFieldCount(long jarg1); + public final static native long FeatureDefn_GetFieldDefn(long jarg1, int jarg2); + public final static native int FeatureDefn_GetFieldIndex(long jarg1, String jarg2); + public final static native void FeatureDefn_AddFieldDefn(long jarg1, long jarg2); + public final static native int FeatureDefn_GetGeomType(long jarg1); + public final static native void FeatureDefn_SetGeomType(long jarg1, int jarg2); + public final static native int FeatureDefn_GetReferenceCount(long jarg1); + public final static native void delete_FieldDefn(long jarg1); + public final static native long new_FieldDefn(String jarg1, int jarg2); + public final static native String FieldDefn_GetName(long jarg1); + public final static native String FieldDefn_GetNameRef(long jarg1); + public final static native void FieldDefn_SetName(long jarg1, String jarg2); + public final static native int FieldDefn_GetFieldType(long jarg1); + public final static native void FieldDefn_SetType(long jarg1, int jarg2); + public final static native int FieldDefn_GetJustify(long jarg1); + public final static native void FieldDefn_SetJustify(long jarg1, int jarg2); + public final static native int FieldDefn_GetWidth(long jarg1); + public final static native void FieldDefn_SetWidth(long jarg1, int jarg2); + public final static native int FieldDefn_GetPrecision(long jarg1); + public final static native void FieldDefn_SetPrecision(long jarg1, int jarg2); + public final static native String FieldDefn_GetFieldTypeName(long jarg1, int jarg2); + public final static native long CreateGeometryFromWkb(char[] jarg1, long jarg3); + public final static native long CreateGeometryFromWkt(String jarg1, long jarg2); + public final static native long CreateGeometryFromGML(String jarg1); + public final static native void delete_Geometry(long jarg1); + public final static native long new_Geometry(int jarg1, String jarg2, int jarg3, String jarg4, String jarg5); + public final static native int Geometry_ExportToWkt(long jarg1, String[] jarg2); + public final static native int Geometry_ExportToWkb(long jarg1, char[][] jarg2, int jarg4); + public final static native String Geometry_ExportToGML(long jarg1); + public final static native void Geometry_AddPoint(long jarg1, double jarg2, double jarg3, double jarg4); + public final static native int Geometry_AddGeometryDirectly(long jarg1, long jarg2); + public final static native int Geometry_AddGeometry(long jarg1, long jarg2); + public final static native long Geometry_Clone(long jarg1); + public final static native int Geometry_GetGeometryType(long jarg1); + public final static native String Geometry_GetGeometryName(long jarg1); + public final static native double Geometry_GetArea(long jarg1); + public final static native int Geometry_GetPointCount(long jarg1); + public final static native double Geometry_GetX(long jarg1, int jarg2); + public final static native double Geometry_GetY(long jarg1, int jarg2); + public final static native double Geometry_GetZ(long jarg1, int jarg2); + public final static native int Geometry_GetGeometryCount(long jarg1); + public final static native void Geometry_SetPoint(long jarg1, int jarg2, double jarg3, double jarg4, double jarg5); + public final static native long Geometry_GetGeometryRef(long jarg1, int jarg2); + public final static native long Geometry_GetBoundary(long jarg1); + public final static native long Geometry_ConvexHull(long jarg1); + public final static native long Geometry_Buffer(long jarg1, double jarg2, int jarg3); + public final static native long Geometry_Intersection(long jarg1, long jarg2); + public final static native long Geometry_Union(long jarg1, long jarg2); + public final static native long Geometry_Difference(long jarg1, long jarg2); + public final static native long Geometry_SymmetricDifference(long jarg1, long jarg2); + public final static native double Geometry_Distance(long jarg1, long jarg2); + public final static native void Geometry_Empty(long jarg1); + public final static native boolean Geometry_Intersect(long jarg1, long jarg2); + public final static native boolean Geometry_Equal(long jarg1, long jarg2); + public final static native boolean Geometry_Disjoint(long jarg1, long jarg2); + public final static native boolean Geometry_Touches(long jarg1, long jarg2); + public final static native boolean Geometry_Crosses(long jarg1, long jarg2); + public final static native boolean Geometry_Within(long jarg1, long jarg2); + public final static native boolean Geometry_Contains(long jarg1, long jarg2); + public final static native boolean Geometry_Overlaps(long jarg1, long jarg2); + public final static native int Geometry_TransformTo(long jarg1, long jarg2); + public final static native int Geometry_Transform(long jarg1, long jarg2); + public final static native long Geometry_GetSpatialReference(long jarg1); + public final static native void Geometry_AssignSpatialReference(long jarg1, long jarg2); + public final static native void Geometry_CloseRings(long jarg1); + public final static native void Geometry_FlattenTo2D(long jarg1); + public final static native void Geometry_GetEnvelope(long jarg1, double[] jarg2); + public final static native long Geometry_Centroid(long jarg1); + public final static native int Geometry_WkbSize(long jarg1); + public final static native int Geometry_GetCoordinateDimension(long jarg1); + public final static native int Geometry_GetDimension(long jarg1); + public final static native int GetDriverCount(); + public final static native int GetOpenDSCount(); + public final static native int SetGenerate_DB2_V72_BYTE_ORDER(int jarg1); + public final static native void RegisterAll(); + public final static native long GetOpenDS(int jarg1); + public final static native long Open(String jarg1, int jarg2); + public final static native long OpenShared(String jarg1, int jarg2); + public final static native long GetDriverByName(String jarg1); + public final static native long GetDriver(int jarg1); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/CoordinateTransformation.java b/Utilities/GDAL/swig/java/org/gdal/osr/CoordinateTransformation.java new file mode 100644 index 0000000000..8e67820936 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/CoordinateTransformation.java @@ -0,0 +1,48 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +public class CoordinateTransformation { + private long swigCPtr; + protected boolean swigCMemOwn; + + public CoordinateTransformation(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + public static long getCPtr(CoordinateTransformation obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + osrJNI.delete_CoordinateTransformation(swigCPtr); + } + swigCPtr = 0; + } + + public CoordinateTransformation(SpatialReference src, SpatialReference dst) { + this(osrJNI.new_CoordinateTransformation(SpatialReference.getCPtr(src), SpatialReference.getCPtr(dst)), true); + } + + public void TransformPoint(double[] inout) { + osrJNI.CoordinateTransformation_TransformPoint__SWIG_0(swigCPtr, inout); + } + + public void TransformPoint(double[] argout, double x, double y, double z) { + osrJNI.CoordinateTransformation_TransformPoint__SWIG_1(swigCPtr, argout, x, y, z); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/SWIGTYPE_p_double.java b/Utilities/GDAL/swig/java/org/gdal/osr/SWIGTYPE_p_double.java new file mode 100644 index 0000000000..3de83de0f9 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/SWIGTYPE_p_double.java @@ -0,0 +1,26 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +public class SWIGTYPE_p_double { + private long swigCPtr; + + protected SWIGTYPE_p_double(long cPtr, boolean futureUse) { + swigCPtr = cPtr; + } + + protected SWIGTYPE_p_double() { + swigCPtr = 0; + } + + protected static long getCPtr(SWIGTYPE_p_double obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } +} + diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/SpatialReference.java b/Utilities/GDAL/swig/java/org/gdal/osr/SpatialReference.java new file mode 100644 index 0000000000..5df76dd330 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/SpatialReference.java @@ -0,0 +1,273 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +public class SpatialReference { + private long swigCPtr; + protected boolean swigCMemOwn; + + public SpatialReference(long cPtr, boolean cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = cPtr; + } + + public static long getCPtr(SpatialReference obj) { + return (obj == null) ? 0 : obj.swigCPtr; + } + + protected void finalize() { + delete(); + } + + public void delete() { + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + osrJNI.delete_SpatialReference(swigCPtr); + } + swigCPtr = 0; + } + + public SpatialReference(String wkt) { + this(osrJNI.new_SpatialReference(wkt), true); + } + + public String __str__() { + return osrJNI.SpatialReference___str__(swigCPtr); + } + + public int IsSame(SpatialReference rhs) { + return osrJNI.SpatialReference_IsSame(swigCPtr, SpatialReference.getCPtr(rhs)); + } + + public int IsSameGeogCS(SpatialReference rhs) { + return osrJNI.SpatialReference_IsSameGeogCS(swigCPtr, SpatialReference.getCPtr(rhs)); + } + + public int IsGeographic() { + return osrJNI.SpatialReference_IsGeographic(swigCPtr); + } + + public int IsProjected() { + return osrJNI.SpatialReference_IsProjected(swigCPtr); + } + + public String GetAttrValue(String name, int child) { + return osrJNI.SpatialReference_GetAttrValue(swigCPtr, name, child); + } + + public int SetAttrValue(String name, String value) { + return osrJNI.SpatialReference_SetAttrValue(swigCPtr, name, value); + } + + public int SetAngularUnits(String name, double to_radians) { + return osrJNI.SpatialReference_SetAngularUnits(swigCPtr, name, to_radians); + } + + public double GetAngularUnits() { + return osrJNI.SpatialReference_GetAngularUnits(swigCPtr); + } + + public int SetLinearUnits(String name, double to_meters) { + return osrJNI.SpatialReference_SetLinearUnits(swigCPtr, name, to_meters); + } + + public double GetLinearUnits() { + return osrJNI.SpatialReference_GetLinearUnits(swigCPtr); + } + + public String GetLinearUnitsName() { + return osrJNI.SpatialReference_GetLinearUnitsName(swigCPtr); + } + + public String GetAuthorityCode(String target_key) { + return osrJNI.SpatialReference_GetAuthorityCode(swigCPtr, target_key); + } + + public String GetAuthorityName(String target_key) { + return osrJNI.SpatialReference_GetAuthorityName(swigCPtr, target_key); + } + + public int SetUTM(int zone, int north) { + return osrJNI.SpatialReference_SetUTM(swigCPtr, zone, north); + } + + public int SetStatePlane(int zone, int is_nad83, String unitsname, double units) { + return osrJNI.SpatialReference_SetStatePlane(swigCPtr, zone, is_nad83, unitsname, units); + } + + public int AutoIdentifyEPSG() { + return osrJNI.SpatialReference_AutoIdentifyEPSG(swigCPtr); + } + + public int SetProjection(String arg) { + return osrJNI.SpatialReference_SetProjection(swigCPtr, arg); + } + + public int SetProjParm(String name, double val) { + return osrJNI.SpatialReference_SetProjParm(swigCPtr, name, val); + } + + public double GetProjParm(String name, double default_val) { + return osrJNI.SpatialReference_GetProjParm(swigCPtr, name, default_val); + } + + public int SetNormProjParm(String name, double val) { + return osrJNI.SpatialReference_SetNormProjParm(swigCPtr, name, val); + } + + public double GetNormProjParm(String name, double default_val) { + return osrJNI.SpatialReference_GetNormProjParm(swigCPtr, name, default_val); + } + + public int SetACEA(double stdp1, double stdp2, double clat, double clong, double fe, double fn) { + return osrJNI.SpatialReference_SetACEA(swigCPtr, stdp1, stdp2, clat, clong, fe, fn); + } + + public int SetAE(double clat, double clon, double fe, double fn) { + return osrJNI.SpatialReference_SetAE(swigCPtr, clat, clon, fe, fn); + } + + public int SetCS(double clat, double clong, double fe, double fn) { + return osrJNI.SpatialReference_SetCS(swigCPtr, clat, clong, fe, fn); + } + + public int SetBonne(double clat, double clong, double fe, double fn) { + return osrJNI.SpatialReference_SetBonne(swigCPtr, clat, clong, fe, fn); + } + + public int SetEC(double stdp1, double stdp2, double clat, double clong, double fe, double fn) { + return osrJNI.SpatialReference_SetEC(swigCPtr, stdp1, stdp2, clat, clong, fe, fn); + } + + public int SetEckertIV(double cm, double fe, double fn) { + return osrJNI.SpatialReference_SetEckertIV(swigCPtr, cm, fe, fn); + } + + public int SetEckertVI(double cm, double fe, double fn) { + return osrJNI.SpatialReference_SetEckertVI(swigCPtr, cm, fe, fn); + } + + public int SetEquirectangular(double clat, double clong, double fe, double fn) { + return osrJNI.SpatialReference_SetEquirectangular(swigCPtr, clat, clong, fe, fn); + } + + public int SetGS(double cm, double fe, double fn) { + return osrJNI.SpatialReference_SetGS(swigCPtr, cm, fe, fn); + } + + public int SetWellKnownGeogCS(String name) { + return osrJNI.SpatialReference_SetWellKnownGeogCS(swigCPtr, name); + } + + public int SetFromUserInput(String name) { + return osrJNI.SpatialReference_SetFromUserInput(swigCPtr, name); + } + + public int CopyGeogCSFrom(SpatialReference rhs) { + return osrJNI.SpatialReference_CopyGeogCSFrom(swigCPtr, SpatialReference.getCPtr(rhs)); + } + + public int SetTOWGS84(double p1, double p2, double p3, double p4, double p5, double p6, double p7) { + return osrJNI.SpatialReference_SetTOWGS84(swigCPtr, p1, p2, p3, p4, p5, p6, p7); + } + + public int GetTOWGS84(double[] argout) { + return osrJNI.SpatialReference_GetTOWGS84(swigCPtr, argout); + } + + public int SetGeogCS(String pszGeogName, String pszDatumName, String pszEllipsoidName, double dfSemiMajor, double dfInvFlattening, String pszPMName, double dfPMOffset, String pszUnits, double dfConvertToRadians) { + return osrJNI.SpatialReference_SetGeogCS(swigCPtr, pszGeogName, pszDatumName, pszEllipsoidName, dfSemiMajor, dfInvFlattening, pszPMName, dfPMOffset, pszUnits, dfConvertToRadians); + } + + public int SetProjCS(String name) { + return osrJNI.SpatialReference_SetProjCS(swigCPtr, name); + } + + public int ImportFromWkt(String ppszInput) { + return osrJNI.SpatialReference_ImportFromWkt(swigCPtr, ppszInput); + } + + public int ImportFromProj4(String ppszInput) { + return osrJNI.SpatialReference_ImportFromProj4(swigCPtr, ppszInput); + } + + public int ImportFromESRI(String ppszInput) { + return osrJNI.SpatialReference_ImportFromESRI(swigCPtr, ppszInput); + } + + public int ImportFromEPSG(int arg) { + return osrJNI.SpatialReference_ImportFromEPSG(swigCPtr, arg); + } + + public int ImportFromPCI(String proj, String units, double[] argin) { + return osrJNI.SpatialReference_ImportFromPCI(swigCPtr, proj, units, argin); + } + + public int ImportFromUSGS(int proj_code, int zone, double[] argin, int datum_code) { + return osrJNI.SpatialReference_ImportFromUSGS(swigCPtr, proj_code, zone, argin, datum_code); + } + + public int ImportFromXML(String xmlString) { + return osrJNI.SpatialReference_ImportFromXML(swigCPtr, xmlString); + } + + public int ExportToWkt(String[] argout) { + return osrJNI.SpatialReference_ExportToWkt(swigCPtr, argout); + } + + public int ExportToPrettyWkt(String[] argout, int simplify) { + return osrJNI.SpatialReference_ExportToPrettyWkt(swigCPtr, argout, simplify); + } + + public int ExportToProj4(String[] argout) { + return osrJNI.SpatialReference_ExportToProj4(swigCPtr, argout); + } + + public int ExportToPCI(String[] proj, String[] units, double[] parms) { + return osrJNI.SpatialReference_ExportToPCI(swigCPtr, proj, units, parms); + } + + public int ExportToUSGS(int[] code, int[] zone, double[] parms, int[] datum) { + return osrJNI.SpatialReference_ExportToUSGS(swigCPtr, code, zone, parms, datum); + } + + public int ExportToXML(String[] argout, String dialect) { + return osrJNI.SpatialReference_ExportToXML(swigCPtr, argout, dialect); + } + + public SpatialReference CloneGeogCS() { + long cPtr = osrJNI.SpatialReference_CloneGeogCS(swigCPtr); + return (cPtr == 0) ? null : new SpatialReference(cPtr, true); + } + + public int Validate() { + return osrJNI.SpatialReference_Validate(swigCPtr); + } + + public int StripCTParms() { + return osrJNI.SpatialReference_StripCTParms(swigCPtr); + } + + public int FixupOrdering() { + return osrJNI.SpatialReference_FixupOrdering(swigCPtr); + } + + public int Fixup() { + return osrJNI.SpatialReference_Fixup(swigCPtr); + } + + public int MorphToESRI() { + return osrJNI.SpatialReference_MorphToESRI(swigCPtr); + } + + public int MorphFromESRI() { + return osrJNI.SpatialReference_MorphFromESRI(swigCPtr); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/osr.java b/Utilities/GDAL/swig/java/org/gdal/osr/osr.java new file mode 100644 index 0000000000..5dbe383044 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/osr.java @@ -0,0 +1,28 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +public class osr implements osrConstants { + public static int GetWellKnownGeogCSAsWKT(String name, String[] argout) { + return osrJNI.GetWellKnownGeogCSAsWKT(name, argout); + } + + public static String[] GetProjectionMethods() { + return osrJNI.GetProjectionMethods(); + } + + public static String[] GetProjectionMethodParameterList(String method, String[] username) { + return osrJNI.GetProjectionMethodParameterList(method, username); + } + + public static void GetProjectionMethodParamInfo(String method, String param, String[] usrname, String[] type, SWIGTYPE_p_double defaultval) { + osrJNI.GetProjectionMethodParamInfo(method, param, usrname, type, SWIGTYPE_p_double.getCPtr(defaultval)); + } + +} diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/osrConstants.java b/Utilities/GDAL/swig/java/org/gdal/osr/osrConstants.java new file mode 100644 index 0000000000..6249a1e7aa --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/osrConstants.java @@ -0,0 +1,95 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +public interface osrConstants { + public final static String SRS_PT_ALBERS_CONIC_EQUAL_AREA = osrJNI.SRS_PT_ALBERS_CONIC_EQUAL_AREA_get(); + public final static String SRS_PT_AZIMUTHAL_EQUIDISTANT = osrJNI.SRS_PT_AZIMUTHAL_EQUIDISTANT_get(); + public final static String SRS_PT_CASSINI_SOLDNER = osrJNI.SRS_PT_CASSINI_SOLDNER_get(); + public final static String SRS_PT_CYLINDRICAL_EQUAL_AREA = osrJNI.SRS_PT_CYLINDRICAL_EQUAL_AREA_get(); + public final static String SRS_PT_ECKERT_IV = osrJNI.SRS_PT_ECKERT_IV_get(); + public final static String SRS_PT_ECKERT_VI = osrJNI.SRS_PT_ECKERT_VI_get(); + public final static String SRS_PT_EQUIDISTANT_CONIC = osrJNI.SRS_PT_EQUIDISTANT_CONIC_get(); + public final static String SRS_PT_EQUIRECTANGULAR = osrJNI.SRS_PT_EQUIRECTANGULAR_get(); + public final static String SRS_PT_GALL_STEREOGRAPHIC = osrJNI.SRS_PT_GALL_STEREOGRAPHIC_get(); + public final static String SRS_PT_GNOMONIC = osrJNI.SRS_PT_GNOMONIC_get(); + public final static String SRS_PT_GOODE_HOMOLOSINE = osrJNI.SRS_PT_GOODE_HOMOLOSINE_get(); + public final static String SRS_PT_HOTINE_OBLIQUE_MERCATOR = osrJNI.SRS_PT_HOTINE_OBLIQUE_MERCATOR_get(); + public final static String SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN = osrJNI.SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN_get(); + public final static String SRS_PT_LABORDE_OBLIQUE_MERCATOR = osrJNI.SRS_PT_LABORDE_OBLIQUE_MERCATOR_get(); + public final static String SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP = osrJNI.SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP_get(); + public final static String SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP = osrJNI.SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_get(); + public final static String SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM = osrJNI.SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM_get(); + public final static String SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA = osrJNI.SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA_get(); + public final static String SRS_PT_MERCATOR_1SP = osrJNI.SRS_PT_MERCATOR_1SP_get(); + public final static String SRS_PT_MERCATOR_2SP = osrJNI.SRS_PT_MERCATOR_2SP_get(); + public final static String SRS_PT_MILLER_CYLINDRICAL = osrJNI.SRS_PT_MILLER_CYLINDRICAL_get(); + public final static String SRS_PT_MOLLWEIDE = osrJNI.SRS_PT_MOLLWEIDE_get(); + public final static String SRS_PT_NEW_ZEALAND_MAP_GRID = osrJNI.SRS_PT_NEW_ZEALAND_MAP_GRID_get(); + public final static String SRS_PT_OBLIQUE_STEREOGRAPHIC = osrJNI.SRS_PT_OBLIQUE_STEREOGRAPHIC_get(); + public final static String SRS_PT_ORTHOGRAPHIC = osrJNI.SRS_PT_ORTHOGRAPHIC_get(); + public final static String SRS_PT_POLAR_STEREOGRAPHIC = osrJNI.SRS_PT_POLAR_STEREOGRAPHIC_get(); + public final static String SRS_PT_POLYCONIC = osrJNI.SRS_PT_POLYCONIC_get(); + public final static String SRS_PT_ROBINSON = osrJNI.SRS_PT_ROBINSON_get(); + public final static String SRS_PT_SINUSOIDAL = osrJNI.SRS_PT_SINUSOIDAL_get(); + public final static String SRS_PT_STEREOGRAPHIC = osrJNI.SRS_PT_STEREOGRAPHIC_get(); + public final static String SRS_PT_SWISS_OBLIQUE_CYLINDRICAL = osrJNI.SRS_PT_SWISS_OBLIQUE_CYLINDRICAL_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR_MI_22 = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_MI_22_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR_MI_23 = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_MI_23_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR_MI_24 = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_MI_24_get(); + public final static String SRS_PT_TRANSVERSE_MERCATOR_MI_25 = osrJNI.SRS_PT_TRANSVERSE_MERCATOR_MI_25_get(); + public final static String SRS_PT_TUNISIA_MINING_GRID = osrJNI.SRS_PT_TUNISIA_MINING_GRID_get(); + public final static String SRS_PT_VANDERGRINTEN = osrJNI.SRS_PT_VANDERGRINTEN_get(); + public final static String SRS_PT_KROVAK = osrJNI.SRS_PT_KROVAK_get(); + public final static String SRS_PP_CENTRAL_MERIDIAN = osrJNI.SRS_PP_CENTRAL_MERIDIAN_get(); + public final static String SRS_PP_SCALE_FACTOR = osrJNI.SRS_PP_SCALE_FACTOR_get(); + public final static String SRS_PP_STANDARD_PARALLEL_1 = osrJNI.SRS_PP_STANDARD_PARALLEL_1_get(); + public final static String SRS_PP_STANDARD_PARALLEL_2 = osrJNI.SRS_PP_STANDARD_PARALLEL_2_get(); + public final static String SRS_PP_PSEUDO_STD_PARALLEL_1 = osrJNI.SRS_PP_PSEUDO_STD_PARALLEL_1_get(); + public final static String SRS_PP_LONGITUDE_OF_CENTER = osrJNI.SRS_PP_LONGITUDE_OF_CENTER_get(); + public final static String SRS_PP_LATITUDE_OF_CENTER = osrJNI.SRS_PP_LATITUDE_OF_CENTER_get(); + public final static String SRS_PP_LONGITUDE_OF_ORIGIN = osrJNI.SRS_PP_LONGITUDE_OF_ORIGIN_get(); + public final static String SRS_PP_LATITUDE_OF_ORIGIN = osrJNI.SRS_PP_LATITUDE_OF_ORIGIN_get(); + public final static String SRS_PP_FALSE_EASTING = osrJNI.SRS_PP_FALSE_EASTING_get(); + public final static String SRS_PP_FALSE_NORTHING = osrJNI.SRS_PP_FALSE_NORTHING_get(); + public final static String SRS_PP_AZIMUTH = osrJNI.SRS_PP_AZIMUTH_get(); + public final static String SRS_PP_LONGITUDE_OF_POINT_1 = osrJNI.SRS_PP_LONGITUDE_OF_POINT_1_get(); + public final static String SRS_PP_LATITUDE_OF_POINT_1 = osrJNI.SRS_PP_LATITUDE_OF_POINT_1_get(); + public final static String SRS_PP_LONGITUDE_OF_POINT_2 = osrJNI.SRS_PP_LONGITUDE_OF_POINT_2_get(); + public final static String SRS_PP_LATITUDE_OF_POINT_2 = osrJNI.SRS_PP_LATITUDE_OF_POINT_2_get(); + public final static String SRS_PP_LONGITUDE_OF_POINT_3 = osrJNI.SRS_PP_LONGITUDE_OF_POINT_3_get(); + public final static String SRS_PP_LATITUDE_OF_POINT_3 = osrJNI.SRS_PP_LATITUDE_OF_POINT_3_get(); + public final static String SRS_PP_RECTIFIED_GRID_ANGLE = osrJNI.SRS_PP_RECTIFIED_GRID_ANGLE_get(); + public final static String SRS_PP_LANDSAT_NUMBER = osrJNI.SRS_PP_LANDSAT_NUMBER_get(); + public final static String SRS_PP_PATH_NUMBER = osrJNI.SRS_PP_PATH_NUMBER_get(); + public final static String SRS_PP_PERSPECTIVE_POINT_HEIGHT = osrJNI.SRS_PP_PERSPECTIVE_POINT_HEIGHT_get(); + public final static String SRS_PP_FIPSZONE = osrJNI.SRS_PP_FIPSZONE_get(); + public final static String SRS_PP_ZONE = osrJNI.SRS_PP_ZONE_get(); + public final static String SRS_UL_METER = osrJNI.SRS_UL_METER_get(); + public final static String SRS_UL_FOOT = osrJNI.SRS_UL_FOOT_get(); + public final static String SRS_UL_FOOT_CONV = osrJNI.SRS_UL_FOOT_CONV_get(); + public final static String SRS_UL_US_FOOT = osrJNI.SRS_UL_US_FOOT_get(); + public final static String SRS_UL_US_FOOT_CONV = osrJNI.SRS_UL_US_FOOT_CONV_get(); + public final static String SRS_UL_NAUTICAL_MILE = osrJNI.SRS_UL_NAUTICAL_MILE_get(); + public final static String SRS_UL_NAUTICAL_MILE_CONV = osrJNI.SRS_UL_NAUTICAL_MILE_CONV_get(); + public final static String SRS_UL_LINK = osrJNI.SRS_UL_LINK_get(); + public final static String SRS_UL_LINK_CONV = osrJNI.SRS_UL_LINK_CONV_get(); + public final static String SRS_UL_CHAIN = osrJNI.SRS_UL_CHAIN_get(); + public final static String SRS_UL_CHAIN_CONV = osrJNI.SRS_UL_CHAIN_CONV_get(); + public final static String SRS_UL_ROD = osrJNI.SRS_UL_ROD_get(); + public final static String SRS_UL_ROD_CONV = osrJNI.SRS_UL_ROD_CONV_get(); + public final static String SRS_DN_NAD27 = osrJNI.SRS_DN_NAD27_get(); + public final static String SRS_DN_NAD83 = osrJNI.SRS_DN_NAD83_get(); + public final static String SRS_DN_WGS72 = osrJNI.SRS_DN_WGS72_get(); + public final static String SRS_DN_WGS84 = osrJNI.SRS_DN_WGS84_get(); + public final static double SRS_WGS84_SEMIMAJOR = osrJNI.SRS_WGS84_SEMIMAJOR_get(); + public final static double SRS_WGS84_INVFLATTENING = osrJNI.SRS_WGS84_INVFLATTENING_get(); +} diff --git a/Utilities/GDAL/swig/java/org/gdal/osr/osrJNI.java b/Utilities/GDAL/swig/java/org/gdal/osr/osrJNI.java new file mode 100644 index 0000000000..49b0519853 --- /dev/null +++ b/Utilities/GDAL/swig/java/org/gdal/osr/osrJNI.java @@ -0,0 +1,181 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.gdal.osr; + +class osrJNI { + public final static native String SRS_PT_ALBERS_CONIC_EQUAL_AREA_get(); + public final static native String SRS_PT_AZIMUTHAL_EQUIDISTANT_get(); + public final static native String SRS_PT_CASSINI_SOLDNER_get(); + public final static native String SRS_PT_CYLINDRICAL_EQUAL_AREA_get(); + public final static native String SRS_PT_ECKERT_IV_get(); + public final static native String SRS_PT_ECKERT_VI_get(); + public final static native String SRS_PT_EQUIDISTANT_CONIC_get(); + public final static native String SRS_PT_EQUIRECTANGULAR_get(); + public final static native String SRS_PT_GALL_STEREOGRAPHIC_get(); + public final static native String SRS_PT_GNOMONIC_get(); + public final static native String SRS_PT_GOODE_HOMOLOSINE_get(); + public final static native String SRS_PT_HOTINE_OBLIQUE_MERCATOR_get(); + public final static native String SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN_get(); + public final static native String SRS_PT_LABORDE_OBLIQUE_MERCATOR_get(); + public final static native String SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP_get(); + public final static native String SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_get(); + public final static native String SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM_get(); + public final static native String SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA_get(); + public final static native String SRS_PT_MERCATOR_1SP_get(); + public final static native String SRS_PT_MERCATOR_2SP_get(); + public final static native String SRS_PT_MILLER_CYLINDRICAL_get(); + public final static native String SRS_PT_MOLLWEIDE_get(); + public final static native String SRS_PT_NEW_ZEALAND_MAP_GRID_get(); + public final static native String SRS_PT_OBLIQUE_STEREOGRAPHIC_get(); + public final static native String SRS_PT_ORTHOGRAPHIC_get(); + public final static native String SRS_PT_POLAR_STEREOGRAPHIC_get(); + public final static native String SRS_PT_POLYCONIC_get(); + public final static native String SRS_PT_ROBINSON_get(); + public final static native String SRS_PT_SINUSOIDAL_get(); + public final static native String SRS_PT_STEREOGRAPHIC_get(); + public final static native String SRS_PT_SWISS_OBLIQUE_CYLINDRICAL_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_MI_22_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_MI_23_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_MI_24_get(); + public final static native String SRS_PT_TRANSVERSE_MERCATOR_MI_25_get(); + public final static native String SRS_PT_TUNISIA_MINING_GRID_get(); + public final static native String SRS_PT_VANDERGRINTEN_get(); + public final static native String SRS_PT_KROVAK_get(); + public final static native String SRS_PP_CENTRAL_MERIDIAN_get(); + public final static native String SRS_PP_SCALE_FACTOR_get(); + public final static native String SRS_PP_STANDARD_PARALLEL_1_get(); + public final static native String SRS_PP_STANDARD_PARALLEL_2_get(); + public final static native String SRS_PP_PSEUDO_STD_PARALLEL_1_get(); + public final static native String SRS_PP_LONGITUDE_OF_CENTER_get(); + public final static native String SRS_PP_LATITUDE_OF_CENTER_get(); + public final static native String SRS_PP_LONGITUDE_OF_ORIGIN_get(); + public final static native String SRS_PP_LATITUDE_OF_ORIGIN_get(); + public final static native String SRS_PP_FALSE_EASTING_get(); + public final static native String SRS_PP_FALSE_NORTHING_get(); + public final static native String SRS_PP_AZIMUTH_get(); + public final static native String SRS_PP_LONGITUDE_OF_POINT_1_get(); + public final static native String SRS_PP_LATITUDE_OF_POINT_1_get(); + public final static native String SRS_PP_LONGITUDE_OF_POINT_2_get(); + public final static native String SRS_PP_LATITUDE_OF_POINT_2_get(); + public final static native String SRS_PP_LONGITUDE_OF_POINT_3_get(); + public final static native String SRS_PP_LATITUDE_OF_POINT_3_get(); + public final static native String SRS_PP_RECTIFIED_GRID_ANGLE_get(); + public final static native String SRS_PP_LANDSAT_NUMBER_get(); + public final static native String SRS_PP_PATH_NUMBER_get(); + public final static native String SRS_PP_PERSPECTIVE_POINT_HEIGHT_get(); + public final static native String SRS_PP_FIPSZONE_get(); + public final static native String SRS_PP_ZONE_get(); + public final static native String SRS_UL_METER_get(); + public final static native String SRS_UL_FOOT_get(); + public final static native String SRS_UL_FOOT_CONV_get(); + public final static native String SRS_UL_US_FOOT_get(); + public final static native String SRS_UL_US_FOOT_CONV_get(); + public final static native String SRS_UL_NAUTICAL_MILE_get(); + public final static native String SRS_UL_NAUTICAL_MILE_CONV_get(); + public final static native String SRS_UL_LINK_get(); + public final static native String SRS_UL_LINK_CONV_get(); + public final static native String SRS_UL_CHAIN_get(); + public final static native String SRS_UL_CHAIN_CONV_get(); + public final static native String SRS_UL_ROD_get(); + public final static native String SRS_UL_ROD_CONV_get(); + public final static native String SRS_DN_NAD27_get(); + public final static native String SRS_DN_NAD83_get(); + public final static native String SRS_DN_WGS72_get(); + public final static native String SRS_DN_WGS84_get(); + public final static native double SRS_WGS84_SEMIMAJOR_get(); + public final static native double SRS_WGS84_INVFLATTENING_get(); + + private static boolean available = false; + + static { + try { + System.loadLibrary("osrjni"); + available = true; + } catch (UnsatisfiedLinkError e) { + available = false; + System.err.println("Native library load failed."); + System.err.println(e); + } + } + + public static boolean isAvailable() { + return available; + } + + public final static native int GetWellKnownGeogCSAsWKT(String jarg1, String[] jarg2); + public final static native String[] GetProjectionMethods(); + public final static native String[] GetProjectionMethodParameterList(String jarg1, String[] jarg2); + public final static native void GetProjectionMethodParamInfo(String jarg1, String jarg2, String[] jarg3, String[] jarg4, long jarg5); + public final static native long new_SpatialReference(String jarg1); + public final static native void delete_SpatialReference(long jarg1); + public final static native String SpatialReference___str__(long jarg1); + public final static native int SpatialReference_IsSame(long jarg1, long jarg2); + public final static native int SpatialReference_IsSameGeogCS(long jarg1, long jarg2); + public final static native int SpatialReference_IsGeographic(long jarg1); + public final static native int SpatialReference_IsProjected(long jarg1); + public final static native String SpatialReference_GetAttrValue(long jarg1, String jarg2, int jarg3); + public final static native int SpatialReference_SetAttrValue(long jarg1, String jarg2, String jarg3); + public final static native int SpatialReference_SetAngularUnits(long jarg1, String jarg2, double jarg3); + public final static native double SpatialReference_GetAngularUnits(long jarg1); + public final static native int SpatialReference_SetLinearUnits(long jarg1, String jarg2, double jarg3); + public final static native double SpatialReference_GetLinearUnits(long jarg1); + public final static native String SpatialReference_GetLinearUnitsName(long jarg1); + public final static native String SpatialReference_GetAuthorityCode(long jarg1, String jarg2); + public final static native String SpatialReference_GetAuthorityName(long jarg1, String jarg2); + public final static native int SpatialReference_SetUTM(long jarg1, int jarg2, int jarg3); + public final static native int SpatialReference_SetStatePlane(long jarg1, int jarg2, int jarg3, String jarg4, double jarg5); + public final static native int SpatialReference_AutoIdentifyEPSG(long jarg1); + public final static native int SpatialReference_SetProjection(long jarg1, String jarg2); + public final static native int SpatialReference_SetProjParm(long jarg1, String jarg2, double jarg3); + public final static native double SpatialReference_GetProjParm(long jarg1, String jarg2, double jarg3); + public final static native int SpatialReference_SetNormProjParm(long jarg1, String jarg2, double jarg3); + public final static native double SpatialReference_GetNormProjParm(long jarg1, String jarg2, double jarg3); + public final static native int SpatialReference_SetACEA(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5, double jarg6, double jarg7); + public final static native int SpatialReference_SetAE(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5); + public final static native int SpatialReference_SetCS(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5); + public final static native int SpatialReference_SetBonne(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5); + public final static native int SpatialReference_SetEC(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5, double jarg6, double jarg7); + public final static native int SpatialReference_SetEckertIV(long jarg1, double jarg2, double jarg3, double jarg4); + public final static native int SpatialReference_SetEckertVI(long jarg1, double jarg2, double jarg3, double jarg4); + public final static native int SpatialReference_SetEquirectangular(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5); + public final static native int SpatialReference_SetGS(long jarg1, double jarg2, double jarg3, double jarg4); + public final static native int SpatialReference_SetWellKnownGeogCS(long jarg1, String jarg2); + public final static native int SpatialReference_SetFromUserInput(long jarg1, String jarg2); + public final static native int SpatialReference_CopyGeogCSFrom(long jarg1, long jarg2); + public final static native int SpatialReference_SetTOWGS84(long jarg1, double jarg2, double jarg3, double jarg4, double jarg5, double jarg6, double jarg7, double jarg8); + public final static native int SpatialReference_GetTOWGS84(long jarg1, double[] jarg2); + public final static native int SpatialReference_SetGeogCS(long jarg1, String jarg2, String jarg3, String jarg4, double jarg5, double jarg6, String jarg7, double jarg8, String jarg9, double jarg10); + public final static native int SpatialReference_SetProjCS(long jarg1, String jarg2); + public final static native int SpatialReference_ImportFromWkt(long jarg1, String jarg2); + public final static native int SpatialReference_ImportFromProj4(long jarg1, String jarg2); + public final static native int SpatialReference_ImportFromESRI(long jarg1, String jarg2); + public final static native int SpatialReference_ImportFromEPSG(long jarg1, int jarg2); + public final static native int SpatialReference_ImportFromPCI(long jarg1, String jarg2, String jarg3, double[] jarg4); + public final static native int SpatialReference_ImportFromUSGS(long jarg1, int jarg2, int jarg3, double[] jarg4, int jarg5); + public final static native int SpatialReference_ImportFromXML(long jarg1, String jarg2); + public final static native int SpatialReference_ExportToWkt(long jarg1, String[] jarg2); + public final static native int SpatialReference_ExportToPrettyWkt(long jarg1, String[] jarg2, int jarg3); + public final static native int SpatialReference_ExportToProj4(long jarg1, String[] jarg2); + public final static native int SpatialReference_ExportToPCI(long jarg1, String[] jarg2, String[] jarg3, double[] jarg4); + public final static native int SpatialReference_ExportToUSGS(long jarg1, int[] jarg2, int[] jarg3, double[] jarg4, int[] jarg5); + public final static native int SpatialReference_ExportToXML(long jarg1, String[] jarg2, String jarg3); + public final static native long SpatialReference_CloneGeogCS(long jarg1); + public final static native int SpatialReference_Validate(long jarg1); + public final static native int SpatialReference_StripCTParms(long jarg1); + public final static native int SpatialReference_FixupOrdering(long jarg1); + public final static native int SpatialReference_Fixup(long jarg1); + public final static native int SpatialReference_MorphToESRI(long jarg1); + public final static native int SpatialReference_MorphFromESRI(long jarg1); + public final static native long new_CoordinateTransformation(long jarg1, long jarg2); + public final static native void delete_CoordinateTransformation(long jarg1); + public final static native void CoordinateTransformation_TransformPoint__SWIG_0(long jarg1, double[] jarg2); + public final static native void CoordinateTransformation_TransformPoint__SWIG_1(long jarg1, double[] jarg2, double jarg3, double jarg4, double jarg5); +} diff --git a/Utilities/GDAL/swig/java/osr/makefile.vc b/Utilities/GDAL/swig/java/osr/makefile.vc new file mode 100644 index 0000000000..ebf610b6b4 --- /dev/null +++ b/Utilities/GDAL/swig/java/osr/makefile.vc @@ -0,0 +1,17 @@ +OBJ = osr_wrap.obj + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt +!INCLUDE ..\java.opt + +default: $(OBJ) + copy *.obj .. + +clean: + -del *.obj + -del *.cs + -del *.cpp + +.cpp.obj: + $(CC) $(CFLAGS) $(JAVA_INCLUDE) /c $*.cpp diff --git a/Utilities/GDAL/swig/java/osr_wrap.cpp b/Utilities/GDAL/swig/java/osr_wrap.cpp new file mode 100644 index 0000000000..cd9bb2aa60 --- /dev/null +++ b/Utilities/GDAL/swig/java/osr_wrap.cpp @@ -0,0 +1,4756 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTELC__) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + jenv->ExceptionClear(); + excep = jenv->FindClass(except_ptr->java_exception); + if (excep) + jenv->ThrowNew(excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + + + +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) + + +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input); +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input); +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz); + + +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input); +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz); + + +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input); +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz); + + +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input); +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz); + + +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input); +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input); +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz); + + +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input); +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input); +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz); + + +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input); +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz); + + +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input); +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input); +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz); + + +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input); +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz); + + +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input); +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz); + + +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input); +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input); +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz); + + +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input); +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input); +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz); + + +#else + + +/* bool[] support */ +int SWIG_JavaArrayInBool (JNIEnv *jenv, jboolean **jarr, bool **carr, jbooleanArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetBooleanArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new bool[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = ((*jarr)[i] != 0); + return 1; +} + +void SWIG_JavaArrayArgoutBool (JNIEnv *jenv, jboolean *jarr, bool *carr, jbooleanArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jboolean)carr[i]; + jenv->ReleaseBooleanArrayElements(input, jarr, 0); +} + +jbooleanArray SWIG_JavaArrayOutBool (JNIEnv *jenv, bool *result, jsize sz) { + jboolean *arr; + int i; + jbooleanArray jresult = jenv->NewBooleanArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetBooleanArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jboolean)result[i]; + jenv->ReleaseBooleanArrayElements(jresult, arr, 0); + return jresult; +} + + +/* signed char[] support */ +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetByteArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new signed char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (signed char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jbyte)carr[i]; + jenv->ReleaseByteArrayElements(input, jarr, 0); +} + +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) { + jbyte *arr; + int i; + jbyteArray jresult = jenv->NewByteArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetByteArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jbyte)result[i]; + jenv->ReleaseByteArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned char[] support */ +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned char[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned char)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* short[] support */ +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetShortArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jshort)carr[i]; + jenv->ReleaseShortArrayElements(input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = jenv->NewShortArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetShortArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jshort)result[i]; + jenv->ReleaseShortArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned short[] support */ +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned short[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned short)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* int[] support */ +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned int[] support */ +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned int[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned int)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* long[] support */ +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetIntArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jint)carr[i]; + jenv->ReleaseIntArrayElements(input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = jenv->NewIntArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetIntArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jint)result[i]; + jenv->ReleaseIntArrayElements(jresult, arr, 0); + return jresult; +} + + +/* unsigned long[] support */ +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new unsigned long[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (unsigned long)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* jlong[] support */ +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetLongArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new jlong[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (jlong)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jlong)carr[i]; + jenv->ReleaseLongArrayElements(input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = jenv->NewLongArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetLongArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jlong)result[i]; + jenv->ReleaseLongArrayElements(jresult, arr, 0); + return jresult; +} + + +/* float[] support */ +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetFloatArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new float[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (float)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jfloat)carr[i]; + jenv->ReleaseFloatArrayElements(input, jarr, 0); +} + +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) { + jfloat *arr; + int i; + jfloatArray jresult = jenv->NewFloatArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetFloatArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jfloat)result[i]; + jenv->ReleaseFloatArrayElements(jresult, arr, 0); + return jresult; +} + + +/* double[] support */ +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = jenv->GetArrayLength(input); + *jarr = jenv->GetDoubleArrayElements(input, 0); + if (!*jarr) + return 0; + *carr = new double[sz]; + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i<sz; i++) + (*carr)[i] = (double)(*jarr)[i]; + return 1; +} + +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) { + int i; + jsize sz = jenv->GetArrayLength(input); + for (i=0; i<sz; i++) + jarr[i] = (jdouble)carr[i]; + jenv->ReleaseDoubleArrayElements(input, jarr, 0); +} + +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { + jdouble *arr; + int i; + jdoubleArray jresult = jenv->NewDoubleArray(sz); + if (!jresult) + return NULL; + arr = jenv->GetDoubleArrayElements(jresult, 0); + if (!arr) + return NULL; + for (i=0; i<sz; i++) + arr[i] = (jdouble)result[i]; + jenv->ReleaseDoubleArrayElements(jresult, arr, 0); + return jresult; +} + + +#endif + + +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error %d: None"; + case 1: + return "OGR Error %d: Not enough data"; + case 2: + return "OGR Error %d: Unsupported geometry type"; + case 3: + return "OGR Error %d: Unsupported operation"; + case 4: + return "OGR Error %d: Corrupt data"; + case 5: + return "OGR Error %d: General Error"; + case 6: + return "OGR Error %d: Unsupported SRS"; + default: + return "OGR Error %d: Unknown"; + } +} + +static OSRSpatialReferenceShadow *new_OSRSpatialReferenceShadow(char const *wkt=""){ + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } +static void delete_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *self){ + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } +static char *OSRSpatialReferenceShadow___str__(OSRSpatialReferenceShadow *self){ + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } +static int OSRSpatialReferenceShadow_IsSame(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSame( self, rhs ); + } +static int OSRSpatialReferenceShadow_IsSameGeogCS(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSameGeogCS( self, rhs ); + } +static int OSRSpatialReferenceShadow_IsGeographic(OSRSpatialReferenceShadow *self){ + return OSRIsGeographic(self); + } +static int OSRSpatialReferenceShadow_IsProjected(OSRSpatialReferenceShadow *self){ + return OSRIsProjected(self); + } +static char const *OSRSpatialReferenceShadow_GetAttrValue(OSRSpatialReferenceShadow *self,char const *name,int child=0){ + return OSRGetAttrValue( self, name, child ); + } +static OGRErr OSRSpatialReferenceShadow_SetAttrValue(OSRSpatialReferenceShadow *self,char const *name,char const *value){ + return OSRSetAttrValue( self, name, value ); + } +static OGRErr OSRSpatialReferenceShadow_SetAngularUnits(OSRSpatialReferenceShadow *self,char const *name,double to_radians){ + return OSRSetAngularUnits( self, name, to_radians ); + } +static double OSRSpatialReferenceShadow_GetAngularUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetLinearUnits(OSRSpatialReferenceShadow *self,char const *name,double to_meters){ + return OSRSetAngularUnits( self, name, to_meters ); + } +static double OSRSpatialReferenceShadow_GetLinearUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } +static char const *OSRSpatialReferenceShadow_GetLinearUnitsName(OSRSpatialReferenceShadow *self){ + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } +static char const *OSRSpatialReferenceShadow_GetAuthorityCode(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityCode( self, target_key ); + } +static char const *OSRSpatialReferenceShadow_GetAuthorityName(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityName( self, target_key ); + } +static OGRErr OSRSpatialReferenceShadow_SetUTM(OSRSpatialReferenceShadow *self,int zone,int north=1){ + return OSRSetUTM( self, zone, north ); + } +static OGRErr OSRSpatialReferenceShadow_SetStatePlane(OSRSpatialReferenceShadow *self,int zone,int is_nad83=1,char const *unitsname="",double units=0.0){ + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } +static OGRErr OSRSpatialReferenceShadow_AutoIdentifyEPSG(OSRSpatialReferenceShadow *self){ + return OSRAutoIdentifyEPSG( self ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjection(OSRSpatialReferenceShadow *self,char const *arg){ + return OSRSetProjection( self, arg ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetNormProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetACEA(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetAE(OSRSpatialReferenceShadow *self,double clat,double clon,double fe,double fn){ + return OSRSetAE( self, clat, clon, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetCS(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetCS( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetBonne(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetBonne( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEC(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertIV(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertIV( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertVI(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertVI( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEquirectangular(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetGS(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetGS( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetWellKnownGeogCS(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetWellKnownGeogCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_SetFromUserInput(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetFromUserInput( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_CopyGeogCSFrom(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRCopyGeogCSFrom( self, rhs ); + } +static OGRErr OSRSpatialReferenceShadow_SetTOWGS84(OSRSpatialReferenceShadow *self,double p1,double p2,double p3,double p4=0.0,double p5=0.0,double p6=0.0,double p7=0.0){ + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } +static OGRErr OSRSpatialReferenceShadow_GetTOWGS84(OSRSpatialReferenceShadow *self,double argout[7]){ + return OSRGetTOWGS84( self, argout, 7 ); + } +static OGRErr OSRSpatialReferenceShadow_SetGeogCS(OSRSpatialReferenceShadow *self,char const *pszGeogName,char const *pszDatumName,char const *pszEllipsoidName,double dfSemiMajor,double dfInvFlattening,char const *pszPMName="Greenwich",double dfPMOffset=0.0,char const *pszUnits="degree",double dfConvertToRadians=0.0174532925199433){ + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjCS(OSRSpatialReferenceShadow *self,char const *name="unnamed"){ + return OSRSetProjCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromWkt(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromWkt( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromProj4(OSRSpatialReferenceShadow *self,char *ppszInput){ + return OSRImportFromProj4( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromESRI(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromESRI( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromEPSG(OSRSpatialReferenceShadow *self,int arg){ + return OSRImportFromEPSG(self, arg); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromPCI(OSRSpatialReferenceShadow *self,char const *proj,char const *units="METRE",double argin[17]=0){ + return OSRImportFromPCI( self, proj, units, argin ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromUSGS(OSRSpatialReferenceShadow *self,long proj_code,long zone=0,double argin[15]=0,long datum_code=0){ + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromXML(OSRSpatialReferenceShadow *self,char const *xmlString){ + return OSRImportFromXML( self, xmlString ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToWkt(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToWkt( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPrettyWkt(OSRSpatialReferenceShadow *self,char **argout,int simplify=0){ + return OSRExportToPrettyWkt( self, argout, simplify ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToProj4(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToProj4( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPCI(OSRSpatialReferenceShadow *self,char **proj,char **units,double *parms[17]){ + return OSRExportToPCI( self, proj, units, parms ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToUSGS(OSRSpatialReferenceShadow *self,long *code,long *zone,double *parms[15],long *datum){ + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToXML(OSRSpatialReferenceShadow *self,char **argout,char const *dialect=""){ + return OSRExportToXML( self, argout, dialect ); + } +static OSRSpatialReferenceShadow *OSRSpatialReferenceShadow_CloneGeogCS(OSRSpatialReferenceShadow *self){ + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } +static OGRErr OSRSpatialReferenceShadow_Validate(OSRSpatialReferenceShadow *self){ + return OSRValidate(self); + } +static OGRErr OSRSpatialReferenceShadow_StripCTParms(OSRSpatialReferenceShadow *self){ + return OSRStripCTParms(self); + } +static OGRErr OSRSpatialReferenceShadow_FixupOrdering(OSRSpatialReferenceShadow *self){ + return OSRFixupOrdering(self); + } +static OGRErr OSRSpatialReferenceShadow_Fixup(OSRSpatialReferenceShadow *self){ + return OSRFixup(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphToESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphToESRI(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphFromESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphFromESRI(self); + } +static OSRCoordinateTransformationShadow *new_OSRCoordinateTransformationShadow(OSRSpatialReferenceShadow *src,OSRSpatialReferenceShadow *dst){ + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } +static void delete_OSRCoordinateTransformationShadow(OSRCoordinateTransformationShadow *self){ + OCTDestroyCoordinateTransformation( self ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(OSRCoordinateTransformationShadow *self,double inout[3]){ + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(OSRCoordinateTransformationShadow *self,double argout[3],double x,double y,double z=0.0){ + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1ALBERS_1CONIC_1EQUAL_1AREA_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_ALBERS_CONIC_EQUAL_AREA"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1AZIMUTHAL_1EQUIDISTANT_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_AZIMUTHAL_EQUIDISTANT"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1CASSINI_1SOLDNER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_CASSINI_SOLDNER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1CYLINDRICAL_1EQUAL_1AREA_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_CYLINDRICAL_EQUAL_AREA"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1ECKERT_1IV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_ECKERT_IV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1ECKERT_1VI_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_ECKERT_VI"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1EQUIDISTANT_1CONIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_EQUIDISTANT_CONIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1EQUIRECTANGULAR_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_EQUIRECTANGULAR"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1GALL_1STEREOGRAPHIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_GALL_STEREOGRAPHIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1GNOMONIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_GNOMONIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1GOODE_1HOMOLOSINE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_GOODE_HOMOLOSINE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1HOTINE_1OBLIQUE_1MERCATOR_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_HOTINE_OBLIQUE_MERCATOR"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1HOTINE_1OBLIQUE_1MERCATOR_1TWO_1POINT_1NATURAL_1ORIGIN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1LABORDE_1OBLIQUE_1MERCATOR_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_LABORDE_OBLIQUE_MERCATOR"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1LAMBERT_1CONFORMAL_1CONIC_11SP_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1LAMBERT_1CONFORMAL_1CONIC_12SP_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1LAMBERT_1CONFORMAL_1CONIC_12SP_1BELGIUM_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1LAMBERT_1AZIMUTHAL_1EQUAL_1AREA_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1MERCATOR_11SP_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_MERCATOR_1SP"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1MERCATOR_12SP_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_MERCATOR_2SP"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1MILLER_1CYLINDRICAL_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_MILLER_CYLINDRICAL"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1MOLLWEIDE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_MOLLWEIDE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1NEW_1ZEALAND_1MAP_1GRID_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_NEW_ZEALAND_MAP_GRID"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1OBLIQUE_1STEREOGRAPHIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_OBLIQUE_STEREOGRAPHIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1ORTHOGRAPHIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_ORTHOGRAPHIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1POLAR_1STEREOGRAPHIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_POLAR_STEREOGRAPHIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1POLYCONIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_POLYCONIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1ROBINSON_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_ROBINSON"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1SINUSOIDAL_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_SINUSOIDAL"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1STEREOGRAPHIC_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_STEREOGRAPHIC"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1SWISS_1OBLIQUE_1CYLINDRICAL_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_SWISS_OBLIQUE_CYLINDRICAL"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1SOUTH_1ORIENTED_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1MI_122_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR_MI_22"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1MI_123_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR_MI_23"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1MI_124_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR_MI_24"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TRANSVERSE_1MERCATOR_1MI_125_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TRANSVERSE_MERCATOR_MI_25"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1TUNISIA_1MINING_1GRID_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_TUNISIA_MINING_GRID"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1VANDERGRINTEN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_VANDERGRINTEN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PT_1KROVAK_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PT_KROVAK"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1CENTRAL_1MERIDIAN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_CENTRAL_MERIDIAN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1SCALE_1FACTOR_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_SCALE_FACTOR"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1STANDARD_1PARALLEL_11_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_STANDARD_PARALLEL_1"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1STANDARD_1PARALLEL_12_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_STANDARD_PARALLEL_2"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1PSEUDO_1STD_1PARALLEL_11_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_PSEUDO_STD_PARALLEL_1"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LONGITUDE_1OF_1CENTER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LONGITUDE_OF_CENTER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LATITUDE_1OF_1CENTER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LATITUDE_OF_CENTER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LONGITUDE_1OF_1ORIGIN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LONGITUDE_OF_ORIGIN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LATITUDE_1OF_1ORIGIN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LATITUDE_OF_ORIGIN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1FALSE_1EASTING_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_FALSE_EASTING"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1FALSE_1NORTHING_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_FALSE_NORTHING"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1AZIMUTH_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_AZIMUTH"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LONGITUDE_1OF_1POINT_11_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LONGITUDE_OF_POINT_1"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LATITUDE_1OF_1POINT_11_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LATITUDE_OF_POINT_1"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LONGITUDE_1OF_1POINT_12_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LONGITUDE_OF_POINT_2"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LATITUDE_1OF_1POINT_12_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LATITUDE_OF_POINT_2"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LONGITUDE_1OF_1POINT_13_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LONGITUDE_OF_POINT_3"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LATITUDE_1OF_1POINT_13_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LATITUDE_OF_POINT_3"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1RECTIFIED_1GRID_1ANGLE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_RECTIFIED_GRID_ANGLE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1LANDSAT_1NUMBER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_LANDSAT_NUMBER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1PATH_1NUMBER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_PATH_NUMBER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1PERSPECTIVE_1POINT_1HEIGHT_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_PERSPECTIVE_POINT_HEIGHT"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1FIPSZONE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_FIPSZONE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1PP_1ZONE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_PP_ZONE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1METER_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_METER"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1FOOT_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_FOOT"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1FOOT_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_FOOT_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1US_1FOOT_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_US_FOOT"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1US_1FOOT_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_US_FOOT_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1NAUTICAL_1MILE_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_NAUTICAL_MILE"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1NAUTICAL_1MILE_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_NAUTICAL_MILE_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1LINK_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_LINK"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1LINK_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_LINK_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1CHAIN_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_CHAIN"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1CHAIN_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_CHAIN_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1ROD_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_ROD"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1UL_1ROD_1CONV_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_UL_ROD_CONV"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1DN_1NAD27_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_DN_NAD27"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1DN_1NAD83_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_DN_NAD83"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1DN_1WGS72_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_DN_WGS72"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SRS_1DN_1WGS84_1get(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result; + + (void)jenv; + (void)jcls; + result = (char *) "SRS_DN_WGS84"; + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SRS_1WGS84_1SEMIMAJOR_1get(JNIEnv *jenv, jclass jcls) { + jdouble jresult = 0 ; + double result; + + (void)jenv; + (void)jcls; + result = (double) SRS_WGS84_SEMIMAJOR; + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SRS_1WGS84_1INVFLATTENING_1get(JNIEnv *jenv, jclass jcls) { + jdouble jresult = 0 ; + double result; + + (void)jenv; + (void)jcls; + result = (double) SRS_WGS84_INVFLATTENING; + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_GetWellKnownGeogCSAsWKT(JNIEnv *jenv, jclass jcls, jstring jarg1, jobjectArray jarg2) { + jint jresult = 0 ; + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jobjectArray JNICALL Java_org_gdal_osr_osrJNI_GetProjectionMethods(JNIEnv *jenv, jclass jcls) { + jobjectArray jresult = 0 ; + char **result; + + (void)jenv; + (void)jcls; + result = (char **)OPTGetProjectionMethods(); + + { + /* %typemap(out) char ** */ + int i; + int len=0; + jstring temp_string; + const jclass clazz = jenv->FindClass("java/lang/String"); + + while (result[len]) len++; + jresult = jenv->NewObjectArray(len, clazz, NULL); + /* exception checking omitted */ + + for (i=0; i<len; i++) { + temp_string = jenv->NewStringUTF(*result++); + jenv->SetObjectArrayElement(jresult, i, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + return jresult; +} + + +JNIEXPORT jobjectArray JNICALL Java_org_gdal_osr_osrJNI_GetProjectionMethodParameterList(JNIEnv *jenv, jclass jcls, jstring jarg1, jobjectArray jarg2) { + jobjectArray jresult = 0 ; + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + char **result; + jint size2 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + { + /* %typemap(in) char ** (jint size2) */ + int i = 0; + size2 = jenv->GetArrayLength(jarg2); + arg2 = (char **) malloc((size2+1)*sizeof(char *)); + /* make a copy of each string */ + for (i = 0; i<size2; i++) { + jstring j_string = (jstring)jenv->GetObjectArrayElement(jarg2, i); + const char * c_string = jenv->GetStringUTFChars(j_string, 0); + arg2[i] = (char *)malloc(strlen((c_string)+1)*sizeof(const char *)); + strcpy(arg2[i], c_string); + jenv->ReleaseStringUTFChars(j_string, c_string); + jenv->DeleteLocalRef(j_string); + } + arg2[i] = 0; + } + result = (char **)OPTGetParameterList(arg1,arg2); + + { + /* %typemap(out) char ** */ + int i; + int len=0; + jstring temp_string; + const jclass clazz = jenv->FindClass("java/lang/String"); + + while (result[len]) len++; + jresult = jenv->NewObjectArray(len, clazz, NULL); + /* exception checking omitted */ + + for (i=0; i<len; i++) { + temp_string = jenv->NewStringUTF(*result++); + jenv->SetObjectArrayElement(jresult, i, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + /* %typemap(freearg) char ** */ + int i; + for (i=0; i<size2-1; i++) + free(arg2[i]); + free(arg2); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_osr_osrJNI_GetProjectionMethodParamInfo(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jobjectArray jarg3, jobjectArray jarg4, jlong jarg5) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + char **arg4 = (char **) 0 ; + double *arg5 = (double *) 0 ; + jint size3 ; + jint size4 ; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return ; + } + } + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return ; + } + } + { + /* %typemap(in) char ** (jint size3) */ + int i = 0; + size3 = jenv->GetArrayLength(jarg3); + arg3 = (char **) malloc((size3+1)*sizeof(char *)); + /* make a copy of each string */ + for (i = 0; i<size3; i++) { + jstring j_string = (jstring)jenv->GetObjectArrayElement(jarg3, i); + const char * c_string = jenv->GetStringUTFChars(j_string, 0); + arg3[i] = (char *)malloc(strlen((c_string)+1)*sizeof(const char *)); + strcpy(arg3[i], c_string); + jenv->ReleaseStringUTFChars(j_string, c_string); + jenv->DeleteLocalRef(j_string); + } + arg3[i] = 0; + } + { + /* %typemap(in) char ** (jint size4) */ + int i = 0; + size4 = jenv->GetArrayLength(jarg4); + arg4 = (char **) malloc((size4+1)*sizeof(char *)); + /* make a copy of each string */ + for (i = 0; i<size4; i++) { + jstring j_string = (jstring)jenv->GetObjectArrayElement(jarg4, i); + const char * c_string = jenv->GetStringUTFChars(j_string, 0); + arg4[i] = (char *)malloc(strlen((c_string)+1)*sizeof(const char *)); + strcpy(arg4[i], c_string); + jenv->ReleaseStringUTFChars(j_string, c_string); + jenv->DeleteLocalRef(j_string); + } + arg4[i] = 0; + } + arg5 = *(double **)(void *)&jarg5; + OPTGetParameterInfo(arg1,arg2,arg3,arg4,arg5); + + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(freearg) char ** */ + int i; + for (i=0; i<size3-1; i++) + free(arg3[i]); + free(arg3); + } + { + /* %typemap(freearg) char ** */ + int i; + for (i=0; i<size4-1; i++) + free(arg4[i]); + free(arg4); + } +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_osr_osrJNI_new_1SpatialReference(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jlong jresult = 0 ; + char *arg1 = (char *) "" ; + OSRSpatialReferenceShadow *result; + + (void)jenv; + (void)jcls; + { + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + } + result = (OSRSpatialReferenceShadow *)new_OSRSpatialReferenceShadow((char const *)arg1); + + *(OSRSpatialReferenceShadow **)(void *)&jresult = result; + { + if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); + } + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_osr_osrJNI_delete_1SpatialReference(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + delete_OSRSpatialReferenceShadow(arg1); + +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1_1_1str_1_1(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (char *)OSRSpatialReferenceShadow___str__(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + delete [] result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1IsSame(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (int)OSRSpatialReferenceShadow_IsSame(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1IsSameGeogCS(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (int)OSRSpatialReferenceShadow_IsSameGeogCS(arg1,arg2); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1IsGeographic(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (int)OSRSpatialReferenceShadow_IsGeographic(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1IsProjected(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (int)OSRSpatialReferenceShadow_IsProjected(arg1); + + jresult = (jint)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetAttrValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jint jarg3) { + jstring jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (int)jarg3; + result = (char *)OSRSpatialReferenceShadow_GetAttrValue(arg1,(char const *)arg2,arg3); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetAttrValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAttrValue(arg1,(char const *)arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetAngularUnits(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_SetAngularUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetAngularUnits(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (double)OSRSpatialReferenceShadow_GetAngularUnits(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetLinearUnits(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_SetLinearUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetLinearUnits(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jdouble jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (double)OSRSpatialReferenceShadow_GetLinearUnits(arg1); + + jresult = (jdouble)result; + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetLinearUnitsName(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jstring jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (char *)OSRSpatialReferenceShadow_GetLinearUnitsName(arg1); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetAuthorityCode(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jstring jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityCode(arg1,(char const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jstring JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetAuthorityName(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jstring jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityName(arg1,(char const *)arg2); + + { + if(result) jresult = jenv->NewStringUTF(result); + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetUTM(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_SetUTM(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetStatePlane(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jstring jarg4, jdouble jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + char *arg4 = (char *) "" ; + double arg5 = (double) 0.0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + arg3 = (int)jarg3; + { + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + } + arg5 = (double)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_SetStatePlane(arg1,arg2,arg3,(char const *)arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg4) jenv->ReleaseStringUTFChars(jarg4, arg4); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1AutoIdentifyEPSG(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_AutoIdentifyEPSG(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetProjection(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjection(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetProjParm(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_SetProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetProjParm(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jdouble jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (double)OSRSpatialReferenceShadow_GetProjParm(arg1,(char const *)arg2,arg3); + + jresult = (jdouble)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetNormProjParm(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_SetNormProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jdouble JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetNormProjParm(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jdouble jarg3) { + jdouble jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + arg3 = (double)jarg3; + result = (double)OSRSpatialReferenceShadow_GetNormProjParm(arg1,(char const *)arg2,arg3); + + jresult = (jdouble)result; + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetACEA(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5, jdouble jarg6, jdouble jarg7) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + arg6 = (double)jarg6; + arg7 = (double)jarg7; + result = (OGRErr)OSRSpatialReferenceShadow_SetACEA(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetAE(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_SetAE(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetCS(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_SetCS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetBonne(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_SetBonne(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetEC(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5, jdouble jarg6, jdouble jarg7) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + arg6 = (double)jarg6; + arg7 = (double)jarg7; + result = (OGRErr)OSRSpatialReferenceShadow_SetEC(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetEckertIV(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertIV(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetEckertVI(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertVI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetEquirectangular(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_SetEquirectangular(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetGS(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + result = (OGRErr)OSRSpatialReferenceShadow_SetGS(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetWellKnownGeogCS(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetWellKnownGeogCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetFromUserInput(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetFromUserInput(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1CopyGeogCSFrom(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (OGRErr)OSRSpatialReferenceShadow_CopyGeogCSFrom(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetTOWGS84(JNIEnv *jenv, jclass jcls, jlong jarg1, jdouble jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5, jdouble jarg6, jdouble jarg7, jdouble jarg8) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double arg6 = (double) 0.0 ; + double arg7 = (double) 0.0 ; + double arg8 = (double) 0.0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (double)jarg2; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + arg6 = (double)jarg6; + arg7 = (double)jarg7; + arg8 = (double)jarg8; + result = (OGRErr)OSRSpatialReferenceShadow_SetTOWGS84(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1GetTOWGS84(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double *arg2 ; + OGRErr result; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 7) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return 0; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return 0; + result = (OGRErr)OSRSpatialReferenceShadow_GetTOWGS84(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetGeogCS(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3, jstring jarg4, jdouble jarg5, jdouble jarg6, jstring jarg7, jdouble jarg8, jstring jarg9, jdouble jarg10) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + double arg5 ; + double arg6 ; + char *arg7 = (char *) "Greenwich" ; + double arg8 = (double) 0.0 ; + char *arg9 = (char *) "degree" ; + double arg10 = (double) 0.0174532925199433 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + { + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + } + arg5 = (double)jarg5; + arg6 = (double)jarg6; + { + arg7 = 0; + if (jarg7) { + arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0); + if (!arg7) return 0; + } + } + arg8 = (double)jarg8; + { + arg9 = 0; + if (jarg9) { + arg9 = (char *)jenv->GetStringUTFChars(jarg9, 0); + if (!arg9) return 0; + } + } + arg10 = (double)jarg10; + result = (OGRErr)OSRSpatialReferenceShadow_SetGeogCS(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,(char const *)arg7,arg8,(char const *)arg9,arg10); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + if (arg4) jenv->ReleaseStringUTFChars(jarg4, arg4); + } + { + if (arg7) jenv->ReleaseStringUTFChars(jarg7, arg7); + } + { + if (arg9) jenv->ReleaseStringUTFChars(jarg9, arg9); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1SetProjCS(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) "unnamed" ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromWkt(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **ignorechange) */ + val2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(freearg) (char **ignorechange) */ + jenv->ReleaseStringUTFChars(jarg2, val2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromProj4(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromESRI(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **ignorechange) */ + val2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromESRI(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(freearg) (char **ignorechange) */ + jenv->ReleaseStringUTFChars(jarg2, val2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromEPSG(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (int)jarg2; + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromEPSG(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromPCI(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2, jstring jarg3, jdoubleArray jarg4) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "METRE" ; + double *arg4 = (double *) (double *)0 ; + OGRErr result; + jboolean isCopy4 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + { + /* %typemap(in) (double argin[ANY]) */ + arg4 = (double *)jenv->GetDoubleArrayElements(jarg4, &isCopy4); + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromPCI(arg1,(char const *)arg2,(char const *)arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (double argin[ANY]) */ + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + /* %typemap(in) (double argin[ANY]) */ + if(isCopy4 == JNI_TRUE) { + jenv->ReleaseDoubleArrayElements(jarg4, (jdouble *)arg4, 0); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromUSGS(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3, jdoubleArray jarg4, jint jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long arg2 ; + long arg3 = (long) 0 ; + double *arg4 = (double *) (double *)0 ; + long arg5 = (long) 0 ; + OGRErr result; + jboolean isCopy4 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = (long)jarg2; + arg3 = (long)jarg3; + { + /* %typemap(in) (double argin[ANY]) */ + arg4 = (double *)jenv->GetDoubleArrayElements(jarg4, &isCopy4); + } + arg5 = (long)jarg5; + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (double argin[ANY]) */ + } + { + /* %typemap(in) (double argin[ANY]) */ + if(isCopy4 == JNI_TRUE) { + jenv->ReleaseDoubleArrayElements(jarg4, (jdouble *)arg4, 0); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromXML(JNIEnv *jenv, jclass jcls, jlong jarg1, jstring jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromXML(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + if (arg2) jenv->ReleaseStringUTFChars(jarg2, arg2); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToWkt(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToPrettyWkt(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2, jint jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + int arg3 = (int) 0 ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + arg3 = (int)jarg3; + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPrettyWkt(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToProj4(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToPCI(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2, jobjectArray jarg3, jdoubleArray jarg4) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char **arg3 = (char **) 0 ; + double **arg4 ; + OGRErr result; + char *argout2 = 0 ; + char *argout3 = 0 ; + double *argout4[17] ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + { + /* %typemap(in) (char **argout3) */ + arg3 = &argout3; + } + { + /* %typemap(in) (double *argout4[ANY]) */ + arg4 = argout4; + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPCI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg3) >= 1) { + temp_string = jenv->NewStringUTF(argout3); + jenv->SetObjectArrayElement(jarg3, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(argout) (double *argout[ANY]) */ + jenv->SetDoubleArrayRegion(jarg4, (jsize)0, (jsize)17, arg4[0]); + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg3) { + free((void *)argout3); + } + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(arg4); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToUSGS(JNIEnv *jenv, jclass jcls, jlong jarg1, jintArray jarg2, jintArray jarg3, jdoubleArray jarg4, jintArray jarg5) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + double **arg4 ; + long *arg5 = (long *) 0 ; + OGRErr result; + long temp2 ; + long temp3 ; + double *argout4[15] ; + long temp5 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + if (!jarg2) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if (jenv->GetArrayLength(jarg2) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg2 = &temp2; + } + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if (jenv->GetArrayLength(jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + /* %typemap(in) (double *argout4[ANY]) */ + arg4 = argout4; + } + { + if (!jarg5) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if (jenv->GetArrayLength(jarg5) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg5 = &temp5; + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + jint jvalue = (jint)temp2; + jenv->SetIntArrayRegion(jarg2, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp3; + jenv->SetIntArrayRegion(jarg3, 0, 1, &jvalue); + } + { + /* %typemap(argout) (double *argout[ANY]) */ + jenv->SetDoubleArrayRegion(jarg4, (jsize)0, (jsize)15, arg4[0]); + } + { + jint jvalue = (jint)temp5; + jenv->SetIntArrayRegion(jarg5, 0, 1, &jvalue); + } + + + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(arg4); + } + + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1ExportToXML(JNIEnv *jenv, jclass jcls, jlong jarg1, jobjectArray jarg2, jstring jarg3) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + OGRErr result; + char *argout2 = 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + { + /* %typemap(in) (char **argout2) */ + arg2 = &argout2; + } + { + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToXML(arg1,arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(argout) (char **argout) */ + jstring temp_string; + + if((int)jenv->GetArrayLength(jarg2) >= 1) { + temp_string = jenv->NewStringUTF(argout2); + jenv->SetObjectArrayElement(jarg2, 0, temp_string); + jenv->DeleteLocalRef(temp_string); + } + } + { + /* %typemap(freearg) (char **argout) */ + if(arg2) { + free((void *)argout2); + } + } + { + if (arg3) jenv->ReleaseStringUTFChars(jarg3, arg3); + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1CloneGeogCS(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jlong jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OSRSpatialReferenceShadow *)OSRSpatialReferenceShadow_CloneGeogCS(arg1); + + *(OSRSpatialReferenceShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1Validate(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_Validate(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1StripCTParms(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_StripCTParms(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1FixupOrdering(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_FixupOrdering(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1Fixup(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_Fixup(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1MorphToESRI(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_MorphToESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jint JNICALL Java_org_gdal_osr_osrJNI_SpatialReference_1MorphFromESRI(JNIEnv *jenv, jclass jcls, jlong jarg1) { + jint jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + result = (OGRErr)OSRSpatialReferenceShadow_MorphFromESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, + OGRErrMessages(result)); + return 0; + } + jresult = (jint)result; + } + { + /* %typemap(ret) OGRErr */ + + } + return jresult; +} + + +JNIEXPORT jlong JNICALL Java_org_gdal_osr_osrJNI_new_1CoordinateTransformation(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) { + jlong jresult = 0 ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OSRCoordinateTransformationShadow *result; + + (void)jenv; + (void)jcls; + arg1 = *(OSRSpatialReferenceShadow **)(void *)&jarg1; + arg2 = *(OSRSpatialReferenceShadow **)(void *)&jarg2; + result = (OSRCoordinateTransformationShadow *)new_OSRCoordinateTransformationShadow(arg1,arg2); + + *(OSRCoordinateTransformationShadow **)(void *)&jresult = result; + return jresult; +} + + +JNIEXPORT void JNICALL Java_org_gdal_osr_osrJNI_delete_1CoordinateTransformation(JNIEnv *jenv, jclass jcls, jlong jarg1) { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRCoordinateTransformationShadow **)(void *)&jarg1; + delete_OSRCoordinateTransformationShadow(arg1); + +} + + +JNIEXPORT void JNICALL Java_org_gdal_osr_osrJNI_CoordinateTransformation_1TransformPoint_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2) { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + jboolean isCopy2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRCoordinateTransformationShadow **)(void *)&jarg1; + { + /* %typemap(in) (double argin[ANY]) */ + arg2 = (double *)jenv->GetDoubleArrayElements(jarg2, &isCopy2); + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(arg1,arg2); + + { + /* %typemap(argout) (double argin[ANY]) */ + } + { + /* %typemap(in) (double argin[ANY]) */ + if(isCopy2 == JNI_TRUE) { + jenv->ReleaseDoubleArrayElements(jarg2, (jdouble *)arg2, 0); + } + } +} + + +JNIEXPORT void JNICALL Java_org_gdal_osr_osrJNI_CoordinateTransformation_1TransformPoint_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jdoubleArray jarg2, jdouble jarg3, jdouble jarg4, jdouble jarg5) { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + jdouble *jarr2 ; + + (void)jenv; + (void)jcls; + arg1 = *(OSRCoordinateTransformationShadow **)(void *)&jarg1; + if (jarg2 && jenv->GetArrayLength(jarg2) != 3) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "incorrect array size"); + return ; + } + if (!SWIG_JavaArrayInDouble(jenv, &jarr2, &arg2, jarg2)) return ; + arg3 = (double)jarg3; + arg4 = (double)jarg4; + arg5 = (double)jarg5; + OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(arg1,arg2,arg3,arg4,arg5); + + SWIG_JavaArrayArgoutDouble(jenv, jarr2, arg2, jarg2); + delete [] arg2; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/Utilities/GDAL/swig/makefile.vc b/Utilities/GDAL/swig/makefile.vc new file mode 100644 index 0000000000..e38920a722 --- /dev/null +++ b/Utilities/GDAL/swig/makefile.vc @@ -0,0 +1,90 @@ + +GDAL_ROOT = ../ +!INCLUDE $(GDAL_ROOT)\nmake.opt + +SCRIPT_CONFIG = .\setup.ini + +gdalvars: + -del $(SCRIPT_CONFIG) + echo $(GDAL_HOME) > $(SCRIPT_CONFIG) + findstr /c:"define GDAL_RELEASE_NAME " ..\gcore\gdal_version.h >> $(SCRIPT_CONFIG) +#echo $(EXTERNAL_LIBS) >> $(SCRIPT_CONFIG) + +python: gdalvars + cd python + $(SWIG) -python -modern -new_repr -o gdalconst_wrap.c ..\include\gdalconst.i + $(SWIG) -c++ -python -modern -new_repr -I../include/python -o gdal_wrap.cpp ..\include\gdal.i + $(SWIG) -c++ -python -modern -new_repr -I../include/python -o osr_wrap.cpp ..\include\osr.i + $(SWIG) -c++ -python -modern -new_repr -I../include/python -o ogr_wrap.cpp ..\include\ogr.i + $(PYDIR)/python.exe setup.py build + +#d:\Python\debug\Python-2.4\PCbuild\python_d.exe setup.py build --debug + + +csharp: gdalvars + cd csharp + cd const + $(SWIG) -csharp -namespace GDAL -dllimport gdal_gdalconst_wrap -o gdalconst_wrap.c ../../include/gdalconst.i + cd .. + cd gdal + $(SWIG) -c++ -csharp -namespace GDAL -dllimport gdal_gdal_wrap -I../../include/csharp -o gdal_wrap.cpp ../../include/gdal.i + cd .. + cd osr + $(SWIG) -c++ -csharp -namespace OSR -dllimport gdal_osr_wrap -I../../include/csharp -o osr_wrap.cpp ../../include/osr.i + cd .. + cd ogr + $(SWIG) -c++ -csharp -namespace OGR -dllimport gdal_ogr_wrap -I../../include/csharp -o ogr_wrap.cpp ../../include/ogr.i + cd .. + nmake /f makefile.vc + + +java: gdalvars + cd java + mkdir org\gdal\gdal + cd gdal + $(SWIG) -java -c++ -package org.gdal.gdal -outdir ../org/gdal/gdal -I../../include/java -o gdal_wrap.cpp ../../../include/gdal.i + cd .. + cd org\gdal + mkdir ogr + cd ../../ + cd ogr + $(SWIG) -java -c++ -package org.gdal.ogr -outdir ../org/gdal/ogr -I../../include/java -o ogr_wrap.cpp ../../../include/ogr.i + cd .. + cd org\gdal + mkdir osr + cd ../../ + cd osr + $(SWIG) -java -c++ -package org.gdal.osr -outdir ../org/gdal/osr -I../../include/java -o osr_wrap.cpp ../../../include/osr.i + cd .. + cd org\gdal + mkdir gdalconst + cd ../../ + cd const + $(SWIG) -java -c++ -package org.gdal.gdalconst -outdir ../org/gdal/gdalconst -I../../include/java -o gdalconst_wrap.cpp ../../../include/gdalconst.i + cd .. + nmake /f makefile.vc + +ruby: gdalvars + cd ruby + $(SWIG) -ruby -I../include/ruby -o gdalconst_wrap.c -autorename -prefix "gdal::" ../include/gdalconst.i + $(SWIG) -c++ -ruby -I../include/ruby -o gdal_wrap.cpp -autorename -prefix "gdal::" ../include/gdal.i + $(SWIG) -c++ -ruby -I../include/ruby -o osr_wrap.cpp -autorename -prefix "gdal::" ../include/osr.i + $(SWIG) -c++ -ruby -I../include/ruby -o ogr_wrap.cpp -autorename -prefix "gdal::" ../include/ogr.i + nmake /f makefile.vc build + nmake /f makefile.vc install + +clean: + -del setup.ini + cd csharp + nmake /f makefile.vc clean + cd .. + cd python + rmdir /S /Q build + cd .. + cd java + nmake /f makefile.vc clean + cd .. + cd ruby + name /f makefile.vc clean + cd .. + diff --git a/Utilities/GDAL/swig/perl/GNUmakefile b/Utilities/GDAL/swig/perl/GNUmakefile new file mode 100644 index 0000000000..1f4b1d1fcf --- /dev/null +++ b/Utilities/GDAL/swig/perl/GNUmakefile @@ -0,0 +1,52 @@ + + +include ../../GDALmake.opt + +all: + +BINDING = perl +include ../SWIGmake.base + +clean: + -rm -f gdal.bs gdal_wrap.o + -rm -f gdalconst.bs gdalconst_wrap.o + -rm -f ogr.bs ogr_wrap.o + -rm -f osr.bs osr_wrap.o + -rm -rf blib + -rm -f pm_to_blib + -rm -f Makefile_gdal Makefile_gdalconst Makefile_ogr Makefile_osr + +veryclean: clean + -rm -f ${WRAPPERS} + -rm -f gdal.pm gdalconst.pm osr.pm ogr.pm + +generate: ${WRAPPERS} + +Makefile_gdal: Makefile.PL ${GDAL_ROOT}/GDALmake.opt + PREFIX=${INST_PREFIX} perl Makefile.PL + +build: Makefile_gdal + make -f Makefile_gdal + make -f Makefile_gdalconst + make -f Makefile_ogr + make -f Makefile_osr + +install: Makefile_gdal build + make -f Makefile_gdal install + +test: Makefile_gdal + make -f Makefile_gdal test + +gdal.pod.html: gdal.pod + pod2html gdal.pod > gdal.pod.html + +gdalconst.pod.html: gdalconst.pod + pod2html gdalconst.pod > gdalconst.pod.html + +ogr.pod.html: ogr.pod + pod2html ogr.pod > ogr.pod.html + +osr.pod.html: osr.pod + pod2html osr.pod > osr.pod.html + +pod2html: gdal.pod.html gdalconst.pod.html ogr.pod.html osr.pod.html diff --git a/Utilities/GDAL/swig/perl/Makefile.PL b/Utilities/GDAL/swig/perl/Makefile.PL new file mode 100644 index 0000000000..e6d590047e --- /dev/null +++ b/Utilities/GDAL/swig/perl/Makefile.PL @@ -0,0 +1,18 @@ +use ExtUtils::MakeMaker; + +$ExtUtils::MakeMaker::Verbose = 1; + +$libdir=''; + +$libdir = "-L$ENV{'PREFIX'}/lib" if ($ENV{'PREFIX'}); + +for my $lib ('gdal','gdalconst','ogr','osr') { + WriteMakefile( NAME => $lib, + FIRST_MAKEFILE => 'Makefile_'.$lib, + LD => "g++", + MAKEFILE => 'Makefile_'.$lib, + LIBS => "$libdir -L../../.libs -lgdal", + INC => '-I../../gcore -I../../alg -I../../ogr -I../../port', + OBJECT => $lib.'_wrap.o' + ); +} diff --git a/Utilities/GDAL/swig/perl/gdal.pm b/Utilities/GDAL/swig/perl/gdal.pm new file mode 100644 index 0000000000..361cec5281 --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdal.pm @@ -0,0 +1,364 @@ +# This file was created automatically by SWIG 1.3.29. +# Don't modify this file, modify the SWIG interface instead. +package gdal; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +package gdalc; +bootstrap gdal; +package gdal; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package gdal; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); +} + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package gdal; + +*UseExceptions = *gdalc::UseExceptions; +*DontUseExceptions = *gdalc::DontUseExceptions; +*Debug = *gdalc::Debug; +*Error = *gdalc::Error; +*PushErrorHandler = *gdalc::PushErrorHandler; +*PopErrorHandler = *gdalc::PopErrorHandler; +*ErrorReset = *gdalc::ErrorReset; +*GetLastErrorNo = *gdalc::GetLastErrorNo; +*GetLastErrorType = *gdalc::GetLastErrorType; +*GetLastErrorMsg = *gdalc::GetLastErrorMsg; +*PushFinderLocation = *gdalc::PushFinderLocation; +*PopFinderLocation = *gdalc::PopFinderLocation; +*FinderClean = *gdalc::FinderClean; +*FindFile = *gdalc::FindFile; +*SetConfigOption = *gdalc::SetConfigOption; +*GetConfigOption = *gdalc::GetConfigOption; +*CPLBinaryToHex = *gdalc::CPLBinaryToHex; +*CPLHexToBinary = *gdalc::CPLHexToBinary; +*GDAL_GCP_GCPX_get = *gdalc::GDAL_GCP_GCPX_get; +*GDAL_GCP_GCPX_set = *gdalc::GDAL_GCP_GCPX_set; +*GDAL_GCP_GCPY_get = *gdalc::GDAL_GCP_GCPY_get; +*GDAL_GCP_GCPY_set = *gdalc::GDAL_GCP_GCPY_set; +*GDAL_GCP_GCPZ_get = *gdalc::GDAL_GCP_GCPZ_get; +*GDAL_GCP_GCPZ_set = *gdalc::GDAL_GCP_GCPZ_set; +*GDAL_GCP_GCPPixel_get = *gdalc::GDAL_GCP_GCPPixel_get; +*GDAL_GCP_GCPPixel_set = *gdalc::GDAL_GCP_GCPPixel_set; +*GDAL_GCP_GCPLine_get = *gdalc::GDAL_GCP_GCPLine_get; +*GDAL_GCP_GCPLine_set = *gdalc::GDAL_GCP_GCPLine_set; +*GDAL_GCP_Info_get = *gdalc::GDAL_GCP_Info_get; +*GDAL_GCP_Info_set = *gdalc::GDAL_GCP_Info_set; +*GDAL_GCP_Id_get = *gdalc::GDAL_GCP_Id_get; +*GDAL_GCP_Id_set = *gdalc::GDAL_GCP_Id_set; +*GDAL_GCP_get_GCPX = *gdalc::GDAL_GCP_get_GCPX; +*GDAL_GCP_set_GCPX = *gdalc::GDAL_GCP_set_GCPX; +*GDAL_GCP_get_GCPY = *gdalc::GDAL_GCP_get_GCPY; +*GDAL_GCP_set_GCPY = *gdalc::GDAL_GCP_set_GCPY; +*GDAL_GCP_get_GCPZ = *gdalc::GDAL_GCP_get_GCPZ; +*GDAL_GCP_set_GCPZ = *gdalc::GDAL_GCP_set_GCPZ; +*GDAL_GCP_get_GCPPixel = *gdalc::GDAL_GCP_get_GCPPixel; +*GDAL_GCP_set_GCPPixel = *gdalc::GDAL_GCP_set_GCPPixel; +*GDAL_GCP_get_GCPLine = *gdalc::GDAL_GCP_get_GCPLine; +*GDAL_GCP_set_GCPLine = *gdalc::GDAL_GCP_set_GCPLine; +*GDAL_GCP_get_Info = *gdalc::GDAL_GCP_get_Info; +*GDAL_GCP_set_Info = *gdalc::GDAL_GCP_set_Info; +*GDAL_GCP_get_Id = *gdalc::GDAL_GCP_get_Id; +*GDAL_GCP_set_Id = *gdalc::GDAL_GCP_set_Id; +*GCPsToGeoTransform = *gdalc::GCPsToGeoTransform; +*AllRegister = *gdalc::AllRegister; +*GetCacheMax = *gdalc::GetCacheMax; +*SetCacheMax = *gdalc::SetCacheMax; +*GetCacheUsed = *gdalc::GetCacheUsed; +*GetDataTypeSize = *gdalc::GetDataTypeSize; +*DataTypeIsComplex = *gdalc::DataTypeIsComplex; +*GetDataTypeName = *gdalc::GetDataTypeName; +*GetDataTypeByName = *gdalc::GetDataTypeByName; +*GetColorInterpretationName = *gdalc::GetColorInterpretationName; +*GetPaletteInterpretationName = *gdalc::GetPaletteInterpretationName; +*DecToDMS = *gdalc::DecToDMS; +*PackedDMSToDec = *gdalc::PackedDMSToDec; +*DecToPackedDMS = *gdalc::DecToPackedDMS; +*ParseXMLString = *gdalc::ParseXMLString; +*SerializeXMLTree = *gdalc::SerializeXMLTree; +*GetDriverCount = *gdalc::GetDriverCount; +*GetDriverByName = *gdalc::GetDriverByName; +*GetDriver = *gdalc::GetDriver; +*Open = *gdalc::Open; +*OpenShared = *gdalc::OpenShared; +*AutoCreateWarpedVRT = *gdalc::AutoCreateWarpedVRT; + +############# Class : gdal::MajorObject ############## + +package gdal::MajorObject; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal ); +%OWNER = (); +*GetDescription = *gdalc::MajorObject_GetDescription; +*SetDescription = *gdalc::MajorObject_SetDescription; +*GetMetadata = *gdalc::MajorObject_GetMetadata; +*SetMetadata = *gdalc::MajorObject_SetMetadata; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : gdal::Driver ############## + +package gdal::Driver; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal::MajorObject gdal ); +%OWNER = (); +%ITERATORS = (); +*swig_ShortName_get = *gdalc::Driver_ShortName_get; +*swig_ShortName_set = *gdalc::Driver_ShortName_set; +*swig_LongName_get = *gdalc::Driver_LongName_get; +*swig_LongName_set = *gdalc::Driver_LongName_set; +*swig_HelpTopic_get = *gdalc::Driver_HelpTopic_get; +*swig_HelpTopic_set = *gdalc::Driver_HelpTopic_set; +*Create = *gdalc::Driver_Create; +*CreateCopy = *gdalc::Driver_CreateCopy; +*Delete = *gdalc::Driver_Delete; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : gdal::GCP ############## + +package gdal::GCP; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal ); +%OWNER = (); +%ITERATORS = (); +*swig_GCPX_get = *gdalc::GCP_GCPX_get; +*swig_GCPX_set = *gdalc::GCP_GCPX_set; +*swig_GCPY_get = *gdalc::GCP_GCPY_get; +*swig_GCPY_set = *gdalc::GCP_GCPY_set; +*swig_GCPZ_get = *gdalc::GCP_GCPZ_get; +*swig_GCPZ_set = *gdalc::GCP_GCPZ_set; +*swig_GCPPixel_get = *gdalc::GCP_GCPPixel_get; +*swig_GCPPixel_set = *gdalc::GCP_GCPPixel_set; +*swig_GCPLine_get = *gdalc::GCP_GCPLine_get; +*swig_GCPLine_set = *gdalc::GCP_GCPLine_set; +*swig_Info_get = *gdalc::GCP_Info_get; +*swig_Info_set = *gdalc::GCP_Info_set; +*swig_Id_get = *gdalc::GCP_Id_get; +*swig_Id_set = *gdalc::GCP_Id_set; +sub new { + my $pkg = shift; + my $self = gdalc::new_GCP(@_); + bless $self, $pkg if defined($self); +} + +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + gdalc::delete_GCP($self); + delete $OWNER{$self}; + } +} + +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : gdal::Dataset ############## + +package gdal::Dataset; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal::MajorObject gdal ); +%OWNER = (); +%ITERATORS = (); +*swig_RasterXSize_get = *gdalc::Dataset_RasterXSize_get; +*swig_RasterXSize_set = *gdalc::Dataset_RasterXSize_set; +*swig_RasterYSize_get = *gdalc::Dataset_RasterYSize_get; +*swig_RasterYSize_set = *gdalc::Dataset_RasterYSize_set; +*swig_RasterCount_get = *gdalc::Dataset_RasterCount_get; +*swig_RasterCount_set = *gdalc::Dataset_RasterCount_set; +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + gdalc::delete_Dataset($self); + delete $OWNER{$self}; + } +} + +*GetDriver = *gdalc::Dataset_GetDriver; +*GetRasterBand = *gdalc::Dataset_GetRasterBand; +*GetProjection = *gdalc::Dataset_GetProjection; +*GetProjectionRef = *gdalc::Dataset_GetProjectionRef; +*SetProjection = *gdalc::Dataset_SetProjection; +*GetGeoTransform = *gdalc::Dataset_GetGeoTransform; +*SetGeoTransform = *gdalc::Dataset_SetGeoTransform; +*BuildOverviews = *gdalc::Dataset_BuildOverviews; +*GetGCPCount = *gdalc::Dataset_GetGCPCount; +*GetGCPProjection = *gdalc::Dataset_GetGCPProjection; +*GetGCPs = *gdalc::Dataset_GetGCPs; +*SetGCPs = *gdalc::Dataset_SetGCPs; +*FlushCache = *gdalc::Dataset_FlushCache; +*AddBand = *gdalc::Dataset_AddBand; +*WriteRaster = *gdalc::Dataset_WriteRaster; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : gdal::Band ############## + +package gdal::Band; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal::MajorObject gdal ); +%OWNER = (); +%ITERATORS = (); +*swig_XSize_get = *gdalc::Band_XSize_get; +*swig_XSize_set = *gdalc::Band_XSize_set; +*swig_YSize_get = *gdalc::Band_YSize_get; +*swig_YSize_set = *gdalc::Band_YSize_set; +*swig_DataType_get = *gdalc::Band_DataType_get; +*swig_DataType_set = *gdalc::Band_DataType_set; +*GetRasterColorInterpretation = *gdalc::Band_GetRasterColorInterpretation; +*SetRasterColorInterpretation = *gdalc::Band_SetRasterColorInterpretation; +*GetNoDataValue = *gdalc::Band_GetNoDataValue; +*SetNoDataValue = *gdalc::Band_SetNoDataValue; +*GetMinimum = *gdalc::Band_GetMinimum; +*GetMaximum = *gdalc::Band_GetMaximum; +*GetOffset = *gdalc::Band_GetOffset; +*GetScale = *gdalc::Band_GetScale; +*GetOverviewCount = *gdalc::Band_GetOverviewCount; +*GetOverview = *gdalc::Band_GetOverview; +*Checksum = *gdalc::Band_Checksum; +*ComputeRasterMinMax = *gdalc::Band_ComputeRasterMinMax; +*Fill = *gdalc::Band_Fill; +*ReadRaster = *gdalc::Band_ReadRaster; +*WriteRaster = *gdalc::Band_WriteRaster; +*FlushCache = *gdalc::Band_FlushCache; +*GetRasterColorTable = *gdalc::Band_GetRasterColorTable; +*SetRasterColorTable = *gdalc::Band_SetRasterColorTable; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : gdal::ColorTable ############## + +package gdal::ColorTable; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( gdal ); +%OWNER = (); +%ITERATORS = (); +sub new { + my $pkg = shift; + my $self = gdalc::new_ColorTable(@_); + bless $self, $pkg if defined($self); +} + +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + gdalc::delete_ColorTable($self); + delete $OWNER{$self}; + } +} + +*Clone = *gdalc::ColorTable_Clone; +*GetPaletteInterpretation = *gdalc::ColorTable_GetPaletteInterpretation; +*GetCount = *gdalc::ColorTable_GetCount; +*GetColorEntry = *gdalc::ColorTable_GetColorEntry; +*GetColorEntryAsRGB = *gdalc::ColorTable_GetColorEntryAsRGB; +*SetColorEntry = *gdalc::ColorTable_SetColorEntry; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +# ------- VARIABLE STUBS -------- + +package gdal; + +1; diff --git a/Utilities/GDAL/swig/perl/gdal.pod b/Utilities/GDAL/swig/perl/gdal.pod new file mode 100644 index 0000000000..50bed5d8bc --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdal.pod @@ -0,0 +1,464 @@ +=head1 NAME + +gdal - A part of the Perl interface to the GDAL library. + +=head1 SYNOPSIS + + use gdalconst; + use gdal; + +=head1 ABSTRACT + +This module is a part of the Perl bindings to the GDAL library. The +GDAL modules allows you to access and manipulate from Perl all +geospatial data that the installed GDAL library is configured to +read/write. + +=head1 STATUS + +This module is beta quality. As most of the names and calling +conventions come directly from the underlying GDAL library they are +quite stable and will continue to work like they do now. However, many +things could, should, and will be made more perlish. + +Generally, those methods which are documented, have been tested. If +the method or constructor you are looking for is not documented, +perhaps there is another way of doing what you want to do. + +=head1 DESCRIPTION + +The gdal module allows a geospatial programmer to use the GDAL library +with the ease and comfort of Perl. Find out more about GDAL at +http://www.gdal.org. + +To discuss gdal, ask questions and flame/praise the authors, join +gdal-dev@lists.maptools.org at +http://lists.maptools.org/mailman/listinfo/gdal-dev/. + +=head1 PACKAGE METHODS + +Note: some arguments are optional and have a default value. This is +illustrated like this: + +SomeMethod(arg1, arg2 = 4); + +arg1 is a required argument and an example or a variable with illustrative +name is given + +arg2 is optional and if left off, will get the value 4 (in this case) + +=over + +=item UseExceptions + + Turned on by default. + +=item DontUseExceptions + +=item Debug + +=item Error + +=item PushErrorHandler + +=item PopErrorHandler + +=item ErrorReset + +=item GetLastErrorNo + +=item GetLastErrorType + +=item GetLastErrorMsg + +=item PushFinderLocation + +=item PopFinderLocation + +=item FinderClean + +=item FindFile + +=item SetConfigOption + +=item GetConfigOption + +=item GCPsToGeoTransform + +=item AllRegister + + Done by default. + +=item GetCacheMax + +=item SetCacheMax + +=item GetCacheUsed + +=item GetDataTypeSize + +=item DataTypeIsComplex + +=item GetDataTypeName + +=item GetDataTypeByName + +=item GetColorInterpretationName + +=item GetPaletteInterpretationName + +=item DecToDMS + +=item PackedDMSToDec + +=item DecToPackedDMS + +=item ParseXMLString + +=item SerializeXMLTree + +=item GetDriverCount + + $n = gdal::GetDriverCount(); + +=item GetDriverByName + + $driver = gdal::GetDriverByName('driver name'); + +The driver name is the $driver->{ShortName}, but that is a chicken and +an egg problem! + +=item GetDriver + + $driver = gdal::GetDriver($i); + +=item Open + + $dataset = gdal::Open('filename', + $access = $gdalconst::GA_ReadOnly); + + $access = $gdalconst::GA_ReadOnly | $gdalconst::GA_Update + +=item OpenShared + +=item AutoCreateWarpedVRT + +=back + +=head1 CLASSES + +=head2 gdal::MajorObject + +Superclass of gdal::Driver, gdal::Dataset, and gdal::Band + +=over + +=item GetDescription + +=item SetDescription + +=item GetMetadata + + $metadata = $object->GetMetadata(); + +=item SetMetadata + +=back + +=head2 gdal::Driver + +=over + +=item ShortName + + $driver->{ShortName} + +=item LongName + + $driver->{LongName} + +=item HelpTopic + + $driver->{HelpTopic} + +=item Create + + $dataset = $driver->Create('filename', $width, $height, + $bands = 1, $type = $gdalconst::GDT_Byte, $options = []); + +=item CreateCopy + + $dataset = $driver->CreateCopy('filename', $src_dataset, + $strict =1, $options = []); + +=item Delete + +=back + +=head2 gdal::Dataset + +=over + +=item RasterXSize + + $dataset->{RasterXSize} + +=item RasterYSize + + $dataset->{RasterYSize} + +=item RasterCount + + $dataset->{RasterCount} + +=item GetDriver + +=item GetRasterBand + + for $i (1..$dataset->RasterCount) { + $band = $dataset->GetRasterBand($i); + } + +=item GetProjection + + $projection = $dataset->GetProjection; + +=item GetProjectionRef + +=item SetProjection + + $dataset->SetProjection($projection); + +=item GetGeoTransform + + $transform = $dataset->GetGeoTransform(); + +=item SetGeoTransform + + @transform = ($minX, $dx, 0, $maxY, 0, $dy); + $dataset->SetGeoTransform(\@transform); + +=item BuildOverviews + +=item GetGCPCount + + $gcp_count = $dataset->GetGCPCount(); + +=item GetGCPProjection + + $gcp_projection = $dataset->GetGCPProjection(); + +=item GetGCPs + +An example: + + my $gcps = $dataset->GetGCPs(); + for (0..$#$gcps) { + $x[$_] = $gcps->[$_]->{GCPX}; + $y[$_] = $gcps->[$_]->{GCPY}; + } + +=item SetGCPs + +An example: + + my @gcps = (); + push @gcps,new gdal::GCP($x1, $y1); + push @gcps,new gdal::GCP($x2, $y2); + $dataset->SetGCPs(\@gcps, "some projection"); + +=item FlushCache + +=item AddBand + +=item WriteRaster + +=back + +=head2 gdal::Band + +=over + +=item XSize + + $band->{XSize} + +=item YSize + + $band->{YSize} + +=item DataType + + $band->{DataType} + +=item GetRasterColorInterpretation + +=item SetRasterColorInterpretation + +=item GetNoDataValue + + $value = $band->GetNoDataValue; + +=item SetNoDataValue + + $band->SetNoDataValue($value); + +=item GetMinimum + +=item GetMaximum + +=item GetOffset + +=item GetScale + +=item GetOverviewCount + +=item GetOverview + +=item Checksum + +=item ComputeRasterMinMax + +=item Fill + +=item ReadRaster + + $scanline = $band->ReadRaster( 0, 0, $width, 1 ); + @data = unpack("i[$width]", $scanline); + +See also the example below. + +=item WriteRaster + + SWITCH: for ($band->{DataType}) { + if ($_ == $gdalconst::$GDT_Byte) { $type = 'C'; last SWITCH; } + if ($_ == $gdalconst::$GDT_Int16) { $type = 's'; last SWITCH; } + if ($_ == $gdalconst::$GDT_Int32) { $type = 'i'; last SWITCH; } + $nothing = 1; + } + + unless ($nothing) { + + $buf = pack($type.'['.$width*$height.']',@data); + + $band->WriteRaster( $xoff, $yoff, $width, $height, $buf ); + + } + + The $type chars are listed in the documentation for "pack" in man perlfunc. + +=item FlushCache + +=item GetRasterColorTable + + $colortable = $band->GetRasterColorTable; + +=item SetRasterColorTable + + $band->SetRasterColorTable($colortable); + +=back + +=head2 gdal::ColorTable + + $colortable = new gdal::ColorTable( + $palette_interpretation = $gdalconst::GPI_RGB); + +=over + +=item Clone + +=item GetPaletteInterpretation + +=item GetCount + +=item GetColorEntry + + @color = $colortable->GetColorEntryAsRGB($i); + +=item GetColorEntryAsRGB + + @color = $colortable->GetColorEntryAsRGB($i); + +=item SetColorEntry + + @color = (255,0,0,255); # an example, opaque red, + # and RGBA color interpretation + $colortable->SetColorEntry($i, \@color); + +=back + +=head2 gdal::GCP + +=over + +=item GCPX + + $gcp->{GCPX} + +=item GCPY + + $gcp->{GCPY} + +=item GCPZ + + $gcp->{GCPZ} + +=item GCPPixel + + $gcp->{GCPPixel} + +=item GCPLine + + $gcp->{GCPLine} + +=item Info + + $gcp->{Info} + +=item Id + + $gcp->{Id} + +=back + +=head1 KNOWN BUGS + +The reference counting scheme is not yet implemented. Make sure that +parents are not deleted before their children! Use "my" a lot. Do not +give undefined/uninitialized variables to methods. + +=head1 SEE ALSO + +L<perl>(1), L<perlfunc>(1), L<gdalconst>(3pm), L<osr>(3pm), L<ogr>(3pm). + +http://www.gdal.org + +=head1 AUTHORS + +The GDAL bindings team (in alphabetical order): + +ari.jolma at tkk.fi +cfis at interserv.com +hobu at iastate.edu +kruland at ku.edu +warmerdam at pobox.com + +=head1 COPYRIGHT AND LICENSE + +Copyright 2005-2006 by the GDAL bindings team. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307 USA. diff --git a/Utilities/GDAL/swig/perl/gdal_wrap.cpp b/Utilities/GDAL/swig/perl/gdal_wrap.cpp new file mode 100644 index 0000000000..7fbdbf11fd --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdal_wrap.cpp @@ -0,0 +1,9543 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.29 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPERL +#define SWIG_CASTRANK_MODE + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include <patchlevel.h> +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include <could_not_find_Perl_patchlevel.h> +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + + +#else +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif +#endif + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc,voidptr); + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV(obj, PL_na); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XS(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_CPLErrorHandler swig_types[0] +#define SWIGTYPE_p_CPLXMLNode swig_types[1] +#define SWIGTYPE_p_GByte swig_types[2] +#define SWIGTYPE_p_GDALColorEntry swig_types[3] +#define SWIGTYPE_p_GDALColorTable swig_types[4] +#define SWIGTYPE_p_GDALDatasetShadow swig_types[5] +#define SWIGTYPE_p_GDALDriverShadow swig_types[6] +#define SWIGTYPE_p_GDALMajorObjectShadow swig_types[7] +#define SWIGTYPE_p_GDALRasterBandShadow swig_types[8] +#define SWIGTYPE_p_GDAL_GCP swig_types[9] +#define SWIGTYPE_p_char swig_types[10] +#define SWIGTYPE_p_double swig_types[11] +#define SWIGTYPE_p_int swig_types[12] +#define SWIGTYPE_p_p_GDAL_GCP swig_types[13] +#define SWIGTYPE_p_p_char swig_types[14] +static swig_type_info *swig_types[16]; +static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_gdal + +#define SWIG_name "gdalc::boot_gdal" +#define SWIG_prefix "gdalc::" + +#define SWIGVERSION 0x010329 + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include <stdexcept> + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + + + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} + + +void UseExceptions() { + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} + + + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + long v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (size && carray) { + if (carray[size - 1] == 0) { + sv_setpv(obj, carray); + } else { + char *tmp = (new char[size + 1]); + memcpy(tmp, carray, size); + tmp[size] = 0; + sv_setpv(obj, tmp); + delete[] tmp; + } + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + +SWIGINTERN char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){ + return GDALGetDescription( self ); + } +SWIGINTERN void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){ + GDALSetDescription( self, pszNewDesc ); + } +SWIGINTERN char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){ + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){ + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } +SWIGINTERN GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *name,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){ + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } +SWIGINTERN GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *name,GDALDatasetShadow *src,int strict=1,char **options=0){ + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } +SWIGINTERN int GDALDriverShadow_Delete(GDALDriverShadow *self,char const *name){ + return GDALDeleteDataset( self, name ); + } + +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} + + +SWIGINTERNINLINE SV * +SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value) +{ + SV *obj = sv_newmortal(); + sv_setnv(obj, value); + return obj; +} + +SWIGINTERN GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){ + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } +SWIGINTERN void delete_GDAL_GCP(GDAL_GCP *self){ + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } + + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +static SV * +CreateArrayFromDoubleArray( double *first, unsigned int size ) { + AV *av = (AV*)sv_2mortal((SV*)newAV()); + for( unsigned int i=0; i<size; i++ ) { + av_store(av,i,newSVnv(*first)); + ++first; + } + return newRV_noinc((SV*)av); +} + +SWIGINTERN void delete_GDALDatasetShadow(GDALDatasetShadow *self){ + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } +SWIGINTERN GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){ + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } +SWIGINTERN GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){ + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } +SWIGINTERN char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +SWIGINTERN char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){ + return GDALSetProjection( self, prj ); + } +SWIGINTERN void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6]){ + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } +SWIGINTERN CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){ + return GDALSetGeoTransform( self, argin ); + } +SWIGINTERN int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0){ + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +SWIGINTERN int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){ + return GDALGetGCPCount( self ); + } +SWIGINTERN char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){ + return GDALGetGCPProjection( self ); + } +SWIGINTERN void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){ + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){ + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } +SWIGINTERN void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){ + GDALFlushCache( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){ + return GDALAddBand( self, datatype, options ); + } +SWIGINTERN CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } + +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} + + +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} + +SWIGINTERN GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){ + return GDALGetRasterColorInterpretation( self ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){ + return GDALSetRasterColorInterpretation( self, val ); + } +SWIGINTERN void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterNoDataValue( self, hasval ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){ + return GDALSetRasterNoDataValue( self, d ); + } +SWIGINTERN void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMinimum( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMaximum( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterOffset( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterScale( self, hasval ); + } +SWIGINTERN int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){ + return GDALGetOverviewCount( self ); + } +SWIGINTERN GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){ + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } +SWIGINTERN int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){ + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +SWIGINTERN void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){ + GDALComputeRasterMinMax( self, approx_ok, argout ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){ + return GDALFillRaster( self, real_fill, imag_fill ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_ReadRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_len,char **buf,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +SWIGINTERN void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){ + GDALFlushRasterCache( self ); + } +SWIGINTERN GDALColorTable *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){ + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } +SWIGINTERN int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTable *arg){ + return GDALSetRasterColorTable( self, arg ); + } + +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} + + +/************************************************************************/ +/* XMLTreeToAV() */ +/************************************************************************/ +static AV *XMLTreeToAV( CPLXMLNode *psTree ) +{ + AV *av; + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + av = (AV*)sv_2mortal((SV*)newAV()); + + av_store(av,0,newSViv((int) psTree->eType)); + av_store(av,1,newSVpv(psTree->pszValue, strlen(psTree->pszValue))); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + av_store(av, iChild, newRV_noinc((SV*)(XMLTreeToAV( psChild ))) ); + } + + return av; +} + + +/************************************************************************/ +/* AVToXMLTree() */ +/************************************************************************/ +static CPLXMLNode *AVToXMLTree( AV *av ) + +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = av_len(av) - 1; + if( nChildCount < 0 ) + { + croak("Error in input XMLTree."); + return NULL; + } + + nType = SvIV(*(av_fetch(av,0,0))); + pszText = SvPV_nolen(*(av_fetch(av,1,0))); + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = AVToXMLTree( (AV *)(*(av_fetch(av,iChild+2,0))) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} + + +int GetDriverCount() { + return GDALGetDriverCount(); +} + + +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} + + +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} + + +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} + +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_gdal_var:: +class _wrap_gdal_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_UseExceptions) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: UseExceptions();"); + } + UseExceptions(); + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_DontUseExceptions) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: DontUseExceptions();"); + } + DontUseExceptions(); + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_Debug) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Debug(msg_class,message);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Debug" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Debug" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + Debug((char const *)arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Error) { + { + CPLErr arg1 = (CPLErr) CE_Failure ; + int arg2 = (int) 0 ; + char *arg3 = (char *) "error" ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 3)) { + SWIG_croak("Usage: Error(msg_class,err_code,msg);"); + } + if (items > 0) { + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "Error" "', argument " "1"" of type '" "CPLErr""'"); + } + arg1 = static_cast< CPLErr >(val1); + } + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Error" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Error" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + Error(arg1,arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_PushErrorHandler__SWIG_0) { + { + char *arg1 = (char *) "CPLQuietErrorHandler" ; + CPLErr result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 1)) { + SWIG_croak("Usage: PushErrorHandler(pszCallbackName);"); + } + if (items > 0) { + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PushErrorHandler" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + { + CPLErrorReset(); + result = (CPLErr)PushErrorHandler((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_PushErrorHandler__SWIG_1) { + { + CPLErrorHandler arg1 ; + void *argp1 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: PushErrorHandler(CPLErrorHandler);"); + } + { + res1 = SWIG_ConvertPtr(ST(0), &argp1, SWIGTYPE_p_CPLErrorHandler, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PushErrorHandler" "', argument " "1"" of type '" "CPLErrorHandler""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PushErrorHandler" "', argument " "1"" of type '" "CPLErrorHandler""'"); + } else { + arg1 = *(reinterpret_cast< CPLErrorHandler * >(argp1)); + } + } + { + CPLErrorReset(); + CPLPushErrorHandler(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_PushErrorHandler) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if ((items >= 0) && (items <= 1)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + if (items > 0) { + { + int res = SWIG_AsCharPtrAndSize(ST(0), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 1) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_CPLErrorHandler, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_PushErrorHandler__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_PushErrorHandler__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'PushErrorHandler'"); + XSRETURN(0); +} + + +XS(_wrap_PopErrorHandler) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: PopErrorHandler();"); + } + { + CPLErrorReset(); + CPLPopErrorHandler(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_ErrorReset) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: ErrorReset();"); + } + { + CPLErrorReset(); + CPLErrorReset(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetLastErrorNo) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetLastErrorNo();"); + } + { + CPLErrorReset(); + result = (int)CPLGetLastErrorNo(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetLastErrorType) { + { + CPLErr result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetLastErrorType();"); + } + { + CPLErrorReset(); + result = (CPLErr)CPLGetLastErrorType(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetLastErrorMsg) { + { + char *result = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetLastErrorMsg();"); + } + { + CPLErrorReset(); + result = (char *)CPLGetLastErrorMsg(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_PushFinderLocation) { + { + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: PushFinderLocation(char const *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PushFinderLocation" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + CPLPushFinderLocation((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_PopFinderLocation) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: PopFinderLocation();"); + } + { + CPLErrorReset(); + CPLPopFinderLocation(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_FinderClean) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: FinderClean();"); + } + { + CPLErrorReset(); + CPLFinderClean(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_FindFile) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FindFile(char const *,char const *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FindFile" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FindFile" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)CPLFindFile((char const *)arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SetConfigOption) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SetConfigOption(char const *,char const *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SetConfigOption" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SetConfigOption" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + CPLSetConfigOption((char const *)arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GetConfigOption) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GetConfigOption(char const *,char const *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetConfigOption" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GetConfigOption" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)CPLGetConfigOption((char const *)arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_CPLBinaryToHex) { + { + int arg1 ; + GByte *arg2 = (GByte *) 0 ; + char *result = 0 ; + int val1 ; + int ecode1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: CPLBinaryToHex(nBytes,pabyData);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "CPLBinaryToHex" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_GByte, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CPLBinaryToHex" "', argument " "2"" of type '" "GByte const *""'"); + } + arg2 = reinterpret_cast< GByte * >(argp2); + { + CPLErrorReset(); + result = (char *)CPLBinaryToHex(arg1,(GByte const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_CPLHexToBinary) { + { + char *arg1 = (char *) 0 ; + int *arg2 = (int *) 0 ; + GByte *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: CPLHexToBinary(pszHex,pnBytes);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CPLHexToBinary" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CPLHexToBinary" "', argument " "2"" of type '" "int *""'"); + } + arg2 = reinterpret_cast< int * >(argp2); + { + CPLErrorReset(); + result = (GByte *)CPLHexToBinary((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GByte, 0 | 0); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_GetDescription) { + { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: MajorObject_GetDescription(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MajorObject_GetDescription" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast< GDALMajorObjectShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALMajorObjectShadow_GetDescription(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_SetDescription) { + { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: MajorObject_SetDescription(self,pszNewDesc);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MajorObject_SetDescription" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast< GDALMajorObjectShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MajorObject_SetDescription" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDALMajorObjectShadow_SetDescription(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_GetMetadata) { + { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: MajorObject_GetMetadata(self,pszDomain);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MajorObject_GetMetadata" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast< GDALMajorObjectShadow * >(argp1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MajorObject_GetMetadata" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + { + CPLErrorReset(); + result = (char **)GDALMajorObjectShadow_GetMetadata_Dict(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) char **dict */ + char **stringarray = result; + HV *hv = (HV*)sv_2mortal((SV*)newHV()); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + hv_store(hv, keyptr, strlen(keyptr), newSVpv(valptr, strlen(valptr)), 0); + CPLFree( keyptr ); + } + stringarray++; + } + } + ST(argvi) = newRV_noinc((SV*)hv); + argvi++; + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_SetMetadata__SWIG_0) { + { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: MajorObject_SetMetadata(self,papszMetadata,pszDomain);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MajorObject_SetMetadata" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast< GDALMajorObjectShadow * >(argp1); + { + /* %typemap(in) char **dict */ + HV *hv = (HV*)SvRV(ST(1)); + SV *sv; + char *key; + I32 klen; + arg2 = NULL; + hv_iterinit(hv); + while(sv = hv_iternextsv(hv,&key,&klen)) { + arg2 = CSLAddNameValue( arg2, key, SvPV_nolen(sv) ); + } + } + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "MajorObject_SetMetadata" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_0(arg1,arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_SetMetadata__SWIG_1) { + { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: MajorObject_SetMetadata(self,pszMetadataString,pszDomain);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MajorObject_SetMetadata" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast< GDALMajorObjectShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MajorObject_SetMetadata" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "MajorObject_SetMetadata" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_1(arg1,arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_MajorObject_SetMetadata) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if ((items >= 2) && (items <= 3)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_GDALMajorObjectShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + _v = (SvROK(ST(1)) && (SvTYPE(SvRV(ST(1)))==SVt_PVHV)) ? 1 : 0; + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (items > 2) { + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if ((items >= 2) && (items <= 3)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_GDALMajorObjectShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (items > 2) { + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_MajorObject_SetMetadata__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_MajorObject_SetMetadata__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'MajorObject_SetMetadata'"); + XSRETURN(0); +} + + +XS(_wrap_Driver_ShortName_get) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Driver_ShortName_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_ShortName_get" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_ShortName_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_LongName_get) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Driver_LongName_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_LongName_get" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_LongName_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_HelpTopic_get) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Driver_HelpTopic_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_HelpTopic_get" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_HelpTopic_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_Create) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 = (int) 1 ; + GDALDataType arg6 = (GDALDataType) GDT_Byte ; + char **arg7 = (char **) 0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 7)) { + SWIG_croak("Usage: Driver_Create(self,name,xsize,ysize,bands,eType,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_Create" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_Create" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Driver_Create" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Driver_Create" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + if (items > 4) { + ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Driver_Create" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + } + if (items > 5) { + ecode6 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(5), &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Driver_Create" "', argument " "6"" of type '" "GDALDataType""'"); + } + arg6 = static_cast< GDALDataType >(val6); + } + if (items > 6) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(6)) && (SvTYPE(SvRV(ST(6)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(6))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg7 = CSLAddString( arg7, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_Create(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_CreateCopy) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + GDALDatasetShadow *arg3 = (GDALDatasetShadow *) 0 ; + int arg4 = (int) 1 ; + char **arg5 = (char **) 0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 5)) { + SWIG_croak("Usage: Driver_CreateCopy(self,name,src,strict,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_CreateCopy" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_CreateCopy" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_ConvertPtr(ST(2), &argp3,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Driver_CreateCopy" "', argument " "3"" of type '" "GDALDatasetShadow *""'"); + } + arg3 = reinterpret_cast< GDALDatasetShadow * >(argp3); + if (items > 3) { + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Driver_CreateCopy" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + } + if (items > 4) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(4)) && (SvTYPE(SvRV(ST(4)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(4))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_CreateCopy(arg1,(char const *)arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_Delete) { + { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Driver_Delete(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_Delete" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast< GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_Delete" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)GDALDriverShadow_Delete(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPX_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_GCPX_set(self,GCPX);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPX_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GCP_GCPX_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPX_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_GCPX_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPX_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPY_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_GCPY_set(self,GCPY);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPY_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GCP_GCPY_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPY_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_GCPY_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPY_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPZ_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_GCPZ_set(self,GCPZ);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPZ_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GCP_GCPZ_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPZ_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_GCPZ_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPZ_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPPixel_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_GCPPixel_set(self,GCPPixel);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPPixel_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GCP_GCPPixel_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPPixel_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_GCPPixel_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPPixel_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPLine_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_GCPLine_set(self,GCPLine);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPLine_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GCP_GCPLine_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_GCPLine_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_GCPLine_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_GCPLine_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_Info_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_Info_set(self,Info);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_Info_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GCP_Info_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_Info_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_Info_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_Info_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_Id_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GCP_Id_set(self,Id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_Id_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GCP_Id_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GCP_Id_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GCP_Id_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GCP_Id_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_GCP) { + { + double arg1 = (double) 0.0 ; + double arg2 = (double) 0.0 ; + double arg3 = (double) 0.0 ; + double arg4 = (double) 0.0 ; + double arg5 = (double) 0.0 ; + char *arg6 = (char *) "" ; + char *arg7 = (char *) "" ; + GDAL_GCP *result = 0 ; + double val1 ; + int ecode1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 7)) { + SWIG_croak("Usage: new_GCP(x,y,z,pixel,line,info,id);"); + } + if (items > 0) { + ecode1 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_GCP" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + } + if (items > 1) { + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_GCP" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + } + if (items > 2) { + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_GCP" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + } + if (items > 3) { + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_GCP" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + } + if (items > 4) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "new_GCP" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + if (items > 5) { + res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "new_GCP" "', argument " "6"" of type '" "char const *""'"); + } + arg6 = buf6; + } + if (items > 6) { + res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "new_GCP" "', argument " "7"" of type '" "char const *""'"); + } + arg7 = buf7; + } + { + CPLErrorReset(); + result = (GDAL_GCP *)new_GDAL_GCP(arg1,arg2,arg3,arg4,arg5,(char const *)arg6,(char const *)arg7); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDAL_GCP, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + + + + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + XSRETURN(argvi); + fail: + + + + + + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_GCP) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_GCP(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_GCP" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + delete_GDAL_GCP(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPX_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_GCPX_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPX_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPX_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_GCPX_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPX_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_GCPX_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPY_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_GCPY_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPY_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPY_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_GCPY_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPY_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_GCPY_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPZ_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_GCPZ_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPZ_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPZ_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_GCPZ_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPZ_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_GCPZ_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPPixel_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_GCPPixel_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPPixel_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPPixel_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_GCPPixel_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPPixel_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_GCPPixel_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPLine_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_GCPLine_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPLine_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_GCPLine_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_GCPLine_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_GCPLine_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_GCPLine_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_Info_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_Info_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_Info_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_Info_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_Info_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_Info_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GDAL_GCP_Info_set" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_Id_get) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_Id_get(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_Id_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_Id_set) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_Id_set(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_Id_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GDAL_GCP_Id_set" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_GCPX) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_GCPX(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPX(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_GCPX) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_GCPX(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_set_GCPX" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPX(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_GCPY) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_GCPY(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPY(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_GCPY) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_GCPY(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_set_GCPY" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPY(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_GCPZ) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_GCPZ(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPZ(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_GCPZ) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_GCPZ(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_set_GCPZ" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPZ(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_GCPPixel) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_GCPPixel(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPPixel(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_GCPPixel) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_GCPPixel(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_set_GCPPixel" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPPixel(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_GCPLine) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_GCPLine(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPLine(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_GCPLine) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_GCPLine(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GDAL_GCP_set_GCPLine" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPLine(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_Info) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_Info(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Info(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_Info) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_Info(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GDAL_GCP_set_Info" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_set_Info(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_get_Id) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GDAL_GCP_get_Id(h);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_get_Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Id(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GDAL_GCP_set_Id) { + { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GDAL_GCP_set_Id(h,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GDAL_GCP_set_Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast< GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GDAL_GCP_set_Id" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_set_Id(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_GCPsToGeoTransform) { + { + int arg1 ; + GDAL_GCP *arg2 = (GDAL_GCP *) 0 ; + double *arg3 ; + int arg4 = (int) 1 ; + FALSE_IS_ERR result; + GDAL_GCP *tmpGCPList1 ; + double argout3[6] ; + int val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout3[ANY]) */ + arg3 = argout3; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: GCPsToGeoTransform(nGCPs,pGCPs,bApproxOK);"); + } + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (! (SvROK(ST(0)) && (SvTYPE(SvRV(ST(0)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(0))); + arg1 = av_len(av)+1; + tmpGCPList1 = (GDAL_GCP*) malloc(arg1*sizeof(GDAL_GCP)); + arg2 = tmpGCPList1; + for( int i = 0; i<arg1; i++ ) { + SV **sv = av_fetch(av, i, 0); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( *sv, (void**)&item, SWIGTYPE_p_GDAL_GCP, 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList1, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList1; + } + } + if (items > 1) { + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "GCPsToGeoTransform" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + } + { + CPLErrorReset(); + result = GDALGCPsToGeoTransform(arg1,(GDAL_GCP const *)arg2,arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) IF_FALSE_RETURN_NONE */ + } + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg3, 6 ); + argvi++; + } + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + + + { + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + if (result == 0 ) { + /* this is currently used only in GDALGCPsToGeoTransform + this is probably a memory leak + ST(argvi-1) is at this point an array which needs to be destr + */ + ST(argvi-1) = sv_newmortal(); + } + } + XSRETURN(argvi); + fail: + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_RasterXSize_get) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_RasterXSize_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_RasterXSize_get" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterXSize_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_RasterYSize_get) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_RasterYSize_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_RasterYSize_get" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterYSize_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_RasterCount_get) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_RasterCount_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_RasterCount_get" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterCount_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_Dataset) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_Dataset(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Dataset" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + delete_GDALDatasetShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetDriver) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDriverShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetDriver(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetDriver" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALDriverShadow *)GDALDatasetShadow_GetDriver(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetRasterBand) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Dataset_GetRasterBand(self,nBand);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetRasterBand" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Dataset_GetRasterBand" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALDatasetShadow_GetRasterBand(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALRasterBandShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetProjection) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetProjection(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjection(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetProjectionRef) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetProjectionRef(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetProjectionRef" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjectionRef(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_SetProjection) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Dataset_SetProjection(self,prj);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_SetProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Dataset_SetProjection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetProjection(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetGeoTransform) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[6] ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetGeoTransform(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetGeoTransform" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_GetGeoTransform(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 6 ); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_SetGeoTransform) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double argin2[6] ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Dataset_SetGeoTransform(self,argin);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_SetGeoTransform" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + /* %typemap(in) (double argin2[ANY]) */ + if (! (SvROK(ST(1)) && (SvTYPE(SvRV(ST(1)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + arg2 = argin2; + AV *av = (AV*)(SvRV(ST(1))); + int seq_size = av_len(av)+1; + if ( seq_size != 6 ) { + croak("argument array must have length %d",6); + SWIG_fail; + } + for (unsigned int i=0; i<6; i++) { + SV **sv = av_fetch(av, i, 0); + arg2[i] = SvNV(*sv); + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGeoTransform(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_BuildOverviews) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) "NEAREST" ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 3)) { + SWIG_croak("Usage: Dataset_BuildOverviews(self,resampling,overviewlist,pOverviews);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_BuildOverviews" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Dataset_BuildOverviews" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + if (items > 2) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + if (! (SvROK(ST(2)) && (SvTYPE(SvRV(ST(2)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(2))); + arg3 = av_len(av)-1; + arg4 = (int*) malloc(arg3*sizeof(int)); + for( int i = 0; i<arg3; i++ ) { + SV **sv = av_fetch(av, i, 0); + arg4[i] = SvIV(*sv); + } + } + } + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_BuildOverviews(arg1,(char const *)arg2,arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetGCPCount) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetGCPCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetGCPCount" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_GetGCPCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetGCPProjection) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetGCPProjection(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetGCPProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetGCPProjection(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_GetGCPs) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int *arg2 = (int *) 0 ; + GDAL_GCP **arg3 = (GDAL_GCP **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int nGCPs2 = 0 ; + GDAL_GCP *pGCPs2 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (int *nGCPs2, GDAL_GCP const **pGCPs2 ) */ + arg2 = &nGCPs2; + arg3 = &pGCPs2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_GetGCPs(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_GetGCPs" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_GetGCPs(arg1,arg2,(GDAL_GCP const **)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + AV *dict = (AV*)sv_2mortal((SV*)newAV()); + for( int i = 0; i < *arg2; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*arg3)[i].dfGCPX, + (*arg3)[i].dfGCPY, + (*arg3)[i].dfGCPZ, + (*arg3)[i].dfGCPPixel, + (*arg3)[i].dfGCPLine, + (*arg3)[i].pszInfo, + (*arg3)[i].pszId ); + SV *sv = newSV(0); + SWIG_MakePtr( sv, (void*)o, SWIGTYPE_p_GDAL_GCP, SWIG_SHADOW|SWIG_OWNER); + av_store(dict, i, sv); + } + ST(argvi) = newRV_noinc((SV*)dict); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_SetGCPs) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDAL_GCP *arg3 = (GDAL_GCP *) 0 ; + char *arg4 = (char *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + GDAL_GCP *tmpGCPList2 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: Dataset_SetGCPs(self,nGCPs,pGCPs,pszGCPProjection);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_SetGCPs" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (! (SvROK(ST(1)) && (SvTYPE(SvRV(ST(1)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(1))); + arg2 = av_len(av)+1; + tmpGCPList2 = (GDAL_GCP*) malloc(arg2*sizeof(GDAL_GCP)); + arg3 = tmpGCPList2; + for( int i = 0; i<arg2; i++ ) { + SV **sv = av_fetch(av, i, 0); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( *sv, (void**)&item, SWIGTYPE_p_GDAL_GCP, 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList2, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList2; + } + } + res4 = SWIG_AsCharPtrAndSize(ST(2), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Dataset_SetGCPs" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGCPs(arg1,arg2,(GDAL_GCP const *)arg3,(char const *)arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_FlushCache) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Dataset_FlushCache(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_FlushCache" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_FlushCache(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_AddBand) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDataType arg2 = (GDALDataType) GDT_Byte ; + char **arg3 = (char **) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 3)) { + SWIG_croak("Usage: Dataset_AddBand(self,datatype,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_AddBand" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Dataset_AddBand" "', argument " "2"" of type '" "GDALDataType""'"); + } + arg2 = static_cast< GDALDataType >(val2); + } + if (items > 2) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(2)) && (SvTYPE(SvRV(ST(2)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(2))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_AddBand(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + XSRETURN(argvi); + fail: + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Dataset_WriteRaster) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + GDALDataType *arg10 = (GDALDataType *) 0 ; + int arg11 = (int) 0 ; + int *arg12 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val8 ; + int val9 ; + int val10 ; + int argvi = 0; + dXSARGS; + + if ((items < 6) || (items > 10)) { + SWIG_croak("Usage: Dataset_WriteRaster(self,xoff,yoff,xsize,ysize,buf_len,buf_string,buf_xsize,buf_ysize,buf_type,band_list,pband_list);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dataset_WriteRaster" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Dataset_WriteRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Dataset_WriteRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Dataset_WriteRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Dataset_WriteRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + if (!SvPOK(ST(5))) { + croak("buf argument has to be binary data"); + SWIG_fail; + } + STRLEN len = SvCUR(ST(5)); + arg7 = SvPV_nolen(ST(5)); + arg6 = len; + } + if (items > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(6)) ) { + arg8 = 0; + } + else { + val8 = SvIV(ST(6)); + arg8 = (int *)&val8; + } + } + } + if (items > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(7)) ) { + arg9 = 0; + } + else { + val9 = SvIV(ST(7)); + arg9 = (int *)&val9; + } + } + } + if (items > 8) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(8)) ) { + arg10 = 0; + } + else { + val10 = SvIV(ST(8)); + arg10 = (GDALDataType *)&val10; + } + } + } + if (items > 9) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + if (! (SvROK(ST(9)) && (SvTYPE(SvRV(ST(9)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(9))); + arg11 = av_len(av)-1; + arg12 = (int*) malloc(arg11*sizeof(int)); + for( int i = 0; i<arg11; i++ ) { + SV **sv = av_fetch(av, i, 0); + arg12[i] = SvIV(*sv); + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + + + + + + + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + XSRETURN(argvi); + fail: + + + + + + + + + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_XSize_get) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_XSize_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_XSize_get" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_XSize_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_YSize_get) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_YSize_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_YSize_get" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_YSize_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_DataType_get) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALDataType result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_DataType_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_DataType_get" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALDataType)GDALRasterBandShadow_DataType_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetRasterColorInterpretation) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetRasterColorInterpretation(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetRasterColorInterpretation" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALColorInterp)GDALRasterBandShadow_GetRasterColorInterpretation(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_SetRasterColorInterpretation) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Band_SetRasterColorInterpretation(self,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_SetRasterColorInterpretation" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_SetRasterColorInterpretation" "', argument " "2"" of type '" "GDALColorInterp""'"); + } + arg2 = static_cast< GDALColorInterp >(val2); + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetRasterColorInterpretation(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetNoDataValue) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double tmpval2 ; + int tmphasval2 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetNoDataValue(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetNoDataValue" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetNoDataValue(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double *val, int *hasval) */ + ST(argvi) = sv_newmortal(); + if ( *arg3 ) + sv_setnv(ST(argvi), *arg2); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_SetNoDataValue) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Band_SetNoDataValue(self,d);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_SetNoDataValue" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_SetNoDataValue" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetNoDataValue(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetMinimum) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double tmpval2 ; + int tmphasval2 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetMinimum(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetMinimum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetMinimum(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double *val, int *hasval) */ + ST(argvi) = sv_newmortal(); + if ( *arg3 ) + sv_setnv(ST(argvi), *arg2); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetMaximum) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double tmpval2 ; + int tmphasval2 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetMaximum(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetMaximum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetMaximum(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double *val, int *hasval) */ + ST(argvi) = sv_newmortal(); + if ( *arg3 ) + sv_setnv(ST(argvi), *arg2); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetOffset) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double tmpval2 ; + int tmphasval2 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetOffset(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetOffset" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetOffset(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double *val, int *hasval) */ + ST(argvi) = sv_newmortal(); + if ( *arg3 ) + sv_setnv(ST(argvi), *arg2); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetScale) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double tmpval2 ; + int tmphasval2 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double *val, int *hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetScale(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetScale" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetScale(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double *val, int *hasval) */ + ST(argvi) = sv_newmortal(); + if ( *arg3 ) + sv_setnv(ST(argvi), *arg2); + argvi++; + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetOverviewCount) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetOverviewCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetOverviewCount" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_GetOverviewCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetOverview) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Band_GetOverview(self,i);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetOverview" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_GetOverview" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALRasterBandShadow_GetOverview(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALRasterBandShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_Checksum) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 = (int) 0 ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int val5 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 5)) { + SWIG_croak("Usage: Band_Checksum(self,xoff,yoff,xsize,ysize);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_Checksum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_Checksum" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Band_Checksum" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + if (items > 3) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(3)) ) { + arg4 = 0; + } + else { + val4 = SvIV(ST(3)); + arg4 = (int *)&val4; + } + } + } + if (items > 4) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(4)) ) { + arg5 = 0; + } + else { + val5 = SvIV(ST(4)); + arg5 = (int *)&val5; + } + } + } + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_Checksum(arg1,arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_ComputeRasterMinMax) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[2] ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Band_ComputeRasterMinMax(self,approx_ok);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_ComputeRasterMinMax" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + if (items > 1) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Band_ComputeRasterMinMax" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + GDALRasterBandShadow_ComputeRasterMinMax(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 2 ); + argvi++; + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_Fill) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + double arg3 = (double) 0.0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Band_Fill(self,real_fill,imag_fill);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_Fill" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_Fill" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + if (items > 2) { + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Band_Fill" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_Fill(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_ReadRaster) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 = (int *) 0 ; + char **arg7 = (char **) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int nLen6 = 0 ; + char *pBuf6 = 0 ; + int val8 ; + int val9 ; + int val10 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (int *nLen6, char **pBuf6 ) */ + arg6 = &nLen6; + arg7 = &pBuf6; + } + if ((items < 5) || (items > 8)) { + SWIG_croak("Usage: Band_ReadRaster(self,xoff,yoff,xsize,ysize,buf_xsize,buf_ysize,buf_type);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_ReadRaster" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_ReadRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Band_ReadRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Band_ReadRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Band_ReadRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + if (items > 5) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(5)) ) { + arg8 = 0; + } + else { + val8 = SvIV(ST(5)); + arg8 = (int *)&val8; + } + } + } + if (items > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(6)) ) { + arg9 = 0; + } + else { + val9 = SvIV(ST(6)); + arg9 = (int *)&val9; + } + } + } + if (items > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(7)) ) { + arg10 = 0; + } + else { + val10 = SvIV(ST(7)); + arg10 = (int *)&val10; + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_ReadRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + ST(argvi) = sv_2mortal(newSVpv( *arg7, *arg6 )); + argvi++; + } + + + + + + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + + + + XSRETURN(argvi); + fail: + + + + + + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_WriteRaster) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val8 ; + int val9 ; + int val10 ; + int argvi = 0; + dXSARGS; + + if ((items < 6) || (items > 9)) { + SWIG_croak("Usage: Band_WriteRaster(self,xoff,yoff,xsize,ysize,buf_len,buf_string,buf_xsize,buf_ysize,buf_type);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_WriteRaster" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Band_WriteRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Band_WriteRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Band_WriteRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast< int >(val4); + ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Band_WriteRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast< int >(val5); + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + if (!SvPOK(ST(5))) { + croak("buf argument has to be binary data"); + SWIG_fail; + } + STRLEN len = SvCUR(ST(5)); + arg7 = SvPV_nolen(ST(5)); + arg6 = len; + } + if (items > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(6)) ) { + arg8 = 0; + } + else { + val8 = SvIV(ST(6)); + arg8 = (int *)&val8; + } + } + } + if (items > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(7)) ) { + arg9 = 0; + } + else { + val9 = SvIV(ST(7)); + arg9 = (int *)&val9; + } + } + } + if (items > 8) { + { + /* %typemap(in) (int *optional_int) */ + if ( !SvOK(ST(8)) ) { + arg10 = 0; + } + else { + val10 = SvIV(ST(8)); + arg10 = (int *)&val10; + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + ST(argvi) = sv_2mortal(newSViv(result)); + argvi++; + } + + + + + + + + + XSRETURN(argvi); + fail: + + + + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_FlushCache) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_FlushCache(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_FlushCache" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_FlushCache(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_GetRasterColorTable) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Band_GetRasterColorTable(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_GetRasterColorTable" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALColorTable *)GDALRasterBandShadow_GetRasterColorTable(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorTable, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Band_SetRasterColorTable) { + { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *arg2 = (GDALColorTable *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Band_SetRasterColorTable(self,arg);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Band_SetRasterColorTable" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Band_SetRasterColorTable" "', argument " "2"" of type '" "GDALColorTable *""'"); + } + arg2 = reinterpret_cast< GDALColorTable * >(argp2); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_SetRasterColorTable(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_ColorTable) { + { + GDALPaletteInterp arg1 = (GDALPaletteInterp) GPI_RGB ; + GDALColorTable *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 1)) { + SWIG_croak("Usage: new_ColorTable(GDALPaletteInterp);"); + } + if (items > 0) { + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_ColorTable" "', argument " "1"" of type '" "GDALPaletteInterp""'"); + } + arg1 = static_cast< GDALPaletteInterp >(val1); + } + { + CPLErrorReset(); + result = (GDALColorTable *)new GDALColorTable(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorTable, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_ColorTable) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_ColorTable(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ColorTable" "', argument " "1"" of type '" "GDALColorTable *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + { + CPLErrorReset(); + delete arg1; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_Clone) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALColorTable *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ColorTable_Clone(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_Clone" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (GDALColorTable *)((GDALColorTable const *)arg1)->Clone(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorTable, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_GetPaletteInterpretation) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALPaletteInterp result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ColorTable_GetPaletteInterpretation(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_GetPaletteInterpretation" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (GDALPaletteInterp)((GDALColorTable const *)arg1)->GetPaletteInterpretation(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_GetCount) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ColorTable_GetCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_GetCount" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryCount(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_GetColorEntry) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ColorTable_GetColorEntry(self,int);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_GetColorEntry" "', argument " "1"" of type '" "GDALColorTable *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ColorTable_GetColorEntry" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (GDALColorEntry *)(arg1)->GetColorEntry(arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) GDALColorEntry* */ + if (result == NULL) + croak("GetColorEntry failed at index %i",result); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c1); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c2); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c3); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) result->c4); + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_GetColorEntryAsRGB) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + GDALColorEntry e3 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) GDALColorEntry*(GDALColorEntry e3) */ + arg3 = &e3; + } + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: ColorTable_GetColorEntryAsRGB(self,int);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_GetColorEntryAsRGB" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ColorTable_GetColorEntryAsRGB" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryAsRGB(arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + { + /* %typemap(argout) GDALColorEntry* */ + if (result == FALSE) + croak("GetColorEntryAsRGB failed at index %i",result); + argvi--; + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c1); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c2); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c3); + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++), (IV) e3.c4); + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_ColorTable_SetColorEntry) { + { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + GDALColorEntry e3 ; + int argvi = 0; + SV * _saved[1] ; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: ColorTable_SetColorEntry(self,int,GDALColorEntry const *);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ColorTable_SetColorEntry" "', argument " "1"" of type '" "GDALColorTable *""'"); + } + arg1 = reinterpret_cast< GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ColorTable_SetColorEntry" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + /* %typemap(in,numinputs=1) const GDALColorEntry*(GDALColorEntry e3) */ + arg3 = &e3; + if (! (SvROK(ST(2)) && (SvTYPE(SvRV(ST(2)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(2))); + int seq_size = av_len(av); + if ( seq_size != 3 ) { + croak("color entry argument array must have length 4 (it is %i)",seq_size+1); + SWIG_fail; + } + SV **sv = av_fetch(av, 0, 0); + arg3->c1 = SvIV(*sv); + sv = av_fetch(av, 1, 0); + arg3->c2 = SvIV(*sv); + sv = av_fetch(av, 2, 0); + arg3->c3 = SvIV(*sv); + sv = av_fetch(av, 3, 0); + arg3->c4 = SvIV(*sv); + } + _saved[0] = ST(2); + { + CPLErrorReset(); + (arg1)->SetColorEntry(arg2,(GDALColorEntry const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) const GDALColorEntry* */ + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_AllRegister) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: AllRegister();"); + } + { + CPLErrorReset(); + GDALAllRegister(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetCacheMax) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetCacheMax();"); + } + { + CPLErrorReset(); + result = (int)GDALGetCacheMax(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_SetCacheMax) { + { + int arg1 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SetCacheMax(nBytes);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SetCacheMax" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + CPLErrorReset(); + GDALSetCacheMax(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetCacheUsed) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetCacheUsed();"); + } + { + CPLErrorReset(); + result = (int)GDALGetCacheUsed(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDataTypeSize) { + { + GDALDataType arg1 ; + int result; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDataTypeSize(GDALDataType);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetDataTypeSize" "', argument " "1"" of type '" "GDALDataType""'"); + } + arg1 = static_cast< GDALDataType >(val1); + { + CPLErrorReset(); + result = (int)GDALGetDataTypeSize(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataTypeIsComplex) { + { + GDALDataType arg1 ; + int result; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataTypeIsComplex(GDALDataType);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "DataTypeIsComplex" "', argument " "1"" of type '" "GDALDataType""'"); + } + arg1 = static_cast< GDALDataType >(val1); + { + CPLErrorReset(); + result = (int)GDALDataTypeIsComplex(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDataTypeName) { + { + GDALDataType arg1 ; + char *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDataTypeName(GDALDataType);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetDataTypeName" "', argument " "1"" of type '" "GDALDataType""'"); + } + arg1 = static_cast< GDALDataType >(val1); + { + CPLErrorReset(); + result = (char *)GDALGetDataTypeName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDataTypeByName) { + { + char *arg1 = (char *) 0 ; + GDALDataType result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDataTypeByName(char const *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetDataTypeByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (GDALDataType)GDALGetDataTypeByName((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_GetColorInterpretationName) { + { + GDALColorInterp arg1 ; + char *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetColorInterpretationName(GDALColorInterp);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetColorInterpretationName" "', argument " "1"" of type '" "GDALColorInterp""'"); + } + arg1 = static_cast< GDALColorInterp >(val1); + { + CPLErrorReset(); + result = (char *)GDALGetColorInterpretationName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetPaletteInterpretationName) { + { + GDALPaletteInterp arg1 ; + char *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetPaletteInterpretationName(GDALPaletteInterp);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetPaletteInterpretationName" "', argument " "1"" of type '" "GDALPaletteInterp""'"); + } + arg1 = static_cast< GDALPaletteInterp >(val1); + { + CPLErrorReset(); + result = (char *)GDALGetPaletteInterpretationName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DecToDMS) { + { + double arg1 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 2 ; + char *result = 0 ; + double val1 ; + int ecode1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: DecToDMS(double,char const *,int);"); + } + ecode1 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "DecToDMS" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DecToDMS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DecToDMS" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (char *)GDALDecToDMS(arg1,(char const *)arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_PackedDMSToDec) { + { + double arg1 ; + double result; + double val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: PackedDMSToDec(double);"); + } + ecode1 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "PackedDMSToDec" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + { + CPLErrorReset(); + result = (double)GDALPackedDMSToDec(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DecToPackedDMS) { + { + double arg1 ; + double result; + double val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DecToPackedDMS(double);"); + } + ecode1 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "DecToPackedDMS" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast< double >(val1); + { + CPLErrorReset(); + result = (double)GDALDecToPackedDMS(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_ParseXMLString) { + { + char *arg1 = (char *) 0 ; + CPLXMLNode *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: ParseXMLString(char *);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParseXMLString" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (CPLXMLNode *)CPLParseXMLString(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) (CPLXMLNode*) */ + ST(argvi) = newRV_noinc((SV*)XMLTreeToAV( result )); + argvi++; + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(ret) (CPLXMLNode*) */ + if ( result ) CPLDestroyXMLNode( result ); + } + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_SerializeXMLTree) { + { + CPLXMLNode *arg1 = (CPLXMLNode *) 0 ; + char *result = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SerializeXMLTree(xmlnode);"); + } + { + /* %typemap(in) (CPLXMLNode* xmlnode ) */ + if ( ! (SvROK(ST(0)) && (SvTYPE(SvRV(ST(0)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(0))); + arg1 = AVToXMLTree( av ); + if ( !arg1 ) SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)CPLSerializeXMLTree(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + { + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + if ( arg1 ) CPLDestroyXMLNode( arg1 ); + } + XSRETURN(argvi); + fail: + { + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + if ( arg1 ) CPLDestroyXMLNode( arg1 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriverCount) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetDriverCount();"); + } + { + CPLErrorReset(); + result = (int)GetDriverCount(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriverByName) { + { + char *arg1 = (char *) 0 ; + GDALDriverShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDriverByName(name);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetDriverByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriverByName((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriver) { + { + int arg1 ; + GDALDriverShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDriver(i);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetDriver" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriver(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Open) { + { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Open(name,eAccess);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Open" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Open" "', argument " "2"" of type '" "GDALAccess""'"); + } + arg2 = static_cast< GDALAccess >(val2); + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)Open((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_OpenShared) { + { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: OpenShared(name,eAccess);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OpenShared" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OpenShared" "', argument " "2"" of type '" "GDALAccess""'"); + } + arg2 = static_cast< GDALAccess >(val2); + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)OpenShared((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_AutoCreateWarpedVRT) { + { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + GDALResampleAlg arg4 = (GDALResampleAlg) GRA_NearestNeighbour ; + double arg5 = (double) 0.0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 5)) { + SWIG_croak("Usage: AutoCreateWarpedVRT(src_ds,src_wkt,dst_wkt,eResampleAlg,maxerror);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AutoCreateWarpedVRT" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast< GDALDatasetShadow * >(argp1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "AutoCreateWarpedVRT" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "AutoCreateWarpedVRT" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + if (items > 3) { + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "AutoCreateWarpedVRT" "', argument " "4"" of type '" "GDALResampleAlg""'"); + } + arg4 = static_cast< GDALResampleAlg >(val4); + } + if (items > 4) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "AutoCreateWarpedVRT" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)AutoCreateWarpedVRT(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + + + SWIG_croak_null(); + } +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static void *_p_GDALDriverShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDriverShadow *) x)); +} +static void *_p_GDALDatasetShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDatasetShadow *) x)); +} +static void *_p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALRasterBandShadow *) x)); +} +static swig_type_info _swigt__p_CPLErrorHandler = {"_p_CPLErrorHandler", "CPLErrorHandler *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_CPLXMLNode = {"_p_CPLXMLNode", "CPLXMLNode *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GByte = {"_p_GByte", "GByte *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALColorEntry = {"_p_GDALColorEntry", "GDALColorEntry *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALColorTable = {"_p_GDALColorTable", "GDALColorTable *", 0, 0, (void*)"gdal::ColorTable", 0}; +static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, (void*)"gdal::Dataset", 0}; +static swig_type_info _swigt__p_GDALDriverShadow = {"_p_GDALDriverShadow", "GDALDriverShadow *", 0, 0, (void*)"gdal::Driver", 0}; +static swig_type_info _swigt__p_GDALMajorObjectShadow = {"_p_GDALMajorObjectShadow", "GDALMajorObjectShadow *", 0, 0, (void*)"gdal::MajorObject", 0}; +static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, (void*)"gdal::Band", 0}; +static swig_type_info _swigt__p_GDAL_GCP = {"_p_GDAL_GCP", "GDAL_GCP *", 0, 0, (void*)"gdal::GCP", 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|GDALPaletteInterp *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_GDAL_GCP = {"_p_p_GDAL_GCP", "GDAL_GCP **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_CPLErrorHandler, + &_swigt__p_CPLXMLNode, + &_swigt__p_GByte, + &_swigt__p_GDALColorEntry, + &_swigt__p_GDALColorTable, + &_swigt__p_GDALDatasetShadow, + &_swigt__p_GDALDriverShadow, + &_swigt__p_GDALMajorObjectShadow, + &_swigt__p_GDALRasterBandShadow, + &_swigt__p_GDAL_GCP, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_GDAL_GCP, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__p_CPLErrorHandler[] = { {&_swigt__p_CPLErrorHandler, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_CPLXMLNode[] = { {&_swigt__p_CPLXMLNode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GByte[] = { {&_swigt__p_GByte, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorEntry[] = { {&_swigt__p_GDALColorEntry, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorTable[] = { {&_swigt__p_GDALColorTable, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDriverShadow[] = { {&_swigt__p_GDALDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALMajorObjectShadow[] = { {&_swigt__p_GDALMajorObjectShadow, 0, 0, 0}, {&_swigt__p_GDALDriverShadow, _p_GDALDriverShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALDatasetShadow, _p_GDALDatasetShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALRasterBandShadow, _p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDAL_GCP[] = { {&_swigt__p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDAL_GCP[] = { {&_swigt__p_p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_CPLErrorHandler, + _swigc__p_CPLXMLNode, + _swigc__p_GByte, + _swigc__p_GDALColorEntry, + _swigc__p_GDALColorTable, + _swigc__p_GDALDatasetShadow, + _swigc__p_GDALDriverShadow, + _swigc__p_GDALMajorObjectShadow, + _swigc__p_GDALRasterBandShadow, + _swigc__p_GDAL_GCP, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_GDAL_GCP, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"gdalc::UseExceptions", _wrap_UseExceptions}, +{"gdalc::DontUseExceptions", _wrap_DontUseExceptions}, +{"gdalc::Debug", _wrap_Debug}, +{"gdalc::Error", _wrap_Error}, +{"gdalc::PushErrorHandler", _wrap_PushErrorHandler}, +{"gdalc::PopErrorHandler", _wrap_PopErrorHandler}, +{"gdalc::ErrorReset", _wrap_ErrorReset}, +{"gdalc::GetLastErrorNo", _wrap_GetLastErrorNo}, +{"gdalc::GetLastErrorType", _wrap_GetLastErrorType}, +{"gdalc::GetLastErrorMsg", _wrap_GetLastErrorMsg}, +{"gdalc::PushFinderLocation", _wrap_PushFinderLocation}, +{"gdalc::PopFinderLocation", _wrap_PopFinderLocation}, +{"gdalc::FinderClean", _wrap_FinderClean}, +{"gdalc::FindFile", _wrap_FindFile}, +{"gdalc::SetConfigOption", _wrap_SetConfigOption}, +{"gdalc::GetConfigOption", _wrap_GetConfigOption}, +{"gdalc::CPLBinaryToHex", _wrap_CPLBinaryToHex}, +{"gdalc::CPLHexToBinary", _wrap_CPLHexToBinary}, +{"gdalc::MajorObject_GetDescription", _wrap_MajorObject_GetDescription}, +{"gdalc::MajorObject_SetDescription", _wrap_MajorObject_SetDescription}, +{"gdalc::MajorObject_GetMetadata", _wrap_MajorObject_GetMetadata}, +{"gdalc::MajorObject_SetMetadata", _wrap_MajorObject_SetMetadata}, +{"gdalc::Driver_ShortName_get", _wrap_Driver_ShortName_get}, +{"gdalc::Driver_LongName_get", _wrap_Driver_LongName_get}, +{"gdalc::Driver_HelpTopic_get", _wrap_Driver_HelpTopic_get}, +{"gdalc::Driver_Create", _wrap_Driver_Create}, +{"gdalc::Driver_CreateCopy", _wrap_Driver_CreateCopy}, +{"gdalc::Driver_Delete", _wrap_Driver_Delete}, +{"gdalc::GCP_GCPX_set", _wrap_GCP_GCPX_set}, +{"gdalc::GCP_GCPX_get", _wrap_GCP_GCPX_get}, +{"gdalc::GCP_GCPY_set", _wrap_GCP_GCPY_set}, +{"gdalc::GCP_GCPY_get", _wrap_GCP_GCPY_get}, +{"gdalc::GCP_GCPZ_set", _wrap_GCP_GCPZ_set}, +{"gdalc::GCP_GCPZ_get", _wrap_GCP_GCPZ_get}, +{"gdalc::GCP_GCPPixel_set", _wrap_GCP_GCPPixel_set}, +{"gdalc::GCP_GCPPixel_get", _wrap_GCP_GCPPixel_get}, +{"gdalc::GCP_GCPLine_set", _wrap_GCP_GCPLine_set}, +{"gdalc::GCP_GCPLine_get", _wrap_GCP_GCPLine_get}, +{"gdalc::GCP_Info_set", _wrap_GCP_Info_set}, +{"gdalc::GCP_Info_get", _wrap_GCP_Info_get}, +{"gdalc::GCP_Id_set", _wrap_GCP_Id_set}, +{"gdalc::GCP_Id_get", _wrap_GCP_Id_get}, +{"gdalc::new_GCP", _wrap_new_GCP}, +{"gdalc::delete_GCP", _wrap_delete_GCP}, +{"gdalc::GDAL_GCP_GCPX_get", _wrap_GDAL_GCP_GCPX_get}, +{"gdalc::GDAL_GCP_GCPX_set", _wrap_GDAL_GCP_GCPX_set}, +{"gdalc::GDAL_GCP_GCPY_get", _wrap_GDAL_GCP_GCPY_get}, +{"gdalc::GDAL_GCP_GCPY_set", _wrap_GDAL_GCP_GCPY_set}, +{"gdalc::GDAL_GCP_GCPZ_get", _wrap_GDAL_GCP_GCPZ_get}, +{"gdalc::GDAL_GCP_GCPZ_set", _wrap_GDAL_GCP_GCPZ_set}, +{"gdalc::GDAL_GCP_GCPPixel_get", _wrap_GDAL_GCP_GCPPixel_get}, +{"gdalc::GDAL_GCP_GCPPixel_set", _wrap_GDAL_GCP_GCPPixel_set}, +{"gdalc::GDAL_GCP_GCPLine_get", _wrap_GDAL_GCP_GCPLine_get}, +{"gdalc::GDAL_GCP_GCPLine_set", _wrap_GDAL_GCP_GCPLine_set}, +{"gdalc::GDAL_GCP_Info_get", _wrap_GDAL_GCP_Info_get}, +{"gdalc::GDAL_GCP_Info_set", _wrap_GDAL_GCP_Info_set}, +{"gdalc::GDAL_GCP_Id_get", _wrap_GDAL_GCP_Id_get}, +{"gdalc::GDAL_GCP_Id_set", _wrap_GDAL_GCP_Id_set}, +{"gdalc::GDAL_GCP_get_GCPX", _wrap_GDAL_GCP_get_GCPX}, +{"gdalc::GDAL_GCP_set_GCPX", _wrap_GDAL_GCP_set_GCPX}, +{"gdalc::GDAL_GCP_get_GCPY", _wrap_GDAL_GCP_get_GCPY}, +{"gdalc::GDAL_GCP_set_GCPY", _wrap_GDAL_GCP_set_GCPY}, +{"gdalc::GDAL_GCP_get_GCPZ", _wrap_GDAL_GCP_get_GCPZ}, +{"gdalc::GDAL_GCP_set_GCPZ", _wrap_GDAL_GCP_set_GCPZ}, +{"gdalc::GDAL_GCP_get_GCPPixel", _wrap_GDAL_GCP_get_GCPPixel}, +{"gdalc::GDAL_GCP_set_GCPPixel", _wrap_GDAL_GCP_set_GCPPixel}, +{"gdalc::GDAL_GCP_get_GCPLine", _wrap_GDAL_GCP_get_GCPLine}, +{"gdalc::GDAL_GCP_set_GCPLine", _wrap_GDAL_GCP_set_GCPLine}, +{"gdalc::GDAL_GCP_get_Info", _wrap_GDAL_GCP_get_Info}, +{"gdalc::GDAL_GCP_set_Info", _wrap_GDAL_GCP_set_Info}, +{"gdalc::GDAL_GCP_get_Id", _wrap_GDAL_GCP_get_Id}, +{"gdalc::GDAL_GCP_set_Id", _wrap_GDAL_GCP_set_Id}, +{"gdalc::GCPsToGeoTransform", _wrap_GCPsToGeoTransform}, +{"gdalc::Dataset_RasterXSize_get", _wrap_Dataset_RasterXSize_get}, +{"gdalc::Dataset_RasterYSize_get", _wrap_Dataset_RasterYSize_get}, +{"gdalc::Dataset_RasterCount_get", _wrap_Dataset_RasterCount_get}, +{"gdalc::delete_Dataset", _wrap_delete_Dataset}, +{"gdalc::Dataset_GetDriver", _wrap_Dataset_GetDriver}, +{"gdalc::Dataset_GetRasterBand", _wrap_Dataset_GetRasterBand}, +{"gdalc::Dataset_GetProjection", _wrap_Dataset_GetProjection}, +{"gdalc::Dataset_GetProjectionRef", _wrap_Dataset_GetProjectionRef}, +{"gdalc::Dataset_SetProjection", _wrap_Dataset_SetProjection}, +{"gdalc::Dataset_GetGeoTransform", _wrap_Dataset_GetGeoTransform}, +{"gdalc::Dataset_SetGeoTransform", _wrap_Dataset_SetGeoTransform}, +{"gdalc::Dataset_BuildOverviews", _wrap_Dataset_BuildOverviews}, +{"gdalc::Dataset_GetGCPCount", _wrap_Dataset_GetGCPCount}, +{"gdalc::Dataset_GetGCPProjection", _wrap_Dataset_GetGCPProjection}, +{"gdalc::Dataset_GetGCPs", _wrap_Dataset_GetGCPs}, +{"gdalc::Dataset_SetGCPs", _wrap_Dataset_SetGCPs}, +{"gdalc::Dataset_FlushCache", _wrap_Dataset_FlushCache}, +{"gdalc::Dataset_AddBand", _wrap_Dataset_AddBand}, +{"gdalc::Dataset_WriteRaster", _wrap_Dataset_WriteRaster}, +{"gdalc::Band_XSize_get", _wrap_Band_XSize_get}, +{"gdalc::Band_YSize_get", _wrap_Band_YSize_get}, +{"gdalc::Band_DataType_get", _wrap_Band_DataType_get}, +{"gdalc::Band_GetRasterColorInterpretation", _wrap_Band_GetRasterColorInterpretation}, +{"gdalc::Band_SetRasterColorInterpretation", _wrap_Band_SetRasterColorInterpretation}, +{"gdalc::Band_GetNoDataValue", _wrap_Band_GetNoDataValue}, +{"gdalc::Band_SetNoDataValue", _wrap_Band_SetNoDataValue}, +{"gdalc::Band_GetMinimum", _wrap_Band_GetMinimum}, +{"gdalc::Band_GetMaximum", _wrap_Band_GetMaximum}, +{"gdalc::Band_GetOffset", _wrap_Band_GetOffset}, +{"gdalc::Band_GetScale", _wrap_Band_GetScale}, +{"gdalc::Band_GetOverviewCount", _wrap_Band_GetOverviewCount}, +{"gdalc::Band_GetOverview", _wrap_Band_GetOverview}, +{"gdalc::Band_Checksum", _wrap_Band_Checksum}, +{"gdalc::Band_ComputeRasterMinMax", _wrap_Band_ComputeRasterMinMax}, +{"gdalc::Band_Fill", _wrap_Band_Fill}, +{"gdalc::Band_ReadRaster", _wrap_Band_ReadRaster}, +{"gdalc::Band_WriteRaster", _wrap_Band_WriteRaster}, +{"gdalc::Band_FlushCache", _wrap_Band_FlushCache}, +{"gdalc::Band_GetRasterColorTable", _wrap_Band_GetRasterColorTable}, +{"gdalc::Band_SetRasterColorTable", _wrap_Band_SetRasterColorTable}, +{"gdalc::new_ColorTable", _wrap_new_ColorTable}, +{"gdalc::delete_ColorTable", _wrap_delete_ColorTable}, +{"gdalc::ColorTable_Clone", _wrap_ColorTable_Clone}, +{"gdalc::ColorTable_GetPaletteInterpretation", _wrap_ColorTable_GetPaletteInterpretation}, +{"gdalc::ColorTable_GetCount", _wrap_ColorTable_GetCount}, +{"gdalc::ColorTable_GetColorEntry", _wrap_ColorTable_GetColorEntry}, +{"gdalc::ColorTable_GetColorEntryAsRGB", _wrap_ColorTable_GetColorEntryAsRGB}, +{"gdalc::ColorTable_SetColorEntry", _wrap_ColorTable_SetColorEntry}, +{"gdalc::AllRegister", _wrap_AllRegister}, +{"gdalc::GetCacheMax", _wrap_GetCacheMax}, +{"gdalc::SetCacheMax", _wrap_SetCacheMax}, +{"gdalc::GetCacheUsed", _wrap_GetCacheUsed}, +{"gdalc::GetDataTypeSize", _wrap_GetDataTypeSize}, +{"gdalc::DataTypeIsComplex", _wrap_DataTypeIsComplex}, +{"gdalc::GetDataTypeName", _wrap_GetDataTypeName}, +{"gdalc::GetDataTypeByName", _wrap_GetDataTypeByName}, +{"gdalc::GetColorInterpretationName", _wrap_GetColorInterpretationName}, +{"gdalc::GetPaletteInterpretationName", _wrap_GetPaletteInterpretationName}, +{"gdalc::DecToDMS", _wrap_DecToDMS}, +{"gdalc::PackedDMSToDec", _wrap_PackedDMSToDec}, +{"gdalc::DecToPackedDMS", _wrap_DecToPackedDMS}, +{"gdalc::ParseXMLString", _wrap_ParseXMLString}, +{"gdalc::SerializeXMLTree", _wrap_SerializeXMLTree}, +{"gdalc::GetDriverCount", _wrap_GetDriverCount}, +{"gdalc::GetDriverByName", _wrap_GetDriverByName}, +{"gdalc::GetDriver", _wrap_GetDriver}, +{"gdalc::Open", _wrap_Open}, +{"gdalc::OpenShared", _wrap_OpenShared}, +{"gdalc::AutoCreateWarpedVRT", _wrap_AutoCreateWarpedVRT}, +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + + /* gdal_perl.i %init code */ + UseExceptions(); + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } + + SWIG_TypeClientData(SWIGTYPE_p_GDALMajorObjectShadow, (void*) "gdal::MajorObject"); + SWIG_TypeClientData(SWIGTYPE_p_GDALDriverShadow, (void*) "gdal::Driver"); + SWIG_TypeClientData(SWIGTYPE_p_GDAL_GCP, (void*) "gdal::GCP"); + SWIG_TypeClientData(SWIGTYPE_p_GDALDatasetShadow, (void*) "gdal::Dataset"); + SWIG_TypeClientData(SWIGTYPE_p_GDALRasterBandShadow, (void*) "gdal::Band"); + SWIG_TypeClientData(SWIGTYPE_p_GDALColorTable, (void*) "gdal::ColorTable"); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/Utilities/GDAL/swig/perl/gdalconst.pm b/Utilities/GDAL/swig/perl/gdalconst.pm new file mode 100644 index 0000000000..c3b6e6cd91 --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdalconst.pm @@ -0,0 +1,126 @@ +# This file was created automatically by SWIG 1.3.29. +# Don't modify this file, modify the SWIG interface instead. +package gdalconst; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +package gdalconstc; +bootstrap gdalconst; +package gdalconst; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package gdalconst; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); +} + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package gdalconst; + + +# ------- VARIABLE STUBS -------- + +package gdalconst; + +*GDT_Unknown = *gdalconstc::GDT_Unknown; +*GDT_Byte = *gdalconstc::GDT_Byte; +*GDT_UInt16 = *gdalconstc::GDT_UInt16; +*GDT_Int16 = *gdalconstc::GDT_Int16; +*GDT_UInt32 = *gdalconstc::GDT_UInt32; +*GDT_Int32 = *gdalconstc::GDT_Int32; +*GDT_Float32 = *gdalconstc::GDT_Float32; +*GDT_Float64 = *gdalconstc::GDT_Float64; +*GDT_CInt16 = *gdalconstc::GDT_CInt16; +*GDT_CInt32 = *gdalconstc::GDT_CInt32; +*GDT_CFloat32 = *gdalconstc::GDT_CFloat32; +*GDT_CFloat64 = *gdalconstc::GDT_CFloat64; +*GDT_TypeCount = *gdalconstc::GDT_TypeCount; +*GA_ReadOnly = *gdalconstc::GA_ReadOnly; +*GA_Update = *gdalconstc::GA_Update; +*GF_Read = *gdalconstc::GF_Read; +*GF_Write = *gdalconstc::GF_Write; +*GCI_Undefined = *gdalconstc::GCI_Undefined; +*GCI_GrayIndex = *gdalconstc::GCI_GrayIndex; +*GCI_PaletteIndex = *gdalconstc::GCI_PaletteIndex; +*GCI_RedBand = *gdalconstc::GCI_RedBand; +*GCI_GreenBand = *gdalconstc::GCI_GreenBand; +*GCI_BlueBand = *gdalconstc::GCI_BlueBand; +*GCI_AlphaBand = *gdalconstc::GCI_AlphaBand; +*GCI_HueBand = *gdalconstc::GCI_HueBand; +*GCI_SaturationBand = *gdalconstc::GCI_SaturationBand; +*GCI_LightnessBand = *gdalconstc::GCI_LightnessBand; +*GCI_CyanBand = *gdalconstc::GCI_CyanBand; +*GCI_MagentaBand = *gdalconstc::GCI_MagentaBand; +*GCI_YellowBand = *gdalconstc::GCI_YellowBand; +*GCI_BlackBand = *gdalconstc::GCI_BlackBand; +*GRA_NearestNeighbour = *gdalconstc::GRA_NearestNeighbour; +*GRA_Bilinear = *gdalconstc::GRA_Bilinear; +*GRA_Cubic = *gdalconstc::GRA_Cubic; +*GRA_CubicSpline = *gdalconstc::GRA_CubicSpline; +*GPI_Gray = *gdalconstc::GPI_Gray; +*GPI_RGB = *gdalconstc::GPI_RGB; +*GPI_CMYK = *gdalconstc::GPI_CMYK; +*GPI_HLS = *gdalconstc::GPI_HLS; +*CXT_Element = *gdalconstc::CXT_Element; +*CXT_Text = *gdalconstc::CXT_Text; +*CXT_Attribute = *gdalconstc::CXT_Attribute; +*CXT_Comment = *gdalconstc::CXT_Comment; +*CXT_Literal = *gdalconstc::CXT_Literal; +*CE_None = *gdalconstc::CE_None; +*CE_Debug = *gdalconstc::CE_Debug; +*CE_Warning = *gdalconstc::CE_Warning; +*CE_Failure = *gdalconstc::CE_Failure; +*CE_Fatal = *gdalconstc::CE_Fatal; +*CPLE_None = *gdalconstc::CPLE_None; +*CPLE_AppDefined = *gdalconstc::CPLE_AppDefined; +*CPLE_OutOfMemory = *gdalconstc::CPLE_OutOfMemory; +*CPLE_FileIO = *gdalconstc::CPLE_FileIO; +*CPLE_OpenFailed = *gdalconstc::CPLE_OpenFailed; +*CPLE_IllegalArg = *gdalconstc::CPLE_IllegalArg; +*CPLE_NotSupported = *gdalconstc::CPLE_NotSupported; +*CPLE_AssertionFailed = *gdalconstc::CPLE_AssertionFailed; +*CPLE_NoWriteAccess = *gdalconstc::CPLE_NoWriteAccess; +*CPLE_UserInterrupt = *gdalconstc::CPLE_UserInterrupt; +*DMD_LONGNAME = *gdalconstc::DMD_LONGNAME; +*DMD_HELPTOPIC = *gdalconstc::DMD_HELPTOPIC; +*DMD_MIMETYPE = *gdalconstc::DMD_MIMETYPE; +*DMD_EXTENSION = *gdalconstc::DMD_EXTENSION; +*DMD_CREATIONOPTIONLIST = *gdalconstc::DMD_CREATIONOPTIONLIST; +*DMD_CREATIONDATATYPES = *gdalconstc::DMD_CREATIONDATATYPES; +*DCAP_CREATE = *gdalconstc::DCAP_CREATE; +*DCAP_CREATECOPY = *gdalconstc::DCAP_CREATECOPY; +*CPLES_BackslashQuotable = *gdalconstc::CPLES_BackslashQuotable; +*CPLES_XML = *gdalconstc::CPLES_XML; +*CPLES_URL = *gdalconstc::CPLES_URL; +*CPLES_SQL = *gdalconstc::CPLES_SQL; +*CPLES_CSV = *gdalconstc::CPLES_CSV; +1; diff --git a/Utilities/GDAL/swig/perl/gdalconst.pod b/Utilities/GDAL/swig/perl/gdalconst.pod new file mode 100644 index 0000000000..a6695c81c4 --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdalconst.pod @@ -0,0 +1,216 @@ +=head1 NAME + +gdalconst - A part of the Perl interface to the GDAL library. + +=head1 SYNOPSIS + + use gdalconst; + +=head1 ABSTRACT + +This module is a part of the Perl bindings to the GDAL library. The +GDAL modules allows you to access and manipulate from Perl all +geospatial data that the installed GDAL library is configured to +read/write. + +=head1 STATUS + +This module is beta quality. As most of the names and calling +conventions come directly from the underlying GDAL library they are +quite stable and will continue to work like the do now. However, many +things could, should, and will be made more perlish. + +Generally, those methods which are documented, have been tested. If +the method or constructor you are looking for is not documented, +perhaps there is another way of doing what you want to do. + +=head1 CONSTANTS + +Access as $gdalconst::<constant> + +=over + +=item GDT_Unknown + +=item GDT_Byte + +=item GDT_UInt16 + +=item GDT_Int16 + +=item GDT_UInt32 + +=item GDT_Int32 + +=item GDT_Float32 + +=item GDT_Float64 + +=item GDT_CInt16 + +=item GDT_CInt32 + +=item GDT_CFloat32 + +=item GDT_CFloat64 + +=item GDT_TypeCount + +=item GA_ReadOnly + +=item GA_Update + +=item GF_Read + +=item GF_Write + +=item GCI_Undefined + +=item GCI_GrayIndex + +=item GCI_PaletteIndex + +=item GCI_RedBand + +=item GCI_GreenBand + +=item GCI_BlueBand + +=item GCI_AlphaBand + +=item GCI_HueBand + +=item GCI_SaturationBand + +=item GCI_LightnessBand + +=item GCI_CyanBand + +=item GCI_MagentaBand + +=item GCI_YellowBand + +=item GCI_BlackBand + +=item GRA_NearestNeighbour + +=item GRA_Bilinear + +=item GRA_Cubic + +=item GRA_CubicSpline + +=item GPI_Gray + +=item GPI_RGB + +=item GPI_CMYK + +=item GPI_HLS + +=item CXT_Element + +=item CXT_Text + +=item CXT_Attribute + +=item CXT_Comment + +=item CXT_Literal + +=item CE_None + +=item CE_Debug + +=item CE_Warning + +=item CE_Failure + +=item CE_Fatal + +=item CPLE_None + +=item CPLE_AppDefined + +=item CPLE_OutOfMemory + +=item CPLE_FileIO + +=item CPLE_OpenFailed + +=item CPLE_IllegalArg + +=item CPLE_NotSupported + +=item CPLE_AssertionFailed + +=item CPLE_NoWriteAccess + +=item CPLE_UserInterrupt + +=item DMD_LONGNAME + +=item DMD_HELPTOPIC + +=item DMD_MIMETYPE + +=item DMD_EXTENSION + +=item DMD_CREATIONOPTIONLIST + +=item DMD_CREATIONDATATYPES + +=item DCAP_CREATE + +=item DCAP_CREATECOPY + +=item CPLES_BackslashQuotable + +=item CPLES_XML + +=item CPLES_URL + +=item CPLES_SQL + +=item CPLES_CSV + +=back + +=head1 KNOWN BUGS + +These constants should be exportable. + +=head1 SEE ALSO + +L<perl>(1), L<gdal>(3pm), L<osr>(3pm), L<ogr>(3pm). + +http://www.gdal.org + +=head1 AUTHORS + +The GDAL bindings team (in alphabetical order): + +ari.jolma at tkk.fi +cfis at interserv.com +hobu at iastate.edu +kruland at ku.edu +warmerdam at pobox.com + +=head1 COPYRIGHT AND LICENSE + +Copyright 2005-2006 by the GDAL bindings team. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307 USA. diff --git a/Utilities/GDAL/swig/perl/gdalconst_wrap.c b/Utilities/GDAL/swig/perl/gdalconst_wrap.c new file mode 100644 index 0000000000..76f5cbf9c3 --- /dev/null +++ b/Utilities/GDAL/swig/perl/gdalconst_wrap.c @@ -0,0 +1,2137 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.29 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPERL +#define SWIG_CASTRANK_MODE +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include <patchlevel.h> +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include <could_not_find_Perl_patchlevel.h> +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + + +#else +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif +#endif + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc,voidptr); + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV(obj, PL_na); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XS(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +static swig_type_info *swig_types[2]; +static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_gdalconst + +#define SWIG_name "gdalconstc::boot_gdalconst" +#define SWIG_prefix "gdalconstc::" + +#define SWIGVERSION 0x010329 + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (size && carray) { + if (carray[size - 1] == 0) { + sv_setpv(obj, carray); + } else { + char *tmp = (char *)malloc((size + 1)*sizeof(char)); + memcpy(tmp, carray, size); + tmp[size] = 0; + sv_setpv(obj, tmp); + free((char*)tmp); + } + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_gdalconst_var:: +class _wrap_gdalconst_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Unknown", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Unknown))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Byte", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Byte))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_UInt16", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_UInt16))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Int16", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Int16))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_UInt32", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_UInt32))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Int32", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Int32))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Float32", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Float32))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_Float64", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_Float64))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_CInt16", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_CInt16))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_CInt32", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_CInt32))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_CFloat32", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_CFloat32))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_CFloat64", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_CFloat64))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GDT_TypeCount", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GDT_TypeCount))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GA_ReadOnly", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GA_ReadOnly))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GA_Update", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GA_Update))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GF_Read", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GF_Read))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GF_Write", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GF_Write))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_Undefined", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_Undefined))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_GrayIndex", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_GrayIndex))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_PaletteIndex", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_PaletteIndex))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_RedBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_RedBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_GreenBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_GreenBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_BlueBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_BlueBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_AlphaBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_AlphaBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_HueBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_HueBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_SaturationBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_SaturationBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_LightnessBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_LightnessBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_CyanBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_CyanBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_MagentaBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_MagentaBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_YellowBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_YellowBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GCI_BlackBand", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GCI_BlackBand))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GRA_NearestNeighbour", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GRA_NearestNeighbour))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GRA_Bilinear", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GRA_Bilinear))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GRA_Cubic", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GRA_Cubic))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GRA_CubicSpline", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GRA_CubicSpline))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GPI_Gray", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GPI_Gray))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GPI_RGB", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GPI_RGB))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GPI_CMYK", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GPI_CMYK))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "GPI_HLS", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(GPI_HLS))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CXT_Element", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CXT_Element))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CXT_Text", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CXT_Text))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CXT_Attribute", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CXT_Attribute))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CXT_Comment", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CXT_Comment))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CXT_Literal", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CXT_Literal))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CE_None", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CE_None))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CE_Debug", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CE_Debug))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CE_Warning", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CE_Warning))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CE_Failure", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CE_Failure))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CE_Fatal", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CE_Fatal))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_None", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_None))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_AppDefined", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_AppDefined))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_OutOfMemory", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_OutOfMemory))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_FileIO", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_FileIO))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_OpenFailed", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_OpenFailed))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_IllegalArg", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_IllegalArg))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_NotSupported", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_NotSupported))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_AssertionFailed", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_AssertionFailed))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_NoWriteAccess", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_NoWriteAccess))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLE_UserInterrupt", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLE_UserInterrupt))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_LONGNAME", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_LONGNAME)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_HELPTOPIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_HELPTOPIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_MIMETYPE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_MIMETYPE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_EXTENSION", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_EXTENSION)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_CREATIONOPTIONLIST", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_CREATIONOPTIONLIST)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DMD_CREATIONDATATYPES", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DMD_CREATIONDATATYPES)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DCAP_CREATE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DCAP_CREATE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "DCAP_CREATECOPY", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(GDAL_DCAP_CREATECOPY)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLES_BackslashQuotable", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLES_BackslashQuotable))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLES_XML", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLES_XML))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLES_URL", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLES_URL))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLES_SQL", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLES_SQL))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "CPLES_CSV", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1((int)(CPLES_CSV))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/Utilities/GDAL/swig/perl/index.html b/Utilities/GDAL/swig/perl/index.html new file mode 100644 index 0000000000..cc2b39b910 --- /dev/null +++ b/Utilities/GDAL/swig/perl/index.html @@ -0,0 +1,80 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + +</head> + + +<body> + +<h1>GDAL/OGR - Swig - Perl</h1> + +<h2>Installation</h2> + +This is one possible way to install the gdal and ogr libraries and the +perl bindings, with a focus on the latter and working on a +Linux. Starting in the gdal directory run +<br> +<br> +<span style="font-family: monospace;">./configure</span><br> +<span style="font-family: monospace;">make</span><br style="font-family: monospace;"> +<span style="font-family: monospace;">make install</span><br style="font-family: monospace;"> +<span style="font-family: monospace;">cd swig/perl</span><br> +running '<span style="font-family: monospace;">make generate</span>' here is suggested<br> +<span style="font-family: monospace;">make build</span><br style="font-family: monospace;"> +<span style="font-family: monospace;">make install</span><br> + +<h3>Notes:</h3> + +* The wrappers (*_wrap.cpp files) may be rebuilt (swig is required) +with the command +<pre style="margin-left: 40px;">make generate<br></pre> + +<div style="margin-left: 40px;">before "<span style="font-family: monospace;">make build</span>". In +some cases "<span style="font-family: monospace;">make +veryclean</span>" needs to be run prior to "<span style="font-family: monospace;">make generate</span>". +</div> + +<p>* Turning on debug in <span style="font-family: monospace;">./configure</span>: +</p> + +<pre style="margin-left: 40px;">export CFG=debug; ./configure<br></pre> + +<h2>Running the test code</h2> + +<pre>make test<br></pre> + +<h3>Notes:</h3> + +* The test code is not very verbose. In the case of unexpected +behavior, +you may want to run the test in verbose mode: +<pre style="margin-left: 40px;">make test VERBOSE=1<br></pre> + +* The test can be run even without installing GDAL itself +(this works in Linux, I'm not sure about other environments): +<pre style="margin-left: 40px;">export LD_LIBRARY_PATH=../../.libs; make test<br></pre> + +<h2>Using the modules</h2> + +The main documentation of the modules are generated from the pods:<br> + +<a href="gdal.pod.html">gdal</a><br> + +<a href="gdalconst.pod.html">gdalconst</a><br> + +<a href="ogr.pod.html">ogr</a><br> + +<a href="osr.pod.html">osr</a><br> + +<h3>Example: creating a vector data set</h3> + +I used this code to import a GPS track, which I created with +GPS::NMEA, into PostGIS. +<pre>use ogr;<br>my $datasource = ogr::Open('PG:dbname=gps', 1);<br>my $layer = $datasource->CreateLayer('track');<br>my $schema = $layer->GetLayerDefn();<br>my $feature = new ogr::Feature($schema);<br>$geometry = new ogr::Geometry($ogr::wkbLineString);<br>while (<STDIN>) {<br> chomp;<br> s/^\(//;<br> s/\)$//;<br> my @l = split(/,/);<br> for ($l[2],$l[4]) {<br> my $i = int;<br> $_ = $i + ($_-$i)/0.6;<br> }<br> $geometry->AddPoint($l[4],$l[2]);<br>}<br>$feature->SetGeometry($geometry);<br>$layer->CreateFeature($feature);<br>$layer->SyncToDisk;<br></pre> + + +<hr style="width: 100%; height: 2px;"><i>Copyright +2006 Ari.Jolma at tkk.fi</i> +</body> +</html> diff --git a/Utilities/GDAL/swig/perl/ogr.pm b/Utilities/GDAL/swig/perl/ogr.pm new file mode 100644 index 0000000000..38b6b6c5c8 --- /dev/null +++ b/Utilities/GDAL/swig/perl/ogr.pm @@ -0,0 +1,470 @@ +# This file was created automatically by SWIG 1.3.29. +# Don't modify this file, modify the SWIG interface instead. +package ogr; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +require osr; +package ogrc; +bootstrap ogr; +package ogr; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package ogr; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); +} + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package ogr; + +*UseExceptions = *ogrc::UseExceptions; +*DontUseExceptions = *ogrc::DontUseExceptions; +*CreateGeometryFromWkb = *ogrc::CreateGeometryFromWkb; +*CreateGeometryFromWkt = *ogrc::CreateGeometryFromWkt; +*CreateGeometryFromGML = *ogrc::CreateGeometryFromGML; +*GetDriverCount = *ogrc::GetDriverCount; +*GetOpenDSCount = *ogrc::GetOpenDSCount; +*SetGenerate_DB2_V72_BYTE_ORDER = *ogrc::SetGenerate_DB2_V72_BYTE_ORDER; +*RegisterAll = *ogrc::RegisterAll; +*GetOpenDS = *ogrc::GetOpenDS; +*Open = *ogrc::Open; +*OpenShared = *ogrc::OpenShared; +*GetDriverByName = *ogrc::GetDriverByName; +*GetDriver = *ogrc::GetDriver; + +############# Class : ogr::Driver ############## + +package ogr::Driver; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +*swig_name_get = *ogrc::Driver_name_get; +*swig_name_set = *ogrc::Driver_name_set; +*CreateDataSource = *ogrc::Driver_CreateDataSource; +*CopyDataSource = *ogrc::Driver_CopyDataSource; +*Open = *ogrc::Driver_Open; +*DeleteDataSource = *ogrc::Driver_DeleteDataSource; +*TestCapability = *ogrc::Driver_TestCapability; +*GetName = *ogrc::Driver_GetName; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::DataSource ############## + +package ogr::DataSource; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +*swig_name_get = *ogrc::DataSource_name_get; +*swig_name_set = *ogrc::DataSource_name_set; +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + ogrc::delete_DataSource($self); + delete $OWNER{$self}; + } +} + +*GetRefCount = *ogrc::DataSource_GetRefCount; +*GetSummaryRefCount = *ogrc::DataSource_GetSummaryRefCount; +*GetLayerCount = *ogrc::DataSource_GetLayerCount; +*GetDriver = *ogrc::DataSource_GetDriver; +*GetName = *ogrc::DataSource_GetName; +*DeleteLayer = *ogrc::DataSource_DeleteLayer; +*CreateLayer = *ogrc::DataSource_CreateLayer; +*CopyLayer = *ogrc::DataSource_CopyLayer; +*GetLayerByIndex = *ogrc::DataSource_GetLayerByIndex; +*GetLayerByName = *ogrc::DataSource_GetLayerByName; +*TestCapability = *ogrc::DataSource_TestCapability; +*ExecuteSQL = *ogrc::DataSource_ExecuteSQL; +*ReleaseResultSet = *ogrc::DataSource_ReleaseResultSet; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::Layer ############## + +package ogr::Layer; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +*GetRefCount = *ogrc::Layer_GetRefCount; +*SetSpatialFilter = *ogrc::Layer_SetSpatialFilter; +*SetSpatialFilterRect = *ogrc::Layer_SetSpatialFilterRect; +*GetSpatialFilter = *ogrc::Layer_GetSpatialFilter; +*SetAttributeFilter = *ogrc::Layer_SetAttributeFilter; +*ResetReading = *ogrc::Layer_ResetReading; +*GetName = *ogrc::Layer_GetName; +*GetFeature = *ogrc::Layer_GetFeature; +*GetNextFeature = *ogrc::Layer_GetNextFeature; +*SetNextByIndex = *ogrc::Layer_SetNextByIndex; +*SetFeature = *ogrc::Layer_SetFeature; +*CreateFeature = *ogrc::Layer_CreateFeature; +*DeleteFeature = *ogrc::Layer_DeleteFeature; +*SyncToDisk = *ogrc::Layer_SyncToDisk; +*GetLayerDefn = *ogrc::Layer_GetLayerDefn; +*GetFeatureCount = *ogrc::Layer_GetFeatureCount; +*GetExtent = *ogrc::Layer_GetExtent; +*TestCapability = *ogrc::Layer_TestCapability; +*CreateField = *ogrc::Layer_CreateField; +*StartTransaction = *ogrc::Layer_StartTransaction; +*CommitTransaction = *ogrc::Layer_CommitTransaction; +*RollbackTransaction = *ogrc::Layer_RollbackTransaction; +*GetSpatialRef = *ogrc::Layer_GetSpatialRef; +*GetFeatureRead = *ogrc::Layer_GetFeatureRead; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::Feature ############## + +package ogr::Feature; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + ogrc::delete_Feature($self); + delete $OWNER{$self}; + } +} + +sub new { + my $pkg = shift; + my $self = ogrc::new_Feature(@_); + bless $self, $pkg if defined($self); +} + +*GetDefnRef = *ogrc::Feature_GetDefnRef; +*SetGeometry = *ogrc::Feature_SetGeometry; +*SetGeometryDirectly = *ogrc::Feature_SetGeometryDirectly; +*GetGeometryRef = *ogrc::Feature_GetGeometryRef; +*Clone = *ogrc::Feature_Clone; +*Equal = *ogrc::Feature_Equal; +*GetFieldCount = *ogrc::Feature_GetFieldCount; +*GetFieldDefnRef = *ogrc::Feature_GetFieldDefnRef; +*GetFieldAsString = *ogrc::Feature_GetFieldAsString; +*GetFieldAsInteger = *ogrc::Feature_GetFieldAsInteger; +*GetFieldAsDouble = *ogrc::Feature_GetFieldAsDouble; +*IsFieldSet = *ogrc::Feature_IsFieldSet; +*GetFieldIndex = *ogrc::Feature_GetFieldIndex; +*GetFID = *ogrc::Feature_GetFID; +*SetFID = *ogrc::Feature_SetFID; +*DumpReadable = *ogrc::Feature_DumpReadable; +*UnsetField = *ogrc::Feature_UnsetField; +*SetField = *ogrc::Feature_SetField; +*SetFrom = *ogrc::Feature_SetFrom; +*GetStyleString = *ogrc::Feature_GetStyleString; +*SetStyleString = *ogrc::Feature_SetStyleString; +*GetFieldType = *ogrc::Feature_GetFieldType; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::FeatureDefn ############## + +package ogr::FeatureDefn; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + ogrc::delete_FeatureDefn($self); + delete $OWNER{$self}; + } +} + +sub new { + my $pkg = shift; + my $self = ogrc::new_FeatureDefn(@_); + bless $self, $pkg if defined($self); +} + +*GetName = *ogrc::FeatureDefn_GetName; +*GetFieldCount = *ogrc::FeatureDefn_GetFieldCount; +*GetFieldDefn = *ogrc::FeatureDefn_GetFieldDefn; +*GetFieldIndex = *ogrc::FeatureDefn_GetFieldIndex; +*AddFieldDefn = *ogrc::FeatureDefn_AddFieldDefn; +*GetGeomType = *ogrc::FeatureDefn_GetGeomType; +*SetGeomType = *ogrc::FeatureDefn_SetGeomType; +*GetReferenceCount = *ogrc::FeatureDefn_GetReferenceCount; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::FieldDefn ############## + +package ogr::FieldDefn; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + ogrc::delete_FieldDefn($self); + delete $OWNER{$self}; + } +} + +sub new { + my $pkg = shift; + my $self = ogrc::new_FieldDefn(@_); + bless $self, $pkg if defined($self); +} + +*GetName = *ogrc::FieldDefn_GetName; +*GetNameRef = *ogrc::FieldDefn_GetNameRef; +*SetName = *ogrc::FieldDefn_SetName; +*GetType = *ogrc::FieldDefn_GetType; +*SetType = *ogrc::FieldDefn_SetType; +*GetJustify = *ogrc::FieldDefn_GetJustify; +*SetJustify = *ogrc::FieldDefn_SetJustify; +*GetWidth = *ogrc::FieldDefn_GetWidth; +*SetWidth = *ogrc::FieldDefn_SetWidth; +*GetPrecision = *ogrc::FieldDefn_GetPrecision; +*SetPrecision = *ogrc::FieldDefn_SetPrecision; +*GetFieldTypeName = *ogrc::FieldDefn_GetFieldTypeName; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : ogr::Geometry ############## + +package ogr::Geometry; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( ogr ); +%OWNER = (); +%ITERATORS = (); +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + ogrc::delete_Geometry($self); + delete $OWNER{$self}; + } +} + +sub new { + my $pkg = shift; + my $self = ogrc::new_Geometry(@_); + bless $self, $pkg if defined($self); +} + +*ExportToWkt = *ogrc::Geometry_ExportToWkt; +*ExportToWkb = *ogrc::Geometry_ExportToWkb; +*ExportToGML = *ogrc::Geometry_ExportToGML; +*AddPoint = *ogrc::Geometry_AddPoint; +*AddGeometryDirectly = *ogrc::Geometry_AddGeometryDirectly; +*AddGeometry = *ogrc::Geometry_AddGeometry; +*Clone = *ogrc::Geometry_Clone; +*GetGeometryType = *ogrc::Geometry_GetGeometryType; +*GetGeometryName = *ogrc::Geometry_GetGeometryName; +*GetArea = *ogrc::Geometry_GetArea; +*GetPointCount = *ogrc::Geometry_GetPointCount; +*GetX = *ogrc::Geometry_GetX; +*GetY = *ogrc::Geometry_GetY; +*GetZ = *ogrc::Geometry_GetZ; +*GetGeometryCount = *ogrc::Geometry_GetGeometryCount; +*SetPoint = *ogrc::Geometry_SetPoint; +*GetGeometryRef = *ogrc::Geometry_GetGeometryRef; +*GetBoundary = *ogrc::Geometry_GetBoundary; +*ConvexHull = *ogrc::Geometry_ConvexHull; +*Buffer = *ogrc::Geometry_Buffer; +*Intersection = *ogrc::Geometry_Intersection; +*Union = *ogrc::Geometry_Union; +*Difference = *ogrc::Geometry_Difference; +*SymmetricDifference = *ogrc::Geometry_SymmetricDifference; +*Distance = *ogrc::Geometry_Distance; +*Empty = *ogrc::Geometry_Empty; +*Intersect = *ogrc::Geometry_Intersect; +*Equal = *ogrc::Geometry_Equal; +*Disjoint = *ogrc::Geometry_Disjoint; +*Touches = *ogrc::Geometry_Touches; +*Crosses = *ogrc::Geometry_Crosses; +*Within = *ogrc::Geometry_Within; +*Contains = *ogrc::Geometry_Contains; +*Overlaps = *ogrc::Geometry_Overlaps; +*TransformTo = *ogrc::Geometry_TransformTo; +*Transform = *ogrc::Geometry_Transform; +*GetSpatialReference = *ogrc::Geometry_GetSpatialReference; +*AssignSpatialReference = *ogrc::Geometry_AssignSpatialReference; +*CloseRings = *ogrc::Geometry_CloseRings; +*FlattenTo2D = *ogrc::Geometry_FlattenTo2D; +*GetEnvelope = *ogrc::Geometry_GetEnvelope; +*Centroid = *ogrc::Geometry_Centroid; +*WkbSize = *ogrc::Geometry_WkbSize; +*GetCoordinateDimension = *ogrc::Geometry_GetCoordinateDimension; +*GetDimension = *ogrc::Geometry_GetDimension; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +# ------- VARIABLE STUBS -------- + +package ogr; + +*wkb25Bit = *ogrc::wkb25Bit; +*wkbUnknown = *ogrc::wkbUnknown; +*wkbPoint = *ogrc::wkbPoint; +*wkbLineString = *ogrc::wkbLineString; +*wkbPolygon = *ogrc::wkbPolygon; +*wkbMultiPoint = *ogrc::wkbMultiPoint; +*wkbMultiLineString = *ogrc::wkbMultiLineString; +*wkbMultiPolygon = *ogrc::wkbMultiPolygon; +*wkbGeometryCollection = *ogrc::wkbGeometryCollection; +*wkbNone = *ogrc::wkbNone; +*wkbLinearRing = *ogrc::wkbLinearRing; +*wkbPoint25D = *ogrc::wkbPoint25D; +*wkbLineString25D = *ogrc::wkbLineString25D; +*wkbPolygon25D = *ogrc::wkbPolygon25D; +*wkbMultiPoint25D = *ogrc::wkbMultiPoint25D; +*wkbMultiLineString25D = *ogrc::wkbMultiLineString25D; +*wkbMultiPolygon25D = *ogrc::wkbMultiPolygon25D; +*wkbGeometryCollection25D = *ogrc::wkbGeometryCollection25D; +*OFTInteger = *ogrc::OFTInteger; +*OFTIntegerList = *ogrc::OFTIntegerList; +*OFTReal = *ogrc::OFTReal; +*OFTRealList = *ogrc::OFTRealList; +*OFTString = *ogrc::OFTString; +*OFTStringList = *ogrc::OFTStringList; +*OFTWideString = *ogrc::OFTWideString; +*OFTWideStringList = *ogrc::OFTWideStringList; +*OFTBinary = *ogrc::OFTBinary; +*OFTDate = *ogrc::OFTDate; +*OFTTime = *ogrc::OFTTime; +*OFTDateTime = *ogrc::OFTDateTime; +*OJUndefined = *ogrc::OJUndefined; +*OJLeft = *ogrc::OJLeft; +*OJRight = *ogrc::OJRight; +*wkbXDR = *ogrc::wkbXDR; +*wkbNDR = *ogrc::wkbNDR; +*OLCRandomRead = *ogrc::OLCRandomRead; +*OLCSequentialWrite = *ogrc::OLCSequentialWrite; +*OLCRandomWrite = *ogrc::OLCRandomWrite; +*OLCFastSpatialFilter = *ogrc::OLCFastSpatialFilter; +*OLCFastFeatureCount = *ogrc::OLCFastFeatureCount; +*OLCFastGetExtent = *ogrc::OLCFastGetExtent; +*OLCCreateField = *ogrc::OLCCreateField; +*OLCTransactions = *ogrc::OLCTransactions; +*OLCDeleteFeature = *ogrc::OLCDeleteFeature; +*OLCFastSetNextByIndex = *ogrc::OLCFastSetNextByIndex; +*ODsCCreateLayer = *ogrc::ODsCCreateLayer; +*ODsCDeleteLayer = *ogrc::ODsCDeleteLayer; +*ODrCCreateDataSource = *ogrc::ODrCCreateDataSource; +*ODrCDeleteDataSource = *ogrc::ODrCDeleteDataSource; +1; diff --git a/Utilities/GDAL/swig/perl/ogr.pod b/Utilities/GDAL/swig/perl/ogr.pod new file mode 100644 index 0000000000..2afee4c650 --- /dev/null +++ b/Utilities/GDAL/swig/perl/ogr.pod @@ -0,0 +1,619 @@ +=head1 NAME + +ogr - A part of the Perl interface to the GDAL library. + +=head1 SYNOPSIS + + use ogr; + +=head1 ABSTRACT + +This module is a part of the Perl bindings to the GDAL library. The +GDAL modules allows you to access and manipulate from Perl all +geospatial data that the installed GDAL library is configured to +read/write. + +=head1 STATUS + +This module is beta quality. As most of the names and calling +conventions come directly from the underlying GDAL library they are +quite stable and will continue to work like the do now. However, many +things could, should, and will be made more perlish. + +Generally, those methods which are documented, have been tested. If +the method or constructor you are looking for is not documented, +perhaps there is another way of doing what you want to do. + +=head1 PACKAGE METHODS + +Note: some arguments are optional and have a default value. This is +illustrated like this: + +SomeMethod(arg1, arg2 = 4); + +arg1 is a required argument and an example or a variable with illustrative +name is given + +arg2 is optional and if left off, will get the value 4 (in this case) + +=over + +=item CreateGeometryFromWkb + +=item CreateGeometryFromWkt + +=item CreateGeometryFromGML + +=item GetDriverCount + +=item GetOpenDSCount + +=item SetGenerate_DB2_V72_BYTE_ORDER + +=item RegisterAll + + Done by default. + +=item GetOpenDS + +=item Open + + $datasource = ogr::Open('directory', $update = 0); + +=item OpenShared + +=item GetDriverByName + +=item GetDriver + +=back + +=head1 CONSTANTS + +Access as $ogr::<constant> + +=over + +=item wkb25Bit + +=item wkbUnknown + +=item wkbPoint + +=item wkbLineString + +=item wkbPolygon + +=item wkbMultiPoint + +=item wkbMultiLineString + +=item wkbMultiPolygon + +=item wkbGeometryCollection + +=item wkbNone + +=item wkbLinearRing + +=item wkbPoint25D + +=item wkbLineString25D + +=item wkbPolygon25D + +=item wkbMultiPoint25D + +=item wkbMultiLineString25D + +=item wkbMultiPolygon25D + +=item wkbGeometryCollection25D + +=item OFTInteger + +=item OFTIntegerList + +=item OFTReal + +=item OFTRealList + +=item OFTString + +=item OFTStringList + +=item OFTWideString + +=item OFTWideStringList + +=item OFTBinary + +=item OJUndefined + +=item OJLeft + +=item OJRight + +=item wkbXDR + +=item wkbNDR + +=item OLCRandomRead + +=item OLCSequentialWrite + +=item OLCRandomWrite + +=item OLCFastSpatialFilter + +=item OLCFastFeatureCount + +=item OLCFastGetExtent + +=item OLCCreateField + +=item OLCTransactions + +=item OLCDeleteFeature + +=item OLCFastSetNextByIndex + +=item ODsCCreateLayer + +=item ODsCDeleteLayer + +=item ODrCCreateDataSource + +=item ODrCDeleteDataSource + +=back + +=head1 CLASSES + +=head2 ogr::Driver + +=over + +=item name + + $driver->{name} + +=item CreateDataSource + + $datasource = $driver->CreateDataSource('directory', + $options = []); + +=item CopyDataSource + +=item Open + +=item DeleteDataSource + +=item TestCapability + +=item GetName + +=back + +=head2 ogr::DataSource + +=over + +=item GetRefCount + +=item GetSummaryRefCount + +=item GetLayerCount + + $n = $datasource->GetLayerCount; + +=item GetName + +=item DeleteLayer + +=item CreateLayer + + $layer = $datasource->CreateLayer('layer_name', + $spatial_reference = undef, + $geom_type = $ogr::wkbUnknown, $options = []); + +layer_name is typically a filename without directory and extension or +table name. + +=item CopyLayer + +=item GetLayerByIndex + + for $i (0..$datasource->GetLayerCount-1) { + $layer = $datasource->GetLayerByIndex($i); + } + +=item GetLayerByName + + $layer = $datasource->GetLayerByName('layer_name'); + +layer_name is typically a filename without directory and extension or +table name. + +=item TestCapability + +=item ExecuteSQL + + $sql = "select * from spatial_data_table"; + $layer = $datasource->ExecuteSQL($sql); + +=item ReleaseResultSet + + $datasource->ReleaseResultSet($layer); + +Do this for all layers that have been obtained with ExecuteSQL. + +=back + +=head2 ogr::Layer + +=over + +=item GetRefCount + +=item SetSpatialFilter + +=item SetSpatialFilterRect + + @rect = ($minX, $minY, $maxX, $maxY); + $layer->SetSpatialFilterRect(@rect); + +=item GetSpatialFilter + +=item SetAttributeFilter + +=item ResetReading + + $layer->ResetReading; + while ($f = $layer->GetNextFeature()) { + ... + } + +=item GetName + +=item GetFeature + + $feature = $layer->GetFeature($i); + +=item GetNextFeature + + See above. + +=item SetNextByIndex + +=item SetFeature + +=item CreateFeature + + $layer->CreateFeature($feature); + +=item DeleteFeature + +=item SyncToDisk + + $layer->SyncToDisk; + +=item GetLayerDefn + + $schema = $layer->GetLayerDefn(); + +=item GetFeatureCount + + $n = $layer->GetFeatureCount; + +=item GetExtent + +=item TestCapability + +=item CreateField + + $column = new ogr::FieldDefn('my_field', + $ogr::OFTInteger); # an example + $layer->CreateField($column); + +=item StartTransaction + +=item CommitTransaction + +=item RollbackTransaction + +=item GetSpatialRef + +=item GetFeatureRead + +=back + +=head2 ogr::Feature + + $feature = new ogr::Feature($schema); + +=over + +=item GetDefnRef + +=item SetGeometry + + $feature->SetGeometry($geom); + +=item SetGeometryDirectly + +=item GetGeometryRef + + $geom = $feature->GetGeometryRef; + +=item Clone + +=item Equal + +=item GetFieldCount + +=item GetFieldDefnRef + +=item GetFieldAsString + + $value = $feature->GetFieldAsString($field); + +$field is either name or index. + +=item GetFieldAsInteger + + $value = $feature->GetFieldAsInteger($field); + +$field is either name or index. + +=item GetFieldAsDouble + + $value = $feature->GetFieldAsDouble($field); + +$field is either name or index + +=item IsFieldSet + +=item GetFieldIndex + +=item GetFID + +=item SetFID + +=item DumpReadable + +=item UnsetField + +=item SetField + + $feature->SetField($field_name, $value); + +or + + $feature->SetField($field_number, $value); + +=item SetFrom + +=item GetStyleString + +=item SetStyleString + +=item GetFieldType + +=back + +=head2 ogr::FeatureDefn (Schema) + +=over + +=item GetName + +=item GetFieldCount + + $n = $schema->GetFieldCount() + +=item GetFieldDefn + + $column = $schema->GetFieldDefn($i) + +=item GetFieldIndex + +=item AddFieldDefn + +=item GetGeomType + +=item SetGeomType + +=item GetReferenceCount + +=back + +=head2 ogr::FieldDefn (Column) + + $column = new ogr::FieldDefn('name', $ogr::OFTxxxx); + +=over + +=item GetName + +=item GetNameRef + +=item SetName + +=item GetType + +=item SetType + +=item GetJustify + +=item SetJustify + +=item GetWidth + +=item SetWidth + +=item GetPrecision + +=item SetPrecision + +=item GetFieldTypeName + +=back + +=head2 ogr::Geometry + + $type = $ogr::wkbPolygon; # an example + $geom = new ogr::Geometry($type); + +=over + +=item ExportToWkt + +=item ExportToWkb + +=item ExportToGML + +=item AddPoint + + $geom->AddPoint($x, $y, $z = 0); + +=item AddGeometryDirectly + +=item AddGeometry + + $geom->AddGeometry($another_geom); + +For example add a LinearRing to a Polygon. + +=item Clone + +=item GetGeometryType + +=item GetGeometryName + +=item GetArea + +=item GetPointCount + + $n = $geom->GetPointCount; + +=item GetX + + $x = $geom->GetX($i); + +=item GetY + + $y = $geom->GetY($i); + +=item GetZ + +=item GetGeometryCount + +=item SetPoint + +=item GetGeometryRef + +=item GetBoundary + +=item ConvexHull + +=item Buffer + +=item Intersection + +=item Union + +=item Difference + +=item SymmetricDifference + +=item Distance + +=item Empty + +=item Intersect + +=item Equal + +=item Disjoint + +=item Touches + +=item Crosses + +=item Within + +=item Contains + +=item Overlaps + +=item TransformTo + +=item Transform + + $geom->Transform($transformation); + +=item GetSpatialReference + +=item AssignSpatialReference + +=item CloseRings + + $geom->CloseRings; + +Defined only for LinearRings. + +=item FlattenTo2D + +=item GetEnvelope + +=item Centroid + +=item WkbSize + +=item GetCoordinateDimension + +=item GetDimension + +=back + +=head1 KNOWN BUGS + +The reference counting scheme is not yet implemented. Make sure that +parents are not deleted before their children! Use "my" a lot. Do not +give undefined/uninitialized variables to methods. + +=head1 SEE ALSO + +L<perl>(1), L<gdalconst>(3pm), L<gdal>(3pm), L<osr>(3pm). + +http://www.gdal.org + +=head1 AUTHORS + +The GDAL bindings team (in alphabetical order): + +ari.jolma at tkk.fi +cfis at interserv.com +hobu at iastate.edu +kruland at ku.edu +warmerdam at pobox.com + +=head1 COPYRIGHT AND LICENSE + +Copyright 2005-2006 by the GDAL bindings team. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307 USA. diff --git a/Utilities/GDAL/swig/perl/ogr_wrap.cpp b/Utilities/GDAL/swig/perl/ogr_wrap.cpp new file mode 100644 index 0000000000..46c8544184 --- /dev/null +++ b/Utilities/GDAL/swig/perl/ogr_wrap.cpp @@ -0,0 +1,10898 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.29 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPERL +#define SWIG_CASTRANK_MODE + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include <patchlevel.h> +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include <could_not_find_Perl_patchlevel.h> +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + + +#else +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif +#endif + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc,voidptr); + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV(obj, PL_na); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XS(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_GIntBig swig_types[0] +#define SWIGTYPE_p_OGRDataSourceShadow swig_types[1] +#define SWIGTYPE_p_OGRDriverShadow swig_types[2] +#define SWIGTYPE_p_OGRFeatureDefnShadow swig_types[3] +#define SWIGTYPE_p_OGRFeatureShadow swig_types[4] +#define SWIGTYPE_p_OGRFieldDefnShadow swig_types[5] +#define SWIGTYPE_p_OGRGeometryShadow swig_types[6] +#define SWIGTYPE_p_OGRLayerShadow swig_types[7] +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[8] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[9] +#define SWIGTYPE_p_char swig_types[10] +#define SWIGTYPE_p_double swig_types[11] +#define SWIGTYPE_p_int swig_types[12] +#define SWIGTYPE_p_p_char swig_types[13] +static swig_type_info *swig_types[15]; +static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_ogr + +#define SWIG_name "ogrc::boot_ogr" +#define SWIG_prefix "ogrc::" + +#define SWIGVERSION 0x010329 + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include <stdexcept> + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; + + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (size && carray) { + if (carray[size - 1] == 0) { + sv_setpv(obj, carray); + } else { + char *tmp = (new char[size + 1]); + memcpy(tmp, carray, size); + tmp[size] = 0; + sv_setpv(obj, tmp); + delete[] tmp; + } + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} + + +void UseExceptions() { + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_CreateDataSource(OGRDriverShadow *self,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_CopyDataSource(OGRDriverShadow *self,OGRDataSourceShadow *copy_ds,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + long v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_Open(OGRDriverShadow *self,char const *name,int update=0){ + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } +SWIGINTERN int OGRDriverShadow_DeleteDataSource(OGRDriverShadow *self,char const *name){ + return OGR_Dr_DeleteDataSource( self, name ); + } +SWIGINTERN bool OGRDriverShadow_TestCapability(OGRDriverShadow *self,char const *cap){ + return OGR_Dr_TestCapability(self, cap); + } + +SWIGINTERNINLINE SV * +SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) +{ + SV *obj = sv_newmortal(); + if (value) { + sv_setsv(obj, &PL_sv_yes); + } else { + sv_setsv(obj, &PL_sv_no); + } + return obj; +} + +SWIGINTERN char const *OGRDriverShadow_GetName(OGRDriverShadow *self){ + return OGR_Dr_GetName( self ); + } +SWIGINTERN void delete_OGRDataSourceShadow(OGRDataSourceShadow *self){ + OGRReleaseDataSource(self); + } +SWIGINTERN int OGRDataSourceShadow_GetRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetRefCount(self); + } +SWIGINTERN int OGRDataSourceShadow_GetSummaryRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetSummaryRefCount(self); + } +SWIGINTERN int OGRDataSourceShadow_GetLayerCount(OGRDataSourceShadow *self){ + return OGR_DS_GetLayerCount(self); + } +SWIGINTERN OGRDriverShadow *OGRDataSourceShadow_GetDriver(OGRDataSourceShadow *self){ + OGRDriverShadow* driver; + OGRDataSourceShadow* ds; + ds = (OGRDataSourceShadow*)OGROpen((const char *) OGR_DS_GetName(self),0,&driver); + OGRReleaseDataSource(ds); + return driver; + } +SWIGINTERN char const *OGRDataSourceShadow_GetName(OGRDataSourceShadow *self){ + return OGR_DS_GetName(self); + } +SWIGINTERN OGRErr OGRDataSourceShadow_DeleteLayer(OGRDataSourceShadow *self,int index){ + return OGR_DS_DeleteLayer(self, index); + } + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_CreateLayer(OGRDataSourceShadow *self,char const *name,OSRSpatialReferenceShadow *reference=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_CopyLayer(OGRDataSourceShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_GetLayerByIndex(OGRDataSourceShadow *self,int index=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayer(self, index); + return layer; + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_GetLayerByName(OGRDataSourceShadow *self,char const *layer_name){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayerByName(self, layer_name); + return layer; + } +SWIGINTERN bool OGRDataSourceShadow_TestCapability(OGRDataSourceShadow *self,char const *cap){ + return OGR_DS_TestCapability(self, cap); + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_ExecuteSQL(OGRDataSourceShadow *self,char const *statement,OGRGeometryShadow *geom=NULL,char const *dialect=""){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } +SWIGINTERN void OGRDataSourceShadow_ReleaseResultSet(OGRDataSourceShadow *self,OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +SWIGINTERN int OGRLayerShadow_GetRefCount(OGRLayerShadow *self){ + return OGR_L_GetRefCount(self); + } +SWIGINTERN void OGRLayerShadow_SetSpatialFilter(OGRLayerShadow *self,OGRGeometryShadow *filter){ + OGR_L_SetSpatialFilter (self, filter); + } +SWIGINTERN void OGRLayerShadow_SetSpatialFilterRect(OGRLayerShadow *self,double minx,double miny,double maxx,double maxy){ + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } +SWIGINTERN OGRGeometryShadow *OGRLayerShadow_GetSpatialFilter(OGRLayerShadow *self){ + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } +SWIGINTERN OGRErr OGRLayerShadow_SetAttributeFilter(OGRLayerShadow *self,char *filter_string){ + return OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + } +SWIGINTERN void OGRLayerShadow_ResetReading(OGRLayerShadow *self){ + OGR_L_ResetReading(self); + } +SWIGINTERN char const *OGRLayerShadow_GetName(OGRLayerShadow *self){ + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } +SWIGINTERN OGRFeatureShadow *OGRLayerShadow_GetFeature(OGRLayerShadow *self,long fid){ + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } +SWIGINTERN OGRFeatureShadow *OGRLayerShadow_GetNextFeature(OGRLayerShadow *self){ + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } +SWIGINTERN OGRErr OGRLayerShadow_SetNextByIndex(OGRLayerShadow *self,long new_index){ + return OGR_L_SetNextByIndex(self, new_index); + } +SWIGINTERN OGRErr OGRLayerShadow_SetFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_SetFeature(self, feature); + } +SWIGINTERN OGRErr OGRLayerShadow_CreateFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_CreateFeature(self, feature); + } +SWIGINTERN OGRErr OGRLayerShadow_DeleteFeature(OGRLayerShadow *self,long fid){ + return OGR_L_DeleteFeature(self, fid); + } +SWIGINTERN OGRErr OGRLayerShadow_SyncToDisk(OGRLayerShadow *self){ + return OGR_L_SyncToDisk(self); + } +SWIGINTERN OGRFeatureDefnShadow *OGRLayerShadow_GetLayerDefn(OGRLayerShadow *self){ + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } +SWIGINTERN int OGRLayerShadow_GetFeatureCount(OGRLayerShadow *self,int force=1){ + return OGR_L_GetFeatureCount(self, force); + } + +static SV * +CreateArrayFromDoubleArray( double *first, unsigned int size ) { + AV *av = (AV*)sv_2mortal((SV*)newAV()); + for( unsigned int i=0; i<size; i++ ) { + av_store(av,i,newSVnv(*first)); + ++first; + } + return newRV_noinc((SV*)av); +} + +SWIGINTERN OGRErr OGRLayerShadow_GetExtent(OGRLayerShadow *self,double argout[4],int force=1){ + return OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + } +SWIGINTERN bool OGRLayerShadow_TestCapability(OGRLayerShadow *self,char const *cap){ + return OGR_L_TestCapability(self, cap); + } +SWIGINTERN OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){ + return OGR_L_CreateField(self, field_def, approx_ok); + } +SWIGINTERN OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){ + return OGR_L_StartTransaction(self); + } +SWIGINTERN OGRErr OGRLayerShadow_CommitTransaction(OGRLayerShadow *self){ + return OGR_L_CommitTransaction(self); + } +SWIGINTERN OGRErr OGRLayerShadow_RollbackTransaction(OGRLayerShadow *self){ + return OGR_L_RollbackTransaction(self); + } +SWIGINTERN OSRSpatialReferenceShadow *OGRLayerShadow_GetSpatialRef(OGRLayerShadow *self){ + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } +SWIGINTERN GIntBig OGRLayerShadow_GetFeatureRead(OGRLayerShadow *self){ + return OGR_L_GetFeaturesRead(self); + } +SWIGINTERN void delete_OGRFeatureShadow(OGRFeatureShadow *self){ + OGR_F_Destroy(self); + } +SWIGINTERN OGRFeatureShadow *new_OGRFeatureShadow(OGRFeatureDefnShadow *feature_def=0){ + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } +SWIGINTERN OGRFeatureDefnShadow *OGRFeatureShadow_GetDefnRef(OGRFeatureShadow *self){ + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetGeometry(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometry(self, geom); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetGeometryDirectly(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometryDirectly(self, geom); + } +SWIGINTERN OGRGeometryShadow *OGRFeatureShadow_GetGeometryRef(OGRFeatureShadow *self){ + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } +SWIGINTERN OGRFeatureShadow *OGRFeatureShadow_Clone(OGRFeatureShadow *self){ + return (OGRFeatureShadow*) OGR_F_Clone(self); + } +SWIGINTERN bool OGRFeatureShadow_Equal(OGRFeatureShadow *self,OGRFeatureShadow *feature){ + return OGR_F_Equal(self, feature); + } +SWIGINTERN int OGRFeatureShadow_GetFieldCount(OGRFeatureShadow *self){ + return OGR_F_GetFieldCount(self); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN char const *OGRFeatureShadow_GetFieldAsString__SWIG_0(OGRFeatureShadow *self,int id){ + return (const char *) OGR_F_GetFieldAsString(self, id); + } +SWIGINTERN char const *OGRFeatureShadow_GetFieldAsString__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN int OGRFeatureShadow_GetFieldAsInteger__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsInteger(self, id); + } +SWIGINTERN int OGRFeatureShadow_GetFieldAsInteger__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN double OGRFeatureShadow_GetFieldAsDouble__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsDouble(self, id); + } + +SWIGINTERNINLINE SV * +SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value) +{ + SV *obj = sv_newmortal(); + sv_setnv(obj, value); + return obj; +} + +SWIGINTERN double OGRFeatureShadow_GetFieldAsDouble__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN bool OGRFeatureShadow_IsFieldSet__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_IsFieldSet(self, id); + } +SWIGINTERN bool OGRFeatureShadow_IsFieldSet__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN int OGRFeatureShadow_GetFieldIndex(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldIndex(self, name); + } +SWIGINTERN int OGRFeatureShadow_GetFID(OGRFeatureShadow *self){ + return OGR_F_GetFID(self); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetFID(OGRFeatureShadow *self,int fid){ + return OGR_F_SetFID(self, fid); + } +SWIGINTERN void OGRFeatureShadow_DumpReadable(OGRFeatureShadow *self){ + OGR_F_DumpReadable(self, NULL); + } +SWIGINTERN void OGRFeatureShadow_UnsetField__SWIG_0(OGRFeatureShadow *self,int id){ + OGR_F_UnsetField(self, id); + } +SWIGINTERN void OGRFeatureShadow_UnsetField__SWIG_1(OGRFeatureShadow *self,char const *name){ + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN void OGRFeatureShadow_SetField__SWIG_0(OGRFeatureShadow *self,int id,char const *value){ + OGR_F_SetFieldString(self, id, value); + } +SWIGINTERN void OGRFeatureShadow_SetField__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetFrom(OGRFeatureShadow *self,OGRFeatureShadow *other,int forgiving=1){ + return OGR_F_SetFrom(self, other, forgiving); + } +SWIGINTERN char const *OGRFeatureShadow_GetStyleString(OGRFeatureShadow *self){ + return (const char*) OGR_F_GetStyleString(self); + } +SWIGINTERN void OGRFeatureShadow_SetStyleString(OGRFeatureShadow *self,char const *the_string){ + OGR_F_SetStyleString(self, the_string); + } +SWIGINTERN OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } +SWIGINTERN OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } +SWIGINTERN void delete_OGRFeatureDefnShadow(OGRFeatureDefnShadow *self){ + OGR_FD_Destroy(self); + } +SWIGINTERN OGRFeatureDefnShadow *new_OGRFeatureDefnShadow(char const *name=NULL){ + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } +SWIGINTERN char const *OGRFeatureDefnShadow_GetName(OGRFeatureDefnShadow *self){ + return OGR_FD_GetName(self); + } +SWIGINTERN int OGRFeatureDefnShadow_GetFieldCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetFieldCount(self); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureDefnShadow_GetFieldDefn(OGRFeatureDefnShadow *self,int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } +SWIGINTERN int OGRFeatureDefnShadow_GetFieldIndex(OGRFeatureDefnShadow *self,char const *name){ + return OGR_FD_GetFieldIndex(self, name); + } +SWIGINTERN void OGRFeatureDefnShadow_AddFieldDefn(OGRFeatureDefnShadow *self,OGRFieldDefnShadow *defn){ + OGR_FD_AddFieldDefn(self, defn); + } +SWIGINTERN OGRwkbGeometryType OGRFeatureDefnShadow_GetGeomType(OGRFeatureDefnShadow *self){ + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } +SWIGINTERN void OGRFeatureDefnShadow_SetGeomType(OGRFeatureDefnShadow *self,OGRwkbGeometryType geom_type){ + OGR_FD_SetGeomType(self, geom_type); + } +SWIGINTERN int OGRFeatureDefnShadow_GetReferenceCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetReferenceCount(self); + } +SWIGINTERN void delete_OGRFieldDefnShadow(OGRFieldDefnShadow *self){ + OGR_Fld_Destroy(self); + } +SWIGINTERN OGRFieldDefnShadow *new_OGRFieldDefnShadow(char const *name="unnamed",OGRFieldType field_type=OFTString){ + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetName(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetNameRef(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetName(OGRFieldDefnShadow *self,char const *name){ + OGR_Fld_SetName(self, name); + } +SWIGINTERN OGRFieldType OGRFieldDefnShadow_GetType(OGRFieldDefnShadow *self){ + return OGR_Fld_GetType(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetType(OGRFieldDefnShadow *self,OGRFieldType type){ + OGR_Fld_SetType(self, type); + } +SWIGINTERN OGRJustification OGRFieldDefnShadow_GetJustify(OGRFieldDefnShadow *self){ + return OGR_Fld_GetJustify(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetJustify(OGRFieldDefnShadow *self,OGRJustification justify){ + OGR_Fld_SetJustify(self, justify); + } +SWIGINTERN int OGRFieldDefnShadow_GetWidth(OGRFieldDefnShadow *self){ + return OGR_Fld_GetWidth(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetWidth(OGRFieldDefnShadow *self,int width){ + OGR_Fld_SetWidth(self, width); + } +SWIGINTERN int OGRFieldDefnShadow_GetPrecision(OGRFieldDefnShadow *self){ + return OGR_Fld_GetPrecision(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetPrecision(OGRFieldDefnShadow *self,int precision){ + OGR_Fld_SetPrecision(self, precision); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetFieldTypeName(OGRFieldDefnShadow *self,OGRFieldType type){ + return OGR_GetFieldTypeName(type); + } + + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + + +SWIGINTERN void delete_OGRGeometryShadow(OGRGeometryShadow *self){ + OGR_G_DestroyGeometry( self ); + } +SWIGINTERN OGRGeometryShadow *new_OGRGeometryShadow(OGRwkbGeometryType type=wkbUnknown,char *wkt=0,int wkb=0,char *wkb_buf=0,char *gml=0){ + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } +SWIGINTERN OGRErr OGRGeometryShadow_ExportToWkt(OGRGeometryShadow *self,char **argout){ + return OGR_G_ExportToWkt(self, argout); + } +SWIGINTERN OGRErr OGRGeometryShadow_ExportToWkb(OGRGeometryShadow *self,int *nLen,char **pBuf,OGRwkbByteOrder byte_order=wkbXDR){ + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } +SWIGINTERN char const *OGRGeometryShadow_ExportToGML(OGRGeometryShadow *self){ + return (const char *) OGR_G_ExportToGML(self); + } +SWIGINTERN void OGRGeometryShadow_AddPoint(OGRGeometryShadow *self,double x,double y,double z=0){ + OGR_G_AddPoint( self, x, y, z ); + } +SWIGINTERN OGRErr OGRGeometryShadow_AddGeometryDirectly(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometryDirectly( self, other ); + } +SWIGINTERN OGRErr OGRGeometryShadow_AddGeometry(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometry( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Clone(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_Clone(self); + } +SWIGINTERN OGRwkbGeometryType OGRGeometryShadow_GetGeometryType(OGRGeometryShadow *self){ + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } +SWIGINTERN char const *OGRGeometryShadow_GetGeometryName(OGRGeometryShadow *self){ + return (const char *) OGR_G_GetGeometryName(self); + } +SWIGINTERN double OGRGeometryShadow_GetArea(OGRGeometryShadow *self){ + return OGR_G_GetArea(self); + } +SWIGINTERN int OGRGeometryShadow_GetPointCount(OGRGeometryShadow *self){ + return OGR_G_GetPointCount(self); + } +SWIGINTERN double OGRGeometryShadow_GetX(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetX(self, point); + } +SWIGINTERN double OGRGeometryShadow_GetY(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetY(self, point); + } +SWIGINTERN double OGRGeometryShadow_GetZ(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetZ(self, point); + } +SWIGINTERN int OGRGeometryShadow_GetGeometryCount(OGRGeometryShadow *self){ + return OGR_G_GetGeometryCount(self); + } +SWIGINTERN void OGRGeometryShadow_SetPoint(OGRGeometryShadow *self,int point,double x,double y,double z=0){ + OGR_G_SetPoint(self, point, x, y, z); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_GetGeometryRef(OGRGeometryShadow *self,int geom){ + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_GetBoundary(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_ConvexHull(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Buffer(OGRGeometryShadow *self,double distance,int quadsecs=30){ + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Intersection(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Union(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Difference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_SymmetricDifference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } +SWIGINTERN double OGRGeometryShadow_Distance(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Distance(self, other); + } +SWIGINTERN void OGRGeometryShadow_Empty(OGRGeometryShadow *self){ + OGR_G_Empty(self); + } +SWIGINTERN bool OGRGeometryShadow_Intersect(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Intersect(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Equal(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Equal(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Disjoint(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Disjoint(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Touches(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Touches(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Crosses(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Crosses(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Within(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Within(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Contains(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Contains(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Overlaps(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Overlaps(self, other); + } +SWIGINTERN OGRErr OGRGeometryShadow_TransformTo(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + return OGR_G_TransformTo(self, reference); + } +SWIGINTERN OGRErr OGRGeometryShadow_Transform(OGRGeometryShadow *self,OSRCoordinateTransformationShadow *trans){ + return OGR_G_Transform(self, trans); + } +SWIGINTERN OSRSpatialReferenceShadow *OGRGeometryShadow_GetSpatialReference(OGRGeometryShadow *self){ + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } +SWIGINTERN void OGRGeometryShadow_AssignSpatialReference(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + OGR_G_AssignSpatialReference(self, reference); + } +SWIGINTERN void OGRGeometryShadow_CloseRings(OGRGeometryShadow *self){ + OGR_G_CloseRings(self); + } +SWIGINTERN void OGRGeometryShadow_FlattenTo2D(OGRGeometryShadow *self){ + OGR_G_FlattenTo2D(self); + } +SWIGINTERN void OGRGeometryShadow_GetEnvelope(OGRGeometryShadow *self,double argout[4]){ + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Centroid(OGRGeometryShadow *self){ + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } +SWIGINTERN int OGRGeometryShadow_WkbSize(OGRGeometryShadow *self){ + return OGR_G_WkbSize(self); + } +SWIGINTERN int OGRGeometryShadow_GetCoordinateDimension(OGRGeometryShadow *self){ + return OGR_G_GetCoordinateDimension(self); + } +SWIGINTERN int OGRGeometryShadow_GetDimension(OGRGeometryShadow *self){ + return OGR_G_GetDimension(self); + } + +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + + + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } + + + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } + + + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } + + +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} + +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_ogr_var:: +class _wrap_ogr_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_UseExceptions) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: UseExceptions();"); + } + UseExceptions(); + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_DontUseExceptions) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: DontUseExceptions();"); + } + DontUseExceptions(); + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_name_get) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Driver_name_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_name_get" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDriverShadow_name_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_CreateDataSource) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Driver_CreateDataSource(self,name,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_CreateDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_CreateDataSource" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(2)) && (SvTYPE(SvRV(ST(2)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(2))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_CreateDataSource(arg1,(char const *)arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_CopyDataSource) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + OGRDataSourceShadow *arg2 = (OGRDataSourceShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 4)) { + SWIG_croak("Usage: Driver_CopyDataSource(self,copy_ds,name,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_CopyDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_CopyDataSource" "', argument " "2"" of type '" "OGRDataSourceShadow *""'"); + } + arg2 = reinterpret_cast< OGRDataSourceShadow * >(argp2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Driver_CopyDataSource" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + if (items > 3) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(3)) && (SvTYPE(SvRV(ST(3)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(3))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_CopyDataSource(arg1,arg2,(char const *)arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + XSRETURN(argvi); + fail: + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_Open) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Driver_Open(self,name,update);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_Open" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_Open" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Driver_Open" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_Open(arg1,(char const *)arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_DeleteDataSource) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Driver_DeleteDataSource(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_DeleteDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_DeleteDataSource" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRDriverShadow_DeleteDataSource(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_TestCapability) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Driver_TestCapability(self,cap);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_TestCapability" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Driver_TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRDriverShadow_TestCapability(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Driver_GetName) { + { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Driver_GetName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Driver_GetName" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast< OGRDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDriverShadow_GetName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_name_get) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_name_get(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_name_get" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDataSourceShadow_name_get(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_DataSource) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_DataSource(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DataSource" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + delete_OGRDataSourceShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetRefCount) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_GetRefCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetRefCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetRefCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetSummaryRefCount) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_GetSummaryRefCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetSummaryRefCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetSummaryRefCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetLayerCount) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_GetLayerCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetLayerCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetLayerCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetDriver) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRDriverShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_GetDriver(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetDriver" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRDriverShadow *)OGRDataSourceShadow_GetDriver(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetName) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: DataSource_GetName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetName" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDataSourceShadow_GetName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_DeleteLayer) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: DataSource_DeleteLayer(self,index);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_DeleteLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DataSource_DeleteLayer" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRDataSourceShadow_DeleteLayer(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_CreateLayer) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRwkbGeometryType arg4 = (OGRwkbGeometryType) wkbUnknown ; + char **arg5 = (char **) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 5)) { + SWIG_croak("Usage: DataSource_CreateLayer(self,name,reference,geom_type,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_CreateLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_CreateLayer" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + res3 = SWIG_ConvertPtr(ST(2), &argp3,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DataSource_CreateLayer" "', argument " "3"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg3 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp3); + } + if (items > 3) { + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "DataSource_CreateLayer" "', argument " "4"" of type '" "OGRwkbGeometryType""'"); + } + arg4 = static_cast< OGRwkbGeometryType >(val4); + } + if (items > 4) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(4)) && (SvTYPE(SvRV(ST(4)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(4))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_CreateLayer(arg1,(char const *)arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_CopyLayer) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 4)) { + SWIG_croak("Usage: DataSource_CopyLayer(self,src_layer,new_name,options);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_CopyLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_CopyLayer" "', argument " "2"" of type '" "OGRLayerShadow *""'"); + } + arg2 = reinterpret_cast< OGRLayerShadow * >(argp2); + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DataSource_CopyLayer" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + if (items > 3) { + { + /* %typemap(in) char **options */ + if ( ! (SvROK(ST(3)) && (SvTYPE(SvRV(ST(3)))==SVt_PVAV)) ) { + croak("argument is not an array ref"); + SWIG_fail; + } + AV *av = (AV*)(SvRV(ST(3))); + for (int i = 0; i < av_len(av)-1; i++) { + char *pszItem = SvPV_nolen(*(av_fetch(av, i, 0))); + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_CopyLayer(arg1,arg2,(char const *)arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | SWIG_SHADOW); argvi++ ; + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + XSRETURN(argvi); + fail: + + + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetLayerByIndex) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 = (int) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: DataSource_GetLayerByIndex(self,index);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetLayerByIndex" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DataSource_GetLayerByIndex" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByIndex(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_GetLayerByName) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: DataSource_GetLayerByName(self,layer_name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_GetLayerByName" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_GetLayerByName" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByName(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_TestCapability) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: DataSource_TestCapability(self,cap);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_TestCapability" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRDataSourceShadow_TestCapability(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_ExecuteSQL) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRGeometryShadow *arg3 = (OGRGeometryShadow *) NULL ; + char *arg4 = (char *) "" ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: DataSource_ExecuteSQL(self,statement,geom,dialect);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_ExecuteSQL" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_ExecuteSQL" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + res3 = SWIG_ConvertPtr(ST(2), &argp3,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DataSource_ExecuteSQL" "', argument " "3"" of type '" "OGRGeometryShadow *""'"); + } + arg3 = reinterpret_cast< OGRGeometryShadow * >(argp3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DataSource_ExecuteSQL" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_ExecuteSQL(arg1,(char const *)arg2,arg3,(char const *)arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + SWIG_croak_null(); + } +} + + +XS(_wrap_DataSource_ReleaseResultSet) { + { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: DataSource_ReleaseResultSet(self,layer);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DataSource_ReleaseResultSet" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast< OGRDataSourceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DataSource_ReleaseResultSet" "', argument " "2"" of type '" "OGRLayerShadow *""'"); + } + { + CPLErrorReset(); + OGRDataSourceShadow_ReleaseResultSet(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetRefCount) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetRefCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetRefCount" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRLayerShadow_GetRefCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SetSpatialFilter) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_SetSpatialFilter(self,filter);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SetSpatialFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_SetSpatialFilter" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + OGRLayerShadow_SetSpatialFilter(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SetSpatialFilterRect) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: Layer_SetSpatialFilterRect(self,minx,miny,maxx,maxy);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SetSpatialFilterRect" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_SetSpatialFilterRect" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Layer_SetSpatialFilterRect" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Layer_SetSpatialFilterRect" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Layer_SetSpatialFilterRect" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + { + CPLErrorReset(); + OGRLayerShadow_SetSpatialFilterRect(arg1,arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetSpatialFilter) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetSpatialFilter(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetSpatialFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRLayerShadow_GetSpatialFilter(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SetAttributeFilter) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_SetAttributeFilter(self,filter_string);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SetAttributeFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_SetAttributeFilter" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetAttributeFilter(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_ResetReading) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_ResetReading(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_ResetReading" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + OGRLayerShadow_ResetReading(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetName) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetName" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRLayerShadow_GetName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetFeature) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_GetFeature(self,fid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_GetFeature" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRLayerShadow_GetFeature(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetNextFeature) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetNextFeature(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetNextFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRLayerShadow_GetNextFeature(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SetNextByIndex) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_SetNextByIndex(self,new_index);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SetNextByIndex" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_SetNextByIndex" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetNextByIndex(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SetFeature) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_SetFeature(self,feature);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SetFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_SetFeature" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast< OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetFeature(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_CreateFeature) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_CreateFeature(self,feature);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_CreateFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_CreateFeature" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast< OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CreateFeature(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_DeleteFeature) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_DeleteFeature(self,fid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_DeleteFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_DeleteFeature" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_DeleteFeature(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_SyncToDisk) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_SyncToDisk(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_SyncToDisk" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SyncToDisk(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetLayerDefn) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetLayerDefn(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetLayerDefn" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)OGRLayerShadow_GetLayerDefn(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetFeatureCount) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int arg2 = (int) 1 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Layer_GetFeatureCount(self,force);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetFeatureCount" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_GetFeatureCount" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (int)OGRLayerShadow_GetFeatureCount(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetExtent) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[4] ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Layer_GetExtent(self,force);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetExtent" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + if (items > 1) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Layer_GetExtent" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_GetExtent(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 4 ); + argvi++; + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_TestCapability) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Layer_TestCapability(self,cap);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_TestCapability" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRLayerShadow_TestCapability(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_CreateField) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Layer_CreateField(self,field_def,approx_ok);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_CreateField" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Layer_CreateField" "', argument " "2"" of type '" "OGRFieldDefnShadow *""'"); + } + arg2 = reinterpret_cast< OGRFieldDefnShadow * >(argp2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Layer_CreateField" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CreateField(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_StartTransaction) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_StartTransaction(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_StartTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_StartTransaction(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_CommitTransaction) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_CommitTransaction(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_CommitTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CommitTransaction(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_RollbackTransaction) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_RollbackTransaction(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_RollbackTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_RollbackTransaction(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetSpatialRef) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OSRSpatialReferenceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetSpatialRef(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetSpatialRef" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OSRSpatialReferenceShadow *)OGRLayerShadow_GetSpatialRef(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Layer_GetFeatureRead) { + { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + GIntBig result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Layer_GetFeatureRead(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_GetFeatureRead" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast< OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = OGRLayerShadow_GetFeatureRead(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj((new GIntBig(static_cast< const GIntBig& >(result))), SWIGTYPE_p_GIntBig, SWIG_POINTER_OWN | 0); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_Feature) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_Feature(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Feature" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + delete_OGRFeatureShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_Feature) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 1)) { + SWIG_croak("Usage: new_Feature(feature_def);"); + } + if (items > 0) { + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Feature" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + } + { + CPLErrorReset(); + result = (OGRFeatureShadow *)new_OGRFeatureShadow(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetDefnRef) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_GetDefnRef(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)OGRFeatureShadow_GetDefnRef(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetGeometry) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_SetGeometry(self,geom);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetGeometry" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_SetGeometry" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetGeometryDirectly) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_SetGeometryDirectly(self,geom);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetGeometryDirectly" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_SetGeometryDirectly" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetGeometryDirectly(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetGeometryRef) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_GetGeometryRef(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetGeometryRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRFeatureShadow_GetGeometryRef(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_Clone) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_Clone(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_Clone" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRFeatureShadow_Clone(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_Equal) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_Equal(self,feature);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_Equal" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_Equal" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast< OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_Equal(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldCount) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_GetFieldCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldCount" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldDefnRef__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldDefnRef(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_GetFieldDefnRef" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldDefnRef__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldDefnRef(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldDefnRef" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldDefnRef) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldDefnRef__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldDefnRef__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_GetFieldDefnRef'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_GetFieldAsString__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsString(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_GetFieldAsString" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsString__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsString(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldAsString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsString) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsString__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsString__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_GetFieldAsString'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_GetFieldAsInteger__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsInteger(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsInteger" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_GetFieldAsInteger" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsInteger__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsInteger(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsInteger" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldAsInteger" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsInteger) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsInteger__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsInteger__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_GetFieldAsInteger'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_GetFieldAsDouble__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsDouble(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsDouble" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_GetFieldAsDouble" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsDouble__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldAsDouble(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldAsDouble" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldAsDouble" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldAsDouble) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsDouble__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldAsDouble__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_GetFieldAsDouble'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_IsFieldSet__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_IsFieldSet(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_IsFieldSet" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_IsFieldSet" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_IsFieldSet__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_IsFieldSet(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_IsFieldSet" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_IsFieldSet" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_IsFieldSet) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_IsFieldSet__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_IsFieldSet__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_IsFieldSet'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_GetFieldIndex) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldIndex(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldIndex" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldIndex" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldIndex(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFID) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_GetFID(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFID" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFID(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetFID) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_SetFID(self,fid);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetFID" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_SetFID" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetFID(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_DumpReadable) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_DumpReadable(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_DumpReadable" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + OGRFeatureShadow_DumpReadable(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_UnsetField__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_UnsetField(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_UnsetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_UnsetField" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + OGRFeatureShadow_UnsetField__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_UnsetField__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_UnsetField(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_UnsetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_UnsetField" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFeatureShadow_UnsetField__SWIG_1(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_UnsetField) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_UnsetField__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_UnsetField__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_UnsetField'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_SetField__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: Feature_SetField(self,id,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_SetField" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + /* %typemap(in) (tostring argin) */ + arg3 = SvPV_nolen( ST(2) ); + } + { + CPLErrorReset(); + OGRFeatureShadow_SetField__SWIG_0(arg1,arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetField__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: Feature_SetField(self,name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_SetField" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + /* %typemap(in) (tostring argin) */ + arg3 = SvPV_nolen( ST(2) ); + } + { + CPLErrorReset(); + OGRFeatureShadow_SetField__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetField) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 3) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 3) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_SetField__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_SetField__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_SetField'"); + XSRETURN(0); +} + + +XS(_wrap_Feature_SetFrom) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Feature_SetFrom(self,other,forgiving);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetFrom" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_SetFrom" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast< OGRFeatureShadow * >(argp2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Feature_SetFrom" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetFrom(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetStyleString) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Feature_GetStyleString(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetStyleString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetStyleString(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_SetStyleString) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_SetStyleString(self,the_string);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_SetStyleString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_SetStyleString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFeatureShadow_SetStyleString(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldType__SWIG_0) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Feature_GetFieldType(self,id);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldType" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Feature_GetFieldType" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_0(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldType__SWIG_1) { + { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: Feature_GetFieldType(self,name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Feature_GetFieldType" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Feature_GetFieldType" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Feature_GetFieldType" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + { + CPLErrorReset(); + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_Feature_GetFieldType) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if (items == 3) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(1), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + int res = SWIG_AsCharPtrAndSize(ST(2), 0, NULL, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldType__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Feature_GetFieldType__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'Feature_GetFieldType'"); + XSRETURN(0); +} + + +XS(_wrap_delete_FeatureDefn) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_FeatureDefn(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_FeatureDefn" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + delete_OGRFeatureDefnShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_FeatureDefn) { + { + char *arg1 = (char *) NULL ; + OGRFeatureDefnShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 1)) { + SWIG_croak("Usage: new_FeatureDefn(name);"); + } + if (items > 0) { + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_FeatureDefn" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)new_OGRFeatureDefnShadow((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetName) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FeatureDefn_GetName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetName" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFeatureDefnShadow_GetName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetFieldCount) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FeatureDefn_GetFieldCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetFieldCount" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetFieldCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetFieldDefn) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FeatureDefn_GetFieldDefn(self,i);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetFieldDefn" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FeatureDefn_GetFieldDefn" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureDefnShadow_GetFieldDefn(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetFieldIndex) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FeatureDefn_GetFieldIndex(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetFieldIndex" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FeatureDefn_GetFieldIndex" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetFieldIndex(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_AddFieldDefn) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FeatureDefn_AddFieldDefn(self,defn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_AddFieldDefn" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FeatureDefn_AddFieldDefn" "', argument " "2"" of type '" "OGRFieldDefnShadow *""'"); + } + arg2 = reinterpret_cast< OGRFieldDefnShadow * >(argp2); + { + CPLErrorReset(); + OGRFeatureDefnShadow_AddFieldDefn(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetGeomType) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FeatureDefn_GetGeomType(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetGeomType" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRwkbGeometryType)OGRFeatureDefnShadow_GetGeomType(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_SetGeomType) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FeatureDefn_SetGeomType(self,geom_type);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_SetGeomType" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FeatureDefn_SetGeomType" "', argument " "2"" of type '" "OGRwkbGeometryType""'"); + } + arg2 = static_cast< OGRwkbGeometryType >(val2); + { + CPLErrorReset(); + OGRFeatureDefnShadow_SetGeomType(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FeatureDefn_GetReferenceCount) { + { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FeatureDefn_GetReferenceCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FeatureDefn_GetReferenceCount" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetReferenceCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_FieldDefn) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_FieldDefn(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_FieldDefn" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + delete_OGRFieldDefnShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_FieldDefn) { + { + char *arg1 = (char *) "unnamed" ; + OGRFieldType arg2 = (OGRFieldType) OFTString ; + OGRFieldDefnShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 2)) { + SWIG_croak("Usage: new_FieldDefn(name,field_type);"); + } + if (items > 0) { + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_FieldDefn" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_FieldDefn" "', argument " "2"" of type '" "OGRFieldType""'"); + } + arg2 = static_cast< OGRFieldType >(val2); + } + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)new_OGRFieldDefnShadow((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetName) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetNameRef) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetNameRef(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetNameRef" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetNameRef(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_SetName) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_SetName(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_SetName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FieldDefn_SetName" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFieldDefnShadow_SetName(arg1,(char const *)arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetType) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetType(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetType" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFieldType)OGRFieldDefnShadow_GetType(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_SetType) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_SetType(self,type);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_SetType" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldDefn_SetType" "', argument " "2"" of type '" "OGRFieldType""'"); + } + arg2 = static_cast< OGRFieldType >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetType(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetJustify) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetJustify(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetJustify" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRJustification)OGRFieldDefnShadow_GetJustify(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_SetJustify) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_SetJustify(self,justify);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_SetJustify" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldDefn_SetJustify" "', argument " "2"" of type '" "OGRJustification""'"); + } + arg2 = static_cast< OGRJustification >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetJustify(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetWidth) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetWidth(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetWidth" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFieldDefnShadow_GetWidth(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_SetWidth) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_SetWidth(self,width);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_SetWidth" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldDefn_SetWidth" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetWidth(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetPrecision) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: FieldDefn_GetPrecision(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetPrecision" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFieldDefnShadow_GetPrecision(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_SetPrecision) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_SetPrecision(self,precision);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_SetPrecision" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldDefn_SetPrecision" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetPrecision(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_FieldDefn_GetFieldTypeName) { + { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: FieldDefn_GetFieldTypeName(self,type);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FieldDefn_GetFieldTypeName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast< OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FieldDefn_GetFieldTypeName" "', argument " "2"" of type '" "OGRFieldType""'"); + } + arg2 = static_cast< OGRFieldType >(val2); + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetFieldTypeName(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_CreateGeometryFromWkb) { + { + int arg1 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: CreateGeometryFromWkb(len,bin_string,reference);"); + } + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + if (!SvPOK(ST(0))) { + croak("buf argument has to be binary data"); + SWIG_fail; + } + STRLEN len = SvCUR(ST(0)); + arg2 = SvPV_nolen(ST(0)); + arg1 = len; + } + if (items > 1) { + res3 = SWIG_ConvertPtr(ST(1), &argp3,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CreateGeometryFromWkb" "', argument " "3"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg3 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp3); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromWkb(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_CreateGeometryFromWkt) { + { + char **arg1 = (char **) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result = 0 ; + char *val1 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: CreateGeometryFromWkt(val,reference);"); + } + { + /* %typemap(in) (char **ignorechange) */ + val1 = SvPV_nolen(ST(0)); + arg1 = &val1; + } + if (items > 1) { + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CreateGeometryFromWkt" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromWkt(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_CreateGeometryFromGML) { + { + char *arg1 = (char *) 0 ; + OGRGeometryShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: CreateGeometryFromGML(input_string);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CreateGeometryFromGML" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromGML((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_Geometry) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_Geometry(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Geometry" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + delete_OGRGeometryShadow(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_Geometry) { + { + OGRwkbGeometryType arg1 = (OGRwkbGeometryType) wkbUnknown ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + OGRGeometryShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 5)) { + SWIG_croak("Usage: new_Geometry(type,wkt,wkb,wkb_buf,gml);"); + } + if (items > 0) { + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Geometry" "', argument " "1"" of type '" "OGRwkbGeometryType""'"); + } + arg1 = static_cast< OGRwkbGeometryType >(val1); + } + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Geometry" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + } + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "new_Geometry" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "new_Geometry" "', argument " "4"" of type '" "char *""'"); + } + arg4 = buf4; + } + if (items > 4) { + res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "new_Geometry" "', argument " "5"" of type '" "char *""'"); + } + arg5 = buf5; + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)new_OGRGeometryShadow(arg1,arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_ExportToWkt) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_ExportToWkt(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_ExportToWkt" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_ExportToWkt(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_ExportToWkb) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int *arg2 = (int *) 0 ; + char **arg3 = (char **) 0 ; + OGRwkbByteOrder arg4 = (OGRwkbByteOrder) wkbXDR ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int nLen2 = 0 ; + char *pBuf2 = 0 ; + int val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (int *nLen2, char **pBuf2 ) */ + arg2 = &nLen2; + arg3 = &pBuf2; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Geometry_ExportToWkb(self,byte_order);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_ExportToWkb" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + if (items > 1) { + ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Geometry_ExportToWkb" "', argument " "4"" of type '" "OGRwkbByteOrder""'"); + } + arg4 = static_cast< OGRwkbByteOrder >(val4); + } + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_ExportToWkb(arg1,arg2,arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + ST(argvi) = sv_2mortal(newSVpv( *arg3, *arg2 )); + argvi++; + } + + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_ExportToGML) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_ExportToGML(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_ExportToGML" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRGeometryShadow_ExportToGML(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_AddPoint) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 = (double) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 4)) { + SWIG_croak("Usage: Geometry_AddPoint(self,x,y,z);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_AddPoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_AddPoint" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Geometry_AddPoint" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + if (items > 3) { + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Geometry_AddPoint" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + } + { + CPLErrorReset(); + OGRGeometryShadow_AddPoint(arg1,arg2,arg3,arg4); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_AddGeometryDirectly) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_AddGeometryDirectly(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_AddGeometryDirectly" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_AddGeometryDirectly" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_AddGeometryDirectly(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_AddGeometry) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_AddGeometry(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_AddGeometry" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_AddGeometry" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_AddGeometry(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Clone) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_Clone(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Clone" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Clone(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetGeometryType) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRwkbGeometryType result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetGeometryType(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetGeometryType" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRwkbGeometryType)OGRGeometryShadow_GetGeometryType(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetGeometryName) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetGeometryName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetGeometryName" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRGeometryShadow_GetGeometryName(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetArea) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetArea(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetArea" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetArea(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetPointCount) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetPointCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetPointCount" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetPointCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetX) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Geometry_GetX(self,point);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetX" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_GetX" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetX(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetY) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Geometry_GetY(self,point);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetY" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_GetY" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetY(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetZ) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Geometry_GetZ(self,point);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetZ" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_GetZ" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetZ(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetGeometryCount) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetGeometryCount(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetGeometryCount" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetGeometryCount(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_SetPoint) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 5)) { + SWIG_croak("Usage: Geometry_SetPoint(self,point,x,y,z);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_SetPoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_SetPoint" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Geometry_SetPoint" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Geometry_SetPoint" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + if (items > 4) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Geometry_SetPoint" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + { + CPLErrorReset(); + OGRGeometryShadow_SetPoint(arg1,arg2,arg3,arg4,arg5); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetGeometryRef) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_GetGeometryRef(self,geom);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetGeometryRef" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_GetGeometryRef" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_GetGeometryRef(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetBoundary) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetBoundary(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetBoundary" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_GetBoundary(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_ConvexHull) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_ConvexHull(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_ConvexHull" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_ConvexHull(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Buffer) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + int arg3 = (int) 30 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: Geometry_Buffer(self,distance,quadsecs);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Buffer" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Geometry_Buffer" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Geometry_Buffer" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Buffer(arg1,arg2,arg3); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Intersection) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Intersection(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Intersection" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Intersection" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Intersection(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Union) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Union(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Union" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Union" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Union(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Difference) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Difference(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Difference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Difference" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Difference(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_SymmetricDifference) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_SymmetricDifference(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_SymmetricDifference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_SymmetricDifference" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_SymmetricDifference(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Distance) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Distance(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Distance" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Distance" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_Distance(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Empty) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_Empty(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Empty" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_Empty(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Intersect) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Intersect(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Intersect" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Intersect" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Intersect(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Equal) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Equal(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Equal" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Equal" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Equal(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Disjoint) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Disjoint(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Disjoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Disjoint" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Disjoint(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Touches) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Touches(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Touches" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Touches" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Touches(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Crosses) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Crosses(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Crosses" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Crosses" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Crosses(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Within) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Within(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Within" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Within" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Within(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Contains) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Contains(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Contains" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Contains" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Contains(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Overlaps) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Overlaps(self,other);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Overlaps" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Overlaps" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast< OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Overlaps(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_TransformTo) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_TransformTo(self,reference);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_TransformTo" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_TransformTo" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_TransformTo(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Transform) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRCoordinateTransformationShadow *arg2 = (OSRCoordinateTransformationShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_Transform(self,trans);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Transform" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRCoordinateTransformationShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_Transform" "', argument " "2"" of type '" "OSRCoordinateTransformationShadow *""'"); + } + arg2 = reinterpret_cast< OSRCoordinateTransformationShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_Transform(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetSpatialReference) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetSpatialReference(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetSpatialReference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OSRSpatialReferenceShadow *)OGRGeometryShadow_GetSpatialReference(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_AssignSpatialReference) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Geometry_AssignSpatialReference(self,reference);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_AssignSpatialReference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Geometry_AssignSpatialReference" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + { + CPLErrorReset(); + OGRGeometryShadow_AssignSpatialReference(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_CloseRings) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_CloseRings(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_CloseRings" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_CloseRings(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_FlattenTo2D) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_FlattenTo2D(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_FlattenTo2D" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_FlattenTo2D(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetEnvelope) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[4] ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetEnvelope(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetEnvelope" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_GetEnvelope(arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 4 ); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_Centroid) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_Centroid(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_Centroid" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Centroid(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_WkbSize) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_WkbSize(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_WkbSize" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_WkbSize(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetCoordinateDimension) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetCoordinateDimension(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetCoordinateDimension" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetCoordinateDimension(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Geometry_GetDimension) { + { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Geometry_GetDimension(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Geometry_GetDimension" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast< OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetDimension(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriverCount) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetDriverCount();"); + } + { + CPLErrorReset(); + result = (int)OGRGetDriverCount(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetOpenDSCount) { + { + int result; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetOpenDSCount();"); + } + { + CPLErrorReset(); + result = (int)OGRGetOpenDSCount(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_SetGenerate_DB2_V72_BYTE_ORDER) { + { + int arg1 ; + OGRErr result; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SetGenerate_DB2_V72_BYTE_ORDER(bGenerate_DB2_V72_BYTE_ORDER);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "SetGenerate_DB2_V72_BYTE_ORDER" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + CPLErrorReset(); + result = (OGRErr)OGRSetGenerate_DB2_V72_BYTE_ORDER(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_RegisterAll) { + { + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: RegisterAll();"); + } + { + CPLErrorReset(); + OGRRegisterAll(); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetOpenDS) { + { + int arg1 ; + OGRDataSourceShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetOpenDS(ds_number);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetOpenDS" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)GetOpenDS(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_Open) { + { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: Open(filename,update);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Open" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Open" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)Open((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_OpenShared) { + { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: OpenShared(filename,update);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OpenShared" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (items > 1) { + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OpenShared" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OpenShared((char const *)arg1,arg2); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriverByName) { + { + char *arg1 = (char *) 0 ; + OGRDriverShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDriverByName(name);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetDriverByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (OGRDriverShadow *)GetDriverByName((char const *)arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_GetDriver) { + { + int arg1 ; + OGRDriverShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetDriver(driver_number);"); + } + ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "GetDriver" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast< int >(val1); + { + CPLErrorReset(); + result = (OGRDriverShadow *)GetDriver(arg1); + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRDataSourceShadow = {"_p_OGRDataSourceShadow", "OGRDataSourceShadow *", 0, 0, (void*)"ogr::DataSource", 0}; +static swig_type_info _swigt__p_OGRDriverShadow = {"_p_OGRDriverShadow", "OGRDriverShadow *", 0, 0, (void*)"ogr::Driver", 0}; +static swig_type_info _swigt__p_OGRFeatureDefnShadow = {"_p_OGRFeatureDefnShadow", "OGRFeatureDefnShadow *", 0, 0, (void*)"ogr::FeatureDefn", 0}; +static swig_type_info _swigt__p_OGRFeatureShadow = {"_p_OGRFeatureShadow", "OGRFeatureShadow *", 0, 0, (void*)"ogr::Feature", 0}; +static swig_type_info _swigt__p_OGRFieldDefnShadow = {"_p_OGRFieldDefnShadow", "OGRFieldDefnShadow *", 0, 0, (void*)"ogr::FieldDefn", 0}; +static swig_type_info _swigt__p_OGRGeometryShadow = {"_p_OGRGeometryShadow", "OGRGeometryShadow *", 0, 0, (void*)"ogr::Geometry", 0}; +static swig_type_info _swigt__p_OGRLayerShadow = {"_p_OGRLayerShadow", "OGRLayerShadow *", 0, 0, (void*)"ogr::Layer", 0}; +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, (void*)"osr::CoordinateTransformation", 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, (void*)"osr::SpatialReference", 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_GIntBig, + &_swigt__p_OGRDataSourceShadow, + &_swigt__p_OGRDriverShadow, + &_swigt__p_OGRFeatureDefnShadow, + &_swigt__p_OGRFeatureShadow, + &_swigt__p_OGRFieldDefnShadow, + &_swigt__p_OGRGeometryShadow, + &_swigt__p_OGRLayerShadow, + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDataSourceShadow[] = { {&_swigt__p_OGRDataSourceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDriverShadow[] = { {&_swigt__p_OGRDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureDefnShadow[] = { {&_swigt__p_OGRFeatureDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureShadow[] = { {&_swigt__p_OGRFeatureShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFieldDefnShadow[] = { {&_swigt__p_OGRFieldDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRGeometryShadow[] = { {&_swigt__p_OGRGeometryShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRLayerShadow[] = { {&_swigt__p_OGRLayerShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_GIntBig, + _swigc__p_OGRDataSourceShadow, + _swigc__p_OGRDriverShadow, + _swigc__p_OGRFeatureDefnShadow, + _swigc__p_OGRFeatureShadow, + _swigc__p_OGRFieldDefnShadow, + _swigc__p_OGRGeometryShadow, + _swigc__p_OGRLayerShadow, + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"ogrc::UseExceptions", _wrap_UseExceptions}, +{"ogrc::DontUseExceptions", _wrap_DontUseExceptions}, +{"ogrc::Driver_name_get", _wrap_Driver_name_get}, +{"ogrc::Driver_CreateDataSource", _wrap_Driver_CreateDataSource}, +{"ogrc::Driver_CopyDataSource", _wrap_Driver_CopyDataSource}, +{"ogrc::Driver_Open", _wrap_Driver_Open}, +{"ogrc::Driver_DeleteDataSource", _wrap_Driver_DeleteDataSource}, +{"ogrc::Driver_TestCapability", _wrap_Driver_TestCapability}, +{"ogrc::Driver_GetName", _wrap_Driver_GetName}, +{"ogrc::DataSource_name_get", _wrap_DataSource_name_get}, +{"ogrc::delete_DataSource", _wrap_delete_DataSource}, +{"ogrc::DataSource_GetRefCount", _wrap_DataSource_GetRefCount}, +{"ogrc::DataSource_GetSummaryRefCount", _wrap_DataSource_GetSummaryRefCount}, +{"ogrc::DataSource_GetLayerCount", _wrap_DataSource_GetLayerCount}, +{"ogrc::DataSource_GetDriver", _wrap_DataSource_GetDriver}, +{"ogrc::DataSource_GetName", _wrap_DataSource_GetName}, +{"ogrc::DataSource_DeleteLayer", _wrap_DataSource_DeleteLayer}, +{"ogrc::DataSource_CreateLayer", _wrap_DataSource_CreateLayer}, +{"ogrc::DataSource_CopyLayer", _wrap_DataSource_CopyLayer}, +{"ogrc::DataSource_GetLayerByIndex", _wrap_DataSource_GetLayerByIndex}, +{"ogrc::DataSource_GetLayerByName", _wrap_DataSource_GetLayerByName}, +{"ogrc::DataSource_TestCapability", _wrap_DataSource_TestCapability}, +{"ogrc::DataSource_ExecuteSQL", _wrap_DataSource_ExecuteSQL}, +{"ogrc::DataSource_ReleaseResultSet", _wrap_DataSource_ReleaseResultSet}, +{"ogrc::Layer_GetRefCount", _wrap_Layer_GetRefCount}, +{"ogrc::Layer_SetSpatialFilter", _wrap_Layer_SetSpatialFilter}, +{"ogrc::Layer_SetSpatialFilterRect", _wrap_Layer_SetSpatialFilterRect}, +{"ogrc::Layer_GetSpatialFilter", _wrap_Layer_GetSpatialFilter}, +{"ogrc::Layer_SetAttributeFilter", _wrap_Layer_SetAttributeFilter}, +{"ogrc::Layer_ResetReading", _wrap_Layer_ResetReading}, +{"ogrc::Layer_GetName", _wrap_Layer_GetName}, +{"ogrc::Layer_GetFeature", _wrap_Layer_GetFeature}, +{"ogrc::Layer_GetNextFeature", _wrap_Layer_GetNextFeature}, +{"ogrc::Layer_SetNextByIndex", _wrap_Layer_SetNextByIndex}, +{"ogrc::Layer_SetFeature", _wrap_Layer_SetFeature}, +{"ogrc::Layer_CreateFeature", _wrap_Layer_CreateFeature}, +{"ogrc::Layer_DeleteFeature", _wrap_Layer_DeleteFeature}, +{"ogrc::Layer_SyncToDisk", _wrap_Layer_SyncToDisk}, +{"ogrc::Layer_GetLayerDefn", _wrap_Layer_GetLayerDefn}, +{"ogrc::Layer_GetFeatureCount", _wrap_Layer_GetFeatureCount}, +{"ogrc::Layer_GetExtent", _wrap_Layer_GetExtent}, +{"ogrc::Layer_TestCapability", _wrap_Layer_TestCapability}, +{"ogrc::Layer_CreateField", _wrap_Layer_CreateField}, +{"ogrc::Layer_StartTransaction", _wrap_Layer_StartTransaction}, +{"ogrc::Layer_CommitTransaction", _wrap_Layer_CommitTransaction}, +{"ogrc::Layer_RollbackTransaction", _wrap_Layer_RollbackTransaction}, +{"ogrc::Layer_GetSpatialRef", _wrap_Layer_GetSpatialRef}, +{"ogrc::Layer_GetFeatureRead", _wrap_Layer_GetFeatureRead}, +{"ogrc::delete_Feature", _wrap_delete_Feature}, +{"ogrc::new_Feature", _wrap_new_Feature}, +{"ogrc::Feature_GetDefnRef", _wrap_Feature_GetDefnRef}, +{"ogrc::Feature_SetGeometry", _wrap_Feature_SetGeometry}, +{"ogrc::Feature_SetGeometryDirectly", _wrap_Feature_SetGeometryDirectly}, +{"ogrc::Feature_GetGeometryRef", _wrap_Feature_GetGeometryRef}, +{"ogrc::Feature_Clone", _wrap_Feature_Clone}, +{"ogrc::Feature_Equal", _wrap_Feature_Equal}, +{"ogrc::Feature_GetFieldCount", _wrap_Feature_GetFieldCount}, +{"ogrc::Feature_GetFieldDefnRef", _wrap_Feature_GetFieldDefnRef}, +{"ogrc::Feature_GetFieldAsString", _wrap_Feature_GetFieldAsString}, +{"ogrc::Feature_GetFieldAsInteger", _wrap_Feature_GetFieldAsInteger}, +{"ogrc::Feature_GetFieldAsDouble", _wrap_Feature_GetFieldAsDouble}, +{"ogrc::Feature_IsFieldSet", _wrap_Feature_IsFieldSet}, +{"ogrc::Feature_GetFieldIndex", _wrap_Feature_GetFieldIndex}, +{"ogrc::Feature_GetFID", _wrap_Feature_GetFID}, +{"ogrc::Feature_SetFID", _wrap_Feature_SetFID}, +{"ogrc::Feature_DumpReadable", _wrap_Feature_DumpReadable}, +{"ogrc::Feature_UnsetField", _wrap_Feature_UnsetField}, +{"ogrc::Feature_SetField", _wrap_Feature_SetField}, +{"ogrc::Feature_SetFrom", _wrap_Feature_SetFrom}, +{"ogrc::Feature_GetStyleString", _wrap_Feature_GetStyleString}, +{"ogrc::Feature_SetStyleString", _wrap_Feature_SetStyleString}, +{"ogrc::Feature_GetFieldType", _wrap_Feature_GetFieldType}, +{"ogrc::delete_FeatureDefn", _wrap_delete_FeatureDefn}, +{"ogrc::new_FeatureDefn", _wrap_new_FeatureDefn}, +{"ogrc::FeatureDefn_GetName", _wrap_FeatureDefn_GetName}, +{"ogrc::FeatureDefn_GetFieldCount", _wrap_FeatureDefn_GetFieldCount}, +{"ogrc::FeatureDefn_GetFieldDefn", _wrap_FeatureDefn_GetFieldDefn}, +{"ogrc::FeatureDefn_GetFieldIndex", _wrap_FeatureDefn_GetFieldIndex}, +{"ogrc::FeatureDefn_AddFieldDefn", _wrap_FeatureDefn_AddFieldDefn}, +{"ogrc::FeatureDefn_GetGeomType", _wrap_FeatureDefn_GetGeomType}, +{"ogrc::FeatureDefn_SetGeomType", _wrap_FeatureDefn_SetGeomType}, +{"ogrc::FeatureDefn_GetReferenceCount", _wrap_FeatureDefn_GetReferenceCount}, +{"ogrc::delete_FieldDefn", _wrap_delete_FieldDefn}, +{"ogrc::new_FieldDefn", _wrap_new_FieldDefn}, +{"ogrc::FieldDefn_GetName", _wrap_FieldDefn_GetName}, +{"ogrc::FieldDefn_GetNameRef", _wrap_FieldDefn_GetNameRef}, +{"ogrc::FieldDefn_SetName", _wrap_FieldDefn_SetName}, +{"ogrc::FieldDefn_GetType", _wrap_FieldDefn_GetType}, +{"ogrc::FieldDefn_SetType", _wrap_FieldDefn_SetType}, +{"ogrc::FieldDefn_GetJustify", _wrap_FieldDefn_GetJustify}, +{"ogrc::FieldDefn_SetJustify", _wrap_FieldDefn_SetJustify}, +{"ogrc::FieldDefn_GetWidth", _wrap_FieldDefn_GetWidth}, +{"ogrc::FieldDefn_SetWidth", _wrap_FieldDefn_SetWidth}, +{"ogrc::FieldDefn_GetPrecision", _wrap_FieldDefn_GetPrecision}, +{"ogrc::FieldDefn_SetPrecision", _wrap_FieldDefn_SetPrecision}, +{"ogrc::FieldDefn_GetFieldTypeName", _wrap_FieldDefn_GetFieldTypeName}, +{"ogrc::CreateGeometryFromWkb", _wrap_CreateGeometryFromWkb}, +{"ogrc::CreateGeometryFromWkt", _wrap_CreateGeometryFromWkt}, +{"ogrc::CreateGeometryFromGML", _wrap_CreateGeometryFromGML}, +{"ogrc::delete_Geometry", _wrap_delete_Geometry}, +{"ogrc::new_Geometry", _wrap_new_Geometry}, +{"ogrc::Geometry_ExportToWkt", _wrap_Geometry_ExportToWkt}, +{"ogrc::Geometry_ExportToWkb", _wrap_Geometry_ExportToWkb}, +{"ogrc::Geometry_ExportToGML", _wrap_Geometry_ExportToGML}, +{"ogrc::Geometry_AddPoint", _wrap_Geometry_AddPoint}, +{"ogrc::Geometry_AddGeometryDirectly", _wrap_Geometry_AddGeometryDirectly}, +{"ogrc::Geometry_AddGeometry", _wrap_Geometry_AddGeometry}, +{"ogrc::Geometry_Clone", _wrap_Geometry_Clone}, +{"ogrc::Geometry_GetGeometryType", _wrap_Geometry_GetGeometryType}, +{"ogrc::Geometry_GetGeometryName", _wrap_Geometry_GetGeometryName}, +{"ogrc::Geometry_GetArea", _wrap_Geometry_GetArea}, +{"ogrc::Geometry_GetPointCount", _wrap_Geometry_GetPointCount}, +{"ogrc::Geometry_GetX", _wrap_Geometry_GetX}, +{"ogrc::Geometry_GetY", _wrap_Geometry_GetY}, +{"ogrc::Geometry_GetZ", _wrap_Geometry_GetZ}, +{"ogrc::Geometry_GetGeometryCount", _wrap_Geometry_GetGeometryCount}, +{"ogrc::Geometry_SetPoint", _wrap_Geometry_SetPoint}, +{"ogrc::Geometry_GetGeometryRef", _wrap_Geometry_GetGeometryRef}, +{"ogrc::Geometry_GetBoundary", _wrap_Geometry_GetBoundary}, +{"ogrc::Geometry_ConvexHull", _wrap_Geometry_ConvexHull}, +{"ogrc::Geometry_Buffer", _wrap_Geometry_Buffer}, +{"ogrc::Geometry_Intersection", _wrap_Geometry_Intersection}, +{"ogrc::Geometry_Union", _wrap_Geometry_Union}, +{"ogrc::Geometry_Difference", _wrap_Geometry_Difference}, +{"ogrc::Geometry_SymmetricDifference", _wrap_Geometry_SymmetricDifference}, +{"ogrc::Geometry_Distance", _wrap_Geometry_Distance}, +{"ogrc::Geometry_Empty", _wrap_Geometry_Empty}, +{"ogrc::Geometry_Intersect", _wrap_Geometry_Intersect}, +{"ogrc::Geometry_Equal", _wrap_Geometry_Equal}, +{"ogrc::Geometry_Disjoint", _wrap_Geometry_Disjoint}, +{"ogrc::Geometry_Touches", _wrap_Geometry_Touches}, +{"ogrc::Geometry_Crosses", _wrap_Geometry_Crosses}, +{"ogrc::Geometry_Within", _wrap_Geometry_Within}, +{"ogrc::Geometry_Contains", _wrap_Geometry_Contains}, +{"ogrc::Geometry_Overlaps", _wrap_Geometry_Overlaps}, +{"ogrc::Geometry_TransformTo", _wrap_Geometry_TransformTo}, +{"ogrc::Geometry_Transform", _wrap_Geometry_Transform}, +{"ogrc::Geometry_GetSpatialReference", _wrap_Geometry_GetSpatialReference}, +{"ogrc::Geometry_AssignSpatialReference", _wrap_Geometry_AssignSpatialReference}, +{"ogrc::Geometry_CloseRings", _wrap_Geometry_CloseRings}, +{"ogrc::Geometry_FlattenTo2D", _wrap_Geometry_FlattenTo2D}, +{"ogrc::Geometry_GetEnvelope", _wrap_Geometry_GetEnvelope}, +{"ogrc::Geometry_Centroid", _wrap_Geometry_Centroid}, +{"ogrc::Geometry_WkbSize", _wrap_Geometry_WkbSize}, +{"ogrc::Geometry_GetCoordinateDimension", _wrap_Geometry_GetCoordinateDimension}, +{"ogrc::Geometry_GetDimension", _wrap_Geometry_GetDimension}, +{"ogrc::GetDriverCount", _wrap_GetDriverCount}, +{"ogrc::GetOpenDSCount", _wrap_GetOpenDSCount}, +{"ogrc::SetGenerate_DB2_V72_BYTE_ORDER", _wrap_SetGenerate_DB2_V72_BYTE_ORDER}, +{"ogrc::RegisterAll", _wrap_RegisterAll}, +{"ogrc::GetOpenDS", _wrap_GetOpenDS}, +{"ogrc::Open", _wrap_Open}, +{"ogrc::OpenShared", _wrap_OpenShared}, +{"ogrc::GetDriverByName", _wrap_GetDriverByName}, +{"ogrc::GetDriver", _wrap_GetDriver}, +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkb25Bit", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbUnknown", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(0))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbPoint", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(1))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbLineString", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(2))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbPolygon", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(3))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiPoint", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(4))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiLineString", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(5))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiPolygon", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(6))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbGeometryCollection", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(7))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbNone", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(100))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbLinearRing", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(101))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbPoint25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbPoint+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbLineString25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbLineString+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbPolygon25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbPolygon+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiPoint25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbMultiPoint+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiLineString25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbMultiLineString+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbMultiPolygon25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbMultiPolygon+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbGeometryCollection25D", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(wkbGeometryCollection+wkb25DBit))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTInteger", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(0))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTIntegerList", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(1))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTReal", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(2))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTRealList", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(3))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTString", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(4))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTStringList", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(5))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTWideString", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(6))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTWideStringList", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(7))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTBinary", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(8))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTDate", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(9))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTTime", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(10))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OFTDateTime", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(11))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OJUndefined", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(0))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OJLeft", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(1))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OJRight", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(2))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbXDR", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(0))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "wkbNDR", TRUE | 0x2); + sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(1))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCRandomRead", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("RandomRead")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCSequentialWrite", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("SequentialWrite")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCRandomWrite", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("RandomWrite")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCFastSpatialFilter", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("FastSpatialFilter")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCFastFeatureCount", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("FastFeatureCount")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCFastGetExtent", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("FastGetExtent")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCCreateField", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("CreateField")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCTransactions", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("Transactions")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCDeleteFeature", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("DeleteFeature")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "OLCFastSetNextByIndex", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("FastSetNextByIndex")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "ODsCCreateLayer", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("CreateLayer")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "ODsCDeleteLayer", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("DeleteLayer")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "ODrCCreateDataSource", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("CreateDataSource")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "ODrCDeleteDataSource", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr("DeleteDataSource")); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + + + UseExceptions(); + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + + + SWIG_TypeClientData(SWIGTYPE_p_OGRDriverShadow, (void*) "ogr::Driver"); + SWIG_TypeClientData(SWIGTYPE_p_OGRDataSourceShadow, (void*) "ogr::DataSource"); + SWIG_TypeClientData(SWIGTYPE_p_OGRLayerShadow, (void*) "ogr::Layer"); + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureShadow, (void*) "ogr::Feature"); + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureDefnShadow, (void*) "ogr::FeatureDefn"); + SWIG_TypeClientData(SWIGTYPE_p_OGRFieldDefnShadow, (void*) "ogr::FieldDefn"); + SWIG_TypeClientData(SWIGTYPE_p_OGRGeometryShadow, (void*) "ogr::Geometry"); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/Utilities/GDAL/swig/perl/osr.pm b/Utilities/GDAL/swig/perl/osr.pm new file mode 100644 index 0000000000..e2cb5c0fd7 --- /dev/null +++ b/Utilities/GDAL/swig/perl/osr.pm @@ -0,0 +1,274 @@ +# This file was created automatically by SWIG 1.3.29. +# Don't modify this file, modify the SWIG interface instead. +package osr; +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +package osrc; +bootstrap osr; +package osr; +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package osr; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub FIRSTKEY { } + +sub NEXTKEY { } + +sub FETCH { + my ($self,$field) = @_; + my $member_func = "swig_${field}_get"; + $self->$member_func(); +} + +sub STORE { + my ($self,$field,$newval) = @_; + my $member_func = "swig_${field}_set"; + $self->$member_func($newval); +} + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package osr; + +*GetWellKnownGeogCSAsWKT = *osrc::GetWellKnownGeogCSAsWKT; +*GetProjectionMethods = *osrc::GetProjectionMethods; +*GetProjectionMethodParameterList = *osrc::GetProjectionMethodParameterList; +*GetProjectionMethodParamInfo = *osrc::GetProjectionMethodParamInfo; + +############# Class : osr::SpatialReference ############## + +package osr::SpatialReference; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( osr ); +%OWNER = (); +%ITERATORS = (); +sub new { + my $pkg = shift; + my $self = osrc::new_SpatialReference(@_); + bless $self, $pkg if defined($self); +} + +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + osrc::delete_SpatialReference($self); + delete $OWNER{$self}; + } +} + +*__str__ = *osrc::SpatialReference___str__; +*IsSame = *osrc::SpatialReference_IsSame; +*IsSameGeogCS = *osrc::SpatialReference_IsSameGeogCS; +*IsGeographic = *osrc::SpatialReference_IsGeographic; +*IsProjected = *osrc::SpatialReference_IsProjected; +*GetAttrValue = *osrc::SpatialReference_GetAttrValue; +*SetAttrValue = *osrc::SpatialReference_SetAttrValue; +*SetAngularUnits = *osrc::SpatialReference_SetAngularUnits; +*GetAngularUnits = *osrc::SpatialReference_GetAngularUnits; +*SetLinearUnits = *osrc::SpatialReference_SetLinearUnits; +*GetLinearUnits = *osrc::SpatialReference_GetLinearUnits; +*GetLinearUnitsName = *osrc::SpatialReference_GetLinearUnitsName; +*GetAuthorityCode = *osrc::SpatialReference_GetAuthorityCode; +*GetAuthorityName = *osrc::SpatialReference_GetAuthorityName; +*SetUTM = *osrc::SpatialReference_SetUTM; +*SetStatePlane = *osrc::SpatialReference_SetStatePlane; +*AutoIdentifyEPSG = *osrc::SpatialReference_AutoIdentifyEPSG; +*SetProjection = *osrc::SpatialReference_SetProjection; +*SetProjParm = *osrc::SpatialReference_SetProjParm; +*GetProjParm = *osrc::SpatialReference_GetProjParm; +*SetNormProjParm = *osrc::SpatialReference_SetNormProjParm; +*GetNormProjParm = *osrc::SpatialReference_GetNormProjParm; +*SetACEA = *osrc::SpatialReference_SetACEA; +*SetAE = *osrc::SpatialReference_SetAE; +*SetCS = *osrc::SpatialReference_SetCS; +*SetBonne = *osrc::SpatialReference_SetBonne; +*SetEC = *osrc::SpatialReference_SetEC; +*SetEckertIV = *osrc::SpatialReference_SetEckertIV; +*SetEckertVI = *osrc::SpatialReference_SetEckertVI; +*SetEquirectangular = *osrc::SpatialReference_SetEquirectangular; +*SetGS = *osrc::SpatialReference_SetGS; +*SetWellKnownGeogCS = *osrc::SpatialReference_SetWellKnownGeogCS; +*SetFromUserInput = *osrc::SpatialReference_SetFromUserInput; +*CopyGeogCSFrom = *osrc::SpatialReference_CopyGeogCSFrom; +*SetTOWGS84 = *osrc::SpatialReference_SetTOWGS84; +*GetTOWGS84 = *osrc::SpatialReference_GetTOWGS84; +*SetGeogCS = *osrc::SpatialReference_SetGeogCS; +*SetProjCS = *osrc::SpatialReference_SetProjCS; +*ImportFromWkt = *osrc::SpatialReference_ImportFromWkt; +*ImportFromProj4 = *osrc::SpatialReference_ImportFromProj4; +*ImportFromESRI = *osrc::SpatialReference_ImportFromESRI; +*ImportFromEPSG = *osrc::SpatialReference_ImportFromEPSG; +*ImportFromPCI = *osrc::SpatialReference_ImportFromPCI; +*ImportFromUSGS = *osrc::SpatialReference_ImportFromUSGS; +*ImportFromXML = *osrc::SpatialReference_ImportFromXML; +*ExportToWkt = *osrc::SpatialReference_ExportToWkt; +*ExportToPrettyWkt = *osrc::SpatialReference_ExportToPrettyWkt; +*ExportToProj4 = *osrc::SpatialReference_ExportToProj4; +*ExportToPCI = *osrc::SpatialReference_ExportToPCI; +*ExportToUSGS = *osrc::SpatialReference_ExportToUSGS; +*ExportToXML = *osrc::SpatialReference_ExportToXML; +*CloneGeogCS = *osrc::SpatialReference_CloneGeogCS; +*Validate = *osrc::SpatialReference_Validate; +*StripCTParms = *osrc::SpatialReference_StripCTParms; +*FixupOrdering = *osrc::SpatialReference_FixupOrdering; +*Fixup = *osrc::SpatialReference_Fixup; +*MorphToESRI = *osrc::SpatialReference_MorphToESRI; +*MorphFromESRI = *osrc::SpatialReference_MorphFromESRI; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +############# Class : osr::CoordinateTransformation ############## + +package osr::CoordinateTransformation; +use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); +@ISA = qw( osr ); +%OWNER = (); +%ITERATORS = (); +sub new { + my $pkg = shift; + my $self = osrc::new_CoordinateTransformation(@_); + bless $self, $pkg if defined($self); +} + +sub DESTROY { + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + return unless defined $self; + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + osrc::delete_CoordinateTransformation($self); + delete $OWNER{$self}; + } +} + +*TransformPoint = *osrc::CoordinateTransformation_TransformPoint; +sub DISOWN { + my $self = shift; + my $ptr = tied(%$self); + delete $OWNER{$ptr}; +} + +sub ACQUIRE { + my $self = shift; + my $ptr = tied(%$self); + $OWNER{$ptr} = 1; +} + + +# ------- VARIABLE STUBS -------- + +package osr; + +*SRS_PT_ALBERS_CONIC_EQUAL_AREA = *osrc::SRS_PT_ALBERS_CONIC_EQUAL_AREA; +*SRS_PT_AZIMUTHAL_EQUIDISTANT = *osrc::SRS_PT_AZIMUTHAL_EQUIDISTANT; +*SRS_PT_CASSINI_SOLDNER = *osrc::SRS_PT_CASSINI_SOLDNER; +*SRS_PT_CYLINDRICAL_EQUAL_AREA = *osrc::SRS_PT_CYLINDRICAL_EQUAL_AREA; +*SRS_PT_ECKERT_IV = *osrc::SRS_PT_ECKERT_IV; +*SRS_PT_ECKERT_VI = *osrc::SRS_PT_ECKERT_VI; +*SRS_PT_EQUIDISTANT_CONIC = *osrc::SRS_PT_EQUIDISTANT_CONIC; +*SRS_PT_EQUIRECTANGULAR = *osrc::SRS_PT_EQUIRECTANGULAR; +*SRS_PT_GALL_STEREOGRAPHIC = *osrc::SRS_PT_GALL_STEREOGRAPHIC; +*SRS_PT_GNOMONIC = *osrc::SRS_PT_GNOMONIC; +*SRS_PT_GOODE_HOMOLOSINE = *osrc::SRS_PT_GOODE_HOMOLOSINE; +*SRS_PT_HOTINE_OBLIQUE_MERCATOR = *osrc::SRS_PT_HOTINE_OBLIQUE_MERCATOR; +*SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN = *osrc::SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN; +*SRS_PT_LABORDE_OBLIQUE_MERCATOR = *osrc::SRS_PT_LABORDE_OBLIQUE_MERCATOR; +*SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP = *osrc::SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP; +*SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP = *osrc::SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP; +*SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM = *osrc::SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM; +*SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA = *osrc::SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA; +*SRS_PT_MERCATOR_1SP = *osrc::SRS_PT_MERCATOR_1SP; +*SRS_PT_MERCATOR_2SP = *osrc::SRS_PT_MERCATOR_2SP; +*SRS_PT_MILLER_CYLINDRICAL = *osrc::SRS_PT_MILLER_CYLINDRICAL; +*SRS_PT_MOLLWEIDE = *osrc::SRS_PT_MOLLWEIDE; +*SRS_PT_NEW_ZEALAND_MAP_GRID = *osrc::SRS_PT_NEW_ZEALAND_MAP_GRID; +*SRS_PT_OBLIQUE_STEREOGRAPHIC = *osrc::SRS_PT_OBLIQUE_STEREOGRAPHIC; +*SRS_PT_ORTHOGRAPHIC = *osrc::SRS_PT_ORTHOGRAPHIC; +*SRS_PT_POLAR_STEREOGRAPHIC = *osrc::SRS_PT_POLAR_STEREOGRAPHIC; +*SRS_PT_POLYCONIC = *osrc::SRS_PT_POLYCONIC; +*SRS_PT_ROBINSON = *osrc::SRS_PT_ROBINSON; +*SRS_PT_SINUSOIDAL = *osrc::SRS_PT_SINUSOIDAL; +*SRS_PT_STEREOGRAPHIC = *osrc::SRS_PT_STEREOGRAPHIC; +*SRS_PT_SWISS_OBLIQUE_CYLINDRICAL = *osrc::SRS_PT_SWISS_OBLIQUE_CYLINDRICAL; +*SRS_PT_TRANSVERSE_MERCATOR = *osrc::SRS_PT_TRANSVERSE_MERCATOR; +*SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED = *osrc::SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED; +*SRS_PT_TRANSVERSE_MERCATOR_MI_22 = *osrc::SRS_PT_TRANSVERSE_MERCATOR_MI_22; +*SRS_PT_TRANSVERSE_MERCATOR_MI_23 = *osrc::SRS_PT_TRANSVERSE_MERCATOR_MI_23; +*SRS_PT_TRANSVERSE_MERCATOR_MI_24 = *osrc::SRS_PT_TRANSVERSE_MERCATOR_MI_24; +*SRS_PT_TRANSVERSE_MERCATOR_MI_25 = *osrc::SRS_PT_TRANSVERSE_MERCATOR_MI_25; +*SRS_PT_TUNISIA_MINING_GRID = *osrc::SRS_PT_TUNISIA_MINING_GRID; +*SRS_PT_VANDERGRINTEN = *osrc::SRS_PT_VANDERGRINTEN; +*SRS_PT_KROVAK = *osrc::SRS_PT_KROVAK; +*SRS_PP_CENTRAL_MERIDIAN = *osrc::SRS_PP_CENTRAL_MERIDIAN; +*SRS_PP_SCALE_FACTOR = *osrc::SRS_PP_SCALE_FACTOR; +*SRS_PP_STANDARD_PARALLEL_1 = *osrc::SRS_PP_STANDARD_PARALLEL_1; +*SRS_PP_STANDARD_PARALLEL_2 = *osrc::SRS_PP_STANDARD_PARALLEL_2; +*SRS_PP_PSEUDO_STD_PARALLEL_1 = *osrc::SRS_PP_PSEUDO_STD_PARALLEL_1; +*SRS_PP_LONGITUDE_OF_CENTER = *osrc::SRS_PP_LONGITUDE_OF_CENTER; +*SRS_PP_LATITUDE_OF_CENTER = *osrc::SRS_PP_LATITUDE_OF_CENTER; +*SRS_PP_LONGITUDE_OF_ORIGIN = *osrc::SRS_PP_LONGITUDE_OF_ORIGIN; +*SRS_PP_LATITUDE_OF_ORIGIN = *osrc::SRS_PP_LATITUDE_OF_ORIGIN; +*SRS_PP_FALSE_EASTING = *osrc::SRS_PP_FALSE_EASTING; +*SRS_PP_FALSE_NORTHING = *osrc::SRS_PP_FALSE_NORTHING; +*SRS_PP_AZIMUTH = *osrc::SRS_PP_AZIMUTH; +*SRS_PP_LONGITUDE_OF_POINT_1 = *osrc::SRS_PP_LONGITUDE_OF_POINT_1; +*SRS_PP_LATITUDE_OF_POINT_1 = *osrc::SRS_PP_LATITUDE_OF_POINT_1; +*SRS_PP_LONGITUDE_OF_POINT_2 = *osrc::SRS_PP_LONGITUDE_OF_POINT_2; +*SRS_PP_LATITUDE_OF_POINT_2 = *osrc::SRS_PP_LATITUDE_OF_POINT_2; +*SRS_PP_LONGITUDE_OF_POINT_3 = *osrc::SRS_PP_LONGITUDE_OF_POINT_3; +*SRS_PP_LATITUDE_OF_POINT_3 = *osrc::SRS_PP_LATITUDE_OF_POINT_3; +*SRS_PP_RECTIFIED_GRID_ANGLE = *osrc::SRS_PP_RECTIFIED_GRID_ANGLE; +*SRS_PP_LANDSAT_NUMBER = *osrc::SRS_PP_LANDSAT_NUMBER; +*SRS_PP_PATH_NUMBER = *osrc::SRS_PP_PATH_NUMBER; +*SRS_PP_PERSPECTIVE_POINT_HEIGHT = *osrc::SRS_PP_PERSPECTIVE_POINT_HEIGHT; +*SRS_PP_FIPSZONE = *osrc::SRS_PP_FIPSZONE; +*SRS_PP_ZONE = *osrc::SRS_PP_ZONE; +*SRS_UL_METER = *osrc::SRS_UL_METER; +*SRS_UL_FOOT = *osrc::SRS_UL_FOOT; +*SRS_UL_FOOT_CONV = *osrc::SRS_UL_FOOT_CONV; +*SRS_UL_US_FOOT = *osrc::SRS_UL_US_FOOT; +*SRS_UL_US_FOOT_CONV = *osrc::SRS_UL_US_FOOT_CONV; +*SRS_UL_NAUTICAL_MILE = *osrc::SRS_UL_NAUTICAL_MILE; +*SRS_UL_NAUTICAL_MILE_CONV = *osrc::SRS_UL_NAUTICAL_MILE_CONV; +*SRS_UL_LINK = *osrc::SRS_UL_LINK; +*SRS_UL_LINK_CONV = *osrc::SRS_UL_LINK_CONV; +*SRS_UL_CHAIN = *osrc::SRS_UL_CHAIN; +*SRS_UL_CHAIN_CONV = *osrc::SRS_UL_CHAIN_CONV; +*SRS_UL_ROD = *osrc::SRS_UL_ROD; +*SRS_UL_ROD_CONV = *osrc::SRS_UL_ROD_CONV; +*SRS_DN_NAD27 = *osrc::SRS_DN_NAD27; +*SRS_DN_NAD83 = *osrc::SRS_DN_NAD83; +*SRS_DN_WGS72 = *osrc::SRS_DN_WGS72; +*SRS_DN_WGS84 = *osrc::SRS_DN_WGS84; +*SRS_WGS84_SEMIMAJOR = *osrc::SRS_WGS84_SEMIMAJOR; +*SRS_WGS84_INVFLATTENING = *osrc::SRS_WGS84_INVFLATTENING; +1; diff --git a/Utilities/GDAL/swig/perl/osr.pod b/Utilities/GDAL/swig/perl/osr.pod new file mode 100644 index 0000000000..609159915b --- /dev/null +++ b/Utilities/GDAL/swig/perl/osr.pod @@ -0,0 +1,398 @@ +=head1 NAME + +osr - A part of the Perl interface to the GDAL library. + +=head1 SYNOPSIS + + use osr; + +=head1 ABSTRACT + +This module is a part of the Perl bindings to the GDAL library. The +GDAL modules allows you to access and manipulate from Perl all +geospatial data that the installed GDAL library is configured to +read/write. + +=head1 STATUS + +This module is beta quality. As most of the names and calling +conventions come directly from the underlying GDAL library they are +quite stable and will continue to work like the do now. However, many +things could, should, and will be made more perlish. + +Generally, those methods which are documented, have been tested. If +the method or constructor you are looking for is not documented, +perhaps there is another way of doing what you want to do. + +=head1 PACKAGE METHODS + +=over + +=item GetWellKnownGeogCSAsWKT + +=item GetProjectionMethods + +=item GetProjectionMethodParameterList + +=item GetProjectionMethodParamInfo + +=back + +=head1 CONSTANTS + +Access as $osr::<constant> + +=over + +=item SRS_PT_ALBERS_CONIC_EQUAL_AREA + +=item SRS_PT_AZIMUTHAL_EQUIDISTANT + +=item SRS_PT_CASSINI_SOLDNER + +=item SRS_PT_CYLINDRICAL_EQUAL_AREA + +=item SRS_PT_ECKERT_IV + +=item SRS_PT_ECKERT_VI + +=item SRS_PT_EQUIDISTANT_CONIC + +=item SRS_PT_EQUIRECTANGULAR + +=item SRS_PT_GALL_STEREOGRAPHIC + +=item SRS_PT_GNOMONIC + +=item SRS_PT_GOODE_HOMOLOSINE + +=item SRS_PT_HOTINE_OBLIQUE_MERCATOR + +=item SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN + +=item SRS_PT_LABORDE_OBLIQUE_MERCATOR + +=item SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP + +=item SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP + +=item SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM + +=item SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA + +=item SRS_PT_MERCATOR_1SP + +=item SRS_PT_MERCATOR_2SP + +=item SRS_PT_MILLER_CYLINDRICAL + +=item SRS_PT_MOLLWEIDE + +=item SRS_PT_NEW_ZEALAND_MAP_GRID + +=item SRS_PT_OBLIQUE_STEREOGRAPHIC + +=item SRS_PT_ORTHOGRAPHIC + +=item SRS_PT_POLAR_STEREOGRAPHIC + +=item SRS_PT_POLYCONIC + +=item SRS_PT_ROBINSON + +=item SRS_PT_SINUSOIDAL + +=item SRS_PT_STEREOGRAPHIC + +=item SRS_PT_SWISS_OBLIQUE_CYLINDRICAL + +=item SRS_PT_TRANSVERSE_MERCATOR + +=item SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED + +=item SRS_PT_TRANSVERSE_MERCATOR_MI_22 + +=item SRS_PT_TRANSVERSE_MERCATOR_MI_23 + +=item SRS_PT_TRANSVERSE_MERCATOR_MI_24 + +=item SRS_PT_TRANSVERSE_MERCATOR_MI_25 + +=item SRS_PT_TUNISIA_MINING_GRID + +=item SRS_PT_VANDERGRINTEN + +=item SRS_PT_KROVAK + +=item SRS_PP_CENTRAL_MERIDIAN + +=item SRS_PP_SCALE_FACTOR + +=item SRS_PP_STANDARD_PARALLEL_1 + +=item SRS_PP_STANDARD_PARALLEL_2 + +=item SRS_PP_PSEUDO_STD_PARALLEL_1 + +=item SRS_PP_LONGITUDE_OF_CENTER + +=item SRS_PP_LATITUDE_OF_CENTER + +=item SRS_PP_LONGITUDE_OF_ORIGIN + +=item SRS_PP_LATITUDE_OF_ORIGIN + +=item SRS_PP_FALSE_EASTING + +=item SRS_PP_FALSE_NORTHING + +=item SRS_PP_AZIMUTH + +=item SRS_PP_LONGITUDE_OF_POINT_1 + +=item SRS_PP_LATITUDE_OF_POINT_1 + +=item SRS_PP_LONGITUDE_OF_POINT_2 + +=item SRS_PP_LATITUDE_OF_POINT_2 + +=item SRS_PP_LONGITUDE_OF_POINT_3 + +=item SRS_PP_LATITUDE_OF_POINT_3 + +=item SRS_PP_RECTIFIED_GRID_ANGLE + +=item SRS_PP_LANDSAT_NUMBER + +=item SRS_PP_PATH_NUMBER + +=item SRS_PP_PERSPECTIVE_POINT_HEIGHT + +=item SRS_PP_FIPSZONE + +=item SRS_PP_ZONE + +=item SRS_UL_METER + +=item SRS_UL_FOOT + +=item SRS_UL_FOOT_CONV + +=item SRS_UL_US_FOOT + +=item SRS_UL_US_FOOT_CONV + +=item SRS_UL_NAUTICAL_MILE + +=item SRS_UL_NAUTICAL_MILE_CONV + +=item SRS_UL_LINK + +=item SRS_UL_LINK_CONV + +=item SRS_UL_CHAIN + +=item SRS_UL_CHAIN_CONV + +=item SRS_UL_ROD + +=item SRS_UL_ROD_CONV + +=item SRS_DN_NAD27 + +=item SRS_DN_NAD83 + +=item SRS_DN_WGS72 + +=item SRS_DN_WGS84 + +=item SRS_WGS84_SEMIMAJOR + +=item SRS_WGS84_INVFLATTENING + +=back + +=head1 CLASSES + +=head2 osr::SpatialReference + + $srs = new osr::SpatialReference; + +=over + +=item __str__ + +=item IsSame + +=item IsSameGeogCS + +=item IsGeographic + +=item IsProjected + +=item GetAttrValue + +=item SetAttrValue + +=item SetAngularUnits + +=item GetAngularUnits + +=item SetLinearUnits + +=item GetLinearUnits + +=item GetLinearUnitsName + +=item GetAuthorityCode + +=item GetAuthorityName + +=item SetUTM + +=item SetStatePlane + +=item AutoIdentifyEPSG + +=item SetProjection + +=item SetProjParm + +=item GetProjParm + +=item SetNormProjParm + +=item GetNormProjParm + +=item SetACEA + +=item SetAE + +=item SetCS + +=item SetBonne + +=item SetEC + +=item SetEckertIV + +=item SetEckertVI + +=item SetEquirectangular + +=item SetGS + +=item SetWellKnownGeogCS + + $cs = 'WGS84'; # an example + $srs->SetWellKnownGeogCS($cs); + +=item SetFromUserInput + +=item CopyGeogCSFrom + +=item SetTOWGS84 + +=item GetTOWGS84 + +=item SetGeogCS + +=item SetProjCS + +=item ImportFromWkt + +=item ImportFromProj4 + +=item ImportFromESRI + +=item ImportFromEPSG + + $nr = 3035; # an example + $srs->ImportFromEPSG($nr); + +=item ImportFromPCI + +=item ImportFromUSGS + +=item ImportFromXML + +=item ExportToWkt + +=item ExportToPrettyWkt + +=item ExportToProj4 + +=item ExportToPCI + +=item ExportToUSGS + +=item ExportToXML + +=item CloneGeogCS + +=item Validate + +=item StripCTParms + +=item FixupOrdering + +=item Fixup + +=item MorphToESRI + +=item MorphFromESRI + +=back + +=head2 osr::CoordinateTransformation + + $transf = new osr::CoordinateTransformation($srs_from, $srs_to); + +=over + +=item TransformPoint + +=back + +=head1 KNOWN BUGS + +Method named __str__ is a Pythonism and deprecated. + +The reference counting scheme is not yet implemented. Make sure that +parents are not deleted before their children! Use "my" a lot. Do not +give undefined/uninitialized variables to methods. + +=head1 SEE ALSO + +L<perl>(1), L<gdalconst>(3pm), L<gdal>(3pm), L<ogr>(3pm). + +http://www.gdal.org + +=head1 AUTHORS + +The GDAL bindings team (in alphabetical order): + +ari.jolma at tkk.fi +cfis at interserv.com +hobu at iastate.edu +kruland at ku.edu +warmerdam at pobox.com + +=head1 COPYRIGHT AND LICENSE + +Copyright 2005-2006 by the GDAL bindings team. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307 USA. diff --git a/Utilities/GDAL/swig/perl/osr_wrap.cpp b/Utilities/GDAL/swig/perl/osr_wrap.cpp new file mode 100644 index 0000000000..0b03c70588 --- /dev/null +++ b/Utilities/GDAL/swig/perl/osr_wrap.cpp @@ -0,0 +1,6464 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.29 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPERL +#define SWIG_CASTRANK_MODE + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */ + +/* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */ +#ifndef PERL_REVISION +# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) +# define PERL_PATCHLEVEL_H_IMPLICIT +# include <patchlevel.h> +# endif +# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) +# include <could_not_find_Perl_patchlevel.h> +# endif +# ifndef PERL_REVISION +# define PERL_REVISION (5) +# define PERL_VERSION PATCHLEVEL +# define PERL_SUBVERSION SUBVERSION +# endif +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))) +# define PL_sv_undef sv_undef +# define PL_na na +# define PL_errgv errgv +# define PL_sv_no sv_no +# define PL_sv_yes sv_yes +# define PL_markstack_ptr markstack_ptr +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + const char* type = 0; + switch(code) { + case SWIG_MemoryError: + type = "MemoryError"; + break; + case SWIG_IOError: + type = "IOError"; + break; + case SWIG_RuntimeError: + type = "RuntimeError"; + break; + case SWIG_IndexError: + type = "IndexError"; + break; + case SWIG_TypeError: + type = "TypeError"; + break; + case SWIG_DivisionByZero: + type = "ZeroDivisionError"; + break; + case SWIG_OverflowError: + type = "OverflowError"; + break; + case SWIG_SyntaxError: + type = "SyntaxError"; + break; + case SWIG_ValueError: + type = "ValueError"; + break; + case SWIG_SystemError: + type = "SystemError"; + break; + case SWIG_AttributeError: + type = "AttributeError"; + break; + default: + type = "RuntimeError"; + } + return type; +} + + + + +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#ifdef PERL_OBJECT +#define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl), +#define SWIG_PERL_OBJECT_CALL pPerl, +#else +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to call an XS function */ +#ifdef PERL_OBJECT +# define SWIG_CALLXS(_name) _name(cv,pPerl) +#else +# ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +# else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +# endif +#endif + +/* Note: SwigMagicFuncHack is a typedef used to get the C++ compiler to just shut up already */ + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (CPerlObj::*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(SV *, MAGIC *); + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + + +#else +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif +#endif + +/* Workaround for bug in perl 5.6.x croak and earlier */ +#if (PERL_VERSION < 8) +# ifdef PERL_OBJECT +# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) +static void SWIG_Perl_croak_null(CPerlObj *pPerl) +# else +static void SWIG_croak_null() +# endif +{ + SV *err=ERRSV; +# if (PERL_VERSION < 6) + croak("%_", err); +# else + if (SvOK(err) && !SvROK(err)) croak("%_", err); + croak(Nullch); +# endif +} +#else +# define SWIG_croak_null() croak(Nullch) +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp((char*)iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); +} + + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + *(ptr) = (void *) 0; + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc,voidptr); + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && (flags & SWIG_POINTER_DISOWN)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + return SWIG_OK; +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & SWIG_SHADOW)) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV(obj, PL_na); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XS(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifndef PERL_OBJECT +#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) + #ifndef MULTIPLICITY + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) + #else + SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) + #endif +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) +SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',(char *) name,strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFuncHack) get; + mg->mg_virtual->svt_set = (SwigMagicFuncHack) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif + +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef bool + #undef bool +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[0] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_double swig_types[3] +#define SWIGTYPE_p_int swig_types[4] +#define SWIGTYPE_p_long swig_types[5] +#define SWIGTYPE_p_p_char swig_types[6] +#define SWIGTYPE_p_p_double swig_types[7] +static swig_type_info *swig_types[9]; +static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init boot_osr + +#define SWIG_name "osrc::boot_osr" +#define SWIG_prefix "osrc::" + +#define SWIGVERSION 0x010329 + + +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) + + +#include <stdexcept> + + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +#else +SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); +#endif + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (size && carray) { + if (carray[size - 1] == 0) { + sv_setpv(obj, carray); + } else { + char *tmp = (new char[size + 1]); + memcpy(tmp, carray, size); + tmp[size] = 0; + sv_setpv(obj, tmp); + delete[] tmp; + } + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +SWIGINTERNINLINE SV * +SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value) +{ + SV *obj = sv_newmortal(); + sv_setnv(obj, value); + return obj; +} + + +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + + + +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +SWIGINTERN OSRSpatialReferenceShadow *new_OSRSpatialReferenceShadow(char const *wkt=""){ + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } +SWIGINTERN void delete_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *self){ + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } +SWIGINTERN char *OSRSpatialReferenceShadow___str__(OSRSpatialReferenceShadow *self){ + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } +SWIGINTERN int OSRSpatialReferenceShadow_IsSame(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSame( self, rhs ); + } + +SWIGINTERNINLINE SV * +SWIG_From_long SWIG_PERL_DECL_ARGS_1(long value) +{ + SV *obj = sv_newmortal(); + sv_setiv(obj, (IV) value); + return obj; +} + + +SWIGINTERNINLINE SV * +SWIG_From_int SWIG_PERL_DECL_ARGS_1(int value) +{ + return SWIG_From_long SWIG_PERL_CALL_ARGS_1(value); +} + +SWIGINTERN int OSRSpatialReferenceShadow_IsSameGeogCS(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSameGeogCS( self, rhs ); + } +SWIGINTERN int OSRSpatialReferenceShadow_IsGeographic(OSRSpatialReferenceShadow *self){ + return OSRIsGeographic(self); + } +SWIGINTERN int OSRSpatialReferenceShadow_IsProjected(OSRSpatialReferenceShadow *self){ + return OSRIsProjected(self); + } + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + double v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val) +{ + if (SvIOK(obj)) { + if (val) *val = SvIV(obj); + return SWIG_OK; + } else { + int dispatch = 0; + const char *nptr = SvPV(obj, PL_na); + if (nptr) { + char *endptr; + long v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast< int >(v); + } + } + return res; +} + +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAttrValue(OSRSpatialReferenceShadow *self,char const *name,int child=0){ + return OSRGetAttrValue( self, name, child ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAttrValue(OSRSpatialReferenceShadow *self,char const *name,char const *value){ + return OSRSetAttrValue( self, name, value ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAngularUnits(OSRSpatialReferenceShadow *self,char const *name,double to_radians){ + return OSRSetAngularUnits( self, name, to_radians ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetAngularUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetLinearUnits(OSRSpatialReferenceShadow *self,char const *name,double to_meters){ + return OSRSetAngularUnits( self, name, to_meters ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetLinearUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetLinearUnitsName(OSRSpatialReferenceShadow *self){ + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAuthorityCode(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityCode( self, target_key ); + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAuthorityName(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityName( self, target_key ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetUTM(OSRSpatialReferenceShadow *self,int zone,int north=1){ + return OSRSetUTM( self, zone, north ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetStatePlane(OSRSpatialReferenceShadow *self,int zone,int is_nad83=1,char const *unitsname="",double units=0.0){ + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_AutoIdentifyEPSG(OSRSpatialReferenceShadow *self){ + return OSRAutoIdentifyEPSG( self ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjection(OSRSpatialReferenceShadow *self,char const *arg){ + return OSRSetProjection( self, arg ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetProjParm( self, name, val ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetNormProjParm( self, name, val ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetACEA(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAE(OSRSpatialReferenceShadow *self,double clat,double clon,double fe,double fn){ + return OSRSetAE( self, clat, clon, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetCS(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetCS( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetBonne(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetBonne( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEC(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEckertIV(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertIV( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEckertVI(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertVI( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEquirectangular(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetGS(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetGS( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetWellKnownGeogCS(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetWellKnownGeogCS( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetFromUserInput(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetFromUserInput( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_CopyGeogCSFrom(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRCopyGeogCSFrom( self, rhs ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetTOWGS84(OSRSpatialReferenceShadow *self,double p1,double p2,double p3,double p4=0.0,double p5=0.0,double p6=0.0,double p7=0.0){ + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } + +static SV * +CreateArrayFromDoubleArray( double *first, unsigned int size ) { + AV *av = (AV*)sv_2mortal((SV*)newAV()); + for( unsigned int i=0; i<size; i++ ) { + av_store(av,i,newSVnv(*first)); + ++first; + } + return newRV_noinc((SV*)av); +} + +SWIGINTERN OGRErr OSRSpatialReferenceShadow_GetTOWGS84(OSRSpatialReferenceShadow *self,double argout[7]){ + return OSRGetTOWGS84( self, argout, 7 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetGeogCS(OSRSpatialReferenceShadow *self,char const *pszGeogName,char const *pszDatumName,char const *pszEllipsoidName,double dfSemiMajor,double dfInvFlattening,char const *pszPMName="Greenwich",double dfPMOffset=0.0,char const *pszUnits="degree",double dfConvertToRadians=0.0174532925199433){ + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjCS(OSRSpatialReferenceShadow *self,char const *name="unnamed"){ + return OSRSetProjCS( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromWkt(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromWkt( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromProj4(OSRSpatialReferenceShadow *self,char *ppszInput){ + return OSRImportFromProj4( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromESRI(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromESRI( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromEPSG(OSRSpatialReferenceShadow *self,int arg){ + return OSRImportFromEPSG(self, arg); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromPCI(OSRSpatialReferenceShadow *self,char const *proj,char const *units="METRE",double argin[17]=0){ + return OSRImportFromPCI( self, proj, units, argin ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromUSGS(OSRSpatialReferenceShadow *self,long proj_code,long zone=0,double argin[15]=0,long datum_code=0){ + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromXML(OSRSpatialReferenceShadow *self,char const *xmlString){ + return OSRImportFromXML( self, xmlString ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToWkt(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToWkt( self, argout ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToPrettyWkt(OSRSpatialReferenceShadow *self,char **argout,int simplify=0){ + return OSRExportToPrettyWkt( self, argout, simplify ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToProj4(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToProj4( self, argout ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToPCI(OSRSpatialReferenceShadow *self,char **proj,char **units,double *parms[17]){ + return OSRExportToPCI( self, proj, units, parms ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToUSGS(OSRSpatialReferenceShadow *self,long *code,long *zone,double *parms[15],long *datum){ + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToXML(OSRSpatialReferenceShadow *self,char **argout,char const *dialect=""){ + return OSRExportToXML( self, argout, dialect ); + } +SWIGINTERN OSRSpatialReferenceShadow *OSRSpatialReferenceShadow_CloneGeogCS(OSRSpatialReferenceShadow *self){ + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_Validate(OSRSpatialReferenceShadow *self){ + return OSRValidate(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_StripCTParms(OSRSpatialReferenceShadow *self){ + return OSRStripCTParms(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_FixupOrdering(OSRSpatialReferenceShadow *self){ + return OSRFixupOrdering(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_Fixup(OSRSpatialReferenceShadow *self){ + return OSRFixup(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_MorphToESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphToESRI(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_MorphFromESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphFromESRI(self); + } +SWIGINTERN OSRCoordinateTransformationShadow *new_OSRCoordinateTransformationShadow(OSRSpatialReferenceShadow *src,OSRSpatialReferenceShadow *dst){ + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } +SWIGINTERN void delete_OSRCoordinateTransformationShadow(OSRCoordinateTransformationShadow *self){ + OCTDestroyCoordinateTransformation( self ); + } +SWIGINTERN void OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(OSRCoordinateTransformationShadow *self,double inout[3]){ + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +SWIGINTERN void OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(OSRCoordinateTransformationShadow *self,double argout[3],double x,double y,double z=0.0){ + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } +#ifdef PERL_OBJECT +#define MAGIC_CLASS _wrap_osr_var:: +class _wrap_osr_var : public CPerlObj { +public: +#else +#define MAGIC_CLASS +#endif +SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) { + MAGIC_PPERL + croak("Value is read-only."); + return 0; +} + + +#ifdef PERL_OBJECT +}; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +XS(_wrap_GetWellKnownGeogCSAsWKT) { + { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *argout2 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: GetWellKnownGeogCSAsWKT(name);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetWellKnownGeogCSAsWKT" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_GetProjectionMethods) { + { + char **result = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 0)) { + SWIG_croak("Usage: GetProjectionMethods();"); + } + result = (char **)OPTGetProjectionMethods(); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0); argvi++ ; + XSRETURN(argvi); + fail: + SWIG_croak_null(); + } +} + + +XS(_wrap_GetProjectionMethodParameterList) { + { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + char **result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: GetProjectionMethodParameterList(method,username);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetProjectionMethodParameterList" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_p_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GetProjectionMethodParameterList" "', argument " "2"" of type '" "char **""'"); + } + arg2 = reinterpret_cast< char ** >(argp2); + result = (char **)OPTGetParameterList(arg1,arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + + SWIG_croak_null(); + } +} + + +XS(_wrap_GetProjectionMethodParamInfo) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + char **arg4 = (char **) 0 ; + double *arg5 = (double *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: GetProjectionMethodParamInfo(method,param,usrname,type,defaultval);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GetProjectionMethodParamInfo" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GetProjectionMethodParamInfo" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + res3 = SWIG_ConvertPtr(ST(2), &argp3,SWIGTYPE_p_p_char, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "GetProjectionMethodParamInfo" "', argument " "3"" of type '" "char **""'"); + } + arg3 = reinterpret_cast< char ** >(argp3); + res4 = SWIG_ConvertPtr(ST(3), &argp4,SWIGTYPE_p_p_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "GetProjectionMethodParamInfo" "', argument " "4"" of type '" "char **""'"); + } + arg4 = reinterpret_cast< char ** >(argp4); + res5 = SWIG_ConvertPtr(ST(4), &argp5,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "GetProjectionMethodParamInfo" "', argument " "5"" of type '" "double *""'"); + } + arg5 = reinterpret_cast< double * >(argp5); + OPTGetParameterInfo(arg1,arg2,arg3,arg4,arg5); + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_SpatialReference) { + { + char *arg1 = (char *) "" ; + OSRSpatialReferenceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 0) || (items > 1)) { + SWIG_croak("Usage: new_SpatialReference(wkt);"); + } + if (items > 0) { + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_SpatialReference" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + result = (OSRSpatialReferenceShadow *)new_OSRSpatialReferenceShadow((char const *)arg1); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_SpatialReference) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_SpatialReference(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SpatialReference" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + delete_OSRSpatialReferenceShadow(arg1); + + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference___str__) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference___str__(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference___str__" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (char *)OSRSpatialReferenceShadow___str__(arg1); + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + delete[] result; + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_IsSame) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_IsSame(self,rhs);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_IsSame" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_IsSame" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + result = (int)OSRSpatialReferenceShadow_IsSame(arg1,arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_IsSameGeogCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_IsSameGeogCS(self,rhs);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_IsSameGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_IsSameGeogCS" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + result = (int)OSRSpatialReferenceShadow_IsSameGeogCS(arg1,arg2); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_IsGeographic) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_IsGeographic(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_IsGeographic" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (int)OSRSpatialReferenceShadow_IsGeographic(arg1); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_IsProjected) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_IsProjected(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_IsProjected" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (int)OSRSpatialReferenceShadow_IsProjected(arg1); + ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetAttrValue) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_GetAttrValue(self,name,child);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetAttrValue" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_GetAttrValue" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_GetAttrValue" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (char *)OSRSpatialReferenceShadow_GetAttrValue(arg1,(char const *)arg2,arg3); + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetAttrValue) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetAttrValue(self,name,value);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetAttrValue" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetAttrValue" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SpatialReference_SetAttrValue" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + result = (OGRErr)OSRSpatialReferenceShadow_SetAttrValue(arg1,(char const *)arg2,(char const *)arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetAngularUnits) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetAngularUnits(self,name,to_radians);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetAngularUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetAngularUnits" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetAngularUnits" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetAngularUnits(arg1,(char const *)arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetAngularUnits) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_GetAngularUnits(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetAngularUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (double)OSRSpatialReferenceShadow_GetAngularUnits(arg1); + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetLinearUnits) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetLinearUnits(self,name,to_meters);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetLinearUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetLinearUnits" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetLinearUnits" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetLinearUnits(arg1,(char const *)arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetLinearUnits) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_GetLinearUnits(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetLinearUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (double)OSRSpatialReferenceShadow_GetLinearUnits(arg1); + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetLinearUnitsName) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_GetLinearUnitsName(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetLinearUnitsName" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (char *)OSRSpatialReferenceShadow_GetLinearUnitsName(arg1); + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetAuthorityCode) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_GetAuthorityCode(self,target_key);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetAuthorityCode" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_GetAuthorityCode" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (char *)OSRSpatialReferenceShadow_GetAuthorityCode(arg1,(char const *)arg2); + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetAuthorityName) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_GetAuthorityName(self,target_key);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetAuthorityName" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_GetAuthorityName" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (char *)OSRSpatialReferenceShadow_GetAuthorityName(arg1,(char const *)arg2); + ST(argvi) = SWIG_FromCharPtr(result); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetUTM) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetUTM(self,zone,north);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetUTM" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetUTM" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetUTM" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetUTM(arg1,arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + XSRETURN(argvi); + fail: + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetStatePlane) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + char *arg4 = (char *) "" ; + double arg5 = (double) 0.0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_SetStatePlane(self,zone,is_nad83,unitsname,units);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetStatePlane" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetStatePlane" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + if (items > 2) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetStatePlane" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "SpatialReference_SetStatePlane" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + } + if (items > 4) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetStatePlane" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetStatePlane(arg1,arg2,arg3,(char const *)arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + + XSRETURN(argvi); + fail: + + + + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_AutoIdentifyEPSG) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_AutoIdentifyEPSG(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_AutoIdentifyEPSG" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_AutoIdentifyEPSG(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetProjection) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_SetProjection(self,arg);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetProjection" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetProjection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetProjection(arg1,(char const *)arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetProjParm) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetProjParm(self,name,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetProjParm(arg1,(char const *)arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetProjParm) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_GetProjParm(self,name,default_val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_GetProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_GetProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + } + result = (double)OSRSpatialReferenceShadow_GetProjParm(arg1,(char const *)arg2,arg3); + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetNormProjParm) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 3) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_SetNormProjParm(self,name,val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetNormProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetNormProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetNormProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetNormProjParm(arg1,(char const *)arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetNormProjParm) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 3)) { + SWIG_croak("Usage: SpatialReference_GetNormProjParm(self,name,default_val);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetNormProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_GetNormProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_GetNormProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + } + result = (double)OSRSpatialReferenceShadow_GetNormProjParm(arg1,(char const *)arg2,arg3); + ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(result)); argvi++ ; + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetACEA) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 7) || (items > 7)) { + SWIG_croak("Usage: SpatialReference_SetACEA(self,stdp1,stdp2,clat,clong,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetACEA" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetACEA" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetACEA" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetACEA" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetACEA" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + ecode6 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(5), &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "SpatialReference_SetACEA" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast< double >(val6); + ecode7 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(6), &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "SpatialReference_SetACEA" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast< double >(val7); + result = (OGRErr)OSRSpatialReferenceShadow_SetACEA(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + + + XSRETURN(argvi); + fail: + + + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetAE) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_SetAE(self,clat,clon,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetAE" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetAE" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetAE" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetAE" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetAE" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetAE(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_SetCS(self,clat,clong,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetCS" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetCS" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetCS" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetCS" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetCS(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetBonne) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_SetBonne(self,clat,clong,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetBonne" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetBonne" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetBonne" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetBonne" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetBonne" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetBonne(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetEC) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 7) || (items > 7)) { + SWIG_croak("Usage: SpatialReference_SetEC(self,stdp1,stdp2,clat,clong,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetEC" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetEC" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetEC" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetEC" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetEC" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + ecode6 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(5), &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "SpatialReference_SetEC" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast< double >(val6); + ecode7 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(6), &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "SpatialReference_SetEC" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast< double >(val7); + result = (OGRErr)OSRSpatialReferenceShadow_SetEC(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + + + XSRETURN(argvi); + fail: + + + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetEckertIV) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: SpatialReference_SetEckertIV(self,cm,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetEckertIV" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetEckertIV" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetEckertIV" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetEckertIV" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertIV(arg1,arg2,arg3,arg4); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + XSRETURN(argvi); + fail: + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetEckertVI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: SpatialReference_SetEckertVI(self,cm,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetEckertVI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetEckertVI" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetEckertVI" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetEckertVI" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertVI(arg1,arg2,arg3,arg4); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + XSRETURN(argvi); + fail: + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetEquirectangular) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 5) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_SetEquirectangular(self,clat,clong,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetEquirectangular" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetEquirectangular" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetEquirectangular" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetEquirectangular" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetEquirectangular" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetEquirectangular(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetGS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 4)) { + SWIG_croak("Usage: SpatialReference_SetGS(self,cm,fe,fn);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetGS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetGS" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetGS" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetGS" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetGS(arg1,arg2,arg3,arg4); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + XSRETURN(argvi); + fail: + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetWellKnownGeogCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_SetWellKnownGeogCS(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetWellKnownGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetWellKnownGeogCS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetWellKnownGeogCS(arg1,(char const *)arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetFromUserInput) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_SetFromUserInput(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetFromUserInput" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetFromUserInput" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetFromUserInput(arg1,(char const *)arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_CopyGeogCSFrom) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_CopyGeogCSFrom(self,rhs);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_CopyGeogCSFrom" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_CopyGeogCSFrom" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + result = (OGRErr)OSRSpatialReferenceShadow_CopyGeogCSFrom(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetTOWGS84) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double arg6 = (double) 0.0 ; + double arg7 = (double) 0.0 ; + double arg8 = (double) 0.0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 4) || (items > 8)) { + SWIG_croak("Usage: SpatialReference_SetTOWGS84(self,p1,p2,p3,p4,p5,p6,p7);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetTOWGS84" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_SetTOWGS84" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast< double >(val2); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_SetTOWGS84" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "SpatialReference_SetTOWGS84" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + if (items > 4) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetTOWGS84" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + if (items > 5) { + ecode6 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(5), &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "SpatialReference_SetTOWGS84" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast< double >(val6); + } + if (items > 6) { + ecode7 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(6), &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "SpatialReference_SetTOWGS84" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast< double >(val7); + } + if (items > 7) { + ecode8 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(7), &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "SpatialReference_SetTOWGS84" "', argument " "8"" of type '" "double""'"); + } + arg8 = static_cast< double >(val8); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetTOWGS84(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + + + + XSRETURN(argvi); + fail: + + + + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_GetTOWGS84) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double *arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[7] ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_GetTOWGS84(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_GetTOWGS84" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_GetTOWGS84(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 7 ); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetGeogCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + double arg5 ; + double arg6 ; + char *arg7 = (char *) "Greenwich" ; + double arg8 = (double) 0.0 ; + char *arg9 = (char *) "degree" ; + double arg10 = (double) 0.0174532925199433 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int res9 ; + char *buf9 = 0 ; + int alloc9 = 0 ; + double val10 ; + int ecode10 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 6) || (items > 10)) { + SWIG_croak("Usage: SpatialReference_SetGeogCS(self,pszGeogName,pszDatumName,pszEllipsoidName,dfSemiMajor,dfInvFlattening,pszPMName,dfPMOffset,pszUnits,dfConvertToRadians);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetGeogCS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SpatialReference_SetGeogCS" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "SpatialReference_SetGeogCS" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_SetGeogCS" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + ecode6 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(5), &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "SpatialReference_SetGeogCS" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast< double >(val6); + if (items > 6) { + res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "SpatialReference_SetGeogCS" "', argument " "7"" of type '" "char const *""'"); + } + arg7 = buf7; + } + if (items > 7) { + ecode8 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(7), &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "SpatialReference_SetGeogCS" "', argument " "8"" of type '" "double""'"); + } + arg8 = static_cast< double >(val8); + } + if (items > 8) { + res9 = SWIG_AsCharPtrAndSize(ST(8), &buf9, NULL, &alloc9); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "SpatialReference_SetGeogCS" "', argument " "9"" of type '" "char const *""'"); + } + arg9 = buf9; + } + if (items > 9) { + ecode10 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(9), &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "SpatialReference_SetGeogCS" "', argument " "10"" of type '" "double""'"); + } + arg10 = static_cast< double >(val10); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetGeogCS(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,(char const *)arg7,arg8,(char const *)arg9,arg10); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + + + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + + if (alloc9 == SWIG_NEWOBJ) delete[] buf9; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + + + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + + if (alloc9 == SWIG_NEWOBJ) delete[] buf9; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_SetProjCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) "unnamed" ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_SetProjCS(self,name);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_SetProjCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + if (items > 1) { + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_SetProjCS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjCS(arg1,(char const *)arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromWkt) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *val2 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ImportFromWkt(self,ppszInput);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromWkt" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + { + /* %typemap(in) (char **ignorechange) */ + val2 = SvPV_nolen(ST(1)); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromWkt(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromProj4) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ImportFromProj4(self,ppszInput);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromProj4" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_ImportFromProj4" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromProj4(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromESRI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *val2 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ImportFromESRI(self,ppszInput);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromESRI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + { + /* %typemap(in) (char **ignorechange) */ + val2 = SvPV_nolen(ST(1)); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromESRI(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromEPSG) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ImportFromEPSG(self,arg);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromEPSG" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_ImportFromEPSG" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast< int >(val2); + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromEPSG(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromPCI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "METRE" ; + double *arg4 = (double *) (double *)0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + double argin4[17] ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 4)) { + SWIG_croak("Usage: SpatialReference_ImportFromPCI(self,proj,units,argin);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromPCI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_ImportFromPCI" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SpatialReference_ImportFromPCI" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + if (items > 3) { + { + /* %typemap(in) (double argin4[ANY]) */ + if (! (SvROK(ST(3)) && (SvTYPE(SvRV(ST(3)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + arg4 = argin4; + AV *av = (AV*)(SvRV(ST(3))); + int seq_size = av_len(av)+1; + if ( seq_size != 17 ) { + croak("argument array must have length %d",17); + SWIG_fail; + } + for (unsigned int i=0; i<17; i++) { + SV **sv = av_fetch(av, i, 0); + arg4[i] = SvNV(*sv); + } + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromPCI(arg1,(char const *)arg2,(char const *)arg3,arg4); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromUSGS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long arg2 ; + long arg3 = (long) 0 ; + double *arg4 = (double *) (double *)0 ; + long arg5 = (long) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + long val3 ; + int ecode3 = 0 ; + double argin4[15] ; + long val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 5)) { + SWIG_croak("Usage: SpatialReference_ImportFromUSGS(self,proj_code,zone,argin,datum_code);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromUSGS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(1), &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpatialReference_ImportFromUSGS" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast< long >(val2); + if (items > 2) { + ecode3 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(2), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_ImportFromUSGS" "', argument " "3"" of type '" "long""'"); + } + arg3 = static_cast< long >(val3); + } + if (items > 3) { + { + /* %typemap(in) (double argin4[ANY]) */ + if (! (SvROK(ST(3)) && (SvTYPE(SvRV(ST(3)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + arg4 = argin4; + AV *av = (AV*)(SvRV(ST(3))); + int seq_size = av_len(av)+1; + if ( seq_size != 15 ) { + croak("argument array must have length %d",15); + SWIG_fail; + } + for (unsigned int i=0; i<15; i++) { + SV **sv = av_fetch(av, i, 0); + arg4[i] = SvNV(*sv); + } + } + } + if (items > 4) { + ecode5 = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(ST(4), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "SpatialReference_ImportFromUSGS" "', argument " "5"" of type '" "long""'"); + } + arg5 = static_cast< long >(val5); + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromUSGS(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ImportFromXML) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ImportFromXML(self,xmlString);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ImportFromXML" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SpatialReference_ImportFromXML" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromXML(arg1,(char const *)arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + XSRETURN(argvi); + fail: + + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToWkt) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_ExportToWkt(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToWkt" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_ExportToWkt(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToPrettyWkt) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + int arg3 = (int) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ExportToPrettyWkt(self,simplify);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToPrettyWkt" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + if (items > 1) { + ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "SpatialReference_ExportToPrettyWkt" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast< int >(val3); + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPrettyWkt(arg1,arg2,arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToProj4) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_ExportToProj4(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToProj4" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_ExportToProj4(arg1,arg2); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToPCI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char **arg3 = (char **) 0 ; + double **arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + char *argout3 = 0 ; + double *argout4 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + { + /* %typemap(in,numinputs=0) (char **argout3) */ + arg3 = &argout3; + } + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_ExportToPCI(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToPCI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPCI(arg1,arg2,arg3,arg4); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg3 ) + sv_setpv(ST(argvi), *arg3); + argvi++; + } + { + /* %typemap(argout) (double *argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( *arg4, 17 ); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToUSGS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + double **arg4 ; + long *arg5 = (long *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + long temp2 ; + int res2 = SWIG_TMPOBJ ; + long temp3 ; + int res3 = SWIG_TMPOBJ ; + double *argout4 ; + long temp5 ; + int res5 = SWIG_TMPOBJ ; + int argvi = 0; + dXSARGS; + + arg2 = &temp2; + arg3 = &temp3; + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + arg5 = &temp5; + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_ExportToUSGS(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToUSGS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_ExportToUSGS(arg1,arg2,arg3,arg4,arg5); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + if (SWIG_IsTmpObj(res2)) { + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_From_long SWIG_PERL_CALL_ARGS_1((*arg2)); argvi++ ; + } else { + int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0) : 0; + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_long, new_flags); argvi++ ; + } + if (SWIG_IsTmpObj(res3)) { + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_From_long SWIG_PERL_CALL_ARGS_1((*arg3)); argvi++ ; + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0) : 0; + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_long, new_flags); argvi++ ; + } + { + /* %typemap(argout) (double *argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( *arg4, 15 ); + argvi++; + } + if (SWIG_IsTmpObj(res5)) { + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_From_long SWIG_PERL_CALL_ARGS_1((*arg5)); argvi++ ; + } else { + int new_flags = SWIG_IsNewObj(res5) ? (SWIG_POINTER_OWN | 0) : 0; + if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_long, new_flags); argvi++ ; + } + + + + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + + XSRETURN(argvi); + fail: + + + + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_ExportToXML) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + char *argout2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if ((items < 1) || (items > 2)) { + SWIG_croak("Usage: SpatialReference_ExportToXML(self,dialect);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_ExportToXML" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + if (items > 1) { + res3 = SWIG_AsCharPtrAndSize(ST(1), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "SpatialReference_ExportToXML" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToXML(arg1,arg2,(char const *)arg3); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + { + /* %typemap(argout) (char **argout) */ + ST(argvi) = sv_newmortal(); + if ( arg2 ) + sv_setpv(ST(argvi), *arg2); + argvi++; + } + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + XSRETURN(argvi); + fail: + + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_CloneGeogCS) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_CloneGeogCS(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_CloneGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OSRSpatialReferenceShadow *)OSRSpatialReferenceShadow_CloneGeogCS(arg1); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_Validate) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_Validate(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_Validate" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_Validate(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_StripCTParms) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_StripCTParms(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_StripCTParms" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_StripCTParms(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_FixupOrdering) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_FixupOrdering(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_FixupOrdering" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_FixupOrdering(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_Fixup) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_Fixup(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_Fixup" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_Fixup(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_MorphToESRI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_MorphToESRI(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_MorphToESRI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_MorphToESRI(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_SpatialReference_MorphFromESRI) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: SpatialReference_MorphFromESRI(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpatialReference_MorphFromESRI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_MorphFromESRI(arg1); + { + /* %typemap(out) OGRErr */ + if ( result != 0 ) { + croak( OGRErrMessages(result) ); + } + } + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_new_CoordinateTransformation) { + { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OSRCoordinateTransformationShadow *result = 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: new_CoordinateTransformation(src,dst);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_CoordinateTransformation" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_CoordinateTransformation" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast< OSRSpatialReferenceShadow * >(argp2); + result = (OSRCoordinateTransformationShadow *)new_OSRCoordinateTransformationShadow(arg1,arg2); + ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_OWNER | SWIG_SHADOW); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_delete_CoordinateTransformation) { + { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: delete_CoordinateTransformation(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_CoordinateTransformation" "', argument " "1"" of type '" "OSRCoordinateTransformationShadow *""'"); + } + arg1 = reinterpret_cast< OSRCoordinateTransformationShadow * >(argp1); + delete_OSRCoordinateTransformationShadow(arg1); + + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + +XS(_wrap_CoordinateTransformation_TransformPoint__SWIG_0) { + { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + double argin2[3] ; + int argvi = 0; + SV * _saved[1] ; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: CoordinateTransformation_TransformPoint(self,inout);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRCoordinateTransformationShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoordinateTransformation_TransformPoint" "', argument " "1"" of type '" "OSRCoordinateTransformationShadow *""'"); + } + arg1 = reinterpret_cast< OSRCoordinateTransformationShadow * >(argp1); + { + /* %typemap(in) (double argin2[ANY]) */ + if (! (SvROK(ST(1)) && (SvTYPE(SvRV(ST(1)))==SVt_PVAV))) { + croak("argument is not an array ref"); + SWIG_fail; + } + arg2 = argin2; + AV *av = (AV*)(SvRV(ST(1))); + int seq_size = av_len(av)+1; + if ( seq_size != 3 ) { + croak("argument array must have length %d",3); + SWIG_fail; + } + for (unsigned int i=0; i<3; i++) { + SV **sv = av_fetch(av, i, 0); + arg2[i] = SvNV(*sv); + } + } + _saved[0] = ST(1); + OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(arg1,arg2); + + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 3 ); + argvi++; + } + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + +XS(_wrap_CoordinateTransformation_TransformPoint__SWIG_1) { + { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + void *argp1 = 0 ; + int res1 = 0 ; + double argout2[3] ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int argvi = 0; + dXSARGS; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((items < 3) || (items > 4)) { + SWIG_croak("Usage: CoordinateTransformation_TransformPoint(self,x,y,z);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_OSRCoordinateTransformationShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoordinateTransformation_TransformPoint" "', argument " "1"" of type '" "OSRCoordinateTransformationShadow *""'"); + } + arg1 = reinterpret_cast< OSRCoordinateTransformationShadow * >(argp1); + ecode3 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoordinateTransformation_TransformPoint" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast< double >(val3); + ecode4 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoordinateTransformation_TransformPoint" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast< double >(val4); + if (items > 3) { + ecode5 = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoordinateTransformation_TransformPoint" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast< double >(val5); + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(argout) (double argout[ANY]) */ + ST(argvi) = CreateArrayFromDoubleArray( arg2, 3 ); + argvi++; + } + + + + + + XSRETURN(argvi); + fail: + + + + + + SWIG_croak_null(); + } +} + + +XS(_wrap_CoordinateTransformation_TransformPoint) { + dXSARGS; + + { + unsigned long _index = 0; + SWIG_TypeRank _rank = 0; + if (items == 2) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(1), &vptr, SWIGTYPE_p_double, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_1; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 1; + if (_rank == _rankm) goto dispatch; + } + } + check_1: + + if ((items >= 3) && (items <= 4)) { + SWIG_TypeRank _ranki = 0; + SWIG_TypeRank _rankm = 0; + SWIG_TypeRank _pi = 1; + int _v = 0; + { + void *vptr = 0; + int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0); + _v = SWIG_CheckState(res); + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(1), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + { + { + int res = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(2), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + if (items > 3) { + { + { + int res = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(ST(3), NULL); + _v = SWIG_CheckState(res); + } + } + if (!_v) goto check_2; + _ranki += _v*_pi; + _rankm += _pi; + _pi *= SWIG_MAXCASTRANK; + } + if (!_index || (_ranki < _rank)) { + _rank = _ranki; _index = 2; + if (_rank == _rankm) goto dispatch; + } + } + check_2: + + dispatch: + switch(_index) { + case 1: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoordinateTransformation_TransformPoint__SWIG_0); return; + case 2: + ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoordinateTransformation_TransformPoint__SWIG_1); return; + } + } + + croak("No matching function for overloaded 'CoordinateTransformation_TransformPoint'"); + XSRETURN(0); +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, (void*)"osr::CoordinateTransformation", 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, (void*)"osr::SpatialReference", 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|OGRErr *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_long = {"_p_long", "long *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_double = {"_p_p_double", "double **", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_long, + &_swigt__p_p_char, + &_swigt__p_p_double, +}; + +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_double[] = { {&_swigt__p_p_double, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_long, + _swigc__p_p_char, + _swigc__p_p_double, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_constant_info swig_constants[] = { +{0,0,0,0,0,0} +}; +#ifdef __cplusplus +} +#endif +static swig_variable_info swig_variables[] = { +{0,0,0,0} +}; +static swig_command_info swig_commands[] = { +{"osrc::GetWellKnownGeogCSAsWKT", _wrap_GetWellKnownGeogCSAsWKT}, +{"osrc::GetProjectionMethods", _wrap_GetProjectionMethods}, +{"osrc::GetProjectionMethodParameterList", _wrap_GetProjectionMethodParameterList}, +{"osrc::GetProjectionMethodParamInfo", _wrap_GetProjectionMethodParamInfo}, +{"osrc::new_SpatialReference", _wrap_new_SpatialReference}, +{"osrc::delete_SpatialReference", _wrap_delete_SpatialReference}, +{"osrc::SpatialReference___str__", _wrap_SpatialReference___str__}, +{"osrc::SpatialReference_IsSame", _wrap_SpatialReference_IsSame}, +{"osrc::SpatialReference_IsSameGeogCS", _wrap_SpatialReference_IsSameGeogCS}, +{"osrc::SpatialReference_IsGeographic", _wrap_SpatialReference_IsGeographic}, +{"osrc::SpatialReference_IsProjected", _wrap_SpatialReference_IsProjected}, +{"osrc::SpatialReference_GetAttrValue", _wrap_SpatialReference_GetAttrValue}, +{"osrc::SpatialReference_SetAttrValue", _wrap_SpatialReference_SetAttrValue}, +{"osrc::SpatialReference_SetAngularUnits", _wrap_SpatialReference_SetAngularUnits}, +{"osrc::SpatialReference_GetAngularUnits", _wrap_SpatialReference_GetAngularUnits}, +{"osrc::SpatialReference_SetLinearUnits", _wrap_SpatialReference_SetLinearUnits}, +{"osrc::SpatialReference_GetLinearUnits", _wrap_SpatialReference_GetLinearUnits}, +{"osrc::SpatialReference_GetLinearUnitsName", _wrap_SpatialReference_GetLinearUnitsName}, +{"osrc::SpatialReference_GetAuthorityCode", _wrap_SpatialReference_GetAuthorityCode}, +{"osrc::SpatialReference_GetAuthorityName", _wrap_SpatialReference_GetAuthorityName}, +{"osrc::SpatialReference_SetUTM", _wrap_SpatialReference_SetUTM}, +{"osrc::SpatialReference_SetStatePlane", _wrap_SpatialReference_SetStatePlane}, +{"osrc::SpatialReference_AutoIdentifyEPSG", _wrap_SpatialReference_AutoIdentifyEPSG}, +{"osrc::SpatialReference_SetProjection", _wrap_SpatialReference_SetProjection}, +{"osrc::SpatialReference_SetProjParm", _wrap_SpatialReference_SetProjParm}, +{"osrc::SpatialReference_GetProjParm", _wrap_SpatialReference_GetProjParm}, +{"osrc::SpatialReference_SetNormProjParm", _wrap_SpatialReference_SetNormProjParm}, +{"osrc::SpatialReference_GetNormProjParm", _wrap_SpatialReference_GetNormProjParm}, +{"osrc::SpatialReference_SetACEA", _wrap_SpatialReference_SetACEA}, +{"osrc::SpatialReference_SetAE", _wrap_SpatialReference_SetAE}, +{"osrc::SpatialReference_SetCS", _wrap_SpatialReference_SetCS}, +{"osrc::SpatialReference_SetBonne", _wrap_SpatialReference_SetBonne}, +{"osrc::SpatialReference_SetEC", _wrap_SpatialReference_SetEC}, +{"osrc::SpatialReference_SetEckertIV", _wrap_SpatialReference_SetEckertIV}, +{"osrc::SpatialReference_SetEckertVI", _wrap_SpatialReference_SetEckertVI}, +{"osrc::SpatialReference_SetEquirectangular", _wrap_SpatialReference_SetEquirectangular}, +{"osrc::SpatialReference_SetGS", _wrap_SpatialReference_SetGS}, +{"osrc::SpatialReference_SetWellKnownGeogCS", _wrap_SpatialReference_SetWellKnownGeogCS}, +{"osrc::SpatialReference_SetFromUserInput", _wrap_SpatialReference_SetFromUserInput}, +{"osrc::SpatialReference_CopyGeogCSFrom", _wrap_SpatialReference_CopyGeogCSFrom}, +{"osrc::SpatialReference_SetTOWGS84", _wrap_SpatialReference_SetTOWGS84}, +{"osrc::SpatialReference_GetTOWGS84", _wrap_SpatialReference_GetTOWGS84}, +{"osrc::SpatialReference_SetGeogCS", _wrap_SpatialReference_SetGeogCS}, +{"osrc::SpatialReference_SetProjCS", _wrap_SpatialReference_SetProjCS}, +{"osrc::SpatialReference_ImportFromWkt", _wrap_SpatialReference_ImportFromWkt}, +{"osrc::SpatialReference_ImportFromProj4", _wrap_SpatialReference_ImportFromProj4}, +{"osrc::SpatialReference_ImportFromESRI", _wrap_SpatialReference_ImportFromESRI}, +{"osrc::SpatialReference_ImportFromEPSG", _wrap_SpatialReference_ImportFromEPSG}, +{"osrc::SpatialReference_ImportFromPCI", _wrap_SpatialReference_ImportFromPCI}, +{"osrc::SpatialReference_ImportFromUSGS", _wrap_SpatialReference_ImportFromUSGS}, +{"osrc::SpatialReference_ImportFromXML", _wrap_SpatialReference_ImportFromXML}, +{"osrc::SpatialReference_ExportToWkt", _wrap_SpatialReference_ExportToWkt}, +{"osrc::SpatialReference_ExportToPrettyWkt", _wrap_SpatialReference_ExportToPrettyWkt}, +{"osrc::SpatialReference_ExportToProj4", _wrap_SpatialReference_ExportToProj4}, +{"osrc::SpatialReference_ExportToPCI", _wrap_SpatialReference_ExportToPCI}, +{"osrc::SpatialReference_ExportToUSGS", _wrap_SpatialReference_ExportToUSGS}, +{"osrc::SpatialReference_ExportToXML", _wrap_SpatialReference_ExportToXML}, +{"osrc::SpatialReference_CloneGeogCS", _wrap_SpatialReference_CloneGeogCS}, +{"osrc::SpatialReference_Validate", _wrap_SpatialReference_Validate}, +{"osrc::SpatialReference_StripCTParms", _wrap_SpatialReference_StripCTParms}, +{"osrc::SpatialReference_FixupOrdering", _wrap_SpatialReference_FixupOrdering}, +{"osrc::SpatialReference_Fixup", _wrap_SpatialReference_Fixup}, +{"osrc::SpatialReference_MorphToESRI", _wrap_SpatialReference_MorphToESRI}, +{"osrc::SpatialReference_MorphFromESRI", _wrap_SpatialReference_MorphFromESRI}, +{"osrc::new_CoordinateTransformation", _wrap_new_CoordinateTransformation}, +{"osrc::delete_CoordinateTransformation", _wrap_delete_CoordinateTransformation}, +{"osrc::CoordinateTransformation_TransformPoint", _wrap_CoordinateTransformation_TransformPoint}, +{0,0} +}; +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } + + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_ALBERS_CONIC_EQUAL_AREA", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_ALBERS_CONIC_EQUAL_AREA)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_AZIMUTHAL_EQUIDISTANT", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_AZIMUTHAL_EQUIDISTANT)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_CASSINI_SOLDNER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_CASSINI_SOLDNER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_CYLINDRICAL_EQUAL_AREA", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_CYLINDRICAL_EQUAL_AREA)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_ECKERT_IV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_ECKERT_IV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_ECKERT_VI", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_ECKERT_VI)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_EQUIDISTANT_CONIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_EQUIDISTANT_CONIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_EQUIRECTANGULAR", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_EQUIRECTANGULAR)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_GALL_STEREOGRAPHIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_GALL_STEREOGRAPHIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_GNOMONIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_GNOMONIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_GOODE_HOMOLOSINE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_GOODE_HOMOLOSINE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_HOTINE_OBLIQUE_MERCATOR", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_HOTINE_OBLIQUE_MERCATOR)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_LABORDE_OBLIQUE_MERCATOR", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_LABORDE_OBLIQUE_MERCATOR)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_MERCATOR_1SP", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_MERCATOR_1SP)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_MERCATOR_2SP", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_MERCATOR_2SP)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_MILLER_CYLINDRICAL", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_MILLER_CYLINDRICAL)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_MOLLWEIDE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_MOLLWEIDE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_NEW_ZEALAND_MAP_GRID", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_NEW_ZEALAND_MAP_GRID)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_OBLIQUE_STEREOGRAPHIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_OBLIQUE_STEREOGRAPHIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_ORTHOGRAPHIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_ORTHOGRAPHIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_POLAR_STEREOGRAPHIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_POLAR_STEREOGRAPHIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_POLYCONIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_POLYCONIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_ROBINSON", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_ROBINSON)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_SINUSOIDAL", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_SINUSOIDAL)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_STEREOGRAPHIC", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_STEREOGRAPHIC)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_SWISS_OBLIQUE_CYLINDRICAL", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_SWISS_OBLIQUE_CYLINDRICAL)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR_MI_22", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_22)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR_MI_23", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_23)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR_MI_24", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_24)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TRANSVERSE_MERCATOR_MI_25", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_25)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_TUNISIA_MINING_GRID", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_TUNISIA_MINING_GRID)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_VANDERGRINTEN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_VANDERGRINTEN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PT_KROVAK", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PT_KROVAK)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_CENTRAL_MERIDIAN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_CENTRAL_MERIDIAN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_SCALE_FACTOR", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_SCALE_FACTOR)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_STANDARD_PARALLEL_1", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_STANDARD_PARALLEL_1)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_STANDARD_PARALLEL_2", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_STANDARD_PARALLEL_2)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_PSEUDO_STD_PARALLEL_1", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_PSEUDO_STD_PARALLEL_1)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LONGITUDE_OF_CENTER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_CENTER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LATITUDE_OF_CENTER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_CENTER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LONGITUDE_OF_ORIGIN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_ORIGIN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LATITUDE_OF_ORIGIN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_ORIGIN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_FALSE_EASTING", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_FALSE_EASTING)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_FALSE_NORTHING", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_FALSE_NORTHING)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_AZIMUTH", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_AZIMUTH)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LONGITUDE_OF_POINT_1", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_1)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LATITUDE_OF_POINT_1", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_1)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LONGITUDE_OF_POINT_2", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_2)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LATITUDE_OF_POINT_2", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_2)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LONGITUDE_OF_POINT_3", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_3)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LATITUDE_OF_POINT_3", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_3)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_RECTIFIED_GRID_ANGLE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_RECTIFIED_GRID_ANGLE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_LANDSAT_NUMBER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_LANDSAT_NUMBER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_PATH_NUMBER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_PATH_NUMBER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_PERSPECTIVE_POINT_HEIGHT", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_PERSPECTIVE_POINT_HEIGHT)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_FIPSZONE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_FIPSZONE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_PP_ZONE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_PP_ZONE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_METER", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_METER)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_FOOT", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_FOOT)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_FOOT_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_FOOT_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_US_FOOT", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_US_FOOT)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_US_FOOT_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_US_FOOT_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_NAUTICAL_MILE", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_NAUTICAL_MILE)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_NAUTICAL_MILE_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_NAUTICAL_MILE_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_LINK", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_LINK)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_LINK_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_LINK_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_CHAIN", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_CHAIN)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_CHAIN_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_CHAIN_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_ROD", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_ROD)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_UL_ROD_CONV", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_UL_ROD_CONV)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_DN_NAD27", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_DN_NAD27)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_DN_NAD83", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_DN_NAD83)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_DN_WGS72", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_DN_WGS72)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_DN_WGS84", TRUE | 0x2); + sv_setsv(sv, SWIG_FromCharPtr(SRS_DN_WGS84)); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_WGS84_SEMIMAJOR", TRUE | 0x2); + sv_setsv(sv, SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(SRS_WGS84_SEMIMAJOR))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + /*@SWIG:%set_constant@*/ do { + SV *sv = get_sv((char*) SWIG_prefix "SRS_WGS84_INVFLATTENING", TRUE | 0x2); + sv_setsv(sv, SWIG_From_double SWIG_PERL_CALL_ARGS_1(static_cast< double >(SRS_WGS84_INVFLATTENING))); + SvREADONLY_on(sv); + } while(0) /*@SWIG@*/; + SWIG_TypeClientData(SWIGTYPE_p_OSRSpatialReferenceShadow, (void*) "osr::SpatialReference"); + SWIG_TypeClientData(SWIGTYPE_p_OSRCoordinateTransformationShadow, (void*) "osr::CoordinateTransformation"); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} + diff --git a/Utilities/GDAL/swig/perl/test.pl b/Utilities/GDAL/swig/perl/test.pl new file mode 100644 index 0000000000..07f2564662 --- /dev/null +++ b/Utilities/GDAL/swig/perl/test.pl @@ -0,0 +1,667 @@ +BEGIN { $| = 1; } +END {print "not ok 1\n" unless $loaded;} +use strict; +use gdal; +use gdalconst; +use osr; +use ogr; +use vars qw/%known_driver $loaded $verbose @types %pack_types %types @fails/; + +$loaded = 1; + +$verbose = $ENV{VERBOSE}; + +# tests: +# +# for pre-tested GDAL drivers: +# Create dataset +# Get/SetGeoTransform +# Get/SetNoDataValue +# Colortable operations +# WriteRaster +# Open dataset +# ReadRaster +# GCPs +# +# not yet tested: +# Overviews +# +# for pre-tested OGR drivers: +# Create datasource +# Create layer +# Create field +# Create geometry +# Open layer +# Open field +# Open geom +# Cmp points +# +# not yet tested +# transactions +# GEOS methods +# osr +# XML typemaps +# +# if verbose = 1, all operations (skip,fail,ok) are printed out + +#system "rm -rf tmp_ds_*"; + +%known_driver = ('VRT' => 1,'GTiff' => 1,'NITF' => 1,'HFA' => 1,'SAR_CEOS' => 1, + 'CEOS' => 1,'ELAS' => 1,'AIG' => 1,'AAIGrid' => 1,'SDTS' => 1, + 'OGDI' => 1,'DTED' => 1,'PNG' => 1,'JPEG' => 1,'MEM' => 1, + 'JDEM' => 1,'GIF' => 1,'ESAT' => 1,'BSB' => 1,'XPM' => 1, + 'BMP' => 1,'AirSAR' => 1,'RS2' => 1,'PCIDSK' => 1,'PCRaster' => 1, + 'ILWIS' => 1,'RIK' => 1,'SGI' => 1,'Leveller' => 1,'GMT' => 1, + 'netCDF' => 1,'PNM' => 1,'DOQ1' => 1,'DOQ2' => 1,'ENVI' => 1, + 'EHdr' => 1,'PAux' => 1,'MFF' => 1,'MFF2' => 1,'FujiBAS' => 1, + 'GSC' => 1,'FAST' => 1,'BT' => 1,'LAN' => 1,'CPG' => 1,'IDA' => 1, + 'NDF' => 1,'DIPEx' => 1,'ISIS2' => 1,'L1B' => 1,'FIT' => 1,'RMF' => 1, + 'RST' => 1,'USGSDEM' => 1,'GXF' => 1,'ESRI Shapefile' => 1, + 'MapInfo File' => 1,'UK .NTF' => 1,'SDTS' => 1,'TIGER' => 1, + 'S57' => 1,'DGN' => 1,'VRT' => 1,'AVCBin' => 1,'REC' => 1, + 'Memory' => 1,'CSV' => 1,'GML' => 1,'OGDI' => 1,'PostgreSQL' => 1); + +@types = ('GDT_Byte','GDT_UInt16','GDT_Int16','GDT_UInt32','GDT_Int32', + 'GDT_Float32','GDT_Float64','GDT_CInt16','GDT_CInt32','GDT_CFloat32','GDT_CFloat64'); + +%pack_types = ('GDT_Byte'=>'c', + 'GDT_Int16'=>'s', + 'GDT_Int32'=>'i', + 'GDT_Float32'=>'f', + 'GDT_Float64'=>'d', + ); + +for (@types) {$types{$_} = eval "\$gdalconst::$_"}; + +my %no_colortable = map {$_=>1} ('NITF','ELAS','BMP','ILWIS','BT','RMF','RST'); + +my %no_nodatavalue = map {$_=>1} ('NITF','HFA','ELAS','BMP','ILWIS','BT','IDA','RMF'); + +my %no_geotransform = map {$_=>1} ('NITF','PAux','PNM','MFF','ENVI','BMP','EHdr'); + +my %no_setgcp = map {$_=>1} ('HFA','ELAS','MEM','BMP','PCIDSK','ILWIS','PNM','ENVI', + 'NITF','EHdr','MFF','MFF2','BT','IDA','RMF','RST'); + +my %no_open = map {$_=>1} ('VRT','MEM','ILWIS','MFF2'); + +gdal_tests(gdal::GetDriverCount()); + +my $osr = new osr::SpatialReference; +$osr->SetWellKnownGeogCS('WGS84'); + +@types = ('wkbUnknown','wkbPoint','wkbLineString','wkbPolygon', + 'wkbMultiPoint','wkbMultiLineString','wkbMultiPolygon','wkbGeometryCollection'); + +%types = (); + +for (@types) {$types{$_} = eval "\$ogr::$_"}; + +ogr_tests(ogr::GetDriverCount(),$osr); + +if (@fails) { + print "unexpected failures: (shapefile integer type error is bug #933)\n",@fails; + print "all other tests ok.\n"; +} else { + print "all tests ok.\n"; +} + +system "rm -rf tmp_ds_*"; + +########################################### +# +# only subs below +# +########################################### + +sub gdal_tests { + my $nr_drivers_tested = shift; + + for my $i (0..$nr_drivers_tested-1) { + + my $driver = gdal::GetDriver($i); + unless ($driver) { + mytest('',undef,"gdal::GetDriver($i)"); + next; + } + + my $name = $driver->{ShortName}; +# print "$name\n"; + mytest('skipped: not tested',undef,$name,'test') unless $known_driver{$name}; + + next if $name eq 'MFF2'; # does not work probably because of changes in hkvdataset.cpp + + my $metadata = $driver->GetMetadata(); + + unless ($metadata->{DCAP_CREATE} eq 'YES') { + mytest('skipped: no capability',undef,$name,'dataset create'); + next; + } + + my @create = split /\s+/,$metadata->{DMD_CREATIONDATATYPES}; + + @create = ('Byte','Float32','UInt16','Int16','CInt16','CInt32','CFloat32') + if $driver->{ShortName} eq 'MFF2'; + + unless (@create) { + mytest('skipped: no creation datatypes',undef,$name,'dataset create'); + next; + } + + if ($driver->{ShortName} eq 'PAux') { + mytest('skipped: does not work?',undef,$name,'dataset create'); + next; + } + + my $ext = '.'.$metadata->{DMD_EXTENSION}; + $ext = '' if $driver->{ShortName} eq 'ILWIS'; + + for my $type (@create) { + + if (($driver->{ShortName} eq 'MFF2') and ($type eq 'CInt32')) { + mytest('skipped: does not work?',undef,$name,$type,'dataset create'); + next; + } + + my $typenr = $types{'GDT_'.$type}; + + my $filename = "tmp_ds_".$driver->{ShortName}."_$type$ext"; + my $width = 100; + my $height = 50; + my $bands = 1; + my $options = undef; + + my $dataset; + eval { + $dataset = $driver->Create($filename, $width, $height, $bands , $typenr, []); + }; + mytest($dataset,'no error message',$name,$type,'dataset create'); + next unless $dataset; + + mytest($dataset->{RasterXSize} == $width,'RasterXSize',$name,$type,'RasterXSize'); + mytest($dataset->{RasterYSize} == $height,'RasterYSize',$name,$type,'RasterYSize'); + + my $band = $dataset->GetRasterBand(1); + + if ($no_geotransform{$driver->{ShortName}}) + { + mytest('skipped',undef,$name,$type,'Get/SetGeoTransform'); + + } else + { + my $transform = $dataset->GetGeoTransform(); + $transform->[5] = 12; + $dataset->SetGeoTransform($transform); + my $transform2 = $dataset->GetGeoTransform(); + mytest($transform->[5] == $transform2->[5], + "$transform->[5] != $transform2->[5]",$name,$type,'Get/SetGeoTransform'); + } + + if ($no_nodatavalue{$driver->{ShortName}}) + { + mytest('skipped',undef,$name,$type,'Get/SetNoDataValue'); + + } else + { + $band->SetNoDataValue(5); + my $value = $band->GetNoDataValue; + mytest($value == 5,"$value != 5",$name,$type,'Get/SetNoDataValue'); + } + + if ($no_colortable{$driver->{ShortName}} + or ($driver->{ShortName} eq 'GTiff' and ($type ne 'Byte' or $type ne 'UInt16')) + ) + { + mytest('skipped',undef,$name,$type,'Colortable'); + + } else + { + my $colortable = new gdal::ColorTable(); + my @rgba = (255,0,0,255); + $colortable->SetColorEntry(0, \@rgba); + $band->SetRasterColorTable($colortable); + $colortable = $band->GetRasterColorTable; + my @rgba2 = $colortable->GetColorEntry(0); + + mytest($rgba[0] == $rgba2[0] and + $rgba[1] == $rgba2[1] and + $rgba[2] == $rgba2[2] and + $rgba[3] == $rgba2[3],"colors do not match",$name,$type,'Colortable'); + } + + my $pc = $pack_types{"GDT_$type"}; + + if ($driver->{ShortName} eq 'VRT') + { + mytest('skipped',"",$name,$type,'WriteRaster'); + + } elsif (!$pc) + { + mytest('skipped',"no packtype defined yet",$name,$type,'WriteRaster'); + + } else + { + $pc = "${pc}[$width]"; + my $scanline = pack($pc,(1..$width)); + + for my $yoff (0..$height-1) { + $band->WriteRaster( 0, $yoff, $width, 1, $scanline ); + } + } + + if ($no_setgcp{$driver->{ShortName}}) + { + mytest('skipped',undef,$name,$type,'Set/GetGCPs'); + + } else + { + my @gcps = (); + push @gcps,new gdal::GCP(1.1,2.2); + push @gcps,new gdal::GCP(2.1,3.2); + my $po = "ho ho ho"; + $dataset->SetGCPs(\@gcps,$po); + my $c = $dataset->GetGCPCount(); + my $p = $dataset->GetGCPProjection(); + my $gcps = $dataset->GetGCPs(); + my $y1 = $gcps->[0]->{GCPY}; + my $y2 = $gcps->[1]->{GCPY}; + my $y1o = $gcps[0]->{GCPY}; + my $y2o = $gcps[1]->{GCPY}; + mytest(($c == 2 and $p eq $po and $y1 == $y1o and $y2 == $y2o), + "$c != 2 or $p ne $po or $y1 != $y1o or $y2 != $y2o",$name,$type,'Set/GetGCPs'); + } + + undef $band; + undef $dataset; + + if ($no_open{$driver->{ShortName}} or + ($driver->{ShortName} eq 'MFF2' and + ($type eq 'Int32' or $type eq 'Float64' or $type eq 'CFloat64'))) + { + mytest('skipped',undef,$name,$type,'open'); + + } else + { + $ext = '.'.$metadata->{DMD_EXTENSION}; + $filename = "tmp_ds_".$driver->{ShortName}."_$type$ext"; + + eval { + $dataset = gdal::Open($filename); + }; + mytest($dataset,'no message',$name,$type,'open'); + + if ($dataset) { + mytest($dataset->{RasterXSize} == $width,'RasterXSize',$name,$type,'RasterXSize'); + mytest($dataset->{RasterYSize} == $height,'RasterYSize',$name,$type,'RasterYSize'); + + my $band = $dataset->GetRasterBand(1); + + if ($pc) { + + my $scanline = $band->ReadRaster( 0, 0, $width, 1); + my @data = unpack($pc, $scanline); + mytest($data[49] == 50,'',$name,$type,'ReadRaster'); + + } + + } + undef $dataset; + } + } + } +} + +sub ogr_tests { + my($nr_drivers_tested,$osr) = @_; + + for my $i (0..$nr_drivers_tested-1) { + + my $driver = ogr::GetDriver($i); + unless ($driver) { + mytest('',undef,"ogr::GetDriver($i)"); + next; + } + my $name = $driver->{name}; +# print "$name\n"; + mytest('skipped: not tested',undef,$name,'test') unless $known_driver{$name}; + + if (!$driver->TestCapability($ogr::ODrCCreateDataSource)) { + mytest('skipped: no capability',undef,$name,'datasource create'); + next; + } + + if ($name eq 'S57' or $name eq 'CSV' or $name eq 'GML' or $name eq 'PostgreSQL') { + mytest('skipped: apparently no capability',undef,$name,'datasource create'); + next; + } + + if ($name eq 'TIGER' or $name eq 'DGN') { + mytest("skipped: can't create layers afterwards.",undef,$name,'datasource create'); + next; + } + + my @field_types = ('OFTInteger','OFTIntegerList','OFTReal','OFTRealList','OFTString', + 'OFTStringList','OFTWideString','OFTWideStringList','OFTBinary'); + + if ($name eq 'ESRI Shapefile') { + @field_types = ('OFTInteger','OFTReal','OFTString','OFTInteger'); + } elsif ($name eq 'MapInfo File') { + @field_types = ('OFTInteger','OFTReal','OFTString'); + } + + my %field_types; + for (@field_types) {$field_types{$_} = eval "\$ogr::$_"}; + + my $dir0 = $name; + $dir0 =~ s/ //g; + my $dir = "tmp_ds_$dir0"; + system "mkdir $dir" unless $name eq 'Memory'; + + my $datasource; + eval { + $datasource = $driver->CreateDataSource($dir); + }; + mytest($datasource,'no message',$name,'datasource create'); + + next unless $datasource; + + for my $type (@types) { + + if ($name eq 'ESRI Shapefile' and $type eq 'wkbGeometryCollection') { + mytest("skipped, will fail",undef,$name,$type,'layer create'); + next; + } + + if ($type eq 'wkbMultiPolygon') { + mytest("skipped, no test yet",undef,$name,$type,'layer create'); + next; + } + + if ($name eq 'MapInfo File' and $type eq 'wkbMultiLineString') { + mytest("skipped, no test",undef,$name,$type,'layer create'); + next; + } + + my $layer; + eval { + $layer = $datasource->CreateLayer($type, $osr, $types{$type}); + }; + mytest($layer,'no message',$name,$type,'layer create'); + + next unless $layer; + + # create one field of each type + + for my $ft (@field_types) { + + my $column = new ogr::FieldDefn($ft, $field_types{$ft}); + + $layer->CreateField($column); + + } + + { + my $schema = $layer->GetLayerDefn(); + + $i = 0; + for my $ft (@field_types) { + + my $column = $schema->GetFieldDefn($i++); + my $n = $column->GetName; + mytest($n eq $ft,"$n ne $ft",$name,$type,$ft,'field create'); + + } + + my $feature = new ogr::Feature($schema); + + my $t = $type eq 'wkbUnknown' ? $ogr::wkbPolygon : $types{$type}; + + my $geom = new ogr::Geometry($t); + + if ($type eq 'wkbMultiPoint') { + + for (0..1) { + my $g = new ogr::Geometry($ogr::wkbPoint); + test_geom($g,$name,'wkbPoint','create'); + $geom->AddGeometry($g); + } + + } elsif ($type eq 'wkbMultiLineString') { + + for (0..1) { + my $g = new ogr::Geometry($ogr::wkbLineString); + test_geom($g,$name,'wkbLineString','create'); + $geom->AddGeometry($g); + } + + } else { + + test_geom($geom,$name,$type,'create'); + + } + + $feature->SetGeometry($geom); + + $i = 0; + for my $ft (@field_types) { + my $v = 2; + $v = 'kaksi' if $ft eq 'OFTString'; + $feature->SetField($i++,$v); + } + + $layer->CreateFeature($feature); + $layer->SyncToDisk; + + } + + undef $layer; + + # now open + + if ($name eq 'Memory') + { + mytest('skipped',undef,$name,$type,'layer open'); + + } else { + + undef $datasource; + + eval { + if ($name eq 'MapInfo File') { + $datasource = ogr::Open("$dir/$type.tab"); + $layer = $datasource->GetLayerByIndex; + } else { + $datasource = $driver->CreateDataSource($dir); + $layer = $datasource->GetLayerByName($type); + } + }; + + mytest($layer,'no message',$name,$type,"layer $type open"); + next unless $layer; + + # check to see if the fields exist and the types are the same + + my $schema = $layer->GetLayerDefn(); + + $i = 0; + for my $ft (@field_types) { + my $column = $schema->GetFieldDefn($i++); + my $n = $column->GetName; + mytest($n eq $ft,"$n ne $ft",$name,$type,$ft,'GetName'); + my $t = $column->GetType; + my $t2 = $field_types{$ft}; + mytest($t == $t2,"$t != $t2",$name,$type,$ft,'GetType'); + } + + if ($type eq 'wkbPoint' or $type eq 'wkbLineString' or $type eq 'wkbPolygon') { + + $layer->ResetReading; + my $feature = $layer->GetNextFeature; + + mytest($feature,'GetFeature failed',$name,$type,'GetNextFeature'); + + if ($feature) { + + my $geom = $feature->GetGeometryRef(); + + if ($type eq 'wkbPointlll') { + mytest('skipped',undef,$name,$type,'geom open'); + } else { + my $t = $type eq 'wkbUnknown' ? $ogr::wkbPolygon : $types{$type}; + my $t2 = $geom->GetGeometryType; + mytest($t == $t2,"$t != $t2",$name,$type,'geom open'); + + if ($type eq 'wkbMultiPoint') { + + my $gn = $geom->GetGeometryCount; + mytest($gn == 2,"$gn != 2",$name,$type,'geom count'); + + for my $i (0..1) { + my $g = $geom->GetGeometryRef($i); + test_geom($g,$name,'wkbPoint','open'); + } + + } elsif ($type eq 'wkbMultiLineString') { + + my $gn = $geom->GetGeometryCount; + mytest($gn == 2,"$gn != 2",$name,$type,'geom count'); + + for my $i (0..1) { + my $g = $geom->GetGeometryRef($i); + test_geom($g,$name,'wkbLineString','open'); + } + + } else { + test_geom($geom,$name,$type,'open'); + } + } + + $i = 0; + for my $ft (@field_types) { + #$feature->SetField($i++,2); + my $f; + if ($ft eq 'OFTString') { + $f = $feature->GetFieldAsString($i); + mytest($f eq 'kaksi',"$f ne 'kaksi'",$name,$type,'GetFieldAsString'); + } else { + $f = $feature->GetFieldAsInteger($i); + mytest($f == 2,"$f != 2",$name,$type,'GetFieldAsInteger'); + $f = $feature->GetFieldAsDouble($i); + mytest($f == 2,"$f != 2",$name,$type,'GetFieldAsDouble'); + } + $i++; + } + + } + } else { + mytest('skipped',undef,$name,$type,'feature open'); + } + + undef $layer; + } + + } + + } +} + +sub test_geom { + my($geom,$name,$type,$mode) = @_; + + my $pc = $geom->GetPointCount; + my $gn = $geom->GetGeometryCount; + my $i = 0; + + if ($type eq 'wkbPoint') { + + if ($mode eq 'create') { + $geom->AddPoint(1,1); + } else { + mytest($pc == 1,"$pc != 1",$name,$type,'point count'); + mytest($gn == 0,"$gn != 0",$name,$type,'geom count'); + my @xy = ($geom->GetX($i),$geom->GetY($i)); + mytest(cmp_ar(2,\@xy,[1,1]),"(@xy) != (1,1)",$name,$type,"get point"); + } + + } elsif ($type eq 'wkbLineString') { + + if ($mode eq 'create') { + $geom->AddPoint(1,1); + $geom->AddPoint(2,2); + } else { + mytest($pc == 2,"$pc != 2",$name,$type,'point count'); + mytest($gn == 0,"$gn != 0",$name,$type,'geom count'); + my @xy = ($geom->GetX($i),$geom->GetY($i)); $i++; + mytest(cmp_ar(2,\@xy,[1,1]),"(@xy) != (1,1)",$name,$type,"get point"); + @xy = ($geom->GetX($i),$geom->GetY($i)); + mytest(cmp_ar(2,\@xy,[2,2]),"(@xy) != (2,2)",$name,$type,"get point"); + } + + } elsif ($type eq 'wkbUnknown' or $type eq 'wkbPolygon') { + + my @pts = ([1.1,1],[1.11,0],[0,0.2],[0,2.1],[1,1.23],[1.1,1]); + + if ($mode eq 'create') { + my $r = new ogr::Geometry($ogr::wkbLinearRing); + pop @pts; + for my $pt (@pts) { + $r->AddPoint(@$pt); + } + $geom->AddGeometry($r); + $geom->CloseRings; # this overwrites the last point + } else { + mytest($gn == 1,"$gn != 1",$name,$type,'geom count'); + my $r = $geom->GetGeometryRef(0); + $pc = $r->GetPointCount; + mytest($pc == 6,"$pc != 6",$name,$type,'point count'); + for my $cxy (@pts) { + my @xy = ($r->GetX($i),$r->GetY($i)); $i++; + mytest(cmp_ar(2,\@xy,$cxy),"(@xy) != (@$cxy)",$name,$type,"get point $i"); + } + } + + } else { + mytest('skipped',undef,$name,$type,'geom create/open'); + } +} + +sub cmp_ar { + my($n,$a1,$a2) = @_; + return 0 unless $n == @$a1; + return 0 unless $#$a1 == $#$a2; + for my $i (0..$#$a1) { + return 0 unless abs($a1->[$i] - $a2->[$i]) < 0.001; + } + return 1; +} + +sub mytest { + my $test = shift; + my $msg = shift; + my $context = join(': ',@_); + unless ($test) { + my $err = $msg; + if ($@) { + $@ =~ s/\n/ /g; + $@ =~ s/\s+$//; + $@ =~ s/\s+/ /g; + $@ =~ s/^\s+$//; + $err = $@ ? "'$@'" : $msg; + } + $msg = "$context: $err: not ok\n"; + push @fails,$msg; + } elsif ($test =~ /^skip/) { + $msg = "$context: $test.\n"; + } else { + $msg = "$context: ok.\n"; + } + print $msg if $verbose; + return $msg; +} + +sub dumphash { + my $h = shift; + for (keys %$h) { + print "$_ $h->{$_}\n"; + } +} + diff --git a/Utilities/GDAL/swig/php/GNUmakefile b/Utilities/GDAL/swig/php/GNUmakefile new file mode 100644 index 0000000000..57168ceb56 --- /dev/null +++ b/Utilities/GDAL/swig/php/GNUmakefile @@ -0,0 +1,44 @@ + + +include ../../GDALmake.opt + +all: + +BINDING = php +include ../SWIGmake.base + +CC=gcc +CXX=g++ +CFLAGS=-fpic +LDFLAGS=-shared +PHP_INC=`php-config --includes` +EXTRA_INC=-I../../port -I../../gcore -I../../alg -I../../ogr +EXTRA_LIB= + +all_libs = php_gdal.so php_ogr.so php_gdalconst.so php_osr.so + +PHP_MODULES = gdal.php gdalconst.php ogr.php osr.php +PHP_EXTRADIST = php_gdal.h php_gdalconst.h php_ogr.h php_osr.h + +clean: + -rm -rf ${all_libs} + +veryclean: clean + -rm -f ${WRAPPERS} ${PHP_MODULES} ${PHP_EXTRADIST} + +generate: ${WRAPPERS} + +build: php_gdal.so + +# This directive should actually do an install. +install: build + +php_%.so: %_wrap.o + $(CC) $(LDFLAGS) $< -o $@ $(EXTRA_LIB) + +%.o: %.cpp + $(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $< +%.o: %.cxx + $(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $< +%.o: %.c + $(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $< diff --git a/Utilities/GDAL/swig/php/gdal.php b/Utilities/GDAL/swig/php/gdal.php new file mode 100644 index 0000000000..1f7c4aa100 --- /dev/null +++ b/Utilities/GDAL/swig/php/gdal.php @@ -0,0 +1,24 @@ +<?php + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +global $GDAL_LOADED__; +if ($GDAL_LOADED__) return; +$GDAL_LOADED__ = true; + +/* if our extension has not been loaded, do what we can */ +if (!extension_loaded("php_gdal")) { + if (!dl("php_gdal.so")) return; +} + + + +?> diff --git a/Utilities/GDAL/swig/php/gdal_wrap.cpp b/Utilities/GDAL/swig/php/gdal_wrap.cpp new file mode 100644 index 0000000000..f56e9f7cf1 --- /dev/null +++ b/Utilities/GDAL/swig/php/gdal_wrap.cpp @@ -0,0 +1,7659 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* + * php4.swg + * + * PHP4 runtime library + * + */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "zend.h" +#include "zend_API.h" +#include "php.h" + +/* These TSRMLS_ stuff should already be defined now, but with older php under + redhat are not... */ +#ifndef TSRMLS_D +#define TSRMLS_D +#endif +#ifndef TSRMLS_DC +#define TSRMLS_DC +#endif +#ifndef TSRMLS_C +#define TSRMLS_C +#endif +#ifndef TSRMLS_CC +#define TSRMLS_CC +#endif + +#ifdef __cplusplus +} +#endif + +/* But in fact SWIG_ConvertPtr is the native interface for getting typed + pointer values out of zvals. We need the TSRMLS_ macros for when we + make PHP type calls later as we handle php resources */ +#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) + +/* Flags for SWIG_ConvertPtr */ +#define SWIG_POINTER_DISOWN 0x1 + +#define SWIG_fail goto fail + +static char *default_error_msg = "Unknown error occurred"; +static int default_error_code = E_ERROR; + +#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg + +#define SWIG_PHP_Error(code,msg) ErrorCode() = code; ErrorMsg() = msg; SWIG_fail; + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else + +/* Standard SWIG API */ +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) + +/* used to wrap returned objects in so we know whether they are newobject + and need freeing, or not */ +typedef struct _swig_object_wrapper { + void * ptr; + int newobject; +} swig_object_wrapper; + +/* empty zend destructor for types without one */ +static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) {}; + +#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d, SWIG_module_entry TSRMLS_CC) + +static void +SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject, zend_module_entry* module_entry TSRMLS_DC) { + swig_object_wrapper *value=NULL; + /* + * First test for Null pointers. Return those as PHP native NULL + */ + if (!ptr ) { + ZVAL_NULL(z); + return; + } + if (type->clientdata) { + if (! (*(int *)(type->clientdata))) + zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); + value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); + value->ptr=ptr; + value->newobject=newobject; + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + return; + } else { /* have to deal with old fashioned string pointer? + but this should not get this far */ + zend_error(E_ERROR, "Type: %s not registered with zend",type->name); + } +} + +/* This is a new pointer conversion routine + Taking the native pointer p (which would have been converted from the old + string pointer) and it's php type id, and it's type name (which also would + have come from the old string pointer) it converts it to ptr calling + appropriate casting functions according to ty + Sadly PHP has no API to find a type name from a type id, only from an instance + of a resource of the type id, so we have to pass type_name as well. + The two functions which might call this are: + SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource + and the registered zend destructors for which we have one per type each + with the type name hard wired in. */ +static int +SWIG_ZTS_ConvertResourceData(void * p, int type, const char *type_name, void **ptr, swig_type_info *ty TSRMLS_DC) { + swig_cast_info *tc; + + if (ty) { + if (! type_name) { + /* can't convert p to ptr type ty if we don't know what type p is */ + return -1; + } else { + /* convert and cast p from type_name to ptr as ty + Need to sort out const-ness, can SWIG_TypeCast really not take a const? */ + tc = SWIG_TypeCheck((char *)type_name,ty); + if (!tc) return -1; + *ptr = SWIG_TypeCast(tc, (void*)p); + } + } else { + /* They don't care about the target type, so just pass on the pointer! */ + *ptr = (void *) p; + } + return 0; +} + +/* This function fills ptr with a pointer of type ty by extracting the pointer + and type info from the resource in z. z must be a resource + It uses SWIG_ZTS_ConvertResourceData to do the real work. */ +static int +SWIG_ZTS_ConvertResourcePtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + swig_object_wrapper *value; + void *p; + int type; + char *type_name; + + value = (swig_object_wrapper *) zend_list_find(z->value.lval,&type); + if ( flags && SWIG_POINTER_DISOWN ) { + value->newobject = 0; + } + p = value->ptr; + if (type==-1) return -1; + + type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); + + return SWIG_ZTS_ConvertResourceData(p,type,type_name,ptr,ty TSRMLS_CC); +} + +/* We allow passing of a STRING or RESOURCE pointing to the object + or an OBJECT whose _cPtr is a string or resource pointing to the object + STRING pointers are very depracated */ +static int +SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + char *c; + zval *val; + + if(z == NULL) { + *ptr = 0; + return 0; + } + + if (z->type==IS_OBJECT) { + zval ** _cPtr; + if (zend_hash_find(HASH_OF(z),"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { + /* Don't co-erce to string if it isn't */ + if ((*_cPtr)->type==IS_STRING) c = Z_STRVAL_PP(_cPtr); + else if ((*_cPtr)->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(*_cPtr,ptr,ty, flags TSRMLS_CC); + } else goto type_error; /* _cPtr was not string or resource property */ + } else goto type_error; /* can't find property _cPtr */ + } else if (z->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(z,ptr,ty, flags TSRMLS_CC); + } else goto type_error; + +type_error: + + return -1; +} + +static char const_name[] = "swig_runtime_data_type_pointer"; +static swig_module_info *SWIG_Php4_GetModule() { + zval *pointer; + swig_module_info *ret = 0; + + MAKE_STD_ZVAL(pointer); + + if (zend_get_constant(const_name, sizeof(const_name), pointer)) { + if (pointer->type == IS_LONG) { + ret = (swig_module_info *) pointer->value.lval; + } + } + return 0; +} + +static void SWIG_Php4_SetModule(swig_module_info *pointer) { + REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); +} + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_CPLErrorHandler swig_types[0] +#define SWIGTYPE_p_CPLXMLNode swig_types[1] +#define SWIGTYPE_p_GDALColorEntry swig_types[2] +#define SWIGTYPE_p_GDALColorTable swig_types[3] +#define SWIGTYPE_p_GDALDatasetShadow swig_types[4] +#define SWIGTYPE_p_GDALDriverShadow swig_types[5] +#define SWIGTYPE_p_GDALMajorObjectShadow swig_types[6] +#define SWIGTYPE_p_GDALRasterBandShadow swig_types[7] +#define SWIGTYPE_p_GDAL_GCP swig_types[8] +#define SWIGTYPE_p_double swig_types[9] +#define SWIGTYPE_p_int swig_types[10] +#define SWIGTYPE_p_p_CPLXMLNode swig_types[11] +#define SWIGTYPE_p_p_GDALColorTable swig_types[12] +#define SWIGTYPE_p_p_GDALDatasetShadow swig_types[13] +#define SWIGTYPE_p_p_GDALDriverShadow swig_types[14] +#define SWIGTYPE_p_p_GDALMajorObjectShadow swig_types[15] +#define SWIGTYPE_p_p_GDALRasterBandShadow swig_types[16] +#define SWIGTYPE_p_p_GDAL_GCP swig_types[17] +#define SWIGTYPE_p_p_char swig_types[18] +static swig_type_info *swig_types[20]; +static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +/* header section */ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ +ZEND_BEGIN_MODULE_GLOBALS(gdal) +char *error_msg; +int error_code; +ZEND_END_MODULE_GLOBALS(gdal) +ZEND_DECLARE_MODULE_GLOBALS(gdal) +#ifdef ZTS +#define ErrorMsg() TSRMG(gdal_globals_id, zend_gdal_globals *, error_msg ); +#define ErrorCode() TSRMG(gdal_globals_id, zend_gdal_globals *, error_code ); +#else +#define ErrorMsg() (gdal_globals.error_msg) +#define ErrorCode() (gdal_globals.error_code) +#endif + +static void gdal_init_globals(zend_gdal_globals *gdal_globals ) { + gdal_globals->error_msg = default_error_msg; + gdal_globals->error_code = default_error_code; +} +static void gdal_destroy_globals(zend_gdal_globals *gdal_globals) { } + +void SWIG_ResetError() { + ErrorMsg() = default_error_msg; + ErrorCode() = default_error_code; +} +#define SWIG_name "gdal" +#ifdef __cplusplus +extern "C" { +#endif +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_gdal.h" +#ifdef __cplusplus +} +#endif + + +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + + + + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + + +static char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){ + return GDALGetDescription( self ); + } +static void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){ + GDALSetDescription( self, pszNewDesc ); + } +static char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static char **GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){ + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){ + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } +static int _wrap_propset_MajorObject(zend_property_reference *property_reference, pval *value); +static int _propset_MajorObject(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_MajorObject(zend_property_reference *property_reference); +static int _propget_MajorObject(zend_property_reference *property_reference, pval *value); +static GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *name,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){ + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } +static GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *name,GDALDatasetShadow *src,int strict=1,char **options=0){ + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } +static int GDALDriverShadow_Delete(GDALDriverShadow *self,char const *name){ + return GDALDeleteDataset( self, name ); + } +static int _wrap_propset_Driver(zend_property_reference *property_reference, pval *value); +static int _propset_Driver(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Driver(zend_property_reference *property_reference); +static int _propget_Driver(zend_property_reference *property_reference, pval *value); + +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} + +static GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){ + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } +static void delete_GDAL_GCP(GDAL_GCP *self){ + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } +static int _wrap_propset_GCP(zend_property_reference *property_reference, pval *value); +static int _propset_GCP(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_GCP(zend_property_reference *property_reference); +static int _propget_GCP(zend_property_reference *property_reference, pval *value); + + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + + zval * + CreateTupleFromDoubleArray( double *first, unsigned int size ) { + zval *tmp; + MAKE_STD_ZVAL(tmp); + array_init(tmp); + for( unsigned int i=0; i<size; i++ ) { + add_next_index_double( tmp, *first ); + ++first; + } + return tmp; + } + + +void +t_output_helper( zval **target, zval *o) { + if ( (*target)->type == IS_ARRAY ) { + /* it's already an array, just append */ + add_next_index_zval( *target, o ); + return; + } + if ( (*target)->type == IS_NULL ) { + REPLACE_ZVAL_VALUE(target,o,1); + return; + } + zval *tmp; + tmp = *target; + zval_copy_ctor(tmp); + array_init(*target); + add_next_index_zval( *target, tmp); + add_next_index_zval( *target, o); + +} + +static void delete_GDALDatasetShadow(GDALDatasetShadow *self){ + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } +static GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){ + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } +static GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){ + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } +static char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){ + return GDALSetProjection( self, prj ); + } +static void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6]){ + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } +static CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){ + return GDALSetGeoTransform( self, argin ); + } +static int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0){ + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +static int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){ + return GDALGetGCPCount( self ); + } +static char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){ + return GDALGetGCPProjection( self ); + } +static void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){ + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } +static CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){ + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } +static void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){ + GDALFlushCache( self ); + } +static CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){ + return GDALAddBand( self, datatype, options ); + } +static CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } +static int _wrap_propset_Dataset(zend_property_reference *property_reference, pval *value); +static int _propset_Dataset(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Dataset(zend_property_reference *property_reference); +static int _propget_Dataset(zend_property_reference *property_reference, pval *value); + +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} + + +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} + +static GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){ + return GDALGetRasterColorInterpretation( self ); + } +static CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){ + return GDALSetRasterColorInterpretation( self, val ); + } +static void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterNoDataValue( self, hasval ); + } +static CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){ + return GDALSetRasterNoDataValue( self, d ); + } +static void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMinimum( self, hasval ); + } +static void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMaximum( self, hasval ); + } +static void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterOffset( self, hasval ); + } +static void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterScale( self, hasval ); + } +static int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){ + return GDALGetOverviewCount( self ); + } +static GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){ + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } +static int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){ + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +static void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){ + GDALComputeRasterMinMax( self, approx_ok, argout ); + } +static CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){ + return GDALFillRaster( self, real_fill, imag_fill ); + } +static CPLErr GDALRasterBandShadow_ReadRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_len,char **buf,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +static CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +static void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){ + GDALFlushRasterCache( self ); + } +static GDALColorTable *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){ + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } +static int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTable *arg){ + return GDALSetRasterColorTable( self, arg ); + } +static int _wrap_propset_Band(zend_property_reference *property_reference, pval *value); +static int _propset_Band(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Band(zend_property_reference *property_reference); +static int _propget_Band(zend_property_reference *property_reference, pval *value); + +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} + +static int _wrap_propset_ColorTable(zend_property_reference *property_reference, pval *value); +static int _propset_ColorTable(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_ColorTable(zend_property_reference *property_reference); +static int _propget_ColorTable(zend_property_reference *property_reference, pval *value); + +int GetDriverCount() { + return GDALGetDriverCount(); +} + + +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} + + +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} + + +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} + +/* class entry subsection */ +/* Function entries for MajorObject */ +static zend_function_entry MajorObject_functions[] = { + ZEND_NAMED_FE(majorobject_getdescription,_wrap_MajorObject_GetDescription, NULL) + ZEND_NAMED_FE(getdescription,_wrap_MajorObject_GetDescription, NULL) + ZEND_NAMED_FE(majorobject_setdescription,_wrap_MajorObject_SetDescription, NULL) + ZEND_NAMED_FE(setdescription,_wrap_MajorObject_SetDescription, NULL) + ZEND_NAMED_FE(majorobject_getmetadata_dict,_wrap_MajorObject_GetMetadata_Dict, NULL) + ZEND_NAMED_FE(getmetadata_dict,_wrap_MajorObject_GetMetadata_Dict, NULL) + ZEND_NAMED_FE(majorobject_getmetadata_list,_wrap_MajorObject_GetMetadata_List, NULL) + ZEND_NAMED_FE(getmetadata_list,_wrap_MajorObject_GetMetadata_List, NULL) + ZEND_NAMED_FE(setmetadata,_wrap_MajorObject_SetMetadata, NULL) + ZEND_NAMED_FE(majorobject_setmetadata,_wrap_MajorObject_SetMetadata, NULL) + ZEND_NAMED_FE(setmetadata,_wrap_MajorObject_SetMetadata, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Driver */ +static zend_function_entry Driver_functions[] = { + ZEND_NAMED_FE(driver_create,_wrap_Driver_Create, NULL) + ZEND_NAMED_FE(create,_wrap_Driver_Create, NULL) + ZEND_NAMED_FE(driver_createcopy,_wrap_Driver_CreateCopy, NULL) + ZEND_NAMED_FE(createcopy,_wrap_Driver_CreateCopy, NULL) + ZEND_NAMED_FE(driver_delete,_wrap_Driver_Delete, NULL) + ZEND_NAMED_FE(delete,_wrap_Driver_Delete, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for GCP */ +static zend_function_entry GCP_functions[] = { + ZEND_NAMED_FE(new_gcp,_wrap_new_GCP, NULL) + ZEND_NAMED_FE(gcp,_wrap_new_GCP, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Dataset */ +static zend_function_entry Dataset_functions[] = { + ZEND_NAMED_FE(dataset_getdriver,_wrap_Dataset_GetDriver, NULL) + ZEND_NAMED_FE(getdriver,_wrap_Dataset_GetDriver, NULL) + ZEND_NAMED_FE(dataset_getrasterband,_wrap_Dataset_GetRasterBand, NULL) + ZEND_NAMED_FE(getrasterband,_wrap_Dataset_GetRasterBand, NULL) + ZEND_NAMED_FE(dataset_getprojection,_wrap_Dataset_GetProjection, NULL) + ZEND_NAMED_FE(getprojection,_wrap_Dataset_GetProjection, NULL) + ZEND_NAMED_FE(dataset_getprojectionref,_wrap_Dataset_GetProjectionRef, NULL) + ZEND_NAMED_FE(getprojectionref,_wrap_Dataset_GetProjectionRef, NULL) + ZEND_NAMED_FE(dataset_setprojection,_wrap_Dataset_SetProjection, NULL) + ZEND_NAMED_FE(setprojection,_wrap_Dataset_SetProjection, NULL) + ZEND_NAMED_FE(dataset_getgeotransform,_wrap_Dataset_GetGeoTransform, NULL) + ZEND_NAMED_FE(getgeotransform,_wrap_Dataset_GetGeoTransform, NULL) + ZEND_NAMED_FE(dataset_setgeotransform,_wrap_Dataset_SetGeoTransform, NULL) + ZEND_NAMED_FE(setgeotransform,_wrap_Dataset_SetGeoTransform, NULL) + ZEND_NAMED_FE(dataset_buildoverviews,_wrap_Dataset_BuildOverviews, NULL) + ZEND_NAMED_FE(buildoverviews,_wrap_Dataset_BuildOverviews, NULL) + ZEND_NAMED_FE(dataset_getgcpcount,_wrap_Dataset_GetGCPCount, NULL) + ZEND_NAMED_FE(getgcpcount,_wrap_Dataset_GetGCPCount, NULL) + ZEND_NAMED_FE(dataset_getgcpprojection,_wrap_Dataset_GetGCPProjection, NULL) + ZEND_NAMED_FE(getgcpprojection,_wrap_Dataset_GetGCPProjection, NULL) + ZEND_NAMED_FE(dataset_getgcps,_wrap_Dataset_GetGCPs, NULL) + ZEND_NAMED_FE(getgcps,_wrap_Dataset_GetGCPs, NULL) + ZEND_NAMED_FE(dataset_setgcps,_wrap_Dataset_SetGCPs, NULL) + ZEND_NAMED_FE(setgcps,_wrap_Dataset_SetGCPs, NULL) + ZEND_NAMED_FE(dataset_flushcache,_wrap_Dataset_FlushCache, NULL) + ZEND_NAMED_FE(flushcache,_wrap_Dataset_FlushCache, NULL) + ZEND_NAMED_FE(dataset_addband,_wrap_Dataset_AddBand, NULL) + ZEND_NAMED_FE(addband,_wrap_Dataset_AddBand, NULL) + ZEND_NAMED_FE(dataset_writeraster,_wrap_Dataset_WriteRaster, NULL) + ZEND_NAMED_FE(writeraster,_wrap_Dataset_WriteRaster, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Band */ +static zend_function_entry Band_functions[] = { + ZEND_NAMED_FE(band_getrastercolorinterpretation,_wrap_Band_GetRasterColorInterpretation, NULL) + ZEND_NAMED_FE(getrastercolorinterpretation,_wrap_Band_GetRasterColorInterpretation, NULL) + ZEND_NAMED_FE(band_setrastercolorinterpretation,_wrap_Band_SetRasterColorInterpretation, NULL) + ZEND_NAMED_FE(setrastercolorinterpretation,_wrap_Band_SetRasterColorInterpretation, NULL) + ZEND_NAMED_FE(band_getnodatavalue,_wrap_Band_GetNoDataValue, NULL) + ZEND_NAMED_FE(getnodatavalue,_wrap_Band_GetNoDataValue, NULL) + ZEND_NAMED_FE(band_setnodatavalue,_wrap_Band_SetNoDataValue, NULL) + ZEND_NAMED_FE(setnodatavalue,_wrap_Band_SetNoDataValue, NULL) + ZEND_NAMED_FE(band_getminimum,_wrap_Band_GetMinimum, NULL) + ZEND_NAMED_FE(getminimum,_wrap_Band_GetMinimum, NULL) + ZEND_NAMED_FE(band_getmaximum,_wrap_Band_GetMaximum, NULL) + ZEND_NAMED_FE(getmaximum,_wrap_Band_GetMaximum, NULL) + ZEND_NAMED_FE(band_getoffset,_wrap_Band_GetOffset, NULL) + ZEND_NAMED_FE(getoffset,_wrap_Band_GetOffset, NULL) + ZEND_NAMED_FE(band_getscale,_wrap_Band_GetScale, NULL) + ZEND_NAMED_FE(getscale,_wrap_Band_GetScale, NULL) + ZEND_NAMED_FE(band_getoverviewcount,_wrap_Band_GetOverviewCount, NULL) + ZEND_NAMED_FE(getoverviewcount,_wrap_Band_GetOverviewCount, NULL) + ZEND_NAMED_FE(band_getoverview,_wrap_Band_GetOverview, NULL) + ZEND_NAMED_FE(getoverview,_wrap_Band_GetOverview, NULL) + ZEND_NAMED_FE(band_checksum,_wrap_Band_Checksum, NULL) + ZEND_NAMED_FE(checksum,_wrap_Band_Checksum, NULL) + ZEND_NAMED_FE(band_computerasterminmax,_wrap_Band_ComputeRasterMinMax, NULL) + ZEND_NAMED_FE(computerasterminmax,_wrap_Band_ComputeRasterMinMax, NULL) + ZEND_NAMED_FE(band_fill,_wrap_Band_Fill, NULL) + ZEND_NAMED_FE(fill,_wrap_Band_Fill, NULL) + ZEND_NAMED_FE(band_readraster,_wrap_Band_ReadRaster, NULL) + ZEND_NAMED_FE(readraster,_wrap_Band_ReadRaster, NULL) + ZEND_NAMED_FE(band_writeraster,_wrap_Band_WriteRaster, NULL) + ZEND_NAMED_FE(writeraster,_wrap_Band_WriteRaster, NULL) + ZEND_NAMED_FE(band_flushcache,_wrap_Band_FlushCache, NULL) + ZEND_NAMED_FE(flushcache,_wrap_Band_FlushCache, NULL) + ZEND_NAMED_FE(band_getrastercolortable,_wrap_Band_GetRasterColorTable, NULL) + ZEND_NAMED_FE(getrastercolortable,_wrap_Band_GetRasterColorTable, NULL) + ZEND_NAMED_FE(band_setrastercolortable,_wrap_Band_SetRasterColorTable, NULL) + ZEND_NAMED_FE(setrastercolortable,_wrap_Band_SetRasterColorTable, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for ColorTable */ +static zend_function_entry ColorTable_functions[] = { + ZEND_NAMED_FE(new_colortable,_wrap_new_ColorTable, NULL) + ZEND_NAMED_FE(colortable,_wrap_new_ColorTable, NULL) + ZEND_NAMED_FE(colortable_clone,_wrap_ColorTable_Clone, NULL) + ZEND_NAMED_FE(clone,_wrap_ColorTable_Clone, NULL) + ZEND_NAMED_FE(colortable_getpaletteinterpretation,_wrap_ColorTable_GetPaletteInterpretation, NULL) + ZEND_NAMED_FE(getpaletteinterpretation,_wrap_ColorTable_GetPaletteInterpretation, NULL) + ZEND_NAMED_FE(colortable_getcount,_wrap_ColorTable_GetCount, NULL) + ZEND_NAMED_FE(getcount,_wrap_ColorTable_GetCount, NULL) + ZEND_NAMED_FE(colortable_getcolorentry,_wrap_ColorTable_GetColorEntry, NULL) + ZEND_NAMED_FE(getcolorentry,_wrap_ColorTable_GetColorEntry, NULL) + ZEND_NAMED_FE(colortable_getcolorentryasrgb,_wrap_ColorTable_GetColorEntryAsRGB, NULL) + ZEND_NAMED_FE(getcolorentryasrgb,_wrap_ColorTable_GetColorEntryAsRGB, NULL) + ZEND_NAMED_FE(colortable_setcolorentry,_wrap_ColorTable_SetColorEntry, NULL) + ZEND_NAMED_FE(setcolorentry,_wrap_ColorTable_SetColorEntry, NULL) + { NULL, NULL, NULL} +}; + + +/* entry subsection */ +/* Every non-class user visible function must have an entry here */ +function_entry gdal_functions[] = { + ZEND_NAMED_FE(debug,_wrap_Debug, NULL) + ZEND_NAMED_FE(error,_wrap_Error, NULL) + ZEND_NAMED_FE(pusherrorhandler,_wrap_PushErrorHandler, NULL) + ZEND_NAMED_FE(poperrorhandler,_wrap_PopErrorHandler, NULL) + ZEND_NAMED_FE(errorreset,_wrap_ErrorReset, NULL) + ZEND_NAMED_FE(getlasterrorno,_wrap_GetLastErrorNo, NULL) + ZEND_NAMED_FE(getlasterrortype,_wrap_GetLastErrorType, NULL) + ZEND_NAMED_FE(getlasterrormsg,_wrap_GetLastErrorMsg, NULL) + ZEND_NAMED_FE(pushfinderlocation,_wrap_PushFinderLocation, NULL) + ZEND_NAMED_FE(popfinderlocation,_wrap_PopFinderLocation, NULL) + ZEND_NAMED_FE(finderclean,_wrap_FinderClean, NULL) + ZEND_NAMED_FE(findfile,_wrap_FindFile, NULL) + ZEND_NAMED_FE(setconfigoption,_wrap_SetConfigOption, NULL) + ZEND_NAMED_FE(getconfigoption,_wrap_GetConfigOption, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpx_get,_wrap_GDAL_GCP_GCPX_get, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpx_set,_wrap_GDAL_GCP_GCPX_set, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpy_get,_wrap_GDAL_GCP_GCPY_get, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpy_set,_wrap_GDAL_GCP_GCPY_set, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpz_get,_wrap_GDAL_GCP_GCPZ_get, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpz_set,_wrap_GDAL_GCP_GCPZ_set, NULL) + ZEND_NAMED_FE(gdal_gcp_gcppixel_get,_wrap_GDAL_GCP_GCPPixel_get, NULL) + ZEND_NAMED_FE(gdal_gcp_gcppixel_set,_wrap_GDAL_GCP_GCPPixel_set, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpline_get,_wrap_GDAL_GCP_GCPLine_get, NULL) + ZEND_NAMED_FE(gdal_gcp_gcpline_set,_wrap_GDAL_GCP_GCPLine_set, NULL) + ZEND_NAMED_FE(gdal_gcp_info_get,_wrap_GDAL_GCP_Info_get, NULL) + ZEND_NAMED_FE(gdal_gcp_info_set,_wrap_GDAL_GCP_Info_set, NULL) + ZEND_NAMED_FE(gdal_gcp_id_get,_wrap_GDAL_GCP_Id_get, NULL) + ZEND_NAMED_FE(gdal_gcp_id_set,_wrap_GDAL_GCP_Id_set, NULL) + ZEND_NAMED_FE(gdal_gcp_get_gcpx,_wrap_GDAL_GCP_get_GCPX, NULL) + ZEND_NAMED_FE(gdal_gcp_set_gcpx,_wrap_GDAL_GCP_set_GCPX, NULL) + ZEND_NAMED_FE(gdal_gcp_get_gcpy,_wrap_GDAL_GCP_get_GCPY, NULL) + ZEND_NAMED_FE(gdal_gcp_set_gcpy,_wrap_GDAL_GCP_set_GCPY, NULL) + ZEND_NAMED_FE(gdal_gcp_get_gcpz,_wrap_GDAL_GCP_get_GCPZ, NULL) + ZEND_NAMED_FE(gdal_gcp_set_gcpz,_wrap_GDAL_GCP_set_GCPZ, NULL) + ZEND_NAMED_FE(gdal_gcp_get_gcppixel,_wrap_GDAL_GCP_get_GCPPixel, NULL) + ZEND_NAMED_FE(gdal_gcp_set_gcppixel,_wrap_GDAL_GCP_set_GCPPixel, NULL) + ZEND_NAMED_FE(gdal_gcp_get_gcpline,_wrap_GDAL_GCP_get_GCPLine, NULL) + ZEND_NAMED_FE(gdal_gcp_set_gcpline,_wrap_GDAL_GCP_set_GCPLine, NULL) + ZEND_NAMED_FE(gdal_gcp_get_info,_wrap_GDAL_GCP_get_Info, NULL) + ZEND_NAMED_FE(gdal_gcp_set_info,_wrap_GDAL_GCP_set_Info, NULL) + ZEND_NAMED_FE(gdal_gcp_get_id,_wrap_GDAL_GCP_get_Id, NULL) + ZEND_NAMED_FE(gdal_gcp_set_id,_wrap_GDAL_GCP_set_Id, NULL) + ZEND_NAMED_FE(gcpstogeotransform,_wrap_GCPsToGeoTransform, NULL) + ZEND_NAMED_FE(allregister,_wrap_AllRegister, NULL) + ZEND_NAMED_FE(getcachemax,_wrap_GetCacheMax, NULL) + ZEND_NAMED_FE(setcachemax,_wrap_SetCacheMax, NULL) + ZEND_NAMED_FE(getcacheused,_wrap_GetCacheUsed, NULL) + ZEND_NAMED_FE(getdatatypesize,_wrap_GetDataTypeSize, NULL) + ZEND_NAMED_FE(datatypeiscomplex,_wrap_DataTypeIsComplex, NULL) + ZEND_NAMED_FE(getdatatypename,_wrap_GetDataTypeName, NULL) + ZEND_NAMED_FE(getdatatypebyname,_wrap_GetDataTypeByName, NULL) + ZEND_NAMED_FE(getcolorinterpretationname,_wrap_GetColorInterpretationName, NULL) + ZEND_NAMED_FE(getpaletteinterpretationname,_wrap_GetPaletteInterpretationName, NULL) + ZEND_NAMED_FE(dectodms,_wrap_DecToDMS, NULL) + ZEND_NAMED_FE(packeddmstodec,_wrap_PackedDMSToDec, NULL) + ZEND_NAMED_FE(dectopackeddms,_wrap_DecToPackedDMS, NULL) + ZEND_NAMED_FE(parsexmlstring,_wrap_ParseXMLString, NULL) + ZEND_NAMED_FE(serializexmltree,_wrap_SerializeXMLTree, NULL) + ZEND_NAMED_FE(getdrivercount,_wrap_GetDriverCount, NULL) + ZEND_NAMED_FE(getdriverbyname,_wrap_GetDriverByName, NULL) + ZEND_NAMED_FE(getdriver,_wrap_GetDriver, NULL) + ZEND_NAMED_FE(open,_wrap_Open, NULL) + ZEND_NAMED_FE(openshared,_wrap_OpenShared, NULL) + ZEND_NAMED_FE(autocreatewarpedvrt,_wrap_AutoCreateWarpedVRT, NULL) + {NULL, NULL, NULL} +}; + +zend_module_entry gdal_module_entry = { +#if ZEND_MODULE_API_NO > 20010900 + STANDARD_MODULE_HEADER, +#endif + "gdal", + gdal_functions, + PHP_MINIT(gdal), + PHP_MSHUTDOWN(gdal), + PHP_RINIT(gdal), + PHP_RSHUTDOWN(gdal), + PHP_MINFO(gdal), +#if ZEND_MODULE_API_NO > 20010900 + NO_VERSION_YET, +#endif + STANDARD_MODULE_PROPERTIES +}; +zend_module_entry* SWIG_module_entry = &gdal_module_entry; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static void *_p_p_GDALDriverShadowTo_p_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow **) ((GDALDriverShadow **) x)); +} +static void *_p_p_GDALDatasetShadowTo_p_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow **) ((GDALDatasetShadow **) x)); +} +static void *_p_p_GDALRasterBandShadowTo_p_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow **) ((GDALRasterBandShadow **) x)); +} +static void *_p_GDALDriverShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDriverShadow *) x)); +} +static void *_p_GDALDatasetShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDatasetShadow *) x)); +} +static void *_p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALRasterBandShadow *) x)); +} +static swig_type_info _swigt__p_CPLErrorHandler = {"_p_CPLErrorHandler", "CPLErrorHandler *", 0, 0, 0}; +static swig_type_info _swigt__p_CPLXMLNode = {"_p_CPLXMLNode", "CPLXMLNode *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALColorEntry = {"_p_GDALColorEntry", "GDALColorEntry *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALColorTable = {"_p_GDALColorTable", "GDALColorTable *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALDriverShadow = {"_p_GDALDriverShadow", "GDALDriverShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALMajorObjectShadow = {"_p_GDALMajorObjectShadow", "GDALMajorObjectShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDAL_GCP = {"_p_GDAL_GCP", "GDAL_GCP *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|GDALPaletteInterp *", 0, 0, 0}; +static swig_type_info _swigt__p_p_CPLXMLNode = {"_p_p_CPLXMLNode", "CPLXMLNode **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDALColorTable = {"_p_p_GDALColorTable", "GDALColorTable **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDALDatasetShadow = {"_p_p_GDALDatasetShadow", "GDALDatasetShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDALDriverShadow = {"_p_p_GDALDriverShadow", "GDALDriverShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDALMajorObjectShadow = {"_p_p_GDALMajorObjectShadow", "GDALMajorObjectShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDALRasterBandShadow = {"_p_p_GDALRasterBandShadow", "GDALRasterBandShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDAL_GCP = {"_p_p_GDAL_GCP", "GDAL_GCP **", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_CPLErrorHandler, + &_swigt__p_CPLXMLNode, + &_swigt__p_GDALColorEntry, + &_swigt__p_GDALColorTable, + &_swigt__p_GDALDatasetShadow, + &_swigt__p_GDALDriverShadow, + &_swigt__p_GDALMajorObjectShadow, + &_swigt__p_GDALRasterBandShadow, + &_swigt__p_GDAL_GCP, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_CPLXMLNode, + &_swigt__p_p_GDALColorTable, + &_swigt__p_p_GDALDatasetShadow, + &_swigt__p_p_GDALDriverShadow, + &_swigt__p_p_GDALMajorObjectShadow, + &_swigt__p_p_GDALRasterBandShadow, + &_swigt__p_p_GDAL_GCP, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__p_CPLErrorHandler[] = { {&_swigt__p_CPLErrorHandler, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_CPLXMLNode[] = { {&_swigt__p_CPLXMLNode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorEntry[] = { {&_swigt__p_GDALColorEntry, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorTable[] = { {&_swigt__p_GDALColorTable, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDriverShadow[] = { {&_swigt__p_GDALDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALMajorObjectShadow[] = { {&_swigt__p_GDALMajorObjectShadow, 0, 0, 0}, {&_swigt__p_GDALDriverShadow, _p_GDALDriverShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALDatasetShadow, _p_GDALDatasetShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALRasterBandShadow, _p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDAL_GCP[] = { {&_swigt__p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_CPLXMLNode[] = { {&_swigt__p_p_CPLXMLNode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDALColorTable[] = { {&_swigt__p_p_GDALColorTable, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDALDatasetShadow[] = { {&_swigt__p_p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDALDriverShadow[] = { {&_swigt__p_p_GDALDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDALMajorObjectShadow[] = { {&_swigt__p_p_GDALMajorObjectShadow, 0, 0, 0}, {&_swigt__p_p_GDALDriverShadow, _p_p_GDALDriverShadowTo_p_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_p_GDALDatasetShadow, _p_p_GDALDatasetShadowTo_p_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_p_GDALRasterBandShadow, _p_p_GDALRasterBandShadowTo_p_p_GDALMajorObjectShadow, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDALRasterBandShadow[] = { {&_swigt__p_p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDAL_GCP[] = { {&_swigt__p_p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_CPLErrorHandler, + _swigc__p_CPLXMLNode, + _swigc__p_GDALColorEntry, + _swigc__p_GDALColorTable, + _swigc__p_GDALDatasetShadow, + _swigc__p_GDALDriverShadow, + _swigc__p_GDALMajorObjectShadow, + _swigc__p_GDALRasterBandShadow, + _swigc__p_GDAL_GCP, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_CPLXMLNode, + _swigc__p_p_GDALColorTable, + _swigc__p_p_GDALDatasetShadow, + _swigc__p_p_GDALDriverShadow, + _swigc__p_p_GDALMajorObjectShadow, + _swigc__p_p_GDALRasterBandShadow, + _swigc__p_p_GDAL_GCP, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/* end header section */ +/* vdecl subsection */ +static zend_class_entry ce_swig_MajorObject; +static zend_class_entry* ptr_ce_swig_MajorObject=NULL; +static zend_class_entry ce_swig_Driver; +static zend_class_entry* ptr_ce_swig_Driver=NULL; +static zend_class_entry ce_swig_GCP; +static zend_class_entry* ptr_ce_swig_GCP=NULL; +static zend_class_entry ce_swig_Dataset; +static zend_class_entry* ptr_ce_swig_Dataset=NULL; +static zend_class_entry ce_swig_Band; +static zend_class_entry* ptr_ce_swig_Band=NULL; +static zend_class_entry ce_swig_ColorTable; +static zend_class_entry* ptr_ce_swig_ColorTable=NULL; +static int le_swig__p_double=0; /* handle for */ +static int le_swig__p_GDALColorEntry=0; /* handle for */ +static int le_swig__p_p_char=0; /* handle for */ +static int le_swig__p_p_GDAL_GCP=0; /* handle for */ +static int le_swig__p_GDAL_GCP=0; /* handle for GCP */ +static int le_swig__p_CPLErrorHandler=0; /* handle for GCP */ +static int le_swig__p_CPLXMLNode=0; /* handle for GCP */ +static int le_swig__p_p_CPLXMLNode=0; /* handle for GCP */ +static int le_swig__p_GDALColorTable=0; /* handle for ColorTable */ +static int le_swig__p_p_GDALColorTable=0; /* handle for ColorTable */ +static int le_swig__p_int=0; /* handle for ColorTable */ +static int le_swig__p_p_GDALRasterBandShadow=0; /* handle for ColorTable */ +static int le_swig__p_GDALRasterBandShadow=0; /* handle for Band */ +static int le_swig__p_p_GDALDatasetShadow=0; /* handle for Band */ +static int le_swig__p_GDALDatasetShadow=0; /* handle for Dataset */ +static int le_swig__p_p_GDALDriverShadow=0; /* handle for Dataset */ +static int le_swig__p_GDALDriverShadow=0; /* handle for Driver */ +static int le_swig__p_p_GDALMajorObjectShadow=0; /* handle for Driver */ +static int le_swig__p_GDALMajorObjectShadow=0; /* handle for MajorObject */ +/* end vdecl subsection */ +/* wrapper section */ +ZEND_NAMED_FUNCTION(_wrap_Debug) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + Debug((char const *)arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Error) { + CPLErr arg1 = (CPLErr) CE_Failure ; + int arg2 = (int) 0 ; + char *arg3 = (char *) "error" ; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (CPLErr) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@@*/; + } + } + Error(arg1,arg2,(char const *)arg3); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PushErrorHandler__SWIG_0) { + char *arg1 = (char *) "CPLQuietErrorHandler" ; + CPLErr result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (CPLErr)PushErrorHandler((char const *)arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PushErrorHandler__SWIG_1) { + CPLErrorHandler arg1 ; + CPLErrorHandler *tmp1 ; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + if(SWIG_ConvertPtr(*args[0], (void **) &tmp1, SWIGTYPE_p_CPLErrorHandler, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of PushErrorHandler. Expected SWIGTYPE_p_CPLErrorHandler"); + } + arg1 = *tmp1; + } + CPLPushErrorHandler(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PushErrorHandler) { + int argc; + zval **argv[1]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if ((argc >= 0) && (argc <= 1)) { + int _v; + if (argc <= 0) { + return _wrap_PushErrorHandler__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + _v = (Z_TYPE_PP(argv[0]) == IS_LONG || + Z_TYPE_PP(argv[0]) == IS_DOUBLE || + Z_TYPE_PP(argv[0]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_PushErrorHandler__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + if (argc == 1) { + int _v; + /* typecheck SWIGTYPE */ + if (_v) { + return _wrap_PushErrorHandler__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + + /*No matching function for overloaded 'PushErrorHandler'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_PopErrorHandler) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + CPLPopErrorHandler(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ErrorReset) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + CPLErrorReset(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorNo) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)CPLGetLastErrorNo(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorType) { + CPLErr result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (CPLErr)CPLGetLastErrorType(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorMsg) { + char *result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (char *)CPLGetLastErrorMsg(); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PushFinderLocation) { + char *arg1 = (char *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + CPLPushFinderLocation((char const *)arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PopFinderLocation) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + CPLPopFinderLocation(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FinderClean) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + CPLFinderClean(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FindFile) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + result = (char *)CPLFindFile((char const *)arg1,(char const *)arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SetConfigOption) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + CPLSetConfigOption((char const *)arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetConfigOption) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + result = (char *)CPLGetConfigOption((char const *)arg1,(char const *)arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetDescription) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_GetDescription. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + result = (char *)GDALMajorObjectShadow_GetDescription(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetDescription) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_SetDescription. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + GDALMajorObjectShadow_SetDescription(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_Dict) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_GetMetadata_Dict. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (char **)GDALMajorObjectShadow_GetMetadata_Dict(arg1,(char const *)arg2); + + { + /* %typemap(out) char **dict */ + char **stringarray = result; + array_init(return_value); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + add_assoc_string(return_value,keyptr,(char*)valptr,1); + CPLFree( keyptr ); + } + stringarray++; + } + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_List) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_GetMetadata_List. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (char **)GDALMajorObjectShadow_GetMetadata_List(arg1,(char const *)arg2); + + { + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = result; + if ( stringarray == NULL ) { + RETVAL_NULL(); + } + else { + int len = CSLCount( stringarray ); + array_init(return_value); + for ( int i = 0; i < len; ++i, ++stringarray ) { + add_next_index_string( return_value, *stringarray, 1 ); + } + CSLDestroy( result ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata__SWIG_0) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_SetMetadata. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + { + /* %typemap(in) char **dict */ + zend_error(E_ERROR,"Typemap (in) char **dict not properly defined"); + /* if ( PySequence_Check( args[0] ) ) { + int size = PySequence_Size(args[0]); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(args[0],i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg2 = CSLAddString( arg2, pszItem ); + } + } + */ + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + } + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_0(arg1,arg2,(char const *)arg3); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + return; + fail: + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata__SWIG_1) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of MajorObject_SetMetadata. Expected SWIGTYPE_p_p_GDALMajorObjectShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + } + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_1(arg1,arg2,(char const *)arg3); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata) { + int argc; + zval **argv[3]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if ((argc >= 2) && (argc <= 3)) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0)? 0:1; + } + if (_v) { + { + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + _v = 0; //(PyMapping_Check(argv[1]) || PySequence_Check(argv[1]) ) ? 1 : 0; + } + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_SetMetadata__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + _v = (Z_TYPE_PP(argv[2]) == IS_LONG || + Z_TYPE_PP(argv[2]) == IS_DOUBLE || + Z_TYPE_PP(argv[2]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_MajorObject_SetMetadata__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + if ((argc >= 2) && (argc <= 3)) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_GDALMajorObjectShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_SetMetadata__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + _v = (Z_TYPE_PP(argv[2]) == IS_LONG || + Z_TYPE_PP(argv[2]) == IS_DOUBLE || + Z_TYPE_PP(argv[2]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_MajorObject_SetMetadata__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + + /*No matching function for overloaded 'MajorObject_SetMetadata'*/ + +} + + +/* property handler for class MajorObject */ +static pval _wrap_propget_MajorObject(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_MajorObject(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_MajorObject(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_MajorObject(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is MajorObject */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_MajorObject(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static pval _wrap_Driver_ShortName_get(zend_property_reference *property_reference) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_ShortName_get. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + result = (char *)GDALDriverShadow_ShortName_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Driver_LongName_get(zend_property_reference *property_reference) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_LongName_get. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + result = (char *)GDALDriverShadow_LongName_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Driver_HelpTopic_get(zend_property_reference *property_reference) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_HelpTopic_get. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + result = (char *)GDALDriverShadow_HelpTopic_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_Create) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 = (int) 1 ; + GDALDataType arg6 = (GDALDataType) GDT_Byte ; + char **arg7 = (char **) 0 ; + GDALDatasetShadow *result; + zval **args[6]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<4 || arg_count>7) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_Create. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg5 = (int) Z_LVAL_PP(args[3]); + /*@@*/; + } + } + if(arg_count > 5) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[4]); + arg6 = (GDALDataType) Z_LVAL_PP(args[4]); + /*@@*/; + } + } + if(arg_count > 6) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[5]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[5],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg7 = CSLAddString( arg7, pszItem ); + // } + } + } + result = (GDALDatasetShadow *)GDALDriverShadow_Create(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDatasetShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Dataset); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateCopy) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + GDALDatasetShadow *arg3 = (GDALDatasetShadow *) 0 ; + int arg4 = (int) 1 ; + char **arg5 = (char **) 0 ; + GDALDatasetShadow *result; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<3 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_CreateCopy. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg3, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 3 of Driver_CreateCopy. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[3]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[3],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg5 = CSLAddString( arg5, pszItem ); + // } + } + } + result = (GDALDatasetShadow *)GDALDriverShadow_CreateCopy(arg1,(char const *)arg2,arg3,arg4,arg5); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDatasetShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Dataset); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_Delete) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_Delete. Expected SWIGTYPE_p_p_GDALDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)GDALDriverShadow_Delete(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Driver */ +static pval _wrap_propget_Driver(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Driver(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Driver(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"HelpTopic")==0) { + *value=_wrap_Driver_HelpTopic_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"ShortName")==0) { + *value=_wrap_Driver_ShortName_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"LongName")==0) { + *value=_wrap_Driver_LongName_get(property_reference); + return SUCCESS; + } else { + /* chain to base class */ + if (_propget_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +static int _wrap_propset_Driver(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Driver(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Driver */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Driver(zend_property_reference *property_reference, pval *value) { + /* No extra properties for subclass Driver */ + { + /* chain to base class */ + if (_propset_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +static int _wrap_GCP_GCPX_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPX_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(&value); + arg2 = (double) Z_DVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_GCPX_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_GCPX_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPX_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPX_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_GCPY_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPY_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(&value); + arg2 = (double) Z_DVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_GCPY_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_GCPY_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPY_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPY_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_GCPZ_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPZ_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(&value); + arg2 = (double) Z_DVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_GCPZ_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_GCPZ_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPZ_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPZ_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_GCPPixel_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPPixel_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(&value); + arg2 = (double) Z_DVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_GCPPixel_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_GCPPixel_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPPixel_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_GCPLine_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPLine_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(&value); + arg2 = (double) Z_DVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_GCPLine_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_GCPLine_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_GCPLine_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPLine_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_Info_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_Info_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(&value); + arg2 = (char *) Z_STRVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_Info_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_Info_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_Info_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_Info_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static int _wrap_GCP_Id_set(zend_property_reference *property_reference, pval *value) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_Id_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(&value); + arg2 = (char *) Z_STRVAL_PP(&value); + /*@@*/; + } + GDAL_GCP_Id_set(arg1,arg2); + + + return SUCCESS; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_GCP_Id_get(zend_property_reference *property_reference) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GCP_Id_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_Id_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_GCP) { + double arg1 = (double) 0.0 ; + double arg2 = (double) 0.0 ; + double arg3 = (double) 0.0 ; + double arg4 = (double) 0.0 ; + double arg5 = (double) 0.0 ; + char *arg6 = (char *) "" ; + char *arg7 = (char *) "" ; + GDAL_GCP *result; + zval **args[7]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>7) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg1 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg3 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg4 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg5 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + } + if(arg_count > 5) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[5]); + arg6 = (char *) Z_STRVAL_PP(args[5]); + /*@@*/; + } + } + if(arg_count > 6) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[6]); + arg7 = (char *) Z_STRVAL_PP(args[6]); + /*@@*/; + } + } + result = (GDAL_GCP *)new_GDAL_GCP(arg1,arg2,arg3,arg4,arg5,(char const *)arg6,(char const *)arg7); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDAL_GCP, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_GCP); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_GCP(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_GDAL_GCP TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "GDAL_GCP resource already free'd"); + delete_GDAL_GCP(arg1); + +} + + +/* property handler for class GCP */ +static pval _wrap_propget_GCP(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_GCP(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_GCP(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"GCPLine")==0) { + *value=_wrap_GCP_GCPLine_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"Id")==0) { + *value=_wrap_GCP_Id_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"GCPX")==0) { + *value=_wrap_GCP_GCPX_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"GCPZ")==0) { + *value=_wrap_GCP_GCPZ_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"GCPPixel")==0) { + *value=_wrap_GCP_GCPPixel_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"Info")==0) { + *value=_wrap_GCP_Info_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"GCPY")==0) { + *value=_wrap_GCP_GCPY_get(property_reference); + return SUCCESS; + } else return FAILURE; +} + +static int _wrap_propset_GCP(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_GCP(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is GCP */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_GCP(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"GCPPixel")==0) { + return _wrap_GCP_GCPPixel_set(property_reference, value); + } else if (strcmp(propname,"Info")==0) { + return _wrap_GCP_Info_set(property_reference, value); + } else if (strcmp(propname,"GCPY")==0) { + return _wrap_GCP_GCPY_set(property_reference, value); + } else if (strcmp(propname,"GCPLine")==0) { + return _wrap_GCP_GCPLine_set(property_reference, value); + } else if (strcmp(propname,"Id")==0) { + return _wrap_GCP_Id_set(property_reference, value); + } else if (strcmp(propname,"GCPX")==0) { + return _wrap_GCP_GCPX_set(property_reference, value); + } else if (strcmp(propname,"GCPZ")==0) { + return _wrap_GCP_GCPZ_set(property_reference, value); + } else return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPX_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPX_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPX_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPX_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPX_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_GCPX_set(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPY_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPY_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPY_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPY_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPY_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_GCPY_set(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPZ_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPZ_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPZ_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPZ_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPZ_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_GCPZ_set(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPPixel_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPPixel_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPPixel_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPPixel_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_GCPPixel_set(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPLine_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPLine_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_GCPLine_get(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPLine_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_GCPLine_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_GCPLine_set(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Info_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_Info_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_Info_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Info_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_Info_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_Info_set(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Id_get) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_Id_get. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_Id_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Id_set) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_Id_set. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_Id_set(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPX) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_GCPX. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_get_GCPX(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPX) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_GCPX. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_GCPX(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPY) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_GCPY. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_get_GCPY(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPY) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_GCPY. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_GCPY(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPZ) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_GCPZ. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_get_GCPZ(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPZ) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_GCPZ. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_GCPZ(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPPixel) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_GCPPixel. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_get_GCPPixel(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPPixel) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_GCPPixel. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_GCPPixel(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPLine) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_GCPLine. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (double)GDAL_GCP_get_GCPLine(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPLine) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_GCPLine. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg2 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_GCPLine(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_Info) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_Info. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_get_Info(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_Info) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_Info. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_Info(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_Id) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_get_Id. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + result = (char *)GDAL_GCP_get_Id(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_Id) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDAL_GCP, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of GDAL_GCP_set_Id. Expected SWIGTYPE_p_p_GDAL_GCP"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + GDAL_GCP_set_Id(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GCPsToGeoTransform) { + int arg1 ; + GDAL_GCP *arg2 = (GDAL_GCP *) 0 ; + double *arg3 ; + int arg4 = (int) 1 ; + FALSE_IS_ERR result; + GDAL_GCP *tmpGCPList1 ; + double argout3[6] ; + zval **args[2]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (double argout3[ANY]) */ + arg3 = argout3; + } + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg4 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = GDALGCPsToGeoTransform(arg1,(GDAL_GCP const *)arg2,arg3,arg4); + + { + /* %typemap(out) IF_FALSE_RETURN_NONE */ + RETVAL_NULL(); + } + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg3, 6 ); + t_output_helper( &return_value, t ); + } + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + { + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + RETVAL_NULL(); + } + return; + fail: + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Dataset_RasterXSize_get(zend_property_reference *property_reference) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_RasterXSize_get. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (int)GDALDatasetShadow_RasterXSize_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Dataset_RasterYSize_get(zend_property_reference *property_reference) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_RasterYSize_get. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (int)GDALDatasetShadow_RasterYSize_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Dataset_RasterCount_get(zend_property_reference *property_reference) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_RasterCount_get. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (int)GDALDatasetShadow_RasterCount_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_Dataset(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_GDALDatasetShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "GDALDatasetShadow resource already free'd"); + delete_GDALDatasetShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetDriver) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDriverShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetDriver. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (GDALDriverShadow *)GDALDatasetShadow_GetDriver(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDriverShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Driver); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetRasterBand) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetRasterBand. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (GDALRasterBandShadow *)GDALDatasetShadow_GetRasterBand(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALRasterBandShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Band); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjection) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetProjection. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (char *)GDALDatasetShadow_GetProjection(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjectionRef) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetProjectionRef. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (char *)GDALDatasetShadow_GetProjectionRef(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetProjection) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + CPLErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_SetProjection. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (CPLErr)GDALDatasetShadow_SetProjection(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGeoTransform) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + double argout2[6] ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetGeoTransform. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + GDALDatasetShadow_GetGeoTransform(arg1,arg2); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 6 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGeoTransform) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + CPLErr result; + double argin2[6] ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_SetGeoTransform. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + { + /* %typemap(in) (double argin2[ANY]) */ + arg2 = argin2; + for (unsigned int i=0; i<6; i++) { + double val = 0.0; /* extract val from i-th position of args[0] */ + arg2[i] = val; + } + } + result = (CPLErr)GDALDatasetShadow_SetGeoTransform(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_BuildOverviews) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) "NEAREST" ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_BuildOverviews. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + zend_error(E_ERROR,"Typemap (in,numinputs=1) (int nList, int*pList) not properly defined"); + /* check if is List */ + // if ( !PySequence_Check(args[1]) ) { + // PyErr_SetString(PyExc_TypeError, "not a sequence"); + // SWIG_fail; + // } + // arg3 = PySequence_Size(args[1]); + // arg4 = (int*) malloc(arg3*sizeof(int)); + // for( int i = 0; i<arg3; i++ ) { + // PyObject *o = PySequence_GetItem(args[1],i); + // if ( !PyArg_Parse(o,"i",&arg4[i]) ) { + // SWIG_fail; + // } + // } + } + } + result = (int)GDALDatasetShadow_BuildOverviews(arg1,(char const *)arg2,arg3,arg4); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return; + fail: + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPCount) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetGCPCount. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (int)GDALDatasetShadow_GetGCPCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPProjection) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetGCPProjection. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + result = (char *)GDALDatasetShadow_GetGCPProjection(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPs) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int *arg2 = (int *) 0 ; + GDAL_GCP **arg3 = (GDAL_GCP **) 0 ; + int nGCPs2 = 0 ; + GDAL_GCP *pGCPs2 = 0 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (int *nGCPs2, GDAL_GCP const **pGCPs2 ) */ + arg2 = &nGCPs2; + arg3 = &pGCPs2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_GetGCPs. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + GDALDatasetShadow_GetGCPs(arg1,arg2,(GDAL_GCP const **)arg3); + + + { + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + zval *out; + MAKE_STD_ZVAL(out); + array_init(out); + for( int i = 0; i < *arg2; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*arg3)[i].dfGCPX, + (*arg3)[i].dfGCPY, + (*arg3)[i].dfGCPZ, + (*arg3)[i].dfGCPPixel, + (*arg3)[i].dfGCPLine, + (*arg3)[i].pszInfo, + (*arg3)[i].pszId ); + zval *t; + MAKE_STD_ZVAL(t); + SWIG_SetPointerZval(t,(void*)o,SWIGTYPE_p_GDAL_GCP,1); + add_next_index_zval(out,t); + } + return_value = out; + zval_copy_ctor(return_value); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGCPs) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDAL_GCP *arg3 = (GDAL_GCP *) 0 ; + char *arg4 = (char *) 0 ; + CPLErr result; + GDAL_GCP *tmpGCPList2 ; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_SetGCPs. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg4 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + result = (CPLErr)GDALDatasetShadow_SetGCPs(arg1,arg2,(GDAL_GCP const *)arg3,(char const *)arg4); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + return; + fail: + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_FlushCache) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_FlushCache. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + GDALDatasetShadow_FlushCache(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_AddBand) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDataType arg2 = (GDALDataType) GDT_Byte ; + char **arg3 = (char **) 0 ; + CPLErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_AddBand. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (GDALDataType) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[1]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[1],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg3 = CSLAddString( arg3, pszItem ); + // } + } + } + result = (CPLErr)GDALDatasetShadow_AddBand(arg1,arg2,arg3); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Dataset_WriteRaster) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + GDALDataType *arg10 = (GDALDataType *) 0 ; + int arg11 = (int) 0 ; + int *arg12 = (int *) 0 ; + CPLErr result; + int val8 ; + int val9 ; + GDALDataType val10 ; + zval **args[9]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<6 || arg_count>10) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Dataset_WriteRaster. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg5 = (int) Z_LVAL_PP(args[3]); + /*@@*/; + } + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + convert_to_string_ex(args[4]); + arg7 = Z_STRVAL_PP(args[4]); + arg6 = Z_STRLEN_PP(args[4]); + } + if(arg_count > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[5]) ) { + arg8 = 0; + } + convert_to_long_ex(args[5]); + val8 = (int) Z_LVAL_PP( args[5] ); + arg8 = &val8; + } + } + if(arg_count > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[6]) ) { + arg9 = 0; + } + convert_to_long_ex(args[6]); + val9 = (int) Z_LVAL_PP( args[6] ); + arg9 = &val9; + } + } + if(arg_count > 8) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[7]) ) { + arg10 = 0; + } + convert_to_long_ex(args[7]); + val10 = (GDALDataType) Z_LVAL_PP( args[7] ); + arg10 = &val10; + } + } + if(arg_count > 9) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + zend_error(E_ERROR,"Typemap (in,numinputs=1) (int nList, int*pList) not properly defined"); + /* check if is List */ + // if ( !PySequence_Check(args[8]) ) { + // PyErr_SetString(PyExc_TypeError, "not a sequence"); + // SWIG_fail; + // } + // arg11 = PySequence_Size(args[8]); + // arg12 = (int*) malloc(arg11*sizeof(int)); + // for( int i = 0; i<arg11; i++ ) { + // PyObject *o = PySequence_GetItem(args[8],i); + // if ( !PyArg_Parse(o,"i",&arg12[i]) ) { + // SWIG_fail; + // } + // } + } + } + result = (CPLErr)GDALDatasetShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + return; + fail: + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Dataset */ +static pval _wrap_propget_Dataset(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Dataset(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Dataset(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"RasterXSize")==0) { + *value=_wrap_Dataset_RasterXSize_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"RasterYSize")==0) { + *value=_wrap_Dataset_RasterYSize_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"RasterCount")==0) { + *value=_wrap_Dataset_RasterCount_get(property_reference); + return SUCCESS; + } else { + /* chain to base class */ + if (_propget_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +static int _wrap_propset_Dataset(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Dataset(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Dataset */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Dataset(zend_property_reference *property_reference, pval *value) { + /* No extra properties for subclass Dataset */ + { + /* chain to base class */ + if (_propset_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +static pval _wrap_Band_XSize_get(zend_property_reference *property_reference) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_XSize_get. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (int)GDALRasterBandShadow_XSize_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Band_YSize_get(zend_property_reference *property_reference) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_YSize_get. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (int)GDALRasterBandShadow_YSize_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +static pval _wrap_Band_DataType_get(zend_property_reference *property_reference) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALDataType result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_DataType_get. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (GDALDataType)GDALRasterBandShadow_DataType_get(arg1); + + { + ZVAL_LONG(return_value,result); + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorInterpretation) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetRasterColorInterpretation. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (GDALColorInterp)GDALRasterBandShadow_GetRasterColorInterpretation(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorInterpretation) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp arg2 ; + CPLErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_SetRasterColorInterpretation. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (GDALColorInterp) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (CPLErr)GDALRasterBandShadow_SetRasterColorInterpretation(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetNoDataValue) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetNoDataValue. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_GetNoDataValue(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*arg3 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *arg2 ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_SetNoDataValue) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + CPLErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_SetNoDataValue. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + result = (CPLErr)GDALRasterBandShadow_SetNoDataValue(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetMinimum) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetMinimum. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_GetMinimum(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*arg3 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *arg2 ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetMaximum) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetMaximum. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_GetMaximum(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*arg3 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *arg2 ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetOffset) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetOffset. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_GetOffset(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*arg3 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *arg2 ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetScale) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetScale. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_GetScale(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double *val, int*hasval) */ + if ( !*arg3 ) { + RETVAL_NULL(); + } + else { + RETVAL_DOUBLE( *arg2 ); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverviewCount) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetOverviewCount. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (int)GDALRasterBandShadow_GetOverviewCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverview) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetOverview. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (GDALRasterBandShadow *)GDALRasterBandShadow_GetOverview(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALRasterBandShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Band); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_Checksum) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 = (int) 0 ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int result; + int val4 ; + int val5 ; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_Checksum. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[2]) ) { + arg4 = 0; + } + convert_to_long_ex(args[2]); + val4 = (int) Z_LVAL_PP( args[2] ); + arg4 = &val4; + } + } + if(arg_count > 4) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[3]) ) { + arg5 = 0; + } + convert_to_long_ex(args[3]); + val5 = (int) Z_LVAL_PP( args[3] ); + arg5 = &val5; + } + } + result = (int)GDALRasterBandShadow_Checksum(arg1,arg2,arg3,arg4,arg5); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_ComputeRasterMinMax) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 0 ; + double argout2[2] ; + zval **args[1]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_ComputeRasterMinMax. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg3 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + GDALRasterBandShadow_ComputeRasterMinMax(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 2 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_Fill) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + double arg3 = (double) 0.0 ; + CPLErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_Fill. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + } + result = (CPLErr)GDALRasterBandShadow_Fill(arg1,arg2,arg3); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_ReadRaster) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 = (int *) 0 ; + char **arg7 = (char **) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + int nLen6 = 0 ; + char *pBuf6 = 0 ; + int val8 ; + int val9 ; + int val10 ; + zval **args[7]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (int *nLen6, char **pBuf6 ) */ + arg6 = &nLen6; + arg7 = &pBuf6; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<5 || arg_count>8) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_ReadRaster. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg5 = (int) Z_LVAL_PP(args[3]); + /*@@*/; + } + if(arg_count > 5) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[4]) ) { + arg8 = 0; + } + convert_to_long_ex(args[4]); + val8 = (int) Z_LVAL_PP( args[4] ); + arg8 = &val8; + } + } + if(arg_count > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[5]) ) { + arg9 = 0; + } + convert_to_long_ex(args[5]); + val9 = (int) Z_LVAL_PP( args[5] ); + arg9 = &val9; + } + } + if(arg_count > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[6]) ) { + arg10 = 0; + } + convert_to_long_ex(args[6]); + val10 = (int) Z_LVAL_PP( args[6] ); + arg10 = &val10; + } + } + result = (CPLErr)GDALRasterBandShadow_ReadRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + { + ZVAL_LONG(return_value,result); + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + ZVAL_STRINGL( return_value, *arg7, *arg6, 1 ); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + return; + fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_WriteRaster) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + int val8 ; + int val9 ; + int val10 ; + zval **args[8]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<6 || arg_count>9) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_WriteRaster. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg5 = (int) Z_LVAL_PP(args[3]); + /*@@*/; + } + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + convert_to_string_ex(args[4]); + arg7 = Z_STRVAL_PP(args[4]); + arg6 = Z_STRLEN_PP(args[4]); + } + if(arg_count > 6) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[5]) ) { + arg8 = 0; + } + convert_to_long_ex(args[5]); + val8 = (int) Z_LVAL_PP( args[5] ); + arg8 = &val8; + } + } + if(arg_count > 7) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[6]) ) { + arg9 = 0; + } + convert_to_long_ex(args[6]); + val9 = (int) Z_LVAL_PP( args[6] ); + arg9 = &val9; + } + } + if(arg_count > 8) { + { + /* %typemap(in) (int *optional_int) */ + if ( ZVAL_IS_NULL(*args[7]) ) { + arg10 = 0; + } + convert_to_long_ex(args[7]); + val10 = (int) Z_LVAL_PP( args[7] ); + arg10 = &val10; + } + } + result = (CPLErr)GDALRasterBandShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_FlushCache) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_FlushCache. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + GDALRasterBandShadow_FlushCache(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorTable) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_GetRasterColorTable. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + result = (GDALColorTable *)GDALRasterBandShadow_GetRasterColorTable(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALColorTable, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_ColorTable); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorTable) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *arg2 = (GDALColorTable *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALRasterBandShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Band_SetRasterColorTable. Expected SWIGTYPE_p_p_GDALRasterBandShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Band_SetRasterColorTable. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + result = (int)GDALRasterBandShadow_SetRasterColorTable(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Band */ +static pval _wrap_propget_Band(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Band(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Band(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"XSize")==0) { + *value=_wrap_Band_XSize_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"YSize")==0) { + *value=_wrap_Band_YSize_get(property_reference); + return SUCCESS; + } else if (strcmp(propname,"DataType")==0) { + *value=_wrap_Band_DataType_get(property_reference); + return SUCCESS; + } else { + /* chain to base class */ + if (_propget_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +static int _wrap_propset_Band(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Band(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Band */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Band(zend_property_reference *property_reference, pval *value) { + /* No extra properties for subclass Band */ + { + /* chain to base class */ + if (_propset_MajorObject(property_reference, value)==SUCCESS) return SUCCESS; + } + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_new_ColorTable) { + GDALPaletteInterp arg1 = (GDALPaletteInterp) GPI_RGB ; + GDALColorTable *result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALPaletteInterp) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (GDALColorTable *)new GDALColorTable(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALColorTable, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_ColorTable); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_ColorTable(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_GDALColorTable TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "GDALColorTable resource already free'd"); + delete arg1; + +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_Clone) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALColorTable *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_Clone. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + result = (GDALColorTable *)((GDALColorTable const *)arg1)->Clone(); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALColorTable, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_ColorTable); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetPaletteInterpretation) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALPaletteInterp result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_GetPaletteInterpretation. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + result = (GDALPaletteInterp)((GDALColorTable const *)arg1)->GetPaletteInterpretation(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetCount) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_GetCount. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + result = (int)((GDALColorTable const *)arg1)->GetColorEntryCount(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntry) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_GetColorEntry. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (GDALColorEntry *)(arg1)->GetColorEntry(arg2); + + { + /* %typemap(out) GDALColorEntry* */ + array_init(return_value); + add_next_index_long(return_value,(*result).c1); + add_next_index_long(return_value,(*result).c2); + add_next_index_long(return_value,(*result).c3); + add_next_index_long(return_value,(*result).c4); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntryAsRGB) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + int result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_GetColorEntryAsRGB. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /* %typemap(in) GDALColorEntry* */ + GDALColorEntry ce = { + 255,255,255,255 + }; + // Need to parse the array values from args[1] + arg3 = &ce; + } + result = (int)((GDALColorTable const *)arg1)->GetColorEntryAsRGB(arg2,arg3); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ColorTable_SetColorEntry) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_GDALColorTable, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of ColorTable_SetColorEntry. Expected SWIGTYPE_p_p_GDALColorTable"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /* %typemap(in) GDALColorEntry* */ + GDALColorEntry ce = { + 255,255,255,255 + }; + // Need to parse the array values from args[1] + arg3 = &ce; + } + (arg1)->SetColorEntry(arg2,(GDALColorEntry const *)arg3); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class ColorTable */ +static pval _wrap_propget_ColorTable(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_ColorTable(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_ColorTable(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_ColorTable(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_ColorTable(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is ColorTable */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_ColorTable(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_AllRegister) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + GDALAllRegister(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetCacheMax) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)GDALGetCacheMax(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SetCacheMax) { + int arg1 ; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + GDALSetCacheMax(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetCacheUsed) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)GDALGetCacheUsed(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeSize) { + GDALDataType arg1 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALDataType) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (int)GDALGetDataTypeSize(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataTypeIsComplex) { + GDALDataType arg1 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALDataType) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (int)GDALDataTypeIsComplex(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeName) { + GDALDataType arg1 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALDataType) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (char *)GDALGetDataTypeName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeByName) { + char *arg1 = (char *) 0 ; + GDALDataType result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (GDALDataType)GDALGetDataTypeByName((char const *)arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetColorInterpretationName) { + GDALColorInterp arg1 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALColorInterp) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (char *)GDALGetColorInterpretationName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetPaletteInterpretationName) { + GDALPaletteInterp arg1 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (GDALPaletteInterp) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (char *)GDALGetPaletteInterpretationName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DecToDMS) { + double arg1 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 2 ; + char *result; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg1 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg3 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + } + result = (char *)GDALDecToDMS(arg1,(char const *)arg2,arg3); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_PackedDMSToDec) { + double arg1 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg1 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + result = (double)GDALPackedDMSToDec(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DecToPackedDMS) { + double arg1 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg1 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + result = (double)GDALDecToPackedDMS(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_ParseXMLString) { + char *arg1 = (char *) 0 ; + CPLXMLNode *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (CPLXMLNode *)CPLParseXMLString(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_CPLXMLNode, 0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SerializeXMLTree) { + CPLXMLNode *arg1 = (CPLXMLNode *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_CPLXMLNode, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SerializeXMLTree. Expected SWIGTYPE_p_p_CPLXMLNode"); + } + } + result = (char *)CPLSerializeXMLTree(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDriverCount) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)GetDriverCount(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDriverByName) { + char *arg1 = (char *) 0 ; + GDALDriverShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (GDALDriverShadow *)GetDriverByName((char const *)arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDriverShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Driver); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDriver) { + int arg1 ; + GDALDriverShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (GDALDriverShadow *)GetDriver(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDriverShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Driver); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Open) { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (GDALAccess) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (GDALDatasetShadow *)Open((char const *)arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDatasetShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Dataset); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_OpenShared) { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (GDALAccess) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (GDALDatasetShadow *)OpenShared((char const *)arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDatasetShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Dataset); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_AutoCreateWarpedVRT) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + GDALResampleAlg arg4 = (GDALResampleAlg) GRA_NearestNeighbour ; + double arg5 = (double) 0.0 ; + GDALDatasetShadow *result; + zval **args[5]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_GDALDatasetShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of AutoCreateWarpedVRT. Expected SWIGTYPE_p_p_GDALDatasetShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg3 = (char *) Z_STRVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg4 = (GDALResampleAlg) Z_LVAL_PP(args[3]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg5 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + } + result = (GDALDatasetShadow *)AutoCreateWarpedVRT(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_GDALDatasetShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Dataset); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_double) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALColorEntry) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDAL_GCP) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDAL_GCP) { + /* has destructor: __wrap_delete_GCP */ + __wrap_delete_GCP(rsrc, SWIGTYPE_p_GDAL_GCP->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_CPLErrorHandler) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_CPLXMLNode) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_CPLXMLNode) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALColorTable) { + /* has destructor: __wrap_delete_ColorTable */ + __wrap_delete_ColorTable(rsrc, SWIGTYPE_p_GDALColorTable->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDALColorTable) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_int) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDALRasterBandShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALRasterBandShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDALDatasetShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALDatasetShadow) { + /* has destructor: __wrap_delete_Dataset */ + __wrap_delete_Dataset(rsrc, SWIGTYPE_p_GDALDatasetShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDALDriverShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALDriverShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_GDALMajorObjectShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GDALMajorObjectShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* end wrapper section */ +/* init section */ +#ifdef __cplusplus +extern "C" { +#endif +ZEND_GET_MODULE(gdal) +#ifdef __cplusplus +} +#endif + +#define SWIG_php_minit PHP_MINIT_FUNCTION(gdal) +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + + SWIG_php_minit { + SWIG_InitializeModule(0); + + + if (GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } + +/* oinit subsection */ +ZEND_INIT_MODULE_GLOBALS(gdal, gdal_init_globals, gdal_destroy_globals); +/* Define class MajorObject */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_MajorObject,"majorobject",MajorObject_functions,NULL,_wrap_propget_MajorObject,_wrap_propset_MajorObject); +if (! (ptr_ce_swig_MajorObject=zend_register_internal_class_ex(&ce_swig_MajorObject,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class MajorObject"); + +/* Define class Driver */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Driver,"driver",Driver_functions,NULL,_wrap_propget_Driver,_wrap_propset_Driver); +if (! (ptr_ce_swig_Driver=zend_register_internal_class_ex(&ce_swig_Driver,&ce_swig_MajorObject,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Driver"); + +/* Define class GCP */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_GCP,"gcp",GCP_functions,NULL,_wrap_propget_GCP,_wrap_propset_GCP); +if (! (ptr_ce_swig_GCP=zend_register_internal_class_ex(&ce_swig_GCP,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class GCP"); + +/* Define class Dataset */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Dataset,"dataset",Dataset_functions,NULL,_wrap_propget_Dataset,_wrap_propset_Dataset); +if (! (ptr_ce_swig_Dataset=zend_register_internal_class_ex(&ce_swig_Dataset,&ce_swig_MajorObject,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Dataset"); + +/* Define class Band */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Band,"band",Band_functions,NULL,_wrap_propget_Band,_wrap_propset_Band); +if (! (ptr_ce_swig_Band=zend_register_internal_class_ex(&ce_swig_Band,&ce_swig_MajorObject,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Band"); + +/* Define class ColorTable */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_ColorTable,"colortable",ColorTable_functions,NULL,_wrap_propget_ColorTable,_wrap_propset_ColorTable); +if (! (ptr_ce_swig_ColorTable=zend_register_internal_class_ex(&ce_swig_ColorTable,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class ColorTable"); + + +/* Register resource destructors for pointer types */ +le_swig__p_double=zend_register_list_destructors_ex(_wrap_destroy_p_double,NULL,(char *)(SWIGTYPE_p_double->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_double,&le_swig__p_double); +le_swig__p_GDALColorEntry=zend_register_list_destructors_ex(_wrap_destroy_p_GDALColorEntry,NULL,(char *)(SWIGTYPE_p_GDALColorEntry->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALColorEntry,&le_swig__p_GDALColorEntry); +le_swig__p_p_char=zend_register_list_destructors_ex(_wrap_destroy_p_p_char,NULL,(char *)(SWIGTYPE_p_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_char,&le_swig__p_p_char); +le_swig__p_p_GDAL_GCP=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDAL_GCP,NULL,(char *)(SWIGTYPE_p_p_GDAL_GCP->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDAL_GCP,&le_swig__p_p_GDAL_GCP); +le_swig__p_GDAL_GCP=zend_register_list_destructors_ex(_wrap_destroy_p_GDAL_GCP,NULL,(char *)(SWIGTYPE_p_GDAL_GCP->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDAL_GCP,&le_swig__p_GDAL_GCP); +le_swig__p_CPLErrorHandler=zend_register_list_destructors_ex(_wrap_destroy_p_CPLErrorHandler,NULL,(char *)(SWIGTYPE_p_CPLErrorHandler->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_CPLErrorHandler,&le_swig__p_CPLErrorHandler); +le_swig__p_CPLXMLNode=zend_register_list_destructors_ex(_wrap_destroy_p_CPLXMLNode,NULL,(char *)(SWIGTYPE_p_CPLXMLNode->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_CPLXMLNode,&le_swig__p_CPLXMLNode); +le_swig__p_p_CPLXMLNode=zend_register_list_destructors_ex(_wrap_destroy_p_p_CPLXMLNode,NULL,(char *)(SWIGTYPE_p_p_CPLXMLNode->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_CPLXMLNode,&le_swig__p_p_CPLXMLNode); +le_swig__p_GDALColorTable=zend_register_list_destructors_ex(_wrap_destroy_p_GDALColorTable,NULL,(char *)(SWIGTYPE_p_GDALColorTable->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALColorTable,&le_swig__p_GDALColorTable); +le_swig__p_p_GDALColorTable=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDALColorTable,NULL,(char *)(SWIGTYPE_p_p_GDALColorTable->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDALColorTable,&le_swig__p_p_GDALColorTable); +le_swig__p_int=zend_register_list_destructors_ex(_wrap_destroy_p_int,NULL,(char *)(SWIGTYPE_p_int->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_int,&le_swig__p_int); +le_swig__p_p_GDALRasterBandShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDALRasterBandShadow,NULL,(char *)(SWIGTYPE_p_p_GDALRasterBandShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDALRasterBandShadow,&le_swig__p_p_GDALRasterBandShadow); +le_swig__p_GDALRasterBandShadow=zend_register_list_destructors_ex(_wrap_destroy_p_GDALRasterBandShadow,NULL,(char *)(SWIGTYPE_p_GDALRasterBandShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALRasterBandShadow,&le_swig__p_GDALRasterBandShadow); +le_swig__p_p_GDALDatasetShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDALDatasetShadow,NULL,(char *)(SWIGTYPE_p_p_GDALDatasetShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDALDatasetShadow,&le_swig__p_p_GDALDatasetShadow); +le_swig__p_GDALDatasetShadow=zend_register_list_destructors_ex(_wrap_destroy_p_GDALDatasetShadow,NULL,(char *)(SWIGTYPE_p_GDALDatasetShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALDatasetShadow,&le_swig__p_GDALDatasetShadow); +le_swig__p_p_GDALDriverShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDALDriverShadow,NULL,(char *)(SWIGTYPE_p_p_GDALDriverShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDALDriverShadow,&le_swig__p_p_GDALDriverShadow); +le_swig__p_GDALDriverShadow=zend_register_list_destructors_ex(_wrap_destroy_p_GDALDriverShadow,NULL,(char *)(SWIGTYPE_p_GDALDriverShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALDriverShadow,&le_swig__p_GDALDriverShadow); +le_swig__p_p_GDALMajorObjectShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_GDALMajorObjectShadow,NULL,(char *)(SWIGTYPE_p_p_GDALMajorObjectShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_GDALMajorObjectShadow,&le_swig__p_p_GDALMajorObjectShadow); +le_swig__p_GDALMajorObjectShadow=zend_register_list_destructors_ex(_wrap_destroy_p_GDALMajorObjectShadow,NULL,(char *)(SWIGTYPE_p_GDALMajorObjectShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GDALMajorObjectShadow,&le_swig__p_GDALMajorObjectShadow); +CG(active_class_entry) = NULL; +/* end oinit subsection */ + + return SUCCESS; +} +PHP_RINIT_FUNCTION(gdal) +{ +/* rinit section */ + +/* cinit subsection */ +/* end cinit subsection */ + +/* vinit subsection */ +/* end vinit subsection */ + + return SUCCESS; +} +PHP_MSHUTDOWN_FUNCTION(gdal) +{ +/* shutdown section */ + + return SUCCESS; +} +PHP_RSHUTDOWN_FUNCTION(gdal) +{ +/* rshutdown section */ + + return SUCCESS; +} +PHP_MINFO_FUNCTION(gdal) +{ +} +/* end init section */ diff --git a/Utilities/GDAL/swig/php/gdalconst.php b/Utilities/GDAL/swig/php/gdalconst.php new file mode 100644 index 0000000000..33b0a238f8 --- /dev/null +++ b/Utilities/GDAL/swig/php/gdalconst.php @@ -0,0 +1,24 @@ +<?php + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +global $GDALCONST_LOADED__; +if ($GDALCONST_LOADED__) return; +$GDALCONST_LOADED__ = true; + +/* if our extension has not been loaded, do what we can */ +if (!extension_loaded("php_gdalconst")) { + if (!dl("php_gdalconst.so")) return; +} + + + +?> diff --git a/Utilities/GDAL/swig/php/gdalconst_wrap.c b/Utilities/GDAL/swig/php/gdalconst_wrap.c new file mode 100644 index 0000000000..6d4bf29cd4 --- /dev/null +++ b/Utilities/GDAL/swig/php/gdalconst_wrap.c @@ -0,0 +1,1113 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* + * php4.swg + * + * PHP4 runtime library + * + */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "zend.h" +#include "zend_API.h" +#include "php.h" + +/* These TSRMLS_ stuff should already be defined now, but with older php under + redhat are not... */ +#ifndef TSRMLS_D +#define TSRMLS_D +#endif +#ifndef TSRMLS_DC +#define TSRMLS_DC +#endif +#ifndef TSRMLS_C +#define TSRMLS_C +#endif +#ifndef TSRMLS_CC +#define TSRMLS_CC +#endif + +#ifdef __cplusplus +} +#endif + +/* But in fact SWIG_ConvertPtr is the native interface for getting typed + pointer values out of zvals. We need the TSRMLS_ macros for when we + make PHP type calls later as we handle php resources */ +#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) + +/* Flags for SWIG_ConvertPtr */ +#define SWIG_POINTER_DISOWN 0x1 + +#define SWIG_fail goto fail + +static char *default_error_msg = "Unknown error occurred"; +static int default_error_code = E_ERROR; + +#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg + +#define SWIG_PHP_Error(code,msg) ErrorCode() = code; ErrorMsg() = msg; SWIG_fail; + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else + +/* Standard SWIG API */ +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) + +/* used to wrap returned objects in so we know whether they are newobject + and need freeing, or not */ +typedef struct _swig_object_wrapper { + void * ptr; + int newobject; +} swig_object_wrapper; + +/* empty zend destructor for types without one */ +static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) {}; + +#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d, SWIG_module_entry TSRMLS_CC) + +static void +SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject, zend_module_entry* module_entry TSRMLS_DC) { + swig_object_wrapper *value=NULL; + /* + * First test for Null pointers. Return those as PHP native NULL + */ + if (!ptr ) { + ZVAL_NULL(z); + return; + } + if (type->clientdata) { + if (! (*(int *)(type->clientdata))) + zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); + value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); + value->ptr=ptr; + value->newobject=newobject; + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + return; + } else { /* have to deal with old fashioned string pointer? + but this should not get this far */ + zend_error(E_ERROR, "Type: %s not registered with zend",type->name); + } +} + +/* This is a new pointer conversion routine + Taking the native pointer p (which would have been converted from the old + string pointer) and it's php type id, and it's type name (which also would + have come from the old string pointer) it converts it to ptr calling + appropriate casting functions according to ty + Sadly PHP has no API to find a type name from a type id, only from an instance + of a resource of the type id, so we have to pass type_name as well. + The two functions which might call this are: + SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource + and the registered zend destructors for which we have one per type each + with the type name hard wired in. */ +static int +SWIG_ZTS_ConvertResourceData(void * p, int type, const char *type_name, void **ptr, swig_type_info *ty TSRMLS_DC) { + swig_cast_info *tc; + + if (ty) { + if (! type_name) { + /* can't convert p to ptr type ty if we don't know what type p is */ + return -1; + } else { + /* convert and cast p from type_name to ptr as ty + Need to sort out const-ness, can SWIG_TypeCast really not take a const? */ + tc = SWIG_TypeCheck((char *)type_name,ty); + if (!tc) return -1; + *ptr = SWIG_TypeCast(tc, (void*)p); + } + } else { + /* They don't care about the target type, so just pass on the pointer! */ + *ptr = (void *) p; + } + return 0; +} + +/* This function fills ptr with a pointer of type ty by extracting the pointer + and type info from the resource in z. z must be a resource + It uses SWIG_ZTS_ConvertResourceData to do the real work. */ +static int +SWIG_ZTS_ConvertResourcePtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + swig_object_wrapper *value; + void *p; + int type; + char *type_name; + + value = (swig_object_wrapper *) zend_list_find(z->value.lval,&type); + if ( flags && SWIG_POINTER_DISOWN ) { + value->newobject = 0; + } + p = value->ptr; + if (type==-1) return -1; + + type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); + + return SWIG_ZTS_ConvertResourceData(p,type,type_name,ptr,ty TSRMLS_CC); +} + +/* We allow passing of a STRING or RESOURCE pointing to the object + or an OBJECT whose _cPtr is a string or resource pointing to the object + STRING pointers are very depracated */ +static int +SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + char *c; + zval *val; + + if(z == NULL) { + *ptr = 0; + return 0; + } + + if (z->type==IS_OBJECT) { + zval ** _cPtr; + if (zend_hash_find(HASH_OF(z),"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { + /* Don't co-erce to string if it isn't */ + if ((*_cPtr)->type==IS_STRING) c = Z_STRVAL_PP(_cPtr); + else if ((*_cPtr)->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(*_cPtr,ptr,ty, flags TSRMLS_CC); + } else goto type_error; /* _cPtr was not string or resource property */ + } else goto type_error; /* can't find property _cPtr */ + } else if (z->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(z,ptr,ty, flags TSRMLS_CC); + } else goto type_error; + +type_error: + + return -1; +} + +static char const_name[] = "swig_runtime_data_type_pointer"; +static swig_module_info *SWIG_Php4_GetModule() { + zval *pointer; + swig_module_info *ret = 0; + + MAKE_STD_ZVAL(pointer); + + if (zend_get_constant(const_name, sizeof(const_name), pointer)) { + if (pointer->type == IS_LONG) { + ret = (swig_module_info *) pointer->value.lval; + } + } + return 0; +} + +static void SWIG_Php4_SetModule(swig_module_info *pointer) { + REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); +} + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_int swig_types[0] +#define SWIGTYPE_p_char swig_types[1] +static swig_type_info *swig_types[3]; +static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +/* header section */ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ +ZEND_BEGIN_MODULE_GLOBALS(gdalconst) +char *error_msg; +int error_code; +ZEND_END_MODULE_GLOBALS(gdalconst) +ZEND_DECLARE_MODULE_GLOBALS(gdalconst) +#ifdef ZTS +#define ErrorMsg() TSRMG(gdalconst_globals_id, zend_gdalconst_globals *, error_msg ); +#define ErrorCode() TSRMG(gdalconst_globals_id, zend_gdalconst_globals *, error_code ); +#else +#define ErrorMsg() (gdalconst_globals.error_msg) +#define ErrorCode() (gdalconst_globals.error_code) +#endif + +static void gdalconst_init_globals(zend_gdalconst_globals *gdalconst_globals ) { + gdalconst_globals->error_msg = default_error_msg; + gdalconst_globals->error_code = default_error_code; +} +static void gdalconst_destroy_globals(zend_gdalconst_globals *gdalconst_globals) { } + +void SWIG_ResetError() { + ErrorMsg() = default_error_msg; + ErrorCode() = default_error_code; +} +#define SWIG_name "gdalconst" +#ifdef __cplusplus +extern "C" { +#endif +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_gdalconst.h" +#ifdef __cplusplus +} +#endif + + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + +/* class entry subsection */ + + +/* entry subsection */ +/* Every non-class user visible function must have an entry here */ +function_entry gdalconst_functions[] = { + {NULL, NULL, NULL} +}; + +zend_module_entry gdalconst_module_entry = { +#if ZEND_MODULE_API_NO > 20010900 + STANDARD_MODULE_HEADER, +#endif + "gdalconst", + gdalconst_functions, + PHP_MINIT(gdalconst), + PHP_MSHUTDOWN(gdalconst), + PHP_RINIT(gdalconst), + PHP_RSHUTDOWN(gdalconst), + PHP_MINFO(gdalconst), +#if ZEND_MODULE_API_NO > 20010900 + NO_VERSION_YET, +#endif + STANDARD_MODULE_PROPERTIES +}; +zend_module_entry* SWIG_module_entry = &gdalconst_module_entry; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__int = {"_int", "int", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__int, + &_swigt__p_char, +}; + +static swig_cast_info _swigc__int[] = { {&_swigt__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__int, + _swigc__p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/* end header section */ +/* vdecl subsection */ +static int le_swig__int=0; /* handle for */ +static int le_swig__p_char=0; /* handle for */ +/* end vdecl subsection */ +/* wrapper section */ +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_int) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* end wrapper section */ +/* init section */ +#ifdef __cplusplus +extern "C" { +#endif +ZEND_GET_MODULE(gdalconst) +#ifdef __cplusplus +} +#endif + +#define SWIG_php_minit PHP_MINIT_FUNCTION(gdalconst) +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + + SWIG_php_minit { + SWIG_InitializeModule(0); + +/* oinit subsection */ +ZEND_INIT_MODULE_GLOBALS(gdalconst, gdalconst_init_globals, gdalconst_destroy_globals); + +/* Register resource destructors for pointer types */ +le_swig__int=zend_register_list_destructors_ex(_wrap_destroy_int,NULL,(char *)(SWIGTYPE_int->name),module_number); +SWIG_TypeClientData(SWIGTYPE_int,&le_swig__int); +le_swig__p_char=zend_register_list_destructors_ex(_wrap_destroy_p_char,NULL,(char *)(SWIGTYPE_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_char,&le_swig__p_char); +CG(active_class_entry) = NULL; +/* end oinit subsection */ + + return SUCCESS; +} +PHP_RINIT_FUNCTION(gdalconst) +{ +/* rinit section */ + +/* cinit subsection */ +REGISTER_LONG_CONSTANT( "GDT_Unknown", GDT_Unknown, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_Byte", GDT_Byte, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_UInt16", GDT_UInt16, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_Int16", GDT_Int16, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_UInt32", GDT_UInt32, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_Int32", GDT_Int32, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_Float32", GDT_Float32, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_Float64", GDT_Float64, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_CInt16", GDT_CInt16, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_CInt32", GDT_CInt32, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_CFloat32", GDT_CFloat32, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_CFloat64", GDT_CFloat64, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GDT_TypeCount", GDT_TypeCount, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GA_ReadOnly", GA_ReadOnly, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GA_Update", GA_Update, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GF_Read", GF_Read, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GF_Write", GF_Write, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_Undefined", GCI_Undefined, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_GrayIndex", GCI_GrayIndex, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_PaletteIndex", GCI_PaletteIndex, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_RedBand", GCI_RedBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_GreenBand", GCI_GreenBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_BlueBand", GCI_BlueBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_AlphaBand", GCI_AlphaBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_HueBand", GCI_HueBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_SaturationBand", GCI_SaturationBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_LightnessBand", GCI_LightnessBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_CyanBand", GCI_CyanBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_MagentaBand", GCI_MagentaBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_YellowBand", GCI_YellowBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GCI_BlackBand", GCI_BlackBand, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GRA_NearestNeighbour", GRA_NearestNeighbour, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GRA_Bilinear", GRA_Bilinear, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GRA_Cubic", GRA_Cubic, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GRA_CubicSpline", GRA_CubicSpline, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GPI_Gray", GPI_Gray, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GPI_RGB", GPI_RGB, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GPI_CMYK", GPI_CMYK, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "GPI_HLS", GPI_HLS, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CXT_Element", CXT_Element, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CXT_Text", CXT_Text, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CXT_Attribute", CXT_Attribute, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CXT_Comment", CXT_Comment, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CXT_Literal", CXT_Literal, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CE_None", CE_None, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CE_Debug", CE_Debug, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CE_Warning", CE_Warning, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CE_Failure", CE_Failure, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CE_Fatal", CE_Fatal, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_None", CPLE_None, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_AppDefined", CPLE_AppDefined, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_OutOfMemory", CPLE_OutOfMemory, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_FileIO", CPLE_FileIO, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_OpenFailed", CPLE_OpenFailed, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_IllegalArg", CPLE_IllegalArg, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_NotSupported", CPLE_NotSupported, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_AssertionFailed", CPLE_AssertionFailed, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_NoWriteAccess", CPLE_NoWriteAccess, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLE_UserInterrupt", CPLE_UserInterrupt, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_LONGNAME", GDAL_DMD_LONGNAME, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_HELPTOPIC", GDAL_DMD_HELPTOPIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_MIMETYPE", GDAL_DMD_MIMETYPE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_EXTENSION", GDAL_DMD_EXTENSION, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_CREATIONOPTIONLIST", GDAL_DMD_CREATIONOPTIONLIST, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DMD_CREATIONDATATYPES", GDAL_DMD_CREATIONDATATYPES, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DCAP_CREATE", GDAL_DCAP_CREATE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("DCAP_CREATECOPY", GDAL_DCAP_CREATECOPY, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLES_BackslashQuotable", CPLES_BackslashQuotable, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLES_XML", CPLES_XML, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLES_URL", CPLES_URL, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLES_SQL", CPLES_SQL, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "CPLES_CSV", CPLES_CSV, CONST_CS | CONST_PERSISTENT); +/* end cinit subsection */ + +/* vinit subsection */ +/* end vinit subsection */ + + return SUCCESS; +} +PHP_MSHUTDOWN_FUNCTION(gdalconst) +{ +/* shutdown section */ + + return SUCCESS; +} +PHP_RSHUTDOWN_FUNCTION(gdalconst) +{ +/* rshutdown section */ + + return SUCCESS; +} +PHP_MINFO_FUNCTION(gdalconst) +{ +} +/* end init section */ diff --git a/Utilities/GDAL/swig/php/ogr.php b/Utilities/GDAL/swig/php/ogr.php new file mode 100644 index 0000000000..91a38aafb9 --- /dev/null +++ b/Utilities/GDAL/swig/php/ogr.php @@ -0,0 +1,24 @@ +<?php + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +global $OGR_LOADED__; +if ($OGR_LOADED__) return; +$OGR_LOADED__ = true; + +/* if our extension has not been loaded, do what we can */ +if (!extension_loaded("php_ogr")) { + if (!dl("php_ogr.so")) return; +} + + + +?> diff --git a/Utilities/GDAL/swig/php/ogr_wrap.cpp b/Utilities/GDAL/swig/php/ogr_wrap.cpp new file mode 100644 index 0000000000..516171415c --- /dev/null +++ b/Utilities/GDAL/swig/php/ogr_wrap.cpp @@ -0,0 +1,9323 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* + * php4.swg + * + * PHP4 runtime library + * + */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "zend.h" +#include "zend_API.h" +#include "php.h" + +/* These TSRMLS_ stuff should already be defined now, but with older php under + redhat are not... */ +#ifndef TSRMLS_D +#define TSRMLS_D +#endif +#ifndef TSRMLS_DC +#define TSRMLS_DC +#endif +#ifndef TSRMLS_C +#define TSRMLS_C +#endif +#ifndef TSRMLS_CC +#define TSRMLS_CC +#endif + +#ifdef __cplusplus +} +#endif + +/* But in fact SWIG_ConvertPtr is the native interface for getting typed + pointer values out of zvals. We need the TSRMLS_ macros for when we + make PHP type calls later as we handle php resources */ +#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) + +/* Flags for SWIG_ConvertPtr */ +#define SWIG_POINTER_DISOWN 0x1 + +#define SWIG_fail goto fail + +static char *default_error_msg = "Unknown error occurred"; +static int default_error_code = E_ERROR; + +#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg + +#define SWIG_PHP_Error(code,msg) ErrorCode() = code; ErrorMsg() = msg; SWIG_fail; + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else + +/* Standard SWIG API */ +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) + +/* used to wrap returned objects in so we know whether they are newobject + and need freeing, or not */ +typedef struct _swig_object_wrapper { + void * ptr; + int newobject; +} swig_object_wrapper; + +/* empty zend destructor for types without one */ +static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) {}; + +#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d, SWIG_module_entry TSRMLS_CC) + +static void +SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject, zend_module_entry* module_entry TSRMLS_DC) { + swig_object_wrapper *value=NULL; + /* + * First test for Null pointers. Return those as PHP native NULL + */ + if (!ptr ) { + ZVAL_NULL(z); + return; + } + if (type->clientdata) { + if (! (*(int *)(type->clientdata))) + zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); + value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); + value->ptr=ptr; + value->newobject=newobject; + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + return; + } else { /* have to deal with old fashioned string pointer? + but this should not get this far */ + zend_error(E_ERROR, "Type: %s not registered with zend",type->name); + } +} + +/* This is a new pointer conversion routine + Taking the native pointer p (which would have been converted from the old + string pointer) and it's php type id, and it's type name (which also would + have come from the old string pointer) it converts it to ptr calling + appropriate casting functions according to ty + Sadly PHP has no API to find a type name from a type id, only from an instance + of a resource of the type id, so we have to pass type_name as well. + The two functions which might call this are: + SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource + and the registered zend destructors for which we have one per type each + with the type name hard wired in. */ +static int +SWIG_ZTS_ConvertResourceData(void * p, int type, const char *type_name, void **ptr, swig_type_info *ty TSRMLS_DC) { + swig_cast_info *tc; + + if (ty) { + if (! type_name) { + /* can't convert p to ptr type ty if we don't know what type p is */ + return -1; + } else { + /* convert and cast p from type_name to ptr as ty + Need to sort out const-ness, can SWIG_TypeCast really not take a const? */ + tc = SWIG_TypeCheck((char *)type_name,ty); + if (!tc) return -1; + *ptr = SWIG_TypeCast(tc, (void*)p); + } + } else { + /* They don't care about the target type, so just pass on the pointer! */ + *ptr = (void *) p; + } + return 0; +} + +/* This function fills ptr with a pointer of type ty by extracting the pointer + and type info from the resource in z. z must be a resource + It uses SWIG_ZTS_ConvertResourceData to do the real work. */ +static int +SWIG_ZTS_ConvertResourcePtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + swig_object_wrapper *value; + void *p; + int type; + char *type_name; + + value = (swig_object_wrapper *) zend_list_find(z->value.lval,&type); + if ( flags && SWIG_POINTER_DISOWN ) { + value->newobject = 0; + } + p = value->ptr; + if (type==-1) return -1; + + type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); + + return SWIG_ZTS_ConvertResourceData(p,type,type_name,ptr,ty TSRMLS_CC); +} + +/* We allow passing of a STRING or RESOURCE pointing to the object + or an OBJECT whose _cPtr is a string or resource pointing to the object + STRING pointers are very depracated */ +static int +SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + char *c; + zval *val; + + if(z == NULL) { + *ptr = 0; + return 0; + } + + if (z->type==IS_OBJECT) { + zval ** _cPtr; + if (zend_hash_find(HASH_OF(z),"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { + /* Don't co-erce to string if it isn't */ + if ((*_cPtr)->type==IS_STRING) c = Z_STRVAL_PP(_cPtr); + else if ((*_cPtr)->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(*_cPtr,ptr,ty, flags TSRMLS_CC); + } else goto type_error; /* _cPtr was not string or resource property */ + } else goto type_error; /* can't find property _cPtr */ + } else if (z->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(z,ptr,ty, flags TSRMLS_CC); + } else goto type_error; + +type_error: + + return -1; +} + +static char const_name[] = "swig_runtime_data_type_pointer"; +static swig_module_info *SWIG_Php4_GetModule() { + zval *pointer; + swig_module_info *ret = 0; + + MAKE_STD_ZVAL(pointer); + + if (zend_get_constant(const_name, sizeof(const_name), pointer)) { + if (pointer->type == IS_LONG) { + ret = (swig_module_info *) pointer->value.lval; + } + } + return 0; +} + +static void SWIG_Php4_SetModule(swig_module_info *pointer) { + REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); +} + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_int swig_types[0] +#define SWIGTYPE_p_GIntBig swig_types[1] +#define SWIGTYPE_p_OGRDataSourceShadow swig_types[2] +#define SWIGTYPE_p_OGRDriverShadow swig_types[3] +#define SWIGTYPE_p_OGRFeatureDefnShadow swig_types[4] +#define SWIGTYPE_p_OGRFeatureShadow swig_types[5] +#define SWIGTYPE_p_OGRFieldDefnShadow swig_types[6] +#define SWIGTYPE_p_OGRGeometryShadow swig_types[7] +#define SWIGTYPE_p_OGRLayerShadow swig_types[8] +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[9] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[10] +#define SWIGTYPE_p_char swig_types[11] +#define SWIGTYPE_p_double swig_types[12] +#define SWIGTYPE_p_int swig_types[13] +#define SWIGTYPE_p_p_OGRDataSourceShadow swig_types[14] +#define SWIGTYPE_p_p_OGRDriverShadow swig_types[15] +#define SWIGTYPE_p_p_OGRFeatureDefnShadow swig_types[16] +#define SWIGTYPE_p_p_OGRFeatureShadow swig_types[17] +#define SWIGTYPE_p_p_OGRFieldDefnShadow swig_types[18] +#define SWIGTYPE_p_p_OGRGeometryShadow swig_types[19] +#define SWIGTYPE_p_p_OGRLayerShadow swig_types[20] +#define SWIGTYPE_p_p_OSRCoordinateTransformationShadow swig_types[21] +#define SWIGTYPE_p_p_OSRSpatialReferenceShadow swig_types[22] +#define SWIGTYPE_p_p_char swig_types[23] +static swig_type_info *swig_types[25]; +static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +/* header section */ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ +ZEND_BEGIN_MODULE_GLOBALS(ogr) +char *error_msg; +int error_code; +ZEND_END_MODULE_GLOBALS(ogr) +ZEND_DECLARE_MODULE_GLOBALS(ogr) +#ifdef ZTS +#define ErrorMsg() TSRMG(ogr_globals_id, zend_ogr_globals *, error_msg ); +#define ErrorCode() TSRMG(ogr_globals_id, zend_ogr_globals *, error_code ); +#else +#define ErrorMsg() (ogr_globals.error_msg) +#define ErrorCode() (ogr_globals.error_code) +#endif + +static void ogr_init_globals(zend_ogr_globals *ogr_globals ) { + ogr_globals->error_msg = default_error_msg; + ogr_globals->error_code = default_error_code; +} +static void ogr_destroy_globals(zend_ogr_globals *ogr_globals) { } + +void SWIG_ResetError() { + ErrorMsg() = default_error_msg; + ErrorCode() = default_error_code; +} +#define SWIG_name "ogr" +#ifdef __cplusplus +extern "C" { +#endif +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_ogr.h" +#ifdef __cplusplus +} +#endif + + +#define SWIG_MemoryError 1 +#define SWIG_IOError 2 +#define SWIG_RuntimeError 3 +#define SWIG_IndexError 4 +#define SWIG_TypeError 5 +#define SWIG_DivisionByZero 6 +#define SWIG_OverflowError 7 +#define SWIG_SyntaxError 8 +#define SWIG_ValueError 9 +#define SWIG_SystemError 10 +#define SWIG_UnknownError 99 + + +/* We should make use of "code" if we can */ +#define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); } + + +#include <stdexcept> + + +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; + +static OGRDataSourceShadow *OGRDriverShadow_CreateDataSource(OGRDriverShadow *self,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } +static OGRDataSourceShadow *OGRDriverShadow_CopyDataSource(OGRDriverShadow *self,OGRDataSourceShadow *copy_ds,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } +static OGRDataSourceShadow *OGRDriverShadow_Open(OGRDriverShadow *self,char const *name,int update=0){ + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } +static int OGRDriverShadow_DeleteDataSource(OGRDriverShadow *self,char const *name){ + return OGR_Dr_DeleteDataSource( self, name ); + } +static int OGRDriverShadow_TestCapability(OGRDriverShadow *self,char const *cap){ + return OGR_Dr_TestCapability(self, cap); + } +static char const *OGRDriverShadow_GetName(OGRDriverShadow *self){ + return OGR_Dr_GetName( self ); + } +static int _wrap_propset_Driver(zend_property_reference *property_reference, pval *value); +static int _propset_Driver(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Driver(zend_property_reference *property_reference); +static int _propget_Driver(zend_property_reference *property_reference, pval *value); +static void delete_OGRDataSourceShadow(OGRDataSourceShadow *self){ + OGRReleaseDataSource(self); + } +static int OGRDataSourceShadow_GetRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetRefCount(self); + } +static int OGRDataSourceShadow_GetSummaryRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetSummaryRefCount(self); + } +static int OGRDataSourceShadow_GetLayerCount(OGRDataSourceShadow *self){ + return OGR_DS_GetLayerCount(self); + } +static char const *OGRDataSourceShadow_GetName(OGRDataSourceShadow *self){ + return OGR_DS_GetName(self); + } +static OGRErr OGRDataSourceShadow_DeleteLayer(OGRDataSourceShadow *self,int index){ + return OGR_DS_DeleteLayer(self, index); + } + +static char * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error 0: None"; + case 1: + return "OGR Error 1: Not enough data"; + case 2: + return "OGR Error 2: Unsupported geometry type"; + case 3: + return "OGR Error 3: Unsupported operation"; + case 4: + return "OGR Error 4: Corrupt data"; + case 5: + return "OGR Error 5: General Error"; + case 6: + return "OGR Error 6: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +static OGRLayerShadow *OGRDataSourceShadow_CreateLayer(OGRDataSourceShadow *self,char const *name,OSRSpatialReferenceShadow *reference=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_CopyLayer(OGRDataSourceShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByIndex(OGRDataSourceShadow *self,int index=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayer(self, index); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByName(OGRDataSourceShadow *self,char const *layer_name){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayerByName(self, layer_name); + return layer; + } +static int OGRDataSourceShadow_TestCapability(OGRDataSourceShadow *self,char const *cap){ + return OGR_DS_TestCapability(self, cap); + } +static OGRLayerShadow *OGRDataSourceShadow_ExecuteSQL(OGRDataSourceShadow *self,char const *statement,OGRGeometryShadow *geom=NULL,char const *dialect=""){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } +static void OGRDataSourceShadow_ReleaseResultSet(OGRDataSourceShadow *self,OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +static int _wrap_propset_DataSource(zend_property_reference *property_reference, pval *value); +static int _propset_DataSource(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_DataSource(zend_property_reference *property_reference); +static int _propget_DataSource(zend_property_reference *property_reference, pval *value); +static int OGRLayerShadow_GetRefCount(OGRLayerShadow *self){ + return OGR_L_GetRefCount(self); + } +static void OGRLayerShadow_SetSpatialFilter(OGRLayerShadow *self,OGRGeometryShadow *filter){ + OGR_L_SetSpatialFilter (self, filter); + } +static void OGRLayerShadow_SetSpatialFilterRect(OGRLayerShadow *self,double minx,double miny,double maxx,double maxy){ + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } +static OGRGeometryShadow *OGRLayerShadow_GetSpatialFilter(OGRLayerShadow *self){ + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } +static OGRErr OGRLayerShadow_SetAttributeFilter(OGRLayerShadow *self,char *filter_string){ + OGRErr err = OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + if (err != 0) { + throw err; + } + return 0; + } +static void OGRLayerShadow_ResetReading(OGRLayerShadow *self){ + OGR_L_ResetReading(self); + } +static char const *OGRLayerShadow_GetName(OGRLayerShadow *self){ + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } +static OGRFeatureShadow *OGRLayerShadow_GetFeature(OGRLayerShadow *self,long fid){ + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } +static OGRFeatureShadow *OGRLayerShadow_GetNextFeature(OGRLayerShadow *self){ + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } +static OGRErr OGRLayerShadow_SetNextByIndex(OGRLayerShadow *self,long new_index){ + OGRErr err = OGR_L_SetNextByIndex(self, new_index); + if (err != 0) { + throw err; + } + return 0; + } +static OGRErr OGRLayerShadow_SetFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + OGRErr err = OGR_L_SetFeature(self, feature); + if (err != 0) { + throw err; + } + return 0; + } +static OGRErr OGRLayerShadow_CreateFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + OGRErr err = OGR_L_CreateFeature(self, feature); + if (err != 0) { + throw err; + } + return 0; + } +static OGRErr OGRLayerShadow_DeleteFeature(OGRLayerShadow *self,long fid){ + OGRErr err = OGR_L_DeleteFeature(self, fid); + if (err != 0) { + throw err; + } + return 0; + } +static OGRErr OGRLayerShadow_SyncToDisk(OGRLayerShadow *self){ + OGRErr err = OGR_L_SyncToDisk(self); + if (err != 0) { + throw err; + } + return 0; + } +static OGRFeatureDefnShadow *OGRLayerShadow_GetLayerDefn(OGRLayerShadow *self){ + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } +static int OGRLayerShadow_GetFeatureCount(OGRLayerShadow *self,int force=1){ + return OGR_L_GetFeatureCount(self, force); + } + + zval * + CreateTupleFromDoubleArray( double *first, unsigned int size ) { + zval *tmp; + MAKE_STD_ZVAL(tmp); + array_init(tmp); + for( unsigned int i=0; i<size; i++ ) { + add_next_index_double( tmp, *first ); + ++first; + } + return tmp; + } + + +void +t_output_helper( zval **target, zval *o) { + if ( (*target)->type == IS_ARRAY ) { + /* it's already an array, just append */ + add_next_index_zval( *target, o ); + return; + } + if ( (*target)->type == IS_NULL ) { + REPLACE_ZVAL_VALUE(target,o,1); + return; + } + zval *tmp; + tmp = *target; + zval_copy_ctor(tmp); + array_init(*target); + add_next_index_zval( *target, tmp); + add_next_index_zval( *target, o); + +} + +static void OGRLayerShadow_GetExtent(OGRLayerShadow *self,double argout[4],int force=1){ + OGRErr err = OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + if (err != 0) + throw err; + } +static int OGRLayerShadow_TestCapability(OGRLayerShadow *self,char const *cap){ + return OGR_L_TestCapability(self, cap); + } +static OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){ + OGRErr err = OGR_L_CreateField(self, field_def, approx_ok); + if (err != 0) + throw err; + return 0; + } +static OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){ + OGRErr err = OGR_L_StartTransaction(self); + if (err != 0) + throw err; + return 0; + } +static OGRErr OGRLayerShadow_CommitTransaction(OGRLayerShadow *self){ + OGRErr err = OGR_L_CommitTransaction(self); + if (err != 0) + throw err; + return 0; + } +static OGRErr OGRLayerShadow_RollbackTransaction(OGRLayerShadow *self){ + OGRErr err = OGR_L_RollbackTransaction(self); + if (err != 0) + throw err; + return 0; + } +static OSRSpatialReferenceShadow *OGRLayerShadow_GetSpatialRef(OGRLayerShadow *self){ + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } +static GIntBig OGRLayerShadow_GetFeatureRead(OGRLayerShadow *self){ + return OGR_L_GetFeaturesRead(self); + } +static int _wrap_propset_Layer(zend_property_reference *property_reference, pval *value); +static int _propset_Layer(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Layer(zend_property_reference *property_reference); +static int _propget_Layer(zend_property_reference *property_reference, pval *value); +static void delete_OGRFeatureShadow(OGRFeatureShadow *self){ + OGR_F_Destroy(self); + } +static OGRFeatureShadow *new_OGRFeatureShadow(OGRFeatureDefnShadow *feature_def=0){ + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } +static OGRFeatureDefnShadow *OGRFeatureShadow_GetDefnRef(OGRFeatureShadow *self){ + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } +static OGRErr OGRFeatureShadow_SetGeometry(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + OGRErr err = OGR_F_SetGeometry(self, geom); + if (err != 0) + throw err; + return 0; + } +static OGRErr OGRFeatureShadow_SetGeometryDirectly(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + OGRErr err = OGR_F_SetGeometryDirectly(self, geom); + if (err != 0) + throw err; + return 0; + } +static OGRGeometryShadow *OGRFeatureShadow_GetGeometryRef(OGRFeatureShadow *self){ + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } +static OGRFeatureShadow *OGRFeatureShadow_Clone(OGRFeatureShadow *self){ + return (OGRFeatureShadow*) OGR_F_Clone(self); + } +static int OGRFeatureShadow_Equal(OGRFeatureShadow *self,OGRFeatureShadow *feature){ + return OGR_F_Equal(self, feature); + } +static int OGRFeatureShadow_GetFieldCount(OGRFeatureShadow *self){ + return OGR_F_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_0(OGRFeatureShadow *self,int id){ + return (const char *) OGR_F_GetFieldAsString(self, id); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsInteger(self, id); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsDouble(self, id); + } +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_IsFieldSet__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_IsFieldSet(self, id); + } +static int OGRFeatureShadow_IsFieldSet__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldIndex(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldIndex(self, name); + } +static int OGRFeatureShadow_GetFID(OGRFeatureShadow *self){ + return OGR_F_GetFID(self); + } +static OGRErr OGRFeatureShadow_SetFID(OGRFeatureShadow *self,int fid){ + OGRErr err = OGR_F_SetFID(self, fid); + if (err != 0) + throw err; + return 0; + } +static void OGRFeatureShadow_DumpReadable(OGRFeatureShadow *self){ + OGR_F_DumpReadable(self, NULL); + } +static void OGRFeatureShadow_UnsetField__SWIG_0(OGRFeatureShadow *self,int id){ + OGR_F_UnsetField(self, id); + } +static void OGRFeatureShadow_UnsetField__SWIG_1(OGRFeatureShadow *self,char const *name){ + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } +static void OGRFeatureShadow_SetField__SWIG_0(OGRFeatureShadow *self,int id,char const *value){ + OGR_F_SetFieldString(self, id, value); + } +static void OGRFeatureShadow_SetField__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } +static OGRErr OGRFeatureShadow_SetFrom(OGRFeatureShadow *self,OGRFeatureShadow *other,int forgiving=1){ + OGRErr err = OGR_F_SetFrom(self, other, forgiving); + if (err != 0) + throw err; + return 0; + } +static char const *OGRFeatureShadow_GetStyleString(OGRFeatureShadow *self){ + return (const char*) OGR_F_GetStyleString(self); + } +static void OGRFeatureShadow_SetStyleString(OGRFeatureShadow *self,char const *the_string){ + OGR_F_SetStyleString(self, the_string); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } +static int _wrap_propset_Feature(zend_property_reference *property_reference, pval *value); +static int _propset_Feature(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Feature(zend_property_reference *property_reference); +static int _propget_Feature(zend_property_reference *property_reference, pval *value); +static void delete_OGRFeatureDefnShadow(OGRFeatureDefnShadow *self){ + OGR_FD_Destroy(self); + } +static OGRFeatureDefnShadow *new_OGRFeatureDefnShadow(char const *name=NULL){ + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } +static char const *OGRFeatureDefnShadow_GetName(OGRFeatureDefnShadow *self){ + return OGR_FD_GetName(self); + } +static int OGRFeatureDefnShadow_GetFieldCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureDefnShadow_GetFieldDefn(OGRFeatureDefnShadow *self,int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } +static int OGRFeatureDefnShadow_GetFieldIndex(OGRFeatureDefnShadow *self,char const *name){ + return OGR_FD_GetFieldIndex(self, name); + } +static void OGRFeatureDefnShadow_AddFieldDefn(OGRFeatureDefnShadow *self,OGRFieldDefnShadow *defn){ + OGR_FD_AddFieldDefn(self, defn); + } +static OGRwkbGeometryType OGRFeatureDefnShadow_GetGeomType(OGRFeatureDefnShadow *self){ + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } +static void OGRFeatureDefnShadow_SetGeomType(OGRFeatureDefnShadow *self,OGRwkbGeometryType geom_type){ + OGR_FD_SetGeomType(self, geom_type); + } +static int OGRFeatureDefnShadow_GetReferenceCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetReferenceCount(self); + } +static int _wrap_propset_FeatureDefn(zend_property_reference *property_reference, pval *value); +static int _propset_FeatureDefn(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_FeatureDefn(zend_property_reference *property_reference); +static int _propget_FeatureDefn(zend_property_reference *property_reference, pval *value); +static void delete_OGRFieldDefnShadow(OGRFieldDefnShadow *self){ + OGR_Fld_Destroy(self); + } +static OGRFieldDefnShadow *new_OGRFieldDefnShadow(char const *name="unnamed",OGRFieldType field_type=OFTString){ + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } +static char const *OGRFieldDefnShadow_GetName(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static char const *OGRFieldDefnShadow_GetNameRef(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static void OGRFieldDefnShadow_SetName(OGRFieldDefnShadow *self,char const *name){ + OGR_Fld_SetName(self, name); + } +static OGRFieldType OGRFieldDefnShadow_GetType(OGRFieldDefnShadow *self){ + return OGR_Fld_GetType(self); + } +static void OGRFieldDefnShadow_SetType(OGRFieldDefnShadow *self,OGRFieldType type){ + OGR_Fld_SetType(self, type); + } +static OGRJustification OGRFieldDefnShadow_GetJustify(OGRFieldDefnShadow *self){ + return OGR_Fld_GetJustify(self); + } +static void OGRFieldDefnShadow_SetJustify(OGRFieldDefnShadow *self,OGRJustification justify){ + OGR_Fld_SetJustify(self, justify); + } +static int OGRFieldDefnShadow_GetWidth(OGRFieldDefnShadow *self){ + return OGR_Fld_GetWidth(self); + } +static void OGRFieldDefnShadow_SetWidth(OGRFieldDefnShadow *self,int width){ + OGR_Fld_SetWidth(self, width); + } +static int OGRFieldDefnShadow_GetPrecision(OGRFieldDefnShadow *self){ + return OGR_Fld_GetPrecision(self); + } +static void OGRFieldDefnShadow_SetPrecision(OGRFieldDefnShadow *self,int precision){ + OGR_Fld_SetPrecision(self, precision); + } +static char const *OGRFieldDefnShadow_GetFieldTypeName(OGRFieldDefnShadow *self,OGRFieldType type){ + return OGR_GetFieldTypeName(type); + } +static int _wrap_propset_FieldDefn(zend_property_reference *property_reference, pval *value); +static int _propset_FieldDefn(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_FieldDefn(zend_property_reference *property_reference); +static int _propget_FieldDefn(zend_property_reference *property_reference, pval *value); + + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + throw err; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + throw err; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + + +static void delete_OGRGeometryShadow(OGRGeometryShadow *self){ + OGR_G_DestroyGeometry( self ); + } +static OGRGeometryShadow *new_OGRGeometryShadow(OGRwkbGeometryType type=wkbUnknown,char *wkt=0,int wkb=0,char *wkb_buf=0,char *gml=0){ + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } +static char const *OGRGeometryShadow_ExportToWkt(OGRGeometryShadow *self){ + char * output; + OGRErr err = OGR_G_ExportToWkt(self, &output); + if (err != 0) + throw err; + return output; + } +static OGRErr OGRGeometryShadow_ExportToWkb(OGRGeometryShadow *self,int *nLen,char **pBuf,OGRwkbByteOrder byte_order=wkbXDR){ + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } +static char const *OGRGeometryShadow_ExportToGML(OGRGeometryShadow *self){ + return (const char *) OGR_G_ExportToGML(self); + } +static void OGRGeometryShadow_AddPoint(OGRGeometryShadow *self,double x,double y,double z=0){ + OGR_G_AddPoint( self, x, y, z ); + } +static OGRErr OGRGeometryShadow_AddGeometryDirectly(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometryDirectly( self, other ); + } +static OGRErr OGRGeometryShadow_AddGeometry(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometry( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Clone(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_Clone(self); + } +static OGRwkbGeometryType OGRGeometryShadow_GetGeometryType(OGRGeometryShadow *self){ + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } +static char const *OGRGeometryShadow_GetGeometryName(OGRGeometryShadow *self){ + return (const char *) OGR_G_GetGeometryName(self); + } +static double OGRGeometryShadow_GetArea(OGRGeometryShadow *self){ + return OGR_G_GetArea(self); + } +static int OGRGeometryShadow_GetPointCount(OGRGeometryShadow *self){ + return OGR_G_GetPointCount(self); + } +static double OGRGeometryShadow_GetX(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetX(self, point); + } +static double OGRGeometryShadow_GetY(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetY(self, point); + } +static double OGRGeometryShadow_GetZ(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetZ(self, point); + } +static int OGRGeometryShadow_GetGeometryCount(OGRGeometryShadow *self){ + return OGR_G_GetGeometryCount(self); + } +static void OGRGeometryShadow_SetPoint(OGRGeometryShadow *self,int point,double x,double y,double z=0){ + OGR_G_SetPoint(self, point, x, y, z); + } +static OGRGeometryShadow *OGRGeometryShadow_GetGeometryRef(OGRGeometryShadow *self,int geom){ + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } +static OGRGeometryShadow *OGRGeometryShadow_GetBoundary(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } +static OGRGeometryShadow *OGRGeometryShadow_ConvexHull(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } +static OGRGeometryShadow *OGRGeometryShadow_Buffer(OGRGeometryShadow *self,double distance,int quadsecs=30){ + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } +static OGRGeometryShadow *OGRGeometryShadow_Intersection(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Union(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Difference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_SymmetricDifference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } +static double OGRGeometryShadow_Distance(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Distance(self, other); + } +static void OGRGeometryShadow_Empty(OGRGeometryShadow *self){ + OGR_G_Empty(self); + } +static int OGRGeometryShadow_Intersect(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Intersect(self, other); + } +static int OGRGeometryShadow_Equal(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Equal(self, other); + } +static int OGRGeometryShadow_Disjoint(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Disjoint(self, other); + } +static int OGRGeometryShadow_Touches(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Touches(self, other); + } +static int OGRGeometryShadow_Crosses(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Crosses(self, other); + } +static int OGRGeometryShadow_Within(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Within(self, other); + } +static int OGRGeometryShadow_Contains(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Contains(self, other); + } +static int OGRGeometryShadow_Overlaps(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Overlaps(self, other); + } +static OGRErr OGRGeometryShadow_TransformTo(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + return OGR_G_TransformTo(self, reference); + } +static OGRErr OGRGeometryShadow_Transform(OGRGeometryShadow *self,OSRCoordinateTransformationShadow *trans){ + return OGR_G_Transform(self, trans); + } +static OSRSpatialReferenceShadow *OGRGeometryShadow_GetSpatialReference(OGRGeometryShadow *self){ + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } +static void OGRGeometryShadow_AssignSpatialReference(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + OGR_G_AssignSpatialReference(self, reference); + } +static void OGRGeometryShadow_CloseRings(OGRGeometryShadow *self){ + OGR_G_CloseRings(self); + } +static void OGRGeometryShadow_FlattenTo2D(OGRGeometryShadow *self){ + OGR_G_FlattenTo2D(self); + } +static void OGRGeometryShadow_GetEnvelope(OGRGeometryShadow *self,double argout[4]){ + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } +static OGRGeometryShadow *OGRGeometryShadow_Centroid(OGRGeometryShadow *self){ + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } +static int OGRGeometryShadow_WkbSize(OGRGeometryShadow *self){ + return OGR_G_WkbSize(self); + } +static int OGRGeometryShadow_GetCoordinateDimension(OGRGeometryShadow *self){ + return OGR_G_GetCoordinateDimension(self); + } +static int OGRGeometryShadow_GetDimension(OGRGeometryShadow *self){ + return OGR_G_GetDimension(self); + } +static int _wrap_propset_Geometry(zend_property_reference *property_reference, pval *value); +static int _propset_Geometry(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_Geometry(zend_property_reference *property_reference); +static int _propget_Geometry(zend_property_reference *property_reference, pval *value); + +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + + + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } + + + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } + + + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } + + +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} + +/* class entry subsection */ +/* Function entries for Driver */ +static zend_function_entry Driver_functions[] = { + ZEND_NAMED_FE(driver_createdatasource,_wrap_Driver_CreateDataSource, NULL) + ZEND_NAMED_FE(createdatasource,_wrap_Driver_CreateDataSource, NULL) + ZEND_NAMED_FE(driver_copydatasource,_wrap_Driver_CopyDataSource, NULL) + ZEND_NAMED_FE(copydatasource,_wrap_Driver_CopyDataSource, NULL) + ZEND_NAMED_FE(driver_open,_wrap_Driver_Open, NULL) + ZEND_NAMED_FE(open,_wrap_Driver_Open, NULL) + ZEND_NAMED_FE(driver_deletedatasource,_wrap_Driver_DeleteDataSource, NULL) + ZEND_NAMED_FE(deletedatasource,_wrap_Driver_DeleteDataSource, NULL) + ZEND_NAMED_FE(driver_testcapability,_wrap_Driver_TestCapability, NULL) + ZEND_NAMED_FE(testcapability,_wrap_Driver_TestCapability, NULL) + ZEND_NAMED_FE(driver_getname,_wrap_Driver_GetName, NULL) + ZEND_NAMED_FE(getname,_wrap_Driver_GetName, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for DataSource */ +static zend_function_entry DataSource_functions[] = { + ZEND_NAMED_FE(datasource_getrefcount,_wrap_DataSource_GetRefCount, NULL) + ZEND_NAMED_FE(getrefcount,_wrap_DataSource_GetRefCount, NULL) + ZEND_NAMED_FE(datasource_getsummaryrefcount,_wrap_DataSource_GetSummaryRefCount, NULL) + ZEND_NAMED_FE(getsummaryrefcount,_wrap_DataSource_GetSummaryRefCount, NULL) + ZEND_NAMED_FE(datasource_getlayercount,_wrap_DataSource_GetLayerCount, NULL) + ZEND_NAMED_FE(getlayercount,_wrap_DataSource_GetLayerCount, NULL) + ZEND_NAMED_FE(datasource_getname,_wrap_DataSource_GetName, NULL) + ZEND_NAMED_FE(getname,_wrap_DataSource_GetName, NULL) + ZEND_NAMED_FE(datasource_deletelayer,_wrap_DataSource_DeleteLayer, NULL) + ZEND_NAMED_FE(deletelayer,_wrap_DataSource_DeleteLayer, NULL) + ZEND_NAMED_FE(datasource_createlayer,_wrap_DataSource_CreateLayer, NULL) + ZEND_NAMED_FE(createlayer,_wrap_DataSource_CreateLayer, NULL) + ZEND_NAMED_FE(datasource_copylayer,_wrap_DataSource_CopyLayer, NULL) + ZEND_NAMED_FE(copylayer,_wrap_DataSource_CopyLayer, NULL) + ZEND_NAMED_FE(datasource_getlayerbyindex,_wrap_DataSource_GetLayerByIndex, NULL) + ZEND_NAMED_FE(getlayerbyindex,_wrap_DataSource_GetLayerByIndex, NULL) + ZEND_NAMED_FE(datasource_getlayerbyname,_wrap_DataSource_GetLayerByName, NULL) + ZEND_NAMED_FE(getlayerbyname,_wrap_DataSource_GetLayerByName, NULL) + ZEND_NAMED_FE(datasource_testcapability,_wrap_DataSource_TestCapability, NULL) + ZEND_NAMED_FE(testcapability,_wrap_DataSource_TestCapability, NULL) + ZEND_NAMED_FE(datasource_executesql,_wrap_DataSource_ExecuteSQL, NULL) + ZEND_NAMED_FE(executesql,_wrap_DataSource_ExecuteSQL, NULL) + ZEND_NAMED_FE(datasource_releaseresultset,_wrap_DataSource_ReleaseResultSet, NULL) + ZEND_NAMED_FE(releaseresultset,_wrap_DataSource_ReleaseResultSet, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Layer */ +static zend_function_entry Layer_functions[] = { + ZEND_NAMED_FE(layer_getrefcount,_wrap_Layer_GetRefCount, NULL) + ZEND_NAMED_FE(getrefcount,_wrap_Layer_GetRefCount, NULL) + ZEND_NAMED_FE(layer_setspatialfilter,_wrap_Layer_SetSpatialFilter, NULL) + ZEND_NAMED_FE(setspatialfilter,_wrap_Layer_SetSpatialFilter, NULL) + ZEND_NAMED_FE(layer_setspatialfilterrect,_wrap_Layer_SetSpatialFilterRect, NULL) + ZEND_NAMED_FE(setspatialfilterrect,_wrap_Layer_SetSpatialFilterRect, NULL) + ZEND_NAMED_FE(layer_getspatialfilter,_wrap_Layer_GetSpatialFilter, NULL) + ZEND_NAMED_FE(getspatialfilter,_wrap_Layer_GetSpatialFilter, NULL) + ZEND_NAMED_FE(layer_setattributefilter,_wrap_Layer_SetAttributeFilter, NULL) + ZEND_NAMED_FE(setattributefilter,_wrap_Layer_SetAttributeFilter, NULL) + ZEND_NAMED_FE(layer_resetreading,_wrap_Layer_ResetReading, NULL) + ZEND_NAMED_FE(resetreading,_wrap_Layer_ResetReading, NULL) + ZEND_NAMED_FE(layer_getname,_wrap_Layer_GetName, NULL) + ZEND_NAMED_FE(getname,_wrap_Layer_GetName, NULL) + ZEND_NAMED_FE(layer_getfeature,_wrap_Layer_GetFeature, NULL) + ZEND_NAMED_FE(getfeature,_wrap_Layer_GetFeature, NULL) + ZEND_NAMED_FE(layer_getnextfeature,_wrap_Layer_GetNextFeature, NULL) + ZEND_NAMED_FE(getnextfeature,_wrap_Layer_GetNextFeature, NULL) + ZEND_NAMED_FE(layer_setnextbyindex,_wrap_Layer_SetNextByIndex, NULL) + ZEND_NAMED_FE(setnextbyindex,_wrap_Layer_SetNextByIndex, NULL) + ZEND_NAMED_FE(layer_setfeature,_wrap_Layer_SetFeature, NULL) + ZEND_NAMED_FE(setfeature,_wrap_Layer_SetFeature, NULL) + ZEND_NAMED_FE(layer_createfeature,_wrap_Layer_CreateFeature, NULL) + ZEND_NAMED_FE(createfeature,_wrap_Layer_CreateFeature, NULL) + ZEND_NAMED_FE(layer_deletefeature,_wrap_Layer_DeleteFeature, NULL) + ZEND_NAMED_FE(deletefeature,_wrap_Layer_DeleteFeature, NULL) + ZEND_NAMED_FE(layer_synctodisk,_wrap_Layer_SyncToDisk, NULL) + ZEND_NAMED_FE(synctodisk,_wrap_Layer_SyncToDisk, NULL) + ZEND_NAMED_FE(layer_getlayerdefn,_wrap_Layer_GetLayerDefn, NULL) + ZEND_NAMED_FE(getlayerdefn,_wrap_Layer_GetLayerDefn, NULL) + ZEND_NAMED_FE(layer_getfeaturecount,_wrap_Layer_GetFeatureCount, NULL) + ZEND_NAMED_FE(getfeaturecount,_wrap_Layer_GetFeatureCount, NULL) + ZEND_NAMED_FE(layer_getextent,_wrap_Layer_GetExtent, NULL) + ZEND_NAMED_FE(getextent,_wrap_Layer_GetExtent, NULL) + ZEND_NAMED_FE(layer_testcapability,_wrap_Layer_TestCapability, NULL) + ZEND_NAMED_FE(testcapability,_wrap_Layer_TestCapability, NULL) + ZEND_NAMED_FE(layer_createfield,_wrap_Layer_CreateField, NULL) + ZEND_NAMED_FE(createfield,_wrap_Layer_CreateField, NULL) + ZEND_NAMED_FE(layer_starttransaction,_wrap_Layer_StartTransaction, NULL) + ZEND_NAMED_FE(starttransaction,_wrap_Layer_StartTransaction, NULL) + ZEND_NAMED_FE(layer_committransaction,_wrap_Layer_CommitTransaction, NULL) + ZEND_NAMED_FE(committransaction,_wrap_Layer_CommitTransaction, NULL) + ZEND_NAMED_FE(layer_rollbacktransaction,_wrap_Layer_RollbackTransaction, NULL) + ZEND_NAMED_FE(rollbacktransaction,_wrap_Layer_RollbackTransaction, NULL) + ZEND_NAMED_FE(layer_getspatialref,_wrap_Layer_GetSpatialRef, NULL) + ZEND_NAMED_FE(getspatialref,_wrap_Layer_GetSpatialRef, NULL) + ZEND_NAMED_FE(layer_getfeatureread,_wrap_Layer_GetFeatureRead, NULL) + ZEND_NAMED_FE(getfeatureread,_wrap_Layer_GetFeatureRead, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Feature */ +static zend_function_entry Feature_functions[] = { + ZEND_NAMED_FE(new_feature,_wrap_new_Feature, NULL) + ZEND_NAMED_FE(feature,_wrap_new_Feature, NULL) + ZEND_NAMED_FE(feature_getdefnref,_wrap_Feature_GetDefnRef, NULL) + ZEND_NAMED_FE(getdefnref,_wrap_Feature_GetDefnRef, NULL) + ZEND_NAMED_FE(feature_setgeometry,_wrap_Feature_SetGeometry, NULL) + ZEND_NAMED_FE(setgeometry,_wrap_Feature_SetGeometry, NULL) + ZEND_NAMED_FE(feature_setgeometrydirectly,_wrap_Feature_SetGeometryDirectly, NULL) + ZEND_NAMED_FE(setgeometrydirectly,_wrap_Feature_SetGeometryDirectly, NULL) + ZEND_NAMED_FE(feature_getgeometryref,_wrap_Feature_GetGeometryRef, NULL) + ZEND_NAMED_FE(getgeometryref,_wrap_Feature_GetGeometryRef, NULL) + ZEND_NAMED_FE(feature_clone,_wrap_Feature_Clone, NULL) + ZEND_NAMED_FE(clone,_wrap_Feature_Clone, NULL) + ZEND_NAMED_FE(feature_equal,_wrap_Feature_Equal, NULL) + ZEND_NAMED_FE(equal,_wrap_Feature_Equal, NULL) + ZEND_NAMED_FE(feature_getfieldcount,_wrap_Feature_GetFieldCount, NULL) + ZEND_NAMED_FE(getfieldcount,_wrap_Feature_GetFieldCount, NULL) + ZEND_NAMED_FE(getfielddefnref,_wrap_Feature_GetFieldDefnRef, NULL) + ZEND_NAMED_FE(feature_getfielddefnref,_wrap_Feature_GetFieldDefnRef, NULL) + ZEND_NAMED_FE(getfielddefnref,_wrap_Feature_GetFieldDefnRef, NULL) + ZEND_NAMED_FE(getfieldasstring,_wrap_Feature_GetFieldAsString, NULL) + ZEND_NAMED_FE(feature_getfieldasstring,_wrap_Feature_GetFieldAsString, NULL) + ZEND_NAMED_FE(getfieldasstring,_wrap_Feature_GetFieldAsString, NULL) + ZEND_NAMED_FE(getfieldasinteger,_wrap_Feature_GetFieldAsInteger, NULL) + ZEND_NAMED_FE(feature_getfieldasinteger,_wrap_Feature_GetFieldAsInteger, NULL) + ZEND_NAMED_FE(getfieldasinteger,_wrap_Feature_GetFieldAsInteger, NULL) + ZEND_NAMED_FE(getfieldasdouble,_wrap_Feature_GetFieldAsDouble, NULL) + ZEND_NAMED_FE(feature_getfieldasdouble,_wrap_Feature_GetFieldAsDouble, NULL) + ZEND_NAMED_FE(getfieldasdouble,_wrap_Feature_GetFieldAsDouble, NULL) + ZEND_NAMED_FE(isfieldset,_wrap_Feature_IsFieldSet, NULL) + ZEND_NAMED_FE(feature_isfieldset,_wrap_Feature_IsFieldSet, NULL) + ZEND_NAMED_FE(isfieldset,_wrap_Feature_IsFieldSet, NULL) + ZEND_NAMED_FE(feature_getfieldindex,_wrap_Feature_GetFieldIndex, NULL) + ZEND_NAMED_FE(getfieldindex,_wrap_Feature_GetFieldIndex, NULL) + ZEND_NAMED_FE(feature_getfid,_wrap_Feature_GetFID, NULL) + ZEND_NAMED_FE(getfid,_wrap_Feature_GetFID, NULL) + ZEND_NAMED_FE(feature_setfid,_wrap_Feature_SetFID, NULL) + ZEND_NAMED_FE(setfid,_wrap_Feature_SetFID, NULL) + ZEND_NAMED_FE(feature_dumpreadable,_wrap_Feature_DumpReadable, NULL) + ZEND_NAMED_FE(dumpreadable,_wrap_Feature_DumpReadable, NULL) + ZEND_NAMED_FE(unsetfield,_wrap_Feature_UnsetField, NULL) + ZEND_NAMED_FE(feature_unsetfield,_wrap_Feature_UnsetField, NULL) + ZEND_NAMED_FE(unsetfield,_wrap_Feature_UnsetField, NULL) + ZEND_NAMED_FE(setfield,_wrap_Feature_SetField, NULL) + ZEND_NAMED_FE(feature_setfield,_wrap_Feature_SetField, NULL) + ZEND_NAMED_FE(setfield,_wrap_Feature_SetField, NULL) + ZEND_NAMED_FE(feature_setfrom,_wrap_Feature_SetFrom, NULL) + ZEND_NAMED_FE(setfrom,_wrap_Feature_SetFrom, NULL) + ZEND_NAMED_FE(feature_getstylestring,_wrap_Feature_GetStyleString, NULL) + ZEND_NAMED_FE(getstylestring,_wrap_Feature_GetStyleString, NULL) + ZEND_NAMED_FE(feature_setstylestring,_wrap_Feature_SetStyleString, NULL) + ZEND_NAMED_FE(setstylestring,_wrap_Feature_SetStyleString, NULL) + ZEND_NAMED_FE(getfieldtype,_wrap_Feature_GetFieldType, NULL) + ZEND_NAMED_FE(feature_getfieldtype,_wrap_Feature_GetFieldType, NULL) + ZEND_NAMED_FE(getfieldtype,_wrap_Feature_GetFieldType, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for FeatureDefn */ +static zend_function_entry FeatureDefn_functions[] = { + ZEND_NAMED_FE(new_featuredefn,_wrap_new_FeatureDefn, NULL) + ZEND_NAMED_FE(featuredefn,_wrap_new_FeatureDefn, NULL) + ZEND_NAMED_FE(featuredefn_getname,_wrap_FeatureDefn_GetName, NULL) + ZEND_NAMED_FE(getname,_wrap_FeatureDefn_GetName, NULL) + ZEND_NAMED_FE(featuredefn_getfieldcount,_wrap_FeatureDefn_GetFieldCount, NULL) + ZEND_NAMED_FE(getfieldcount,_wrap_FeatureDefn_GetFieldCount, NULL) + ZEND_NAMED_FE(featuredefn_getfielddefn,_wrap_FeatureDefn_GetFieldDefn, NULL) + ZEND_NAMED_FE(getfielddefn,_wrap_FeatureDefn_GetFieldDefn, NULL) + ZEND_NAMED_FE(featuredefn_getfieldindex,_wrap_FeatureDefn_GetFieldIndex, NULL) + ZEND_NAMED_FE(getfieldindex,_wrap_FeatureDefn_GetFieldIndex, NULL) + ZEND_NAMED_FE(featuredefn_addfielddefn,_wrap_FeatureDefn_AddFieldDefn, NULL) + ZEND_NAMED_FE(addfielddefn,_wrap_FeatureDefn_AddFieldDefn, NULL) + ZEND_NAMED_FE(featuredefn_getgeomtype,_wrap_FeatureDefn_GetGeomType, NULL) + ZEND_NAMED_FE(getgeomtype,_wrap_FeatureDefn_GetGeomType, NULL) + ZEND_NAMED_FE(featuredefn_setgeomtype,_wrap_FeatureDefn_SetGeomType, NULL) + ZEND_NAMED_FE(setgeomtype,_wrap_FeatureDefn_SetGeomType, NULL) + ZEND_NAMED_FE(featuredefn_getreferencecount,_wrap_FeatureDefn_GetReferenceCount, NULL) + ZEND_NAMED_FE(getreferencecount,_wrap_FeatureDefn_GetReferenceCount, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for FieldDefn */ +static zend_function_entry FieldDefn_functions[] = { + ZEND_NAMED_FE(new_fielddefn,_wrap_new_FieldDefn, NULL) + ZEND_NAMED_FE(fielddefn,_wrap_new_FieldDefn, NULL) + ZEND_NAMED_FE(fielddefn_getname,_wrap_FieldDefn_GetName, NULL) + ZEND_NAMED_FE(getname,_wrap_FieldDefn_GetName, NULL) + ZEND_NAMED_FE(fielddefn_getnameref,_wrap_FieldDefn_GetNameRef, NULL) + ZEND_NAMED_FE(getnameref,_wrap_FieldDefn_GetNameRef, NULL) + ZEND_NAMED_FE(fielddefn_setname,_wrap_FieldDefn_SetName, NULL) + ZEND_NAMED_FE(setname,_wrap_FieldDefn_SetName, NULL) + ZEND_NAMED_FE(fielddefn_gettype,_wrap_FieldDefn_GetType, NULL) + ZEND_NAMED_FE(gettype,_wrap_FieldDefn_GetType, NULL) + ZEND_NAMED_FE(fielddefn_settype,_wrap_FieldDefn_SetType, NULL) + ZEND_NAMED_FE(settype,_wrap_FieldDefn_SetType, NULL) + ZEND_NAMED_FE(fielddefn_getjustify,_wrap_FieldDefn_GetJustify, NULL) + ZEND_NAMED_FE(getjustify,_wrap_FieldDefn_GetJustify, NULL) + ZEND_NAMED_FE(fielddefn_setjustify,_wrap_FieldDefn_SetJustify, NULL) + ZEND_NAMED_FE(setjustify,_wrap_FieldDefn_SetJustify, NULL) + ZEND_NAMED_FE(fielddefn_getwidth,_wrap_FieldDefn_GetWidth, NULL) + ZEND_NAMED_FE(getwidth,_wrap_FieldDefn_GetWidth, NULL) + ZEND_NAMED_FE(fielddefn_setwidth,_wrap_FieldDefn_SetWidth, NULL) + ZEND_NAMED_FE(setwidth,_wrap_FieldDefn_SetWidth, NULL) + ZEND_NAMED_FE(fielddefn_getprecision,_wrap_FieldDefn_GetPrecision, NULL) + ZEND_NAMED_FE(getprecision,_wrap_FieldDefn_GetPrecision, NULL) + ZEND_NAMED_FE(fielddefn_setprecision,_wrap_FieldDefn_SetPrecision, NULL) + ZEND_NAMED_FE(setprecision,_wrap_FieldDefn_SetPrecision, NULL) + ZEND_NAMED_FE(fielddefn_getfieldtypename,_wrap_FieldDefn_GetFieldTypeName, NULL) + ZEND_NAMED_FE(getfieldtypename,_wrap_FieldDefn_GetFieldTypeName, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for Geometry */ +static zend_function_entry Geometry_functions[] = { + ZEND_NAMED_FE(new_geometry,_wrap_new_Geometry, NULL) + ZEND_NAMED_FE(geometry,_wrap_new_Geometry, NULL) + ZEND_NAMED_FE(geometry_exporttowkt,_wrap_Geometry_ExportToWkt, NULL) + ZEND_NAMED_FE(exporttowkt,_wrap_Geometry_ExportToWkt, NULL) + ZEND_NAMED_FE(geometry_exporttowkb,_wrap_Geometry_ExportToWkb, NULL) + ZEND_NAMED_FE(exporttowkb,_wrap_Geometry_ExportToWkb, NULL) + ZEND_NAMED_FE(geometry_exporttogml,_wrap_Geometry_ExportToGML, NULL) + ZEND_NAMED_FE(exporttogml,_wrap_Geometry_ExportToGML, NULL) + ZEND_NAMED_FE(geometry_addpoint,_wrap_Geometry_AddPoint, NULL) + ZEND_NAMED_FE(addpoint,_wrap_Geometry_AddPoint, NULL) + ZEND_NAMED_FE(geometry_addgeometrydirectly,_wrap_Geometry_AddGeometryDirectly, NULL) + ZEND_NAMED_FE(addgeometrydirectly,_wrap_Geometry_AddGeometryDirectly, NULL) + ZEND_NAMED_FE(geometry_addgeometry,_wrap_Geometry_AddGeometry, NULL) + ZEND_NAMED_FE(addgeometry,_wrap_Geometry_AddGeometry, NULL) + ZEND_NAMED_FE(geometry_clone,_wrap_Geometry_Clone, NULL) + ZEND_NAMED_FE(clone,_wrap_Geometry_Clone, NULL) + ZEND_NAMED_FE(geometry_getgeometrytype,_wrap_Geometry_GetGeometryType, NULL) + ZEND_NAMED_FE(getgeometrytype,_wrap_Geometry_GetGeometryType, NULL) + ZEND_NAMED_FE(geometry_getgeometryname,_wrap_Geometry_GetGeometryName, NULL) + ZEND_NAMED_FE(getgeometryname,_wrap_Geometry_GetGeometryName, NULL) + ZEND_NAMED_FE(geometry_getarea,_wrap_Geometry_GetArea, NULL) + ZEND_NAMED_FE(getarea,_wrap_Geometry_GetArea, NULL) + ZEND_NAMED_FE(geometry_getpointcount,_wrap_Geometry_GetPointCount, NULL) + ZEND_NAMED_FE(getpointcount,_wrap_Geometry_GetPointCount, NULL) + ZEND_NAMED_FE(geometry_getx,_wrap_Geometry_GetX, NULL) + ZEND_NAMED_FE(getx,_wrap_Geometry_GetX, NULL) + ZEND_NAMED_FE(geometry_gety,_wrap_Geometry_GetY, NULL) + ZEND_NAMED_FE(gety,_wrap_Geometry_GetY, NULL) + ZEND_NAMED_FE(geometry_getz,_wrap_Geometry_GetZ, NULL) + ZEND_NAMED_FE(getz,_wrap_Geometry_GetZ, NULL) + ZEND_NAMED_FE(geometry_getgeometrycount,_wrap_Geometry_GetGeometryCount, NULL) + ZEND_NAMED_FE(getgeometrycount,_wrap_Geometry_GetGeometryCount, NULL) + ZEND_NAMED_FE(geometry_setpoint,_wrap_Geometry_SetPoint, NULL) + ZEND_NAMED_FE(setpoint,_wrap_Geometry_SetPoint, NULL) + ZEND_NAMED_FE(geometry_getgeometryref,_wrap_Geometry_GetGeometryRef, NULL) + ZEND_NAMED_FE(getgeometryref,_wrap_Geometry_GetGeometryRef, NULL) + ZEND_NAMED_FE(geometry_getboundary,_wrap_Geometry_GetBoundary, NULL) + ZEND_NAMED_FE(getboundary,_wrap_Geometry_GetBoundary, NULL) + ZEND_NAMED_FE(geometry_convexhull,_wrap_Geometry_ConvexHull, NULL) + ZEND_NAMED_FE(convexhull,_wrap_Geometry_ConvexHull, NULL) + ZEND_NAMED_FE(geometry_buffer,_wrap_Geometry_Buffer, NULL) + ZEND_NAMED_FE(buffer,_wrap_Geometry_Buffer, NULL) + ZEND_NAMED_FE(geometry_intersection,_wrap_Geometry_Intersection, NULL) + ZEND_NAMED_FE(intersection,_wrap_Geometry_Intersection, NULL) + ZEND_NAMED_FE(geometry_union,_wrap_Geometry_Union, NULL) + ZEND_NAMED_FE(union,_wrap_Geometry_Union, NULL) + ZEND_NAMED_FE(geometry_difference,_wrap_Geometry_Difference, NULL) + ZEND_NAMED_FE(difference,_wrap_Geometry_Difference, NULL) + ZEND_NAMED_FE(geometry_symmetricdifference,_wrap_Geometry_SymmetricDifference, NULL) + ZEND_NAMED_FE(symmetricdifference,_wrap_Geometry_SymmetricDifference, NULL) + ZEND_NAMED_FE(geometry_distance,_wrap_Geometry_Distance, NULL) + ZEND_NAMED_FE(distance,_wrap_Geometry_Distance, NULL) + ZEND_NAMED_FE(geometry_empty,_wrap_Geometry_Empty, NULL) + ZEND_NAMED_FE(empty,_wrap_Geometry_Empty, NULL) + ZEND_NAMED_FE(geometry_intersect,_wrap_Geometry_Intersect, NULL) + ZEND_NAMED_FE(intersect,_wrap_Geometry_Intersect, NULL) + ZEND_NAMED_FE(geometry_equal,_wrap_Geometry_Equal, NULL) + ZEND_NAMED_FE(equal,_wrap_Geometry_Equal, NULL) + ZEND_NAMED_FE(geometry_disjoint,_wrap_Geometry_Disjoint, NULL) + ZEND_NAMED_FE(disjoint,_wrap_Geometry_Disjoint, NULL) + ZEND_NAMED_FE(geometry_touches,_wrap_Geometry_Touches, NULL) + ZEND_NAMED_FE(touches,_wrap_Geometry_Touches, NULL) + ZEND_NAMED_FE(geometry_crosses,_wrap_Geometry_Crosses, NULL) + ZEND_NAMED_FE(crosses,_wrap_Geometry_Crosses, NULL) + ZEND_NAMED_FE(geometry_within,_wrap_Geometry_Within, NULL) + ZEND_NAMED_FE(within,_wrap_Geometry_Within, NULL) + ZEND_NAMED_FE(geometry_contains,_wrap_Geometry_Contains, NULL) + ZEND_NAMED_FE(contains,_wrap_Geometry_Contains, NULL) + ZEND_NAMED_FE(geometry_overlaps,_wrap_Geometry_Overlaps, NULL) + ZEND_NAMED_FE(overlaps,_wrap_Geometry_Overlaps, NULL) + ZEND_NAMED_FE(geometry_transformto,_wrap_Geometry_TransformTo, NULL) + ZEND_NAMED_FE(transformto,_wrap_Geometry_TransformTo, NULL) + ZEND_NAMED_FE(geometry_transform,_wrap_Geometry_Transform, NULL) + ZEND_NAMED_FE(transform,_wrap_Geometry_Transform, NULL) + ZEND_NAMED_FE(geometry_getspatialreference,_wrap_Geometry_GetSpatialReference, NULL) + ZEND_NAMED_FE(getspatialreference,_wrap_Geometry_GetSpatialReference, NULL) + ZEND_NAMED_FE(geometry_assignspatialreference,_wrap_Geometry_AssignSpatialReference, NULL) + ZEND_NAMED_FE(assignspatialreference,_wrap_Geometry_AssignSpatialReference, NULL) + ZEND_NAMED_FE(geometry_closerings,_wrap_Geometry_CloseRings, NULL) + ZEND_NAMED_FE(closerings,_wrap_Geometry_CloseRings, NULL) + ZEND_NAMED_FE(geometry_flattento2d,_wrap_Geometry_FlattenTo2D, NULL) + ZEND_NAMED_FE(flattento2d,_wrap_Geometry_FlattenTo2D, NULL) + ZEND_NAMED_FE(geometry_getenvelope,_wrap_Geometry_GetEnvelope, NULL) + ZEND_NAMED_FE(getenvelope,_wrap_Geometry_GetEnvelope, NULL) + ZEND_NAMED_FE(geometry_centroid,_wrap_Geometry_Centroid, NULL) + ZEND_NAMED_FE(centroid,_wrap_Geometry_Centroid, NULL) + ZEND_NAMED_FE(geometry_wkbsize,_wrap_Geometry_WkbSize, NULL) + ZEND_NAMED_FE(wkbsize,_wrap_Geometry_WkbSize, NULL) + ZEND_NAMED_FE(geometry_getcoordinatedimension,_wrap_Geometry_GetCoordinateDimension, NULL) + ZEND_NAMED_FE(getcoordinatedimension,_wrap_Geometry_GetCoordinateDimension, NULL) + ZEND_NAMED_FE(geometry_getdimension,_wrap_Geometry_GetDimension, NULL) + ZEND_NAMED_FE(getdimension,_wrap_Geometry_GetDimension, NULL) + { NULL, NULL, NULL} +}; + + +/* entry subsection */ +/* Every non-class user visible function must have an entry here */ +function_entry ogr_functions[] = { + ZEND_NAMED_FE(creategeometryfromwkb,_wrap_CreateGeometryFromWkb, NULL) + ZEND_NAMED_FE(creategeometryfromwkt,_wrap_CreateGeometryFromWkt, NULL) + ZEND_NAMED_FE(creategeometryfromgml,_wrap_CreateGeometryFromGML, NULL) + ZEND_NAMED_FE(ogrgetdrivercount,_wrap_OGRGetDriverCount, NULL) + ZEND_NAMED_FE(ogrgetopendscount,_wrap_OGRGetOpenDSCount, NULL) + ZEND_NAMED_FE(ogrsetgenerate_db2_v72_byte_order,_wrap_OGRSetGenerate_DB2_V72_BYTE_ORDER, NULL) + ZEND_NAMED_FE(ogrregisterall,_wrap_OGRRegisterAll, NULL) + ZEND_NAMED_FE(getopends,_wrap_GetOpenDS, NULL) + ZEND_NAMED_FE(open,_wrap_Open, NULL) + ZEND_NAMED_FE(openshared,_wrap_OpenShared, NULL) + ZEND_NAMED_FE(getdriverbyname,_wrap_GetDriverByName, NULL) + ZEND_NAMED_FE(getdriver,_wrap_GetDriver, NULL) + {NULL, NULL, NULL} +}; + +zend_module_entry ogr_module_entry = { +#if ZEND_MODULE_API_NO > 20010900 + STANDARD_MODULE_HEADER, +#endif + "ogr", + ogr_functions, + PHP_MINIT(ogr), + PHP_MSHUTDOWN(ogr), + PHP_RINIT(ogr), + PHP_RSHUTDOWN(ogr), + PHP_MINFO(ogr), +#if ZEND_MODULE_API_NO > 20010900 + NO_VERSION_YET, +#endif + STANDARD_MODULE_PROPERTIES +}; +zend_module_entry* SWIG_module_entry = &ogr_module_entry; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__int = {"_int", "int", 0, 0, 0}; +static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRDataSourceShadow = {"_p_OGRDataSourceShadow", "OGRDataSourceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRDriverShadow = {"_p_OGRDriverShadow", "OGRDriverShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFeatureDefnShadow = {"_p_OGRFeatureDefnShadow", "OGRFeatureDefnShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFeatureShadow = {"_p_OGRFeatureShadow", "OGRFeatureShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFieldDefnShadow = {"_p_OGRFieldDefnShadow", "OGRFieldDefnShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRGeometryShadow = {"_p_OGRGeometryShadow", "OGRGeometryShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRLayerShadow = {"_p_OGRLayerShadow", "OGRLayerShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRDataSourceShadow = {"_p_p_OGRDataSourceShadow", "OGRDataSourceShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRDriverShadow = {"_p_p_OGRDriverShadow", "OGRDriverShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRFeatureDefnShadow = {"_p_p_OGRFeatureDefnShadow", "OGRFeatureDefnShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRFeatureShadow = {"_p_p_OGRFeatureShadow", "OGRFeatureShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRFieldDefnShadow = {"_p_p_OGRFieldDefnShadow", "OGRFieldDefnShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRGeometryShadow = {"_p_p_OGRGeometryShadow", "OGRGeometryShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OGRLayerShadow = {"_p_p_OGRLayerShadow", "OGRLayerShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OSRCoordinateTransformationShadow = {"_p_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OSRSpatialReferenceShadow = {"_p_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__int, + &_swigt__p_GIntBig, + &_swigt__p_OGRDataSourceShadow, + &_swigt__p_OGRDriverShadow, + &_swigt__p_OGRFeatureDefnShadow, + &_swigt__p_OGRFeatureShadow, + &_swigt__p_OGRFieldDefnShadow, + &_swigt__p_OGRGeometryShadow, + &_swigt__p_OGRLayerShadow, + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_OGRDataSourceShadow, + &_swigt__p_p_OGRDriverShadow, + &_swigt__p_p_OGRFeatureDefnShadow, + &_swigt__p_p_OGRFeatureShadow, + &_swigt__p_p_OGRFieldDefnShadow, + &_swigt__p_p_OGRGeometryShadow, + &_swigt__p_p_OGRLayerShadow, + &_swigt__p_p_OSRCoordinateTransformationShadow, + &_swigt__p_p_OSRSpatialReferenceShadow, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__int[] = { {&_swigt__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDataSourceShadow[] = { {&_swigt__p_OGRDataSourceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDriverShadow[] = { {&_swigt__p_OGRDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureDefnShadow[] = { {&_swigt__p_OGRFeatureDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureShadow[] = { {&_swigt__p_OGRFeatureShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFieldDefnShadow[] = { {&_swigt__p_OGRFieldDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRGeometryShadow[] = { {&_swigt__p_OGRGeometryShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRLayerShadow[] = { {&_swigt__p_OGRLayerShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRDataSourceShadow[] = { {&_swigt__p_p_OGRDataSourceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRDriverShadow[] = { {&_swigt__p_p_OGRDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRFeatureDefnShadow[] = { {&_swigt__p_p_OGRFeatureDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRFeatureShadow[] = { {&_swigt__p_p_OGRFeatureShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRFieldDefnShadow[] = { {&_swigt__p_p_OGRFieldDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRGeometryShadow[] = { {&_swigt__p_p_OGRGeometryShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OGRLayerShadow[] = { {&_swigt__p_p_OGRLayerShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OSRSpatialReferenceShadow[] = { {&_swigt__p_p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__int, + _swigc__p_GIntBig, + _swigc__p_OGRDataSourceShadow, + _swigc__p_OGRDriverShadow, + _swigc__p_OGRFeatureDefnShadow, + _swigc__p_OGRFeatureShadow, + _swigc__p_OGRFieldDefnShadow, + _swigc__p_OGRGeometryShadow, + _swigc__p_OGRLayerShadow, + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_OGRDataSourceShadow, + _swigc__p_p_OGRDriverShadow, + _swigc__p_p_OGRFeatureDefnShadow, + _swigc__p_p_OGRFeatureShadow, + _swigc__p_p_OGRFieldDefnShadow, + _swigc__p_p_OGRGeometryShadow, + _swigc__p_p_OGRLayerShadow, + _swigc__p_p_OSRCoordinateTransformationShadow, + _swigc__p_p_OSRSpatialReferenceShadow, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/* end header section */ +/* vdecl subsection */ +static zend_class_entry ce_swig_Driver; +static zend_class_entry* ptr_ce_swig_Driver=NULL; +static zend_class_entry ce_swig_DataSource; +static zend_class_entry* ptr_ce_swig_DataSource=NULL; +static zend_class_entry ce_swig_Layer; +static zend_class_entry* ptr_ce_swig_Layer=NULL; +static zend_class_entry ce_swig_Feature; +static zend_class_entry* ptr_ce_swig_Feature=NULL; +static zend_class_entry ce_swig_FeatureDefn; +static zend_class_entry* ptr_ce_swig_FeatureDefn=NULL; +static zend_class_entry ce_swig_FieldDefn; +static zend_class_entry* ptr_ce_swig_FieldDefn=NULL; +static zend_class_entry ce_swig_Geometry; +static zend_class_entry* ptr_ce_swig_Geometry=NULL; +static int le_swig__p_GIntBig=0; /* handle for */ +static int le_swig__p_double=0; /* handle for */ +static int le_swig__p_p_char=0; /* handle for */ +static int le_swig__p_char=0; /* handle for */ +static int le_swig__p_p_OGRGeometryShadow=0; /* handle for */ +static int le_swig__p_OGRGeometryShadow=0; /* handle for Geometry */ +static int le_swig__p_p_OSRSpatialReferenceShadow=0; /* handle for Geometry */ +static int le_swig__p_OSRSpatialReferenceShadow=0; /* handle for SpatialReference */ +static int le_swig__p_p_OGRDataSourceShadow=0; /* handle for SpatialReference */ +static int le_swig__p_OGRDataSourceShadow=0; /* handle for DataSource */ +static int le_swig__p_OGRFeatureShadow=0; /* handle for Feature */ +static int le_swig__p_p_OGRFeatureShadow=0; /* handle for Feature */ +static int le_swig__int=0; /* handle for Feature */ +static int le_swig__p_int=0; /* handle for Feature */ +static int le_swig__p_p_OGRLayerShadow=0; /* handle for Feature */ +static int le_swig__p_OGRLayerShadow=0; /* handle for Layer */ +static int le_swig__p_p_OGRDriverShadow=0; /* handle for Layer */ +static int le_swig__p_OGRDriverShadow=0; /* handle for Driver */ +static int le_swig__p_OGRFeatureDefnShadow=0; /* handle for FeatureDefn */ +static int le_swig__p_OGRFieldDefnShadow=0; /* handle for FieldDefn */ +static int le_swig__p_p_OGRFieldDefnShadow=0; /* handle for FieldDefn */ +static int le_swig__p_p_OGRFeatureDefnShadow=0; /* handle for FieldDefn */ +static int le_swig__p_OSRCoordinateTransformationShadow=0; /* handle for CoordinateTransformation */ +static int le_swig__p_p_OSRCoordinateTransformationShadow=0; /* handle for CoordinateTransformation */ +/* end vdecl subsection */ +/* wrapper section */ +static pval _wrap_Driver_name_get(zend_property_reference *property_reference) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_name_get. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + result = (char *)OGRDriverShadow_name_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateDataSource) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + OGRDataSourceShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_CreateDataSource. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[1]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[1],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg3 = CSLAddString( arg3, pszItem ); + // } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CreateDataSource(arg1,(char const *)arg2,arg3); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_CopyDataSource) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + OGRDataSourceShadow *arg2 = (OGRDataSourceShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRDataSourceShadow *result; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<3 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_CopyDataSource. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Driver_CopyDataSource. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + if(arg_count > 3) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[2]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[2],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg4 = CSLAddString( arg4, pszItem ); + // } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CopyDataSource(arg1,arg2,(char const *)arg3,arg4); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_Open) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + OGRDataSourceShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_Open. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_Open(arg1,(char const *)arg2,arg3); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_DeleteDataSource) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_DeleteDataSource. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRDriverShadow_DeleteDataSource(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_TestCapability) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_TestCapability. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRDriverShadow_TestCapability(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Driver_GetName) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDriverShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Driver_GetName. Expected SWIGTYPE_p_p_OGRDriverShadow"); + } + } + result = (char *)OGRDriverShadow_GetName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Driver */ +static pval _wrap_propget_Driver(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Driver(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Driver(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"name")==0) { + *value=_wrap_Driver_name_get(property_reference); + return SUCCESS; + } else return FAILURE; +} + +static int _wrap_propset_Driver(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Driver(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Driver */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Driver(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static pval _wrap_DataSource_name_get(zend_property_reference *property_reference) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + zval **args[1]; + zval _return_value; + zval *return_value=&_return_value; + + SWIG_ResetError(); + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&(property_reference->object), (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_name_get. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + result = (char *)OGRDataSourceShadow_name_get(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return _return_value; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_DataSource(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OGRDataSourceShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OGRDataSourceShadow resource already free'd"); + delete_OGRDataSourceShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetRefCount) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetRefCount. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + result = (int)OGRDataSourceShadow_GetRefCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetSummaryRefCount) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetSummaryRefCount. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + result = (int)OGRDataSourceShadow_GetSummaryRefCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerCount) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetLayerCount. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + result = (int)OGRDataSourceShadow_GetLayerCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetName) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetName. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + result = (char *)OGRDataSourceShadow_GetName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_DeleteLayer) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_DeleteLayer. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRDataSourceShadow_DeleteLayer(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_CreateLayer) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRwkbGeometryType arg4 = (OGRwkbGeometryType) wkbUnknown ; + char **arg5 = (char **) 0 ; + OGRLayerShadow *result; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_CreateLayer. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg3, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 3 of DataSource_CreateLayer. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg4 = (OGRwkbGeometryType) Z_LVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[3]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[3],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg5 = CSLAddString( arg5, pszItem ); + // } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CreateLayer(arg1,(char const *)arg2,arg3,arg4,arg5); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRLayerShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Layer); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_CopyLayer) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRLayerShadow *result; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<3 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_CopyLayer. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of DataSource_CopyLayer. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + if(arg_count > 3) { + { + /* %typemap(in) char **options */ + zend_error(E_ERROR,"Typemap (in) char **options not properly defined"); + // int size = PySequence_Size(args[2]); + // for (int i = 0; i < size; i++) { + // char *pszItem = NULL; + // if ( ! PyArg_Parse( PySequence_GetItem(args[2],i), "s", &pszItem ) ) { + // PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + // SWIG_fail; + // } + // arg4 = CSLAddString( arg4, pszItem ); + // } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CopyLayer(arg1,arg2,(char const *)arg3,arg4); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRLayerShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Layer); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByIndex) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 = (int) 0 ; + OGRLayerShadow *result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetLayerByIndex. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByIndex(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRLayerShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Layer); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByName) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRLayerShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_GetLayerByName. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByName(arg1,(char const *)arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRLayerShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Layer); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_TestCapability) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_TestCapability. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRDataSourceShadow_TestCapability(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_ExecuteSQL) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRGeometryShadow *arg3 = (OGRGeometryShadow *) NULL ; + char *arg4 = (char *) "" ; + OGRLayerShadow *result; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_ExecuteSQL. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg3, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 3 of DataSource_ExecuteSQL. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg4 = (char *) Z_STRVAL_PP(args[2]); + /*@@*/; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_ExecuteSQL(arg1,(char const *)arg2,arg3,(char const *)arg4); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRLayerShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Layer); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_DataSource_ReleaseResultSet) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRDataSourceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of DataSource_ReleaseResultSet. Expected SWIGTYPE_p_p_OGRDataSourceShadow"); + } + } + { + /* typemap(in) SWIGTYPE *DISOWN */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_DISOWN ) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of DataSource_ReleaseResultSet. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + OGRDataSourceShadow_ReleaseResultSet(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class DataSource */ +static pval _wrap_propget_DataSource(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_DataSource(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_DataSource(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + if (strcmp(propname,"name")==0) { + *value=_wrap_DataSource_name_get(property_reference); + return SUCCESS; + } else return FAILURE; +} + +static int _wrap_propset_DataSource(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_DataSource(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is DataSource */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_DataSource(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetRefCount) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetRefCount. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (int)OGRLayerShadow_GetRefCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilter) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SetSpatialFilter. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Layer_SetSpatialFilter. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + OGRLayerShadow_SetSpatialFilter(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilterRect) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + zval **args[4]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 4) || (zend_get_parameters_array_ex(4, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SetSpatialFilterRect. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + OGRLayerShadow_SetSpatialFilterRect(arg1,arg2,arg3,arg4,arg5); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialFilter) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetSpatialFilter. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRGeometryShadow *)OGRLayerShadow_GetSpatialFilter(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SetAttributeFilter) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SetAttributeFilter. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRLayerShadow_SetAttributeFilter(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_ResetReading) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_ResetReading. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + OGRLayerShadow_ResetReading(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetName) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetName. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (char *)OGRLayerShadow_GetName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeature) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRFeatureShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetFeature. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (long) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRFeatureShadow *)OGRLayerShadow_GetFeature(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Feature); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetNextFeature) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetNextFeature. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRFeatureShadow *)OGRLayerShadow_GetNextFeature(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Feature); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SetNextByIndex) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SetNextByIndex. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (long) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRLayerShadow_SetNextByIndex(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SetFeature) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SetFeature. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Layer_SetFeature. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (OGRErr)OGRLayerShadow_SetFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateFeature) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_CreateFeature. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Layer_CreateFeature. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (OGRErr)OGRLayerShadow_CreateFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_DeleteFeature) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_DeleteFeature. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (long) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRLayerShadow_DeleteFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_SyncToDisk) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_SyncToDisk. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRErr)OGRLayerShadow_SyncToDisk(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetLayerDefn) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureDefnShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetLayerDefn. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRFeatureDefnShadow *)OGRLayerShadow_GetLayerDefn(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureDefnShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FeatureDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureCount) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int arg2 = (int) 1 ; + int result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetFeatureCount. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (int)OGRLayerShadow_GetFeatureCount(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetExtent) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 1 ; + double argout2[4] ; + zval **args[1]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetExtent. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg3 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + OGRLayerShadow_GetExtent(arg1,arg2,arg3); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 4 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_TestCapability) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_TestCapability. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRLayerShadow_TestCapability(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateField) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_CreateField. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Layer_CreateField. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRErr)OGRLayerShadow_CreateField(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_StartTransaction) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_StartTransaction. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRErr)OGRLayerShadow_StartTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_CommitTransaction) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_CommitTransaction. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRErr)OGRLayerShadow_CommitTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_RollbackTransaction) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_RollbackTransaction. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OGRErr)OGRLayerShadow_RollbackTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialRef) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OSRSpatialReferenceShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetSpatialRef. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = (OSRSpatialReferenceShadow *)OGRLayerShadow_GetSpatialRef(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OSRSpatialReferenceShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_SpatialReference); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureRead) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + GIntBig result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRLayerShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Layer_GetFeatureRead. Expected SWIGTYPE_p_p_OGRLayerShadow"); + } + } + result = OGRLayerShadow_GetFeatureRead(arg1); + + { + GIntBig * resultobj = new GIntBig((GIntBig &) result); + SWIG_SetPointerZval(return_value, (void *)resultobj, SWIGTYPE_p_GIntBig, 1); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Layer */ +static pval _wrap_propget_Layer(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Layer(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Layer(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_Layer(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Layer(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Layer */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Layer(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_Feature(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OGRFeatureShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OGRFeatureShadow resource already free'd"); + delete_OGRFeatureShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_new_Feature) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFeatureShadow *result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of new_Feature. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + } + result = (OGRFeatureShadow *)new_OGRFeatureShadow(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Feature); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetDefnRef) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureDefnShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetDefnRef. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (OGRFeatureDefnShadow *)OGRFeatureShadow_GetDefnRef(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureDefnShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FeatureDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometry) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetGeometry. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Feature_SetGeometry. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometryDirectly) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetGeometryDirectly. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /* typemap(in) SWIGTYPE *DISOWN */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN ) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Feature_SetGeometryDirectly. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRErr)OGRFeatureShadow_SetGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetGeometryRef) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetGeometryRef. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (OGRGeometryShadow *)OGRFeatureShadow_GetGeometryRef(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_Clone) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_Clone. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (OGRFeatureShadow *)OGRFeatureShadow_Clone(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Feature); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_Equal) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_Equal. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Feature_Equal. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (int)OGRFeatureShadow_Equal(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldCount) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldCount. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (int)OGRFeatureShadow_GetFieldCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldDefnRef. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_0(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFieldDefnShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FieldDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRFieldDefnShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldDefnRef. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_1(arg1,(char const *)arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFieldDefnShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FieldDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldDefnRef__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldDefnRef__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_GetFieldDefnRef'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsString. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_0(arg1,arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsString. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_1(arg1,(char const *)arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsString__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsString__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_GetFieldAsString'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsInteger. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_0(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsInteger. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_1(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsInteger__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsInteger__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_GetFieldAsInteger'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsDouble. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_0(arg1,arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldAsDouble. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_1(arg1,(char const *)arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsDouble__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldAsDouble__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_GetFieldAsDouble'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_IsFieldSet. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureShadow_IsFieldSet__SWIG_0(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_IsFieldSet. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureShadow_IsFieldSet__SWIG_1(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_IsFieldSet__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_IsFieldSet__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_IsFieldSet'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldIndex) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldIndex. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureShadow_GetFieldIndex(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFID) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFID. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (int)OGRFeatureShadow_GetFID(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFID) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetFID. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRFeatureShadow_SetFID(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_DumpReadable) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_DumpReadable. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + OGRFeatureShadow_DumpReadable(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_UnsetField. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFeatureShadow_UnsetField__SWIG_0(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_UnsetField. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + OGRFeatureShadow_UnsetField__SWIG_1(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField) { + int argc; + zval **argv[2]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_UnsetField__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_UnsetField__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + + /*No matching function for overloaded 'Feature_UnsetField'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetField. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /* %typemap(in) (tostring argin) */ + convert_to_string_ex(args[1]); + arg3 = Z_STRVAL_PP( args[1] ); + } + OGRFeatureShadow_SetField__SWIG_0(arg1,arg2,(char const *)arg3); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetField. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /* %typemap(in) (tostring argin) */ + convert_to_string_ex(args[1]); + arg3 = Z_STRVAL_PP( args[1] ); + } + OGRFeatureShadow_SetField__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField) { + int argc; + zval **argv[3]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 3) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + if (_v) { + return _wrap_Feature_SetField__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + if (argc == 3) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + if (_v) { + return _wrap_Feature_SetField__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + + /*No matching function for overloaded 'Feature_SetField'*/ + +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFrom) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetFrom. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Feature_SetFrom. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRErr)OGRFeatureShadow_SetFrom(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetStyleString) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetStyleString. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + result = (char *)OGRFeatureShadow_GetStyleString(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_SetStyleString) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_SetStyleString. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + OGRFeatureShadow_SetStyleString(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType__SWIG_0) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldType result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldType. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_0(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType__SWIG_1) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRFieldType result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Feature_GetFieldType. Expected SWIGTYPE_p_p_OGRFeatureShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType) { + int argc; + zval **argv[3]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldType__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if (argc == 3) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OGRFeatureShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_LONG || + Z_TYPE_PP(argv[2]) == IS_DOUBLE || + Z_TYPE_PP(argv[2]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_Feature_GetFieldType__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + + /*No matching function for overloaded 'Feature_GetFieldType'*/ + +} + + +/* property handler for class Feature */ +static pval _wrap_propget_Feature(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Feature(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Feature(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_Feature(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Feature(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Feature */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Feature(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_FeatureDefn(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OGRFeatureDefnShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OGRFeatureDefnShadow resource already free'd"); + delete_OGRFeatureDefnShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_new_FeatureDefn) { + char *arg1 = (char *) NULL ; + OGRFeatureDefnShadow *result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRFeatureDefnShadow *)new_OGRFeatureDefnShadow((char const *)arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFeatureDefnShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FeatureDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetName) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetName. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + result = (char *)OGRFeatureDefnShadow_GetName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldCount) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetFieldCount. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + result = (int)OGRFeatureDefnShadow_GetFieldCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldDefn) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetFieldDefn. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRFieldDefnShadow *)OGRFeatureDefnShadow_GetFieldDefn(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFieldDefnShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FieldDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldIndex) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetFieldIndex. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (int)OGRFeatureDefnShadow_GetFieldIndex(arg1,(char const *)arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_AddFieldDefn) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_AddFieldDefn. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of FeatureDefn_AddFieldDefn. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + OGRFeatureDefnShadow_AddFieldDefn(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetGeomType) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetGeomType. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + result = (OGRwkbGeometryType)OGRFeatureDefnShadow_GetGeomType(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_SetGeomType) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_SetGeomType. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (OGRwkbGeometryType) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFeatureDefnShadow_SetGeomType(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetReferenceCount) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFeatureDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FeatureDefn_GetReferenceCount. Expected SWIGTYPE_p_p_OGRFeatureDefnShadow"); + } + } + result = (int)OGRFeatureDefnShadow_GetReferenceCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class FeatureDefn */ +static pval _wrap_propget_FeatureDefn(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_FeatureDefn(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_FeatureDefn(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_FeatureDefn(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_FeatureDefn(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is FeatureDefn */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_FeatureDefn(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_FieldDefn(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OGRFieldDefnShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OGRFieldDefnShadow resource already free'd"); + delete_OGRFieldDefnShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_new_FieldDefn) { + char *arg1 = (char *) "unnamed" ; + OGRFieldType arg2 = (OGRFieldType) OFTString ; + OGRFieldDefnShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (OGRFieldType) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRFieldDefnShadow *)new_OGRFieldDefnShadow((char const *)arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRFieldDefnShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_FieldDefn); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetName) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetName. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (char *)OGRFieldDefnShadow_GetName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetNameRef) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetNameRef. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (char *)OGRFieldDefnShadow_GetNameRef(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetName) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_SetName. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + OGRFieldDefnShadow_SetName(arg1,(char const *)arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetType) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetType. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (OGRFieldType)OGRFieldDefnShadow_GetType(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetType) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_SetType. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (OGRFieldType) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFieldDefnShadow_SetType(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetJustify) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetJustify. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (OGRJustification)OGRFieldDefnShadow_GetJustify(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetJustify) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_SetJustify. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (OGRJustification) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFieldDefnShadow_SetJustify(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetWidth) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetWidth. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (int)OGRFieldDefnShadow_GetWidth(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetWidth) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_SetWidth. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFieldDefnShadow_SetWidth(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetPrecision) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetPrecision. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + result = (int)OGRFieldDefnShadow_GetPrecision(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetPrecision) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_SetPrecision. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + OGRFieldDefnShadow_SetPrecision(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetFieldTypeName) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRFieldDefnShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of FieldDefn_GetFieldTypeName. Expected SWIGTYPE_p_p_OGRFieldDefnShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (OGRFieldType) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (char *)OGRFieldDefnShadow_GetFieldTypeName(arg1,arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class FieldDefn */ +static pval _wrap_propget_FieldDefn(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_FieldDefn(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_FieldDefn(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_FieldDefn(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_FieldDefn(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is FieldDefn */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_FieldDefn(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromWkb) { + int arg1 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + convert_to_string_ex(args[0]); + arg2 = Z_STRVAL_PP(args[0]); + arg1 = Z_STRLEN_PP(args[0]); + } + if(arg_count > 1) { + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg3, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 3 of CreateGeometryFromWkb. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + } + result = (OGRGeometryShadow *)CreateGeometryFromWkb(arg1,arg2,arg3); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromWkt) { + char **arg1 = (char **) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + char *val1 ; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* %typemap(in) (char **ignorechange) */ + convert_to_string_ex( args[0] ); + arg1 = NULL; + } + if(arg_count > 1) { + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of CreateGeometryFromWkt. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + } + result = (OGRGeometryShadow *)CreateGeometryFromWkt(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromGML) { + char *arg1 = (char *) 0 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRGeometryShadow *)CreateGeometryFromGML((char const *)arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_Geometry(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OGRGeometryShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OGRGeometryShadow resource already free'd"); + delete_OGRGeometryShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_new_Geometry) { + OGRwkbGeometryType arg1 = (OGRwkbGeometryType) wkbUnknown ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + OGRGeometryShadow *result; + zval **args[5]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (OGRwkbGeometryType) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[2]); + arg3 = (int) Z_LVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[3]); + arg4 = (char *) Z_STRVAL_PP(args[3]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[4]); + arg5 = (char *) Z_STRVAL_PP(args[4]); + /*@@*/; + } + } + result = (OGRGeometryShadow *)new_OGRGeometryShadow(arg1,arg2,arg3,arg4,arg5); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkt) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_ExportToWkt. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (char *)OGRGeometryShadow_ExportToWkt(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkb) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int *arg2 = (int *) 0 ; + char **arg3 = (char **) 0 ; + OGRwkbByteOrder arg4 = (OGRwkbByteOrder) wkbXDR ; + OGRErr result; + int nLen2 = 0 ; + char *pBuf2 = 0 ; + zval **args[1]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (int *nLen2, char **pBuf2 ) */ + arg2 = &nLen2; + arg3 = &pBuf2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_ExportToWkb. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg4 = (OGRwkbByteOrder) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRErr)OGRGeometryShadow_ExportToWkb(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + ZVAL_STRINGL( return_value, *arg3, *arg2, 1 ); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToGML) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_ExportToGML. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (char *)OGRGeometryShadow_ExportToGML(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddPoint) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 = (double) 0 ; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<3 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_AddPoint. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + } + OGRGeometryShadow_AddPoint(arg1,arg2,arg3,arg4); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometryDirectly) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_AddGeometryDirectly. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE *DISOWN */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN ) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_AddGeometryDirectly. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRErr)OGRGeometryShadow_AddGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometry) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_AddGeometry. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_AddGeometry. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRErr)OGRGeometryShadow_AddGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Clone) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Clone. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Clone(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryType) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRwkbGeometryType result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetGeometryType. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRwkbGeometryType)OGRGeometryShadow_GetGeometryType(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryName) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetGeometryName. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (char *)OGRGeometryShadow_GetGeometryName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetArea) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetArea. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (double)OGRGeometryShadow_GetArea(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetPointCount) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetPointCount. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_GetPointCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetX) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetX. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (double)OGRGeometryShadow_GetX(arg1,arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetY) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetY. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (double)OGRGeometryShadow_GetY(arg1,arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetZ) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetZ. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (double)OGRGeometryShadow_GetZ(arg1,arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryCount) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetGeometryCount. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_GetGeometryCount(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_SetPoint) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0 ; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<4 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_SetPoint. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + } + OGRGeometryShadow_SetPoint(arg1,arg2,arg3,arg4,arg5); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryRef) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetGeometryRef. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRGeometryShadow *)OGRGeometryShadow_GetGeometryRef(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetBoundary) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetBoundary. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_GetBoundary(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_ConvexHull) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_ConvexHull. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_ConvexHull(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Buffer) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + int arg3 = (int) 30 ; + OGRGeometryShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Buffer. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Buffer(arg1,arg2,arg3); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersection) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Intersection. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Intersection. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Intersection(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Union) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Union. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Union. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Union(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Difference) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Difference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Difference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Difference(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_SymmetricDifference) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_SymmetricDifference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_SymmetricDifference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_SymmetricDifference(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Distance) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + double result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Distance. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Distance. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (double)OGRGeometryShadow_Distance(arg1,arg2); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Empty) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Empty. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + OGRGeometryShadow_Empty(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersect) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Intersect. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Intersect. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Intersect(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Equal) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Equal. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Equal. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Equal(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Disjoint) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Disjoint. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Disjoint. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Disjoint(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Touches) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Touches. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Touches. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Touches(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Crosses) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Crosses. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Crosses. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Crosses(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Within) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Within. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Within. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Within(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Contains) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Contains. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Contains. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Contains(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Overlaps) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Overlaps. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Overlaps. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_Overlaps(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_TransformTo) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_TransformTo. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_TransformTo. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OGRGeometryShadow_TransformTo(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Transform) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRCoordinateTransformationShadow *arg2 = (OSRCoordinateTransformationShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Transform. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_Transform. Expected SWIGTYPE_p_p_OSRCoordinateTransformationShadow"); + } + } + result = (OGRErr)OGRGeometryShadow_Transform(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetSpatialReference) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetSpatialReference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OSRSpatialReferenceShadow *)OGRGeometryShadow_GetSpatialReference(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OSRSpatialReferenceShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_SpatialReference); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_AssignSpatialReference) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_AssignSpatialReference. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of Geometry_AssignSpatialReference. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + OGRGeometryShadow_AssignSpatialReference(arg1,arg2); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_CloseRings) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_CloseRings. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + OGRGeometryShadow_CloseRings(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_FlattenTo2D) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_FlattenTo2D. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + OGRGeometryShadow_FlattenTo2D(arg1); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetEnvelope) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double *arg2 ; + double argout2[4] ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetEnvelope. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + OGRGeometryShadow_GetEnvelope(arg1,arg2); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 4 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_Centroid) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_Centroid. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Centroid(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRGeometryShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Geometry); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_WkbSize) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_WkbSize. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_WkbSize(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetCoordinateDimension) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetCoordinateDimension. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_GetCoordinateDimension(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetDimension) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OGRGeometryShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of Geometry_GetDimension. Expected SWIGTYPE_p_p_OGRGeometryShadow"); + } + } + result = (int)OGRGeometryShadow_GetDimension(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class Geometry */ +static pval _wrap_propget_Geometry(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_Geometry(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_Geometry(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_Geometry(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_Geometry(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is Geometry */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_Geometry(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_OGRGetDriverCount) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)OGRGetDriverCount(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_OGRGetOpenDSCount) { + int result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (int)OGRGetOpenDSCount(); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_OGRSetGenerate_DB2_V72_BYTE_ORDER) { + int arg1 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OGRSetGenerate_DB2_V72_BYTE_ORDER(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_OGRRegisterAll) { + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + OGRRegisterAll(); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetOpenDS) { + int arg1 ; + OGRDataSourceShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRDataSourceShadow *)GetOpenDS(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_Open) { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRDataSourceShadow *)Open((char const *)arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_OpenShared) { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg2 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRDataSourceShadow *)OpenShared((char const *)arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDataSourceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_DataSource); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDriverByName) { + char *arg1 = (char *) 0 ; + OGRDriverShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRDriverShadow *)GetDriverByName((char const *)arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDriverShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Driver); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetDriver) { + int arg1 ; + OGRDriverShadow *result; + zval **args[1]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg1 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRDriverShadow *)GetDriver(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OGRDriverShadow, 0); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_Driver); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_GIntBig) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_double) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRGeometryShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRGeometryShadow) { + /* has destructor: __wrap_delete_Geometry */ + __wrap_delete_Geometry(rsrc, SWIGTYPE_p_OGRGeometryShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OSRSpatialReferenceShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OSRSpatialReferenceShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRDataSourceShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRDataSourceShadow) { + /* has destructor: __wrap_delete_DataSource */ + __wrap_delete_DataSource(rsrc, SWIGTYPE_p_OGRDataSourceShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRFeatureShadow) { + /* has destructor: __wrap_delete_Feature */ + __wrap_delete_Feature(rsrc, SWIGTYPE_p_OGRFeatureShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRFeatureShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_int) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_int) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRLayerShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRLayerShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRDriverShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRDriverShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRFeatureDefnShadow) { + /* has destructor: __wrap_delete_FeatureDefn */ + __wrap_delete_FeatureDefn(rsrc, SWIGTYPE_p_OGRFeatureDefnShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OGRFieldDefnShadow) { + /* has destructor: __wrap_delete_FieldDefn */ + __wrap_delete_FieldDefn(rsrc, SWIGTYPE_p_OGRFieldDefnShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRFieldDefnShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OGRFeatureDefnShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OSRCoordinateTransformationShadow) { + /* bah! No destructor for this wrapped class!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OSRCoordinateTransformationShadow) { + /* bah! No destructor for this simple type!! */ +} +/* end wrapper section */ +/* init section */ +#ifdef __cplusplus +extern "C" { +#endif +ZEND_GET_MODULE(ogr) +#ifdef __cplusplus +} +#endif + +#define SWIG_php_minit PHP_MINIT_FUNCTION(ogr) +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + + SWIG_php_minit { + SWIG_InitializeModule(0); + + + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + +/* oinit subsection */ +ZEND_INIT_MODULE_GLOBALS(ogr, ogr_init_globals, ogr_destroy_globals); +/* Define class Driver */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Driver,"driver",Driver_functions,NULL,_wrap_propget_Driver,_wrap_propset_Driver); +if (! (ptr_ce_swig_Driver=zend_register_internal_class_ex(&ce_swig_Driver,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Driver"); + +/* Define class DataSource */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_DataSource,"datasource",DataSource_functions,NULL,_wrap_propget_DataSource,_wrap_propset_DataSource); +if (! (ptr_ce_swig_DataSource=zend_register_internal_class_ex(&ce_swig_DataSource,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class DataSource"); + +/* Define class Layer */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Layer,"layer",Layer_functions,NULL,_wrap_propget_Layer,_wrap_propset_Layer); +if (! (ptr_ce_swig_Layer=zend_register_internal_class_ex(&ce_swig_Layer,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Layer"); + +/* Define class Feature */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Feature,"feature",Feature_functions,NULL,_wrap_propget_Feature,_wrap_propset_Feature); +if (! (ptr_ce_swig_Feature=zend_register_internal_class_ex(&ce_swig_Feature,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Feature"); + +/* Define class FeatureDefn */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_FeatureDefn,"featuredefn",FeatureDefn_functions,NULL,_wrap_propget_FeatureDefn,_wrap_propset_FeatureDefn); +if (! (ptr_ce_swig_FeatureDefn=zend_register_internal_class_ex(&ce_swig_FeatureDefn,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class FeatureDefn"); + +/* Define class FieldDefn */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_FieldDefn,"fielddefn",FieldDefn_functions,NULL,_wrap_propget_FieldDefn,_wrap_propset_FieldDefn); +if (! (ptr_ce_swig_FieldDefn=zend_register_internal_class_ex(&ce_swig_FieldDefn,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class FieldDefn"); + +/* Define class Geometry */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_Geometry,"geometry",Geometry_functions,NULL,_wrap_propget_Geometry,_wrap_propset_Geometry); +if (! (ptr_ce_swig_Geometry=zend_register_internal_class_ex(&ce_swig_Geometry,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class Geometry"); + + +/* Register resource destructors for pointer types */ +le_swig__p_GIntBig=zend_register_list_destructors_ex(_wrap_destroy_p_GIntBig,NULL,(char *)(SWIGTYPE_p_GIntBig->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_GIntBig,&le_swig__p_GIntBig); +le_swig__p_double=zend_register_list_destructors_ex(_wrap_destroy_p_double,NULL,(char *)(SWIGTYPE_p_double->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_double,&le_swig__p_double); +le_swig__p_p_char=zend_register_list_destructors_ex(_wrap_destroy_p_p_char,NULL,(char *)(SWIGTYPE_p_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_char,&le_swig__p_p_char); +le_swig__p_char=zend_register_list_destructors_ex(_wrap_destroy_p_char,NULL,(char *)(SWIGTYPE_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_char,&le_swig__p_char); +le_swig__p_p_OGRGeometryShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRGeometryShadow,NULL,(char *)(SWIGTYPE_p_p_OGRGeometryShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRGeometryShadow,&le_swig__p_p_OGRGeometryShadow); +le_swig__p_OGRGeometryShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRGeometryShadow,NULL,(char *)(SWIGTYPE_p_OGRGeometryShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRGeometryShadow,&le_swig__p_OGRGeometryShadow); +le_swig__p_p_OSRSpatialReferenceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OSRSpatialReferenceShadow,NULL,(char *)(SWIGTYPE_p_p_OSRSpatialReferenceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OSRSpatialReferenceShadow,&le_swig__p_p_OSRSpatialReferenceShadow); +le_swig__p_OSRSpatialReferenceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OSRSpatialReferenceShadow,NULL,(char *)(SWIGTYPE_p_OSRSpatialReferenceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OSRSpatialReferenceShadow,&le_swig__p_OSRSpatialReferenceShadow); +le_swig__p_p_OGRDataSourceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRDataSourceShadow,NULL,(char *)(SWIGTYPE_p_p_OGRDataSourceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRDataSourceShadow,&le_swig__p_p_OGRDataSourceShadow); +le_swig__p_OGRDataSourceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRDataSourceShadow,NULL,(char *)(SWIGTYPE_p_OGRDataSourceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRDataSourceShadow,&le_swig__p_OGRDataSourceShadow); +le_swig__p_OGRFeatureShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRFeatureShadow,NULL,(char *)(SWIGTYPE_p_OGRFeatureShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureShadow,&le_swig__p_OGRFeatureShadow); +le_swig__p_p_OGRFeatureShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRFeatureShadow,NULL,(char *)(SWIGTYPE_p_p_OGRFeatureShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRFeatureShadow,&le_swig__p_p_OGRFeatureShadow); +le_swig__int=zend_register_list_destructors_ex(_wrap_destroy_int,NULL,(char *)(SWIGTYPE_int->name),module_number); +SWIG_TypeClientData(SWIGTYPE_int,&le_swig__int); +le_swig__p_int=zend_register_list_destructors_ex(_wrap_destroy_p_int,NULL,(char *)(SWIGTYPE_p_int->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_int,&le_swig__p_int); +le_swig__p_p_OGRLayerShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRLayerShadow,NULL,(char *)(SWIGTYPE_p_p_OGRLayerShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRLayerShadow,&le_swig__p_p_OGRLayerShadow); +le_swig__p_OGRLayerShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRLayerShadow,NULL,(char *)(SWIGTYPE_p_OGRLayerShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRLayerShadow,&le_swig__p_OGRLayerShadow); +le_swig__p_p_OGRDriverShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRDriverShadow,NULL,(char *)(SWIGTYPE_p_p_OGRDriverShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRDriverShadow,&le_swig__p_p_OGRDriverShadow); +le_swig__p_OGRDriverShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRDriverShadow,NULL,(char *)(SWIGTYPE_p_OGRDriverShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRDriverShadow,&le_swig__p_OGRDriverShadow); +le_swig__p_OGRFeatureDefnShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRFeatureDefnShadow,NULL,(char *)(SWIGTYPE_p_OGRFeatureDefnShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureDefnShadow,&le_swig__p_OGRFeatureDefnShadow); +le_swig__p_OGRFieldDefnShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OGRFieldDefnShadow,NULL,(char *)(SWIGTYPE_p_OGRFieldDefnShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OGRFieldDefnShadow,&le_swig__p_OGRFieldDefnShadow); +le_swig__p_p_OGRFieldDefnShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRFieldDefnShadow,NULL,(char *)(SWIGTYPE_p_p_OGRFieldDefnShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRFieldDefnShadow,&le_swig__p_p_OGRFieldDefnShadow); +le_swig__p_p_OGRFeatureDefnShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OGRFeatureDefnShadow,NULL,(char *)(SWIGTYPE_p_p_OGRFeatureDefnShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OGRFeatureDefnShadow,&le_swig__p_p_OGRFeatureDefnShadow); +le_swig__p_OSRCoordinateTransformationShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OSRCoordinateTransformationShadow,NULL,(char *)(SWIGTYPE_p_OSRCoordinateTransformationShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OSRCoordinateTransformationShadow,&le_swig__p_OSRCoordinateTransformationShadow); +le_swig__p_p_OSRCoordinateTransformationShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OSRCoordinateTransformationShadow,NULL,(char *)(SWIGTYPE_p_p_OSRCoordinateTransformationShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OSRCoordinateTransformationShadow,&le_swig__p_p_OSRCoordinateTransformationShadow); +CG(active_class_entry) = NULL; +/* end oinit subsection */ + + return SUCCESS; +} +PHP_RINIT_FUNCTION(ogr) +{ +/* rinit section */ + +/* cinit subsection */ +REGISTER_LONG_CONSTANT( "wkb25Bit", wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbUnknown", 0, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbPoint", 1, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbLineString", 2, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbPolygon", 3, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiPoint", 4, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiLineString", 5, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiPolygon", 6, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbGeometryCollection", 7, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbNone", 100, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbLinearRing", 101, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbPoint25D", wkbPoint+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbLineString25D", wkbLineString+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbPolygon25D", wkbPolygon+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiPoint25D", wkbMultiPoint+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiLineString25D", wkbMultiLineString+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbMultiPolygon25D", wkbMultiPolygon+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbGeometryCollection25D", wkbGeometryCollection+wkb25DBit, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTInteger", 0, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTIntegerList", 1, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTReal", 2, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTRealList", 3, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTString", 4, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTStringList", 5, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTWideString", 6, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTWideStringList", 7, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OFTBinary", 8, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OJUndefined", 0, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OJLeft", 1, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "OJRight", 2, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbXDR", 0, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT( "wkbNDR", 1, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCRandomRead", "RandomRead", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCSequentialWrite", "SequentialWrite", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCRandomWrite", "RandomWrite", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCFastSpatialFilter", "FastSpatialFilter", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCFastFeatureCount", "FastFeatureCount", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCFastGetExtent", "FastGetExtent", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCCreateField", "CreateField", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCTransactions", "Transactions", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCDeleteFeature", "DeleteFeature", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("OLCFastSetNextByIndex", "FastSetNextByIndex", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("ODsCCreateLayer", "CreateLayer", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("ODsCDeleteLayer", "DeleteLayer", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("ODrCCreateDataSource", "CreateDataSource", CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("ODrCDeleteDataSource", "DeleteDataSource", CONST_CS | CONST_PERSISTENT); +/* end cinit subsection */ + +/* vinit subsection */ +/* end vinit subsection */ + + return SUCCESS; +} +PHP_MSHUTDOWN_FUNCTION(ogr) +{ +/* shutdown section */ + + return SUCCESS; +} +PHP_RSHUTDOWN_FUNCTION(ogr) +{ +/* rshutdown section */ + + return SUCCESS; +} +PHP_MINFO_FUNCTION(ogr) +{ +} +/* end init section */ diff --git a/Utilities/GDAL/swig/php/osr.php b/Utilities/GDAL/swig/php/osr.php new file mode 100644 index 0000000000..43ac476cfc --- /dev/null +++ b/Utilities/GDAL/swig/php/osr.php @@ -0,0 +1,24 @@ +<?php + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +global $OSR_LOADED__; +if ($OSR_LOADED__) return; +$OSR_LOADED__ = true; + +/* if our extension has not been loaded, do what we can */ +if (!extension_loaded("php_osr")) { + if (!dl("php_osr.so")) return; +} + + + +?> diff --git a/Utilities/GDAL/swig/php/osr_wrap.cpp b/Utilities/GDAL/swig/php/osr_wrap.cpp new file mode 100644 index 0000000000..81f5a531ef --- /dev/null +++ b/Utilities/GDAL/swig/php/osr_wrap.cpp @@ -0,0 +1,5279 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* + * php4.swg + * + * PHP4 runtime library + * + */ + +#ifdef __cplusplus +extern "C" { +#endif +#include "zend.h" +#include "zend_API.h" +#include "php.h" + +/* These TSRMLS_ stuff should already be defined now, but with older php under + redhat are not... */ +#ifndef TSRMLS_D +#define TSRMLS_D +#endif +#ifndef TSRMLS_DC +#define TSRMLS_DC +#endif +#ifndef TSRMLS_C +#define TSRMLS_C +#endif +#ifndef TSRMLS_CC +#define TSRMLS_CC +#endif + +#ifdef __cplusplus +} +#endif + +/* But in fact SWIG_ConvertPtr is the native interface for getting typed + pointer values out of zvals. We need the TSRMLS_ macros for when we + make PHP type calls later as we handle php resources */ +#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) + +/* Flags for SWIG_ConvertPtr */ +#define SWIG_POINTER_DISOWN 0x1 + +#define SWIG_fail goto fail + +static char *default_error_msg = "Unknown error occurred"; +static int default_error_code = E_ERROR; + +#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg + +#define SWIG_PHP_Error(code,msg) ErrorCode() = code; ErrorMsg() = msg; SWIG_fail; + +#define SWIG_contract_assert(expr,msg) \ + if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else + +/* Standard SWIG API */ +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) + +/* used to wrap returned objects in so we know whether they are newobject + and need freeing, or not */ +typedef struct _swig_object_wrapper { + void * ptr; + int newobject; +} swig_object_wrapper; + +/* empty zend destructor for types without one */ +static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) {}; + +#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d, SWIG_module_entry TSRMLS_CC) + +static void +SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject, zend_module_entry* module_entry TSRMLS_DC) { + swig_object_wrapper *value=NULL; + /* + * First test for Null pointers. Return those as PHP native NULL + */ + if (!ptr ) { + ZVAL_NULL(z); + return; + } + if (type->clientdata) { + if (! (*(int *)(type->clientdata))) + zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); + value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); + value->ptr=ptr; + value->newobject=newobject; + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + return; + } else { /* have to deal with old fashioned string pointer? + but this should not get this far */ + zend_error(E_ERROR, "Type: %s not registered with zend",type->name); + } +} + +/* This is a new pointer conversion routine + Taking the native pointer p (which would have been converted from the old + string pointer) and it's php type id, and it's type name (which also would + have come from the old string pointer) it converts it to ptr calling + appropriate casting functions according to ty + Sadly PHP has no API to find a type name from a type id, only from an instance + of a resource of the type id, so we have to pass type_name as well. + The two functions which might call this are: + SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource + and the registered zend destructors for which we have one per type each + with the type name hard wired in. */ +static int +SWIG_ZTS_ConvertResourceData(void * p, int type, const char *type_name, void **ptr, swig_type_info *ty TSRMLS_DC) { + swig_cast_info *tc; + + if (ty) { + if (! type_name) { + /* can't convert p to ptr type ty if we don't know what type p is */ + return -1; + } else { + /* convert and cast p from type_name to ptr as ty + Need to sort out const-ness, can SWIG_TypeCast really not take a const? */ + tc = SWIG_TypeCheck((char *)type_name,ty); + if (!tc) return -1; + *ptr = SWIG_TypeCast(tc, (void*)p); + } + } else { + /* They don't care about the target type, so just pass on the pointer! */ + *ptr = (void *) p; + } + return 0; +} + +/* This function fills ptr with a pointer of type ty by extracting the pointer + and type info from the resource in z. z must be a resource + It uses SWIG_ZTS_ConvertResourceData to do the real work. */ +static int +SWIG_ZTS_ConvertResourcePtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + swig_object_wrapper *value; + void *p; + int type; + char *type_name; + + value = (swig_object_wrapper *) zend_list_find(z->value.lval,&type); + if ( flags && SWIG_POINTER_DISOWN ) { + value->newobject = 0; + } + p = value->ptr; + if (type==-1) return -1; + + type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); + + return SWIG_ZTS_ConvertResourceData(p,type,type_name,ptr,ty TSRMLS_CC); +} + +/* We allow passing of a STRING or RESOURCE pointing to the object + or an OBJECT whose _cPtr is a string or resource pointing to the object + STRING pointers are very depracated */ +static int +SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { + char *c; + zval *val; + + if(z == NULL) { + *ptr = 0; + return 0; + } + + if (z->type==IS_OBJECT) { + zval ** _cPtr; + if (zend_hash_find(HASH_OF(z),"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { + /* Don't co-erce to string if it isn't */ + if ((*_cPtr)->type==IS_STRING) c = Z_STRVAL_PP(_cPtr); + else if ((*_cPtr)->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(*_cPtr,ptr,ty, flags TSRMLS_CC); + } else goto type_error; /* _cPtr was not string or resource property */ + } else goto type_error; /* can't find property _cPtr */ + } else if (z->type==IS_RESOURCE) { + return SWIG_ZTS_ConvertResourcePtr(z,ptr,ty, flags TSRMLS_CC); + } else goto type_error; + +type_error: + + return -1; +} + +static char const_name[] = "swig_runtime_data_type_pointer"; +static swig_module_info *SWIG_Php4_GetModule() { + zval *pointer; + swig_module_info *ret = 0; + + MAKE_STD_ZVAL(pointer); + + if (zend_get_constant(const_name, sizeof(const_name), pointer)) { + if (pointer->type == IS_LONG) { + ret = (swig_module_info *) pointer->value.lval; + } + } + return 0; +} + +static void SWIG_Php4_SetModule(swig_module_info *pointer) { + REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); +} + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_double swig_types[0] +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[1] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[2] +#define SWIGTYPE_p_char swig_types[3] +#define SWIGTYPE_p_double swig_types[4] +#define SWIGTYPE_p_int swig_types[5] +#define SWIGTYPE_p_long swig_types[6] +#define SWIGTYPE_p_p_OSRCoordinateTransformationShadow swig_types[7] +#define SWIGTYPE_p_p_OSRSpatialReferenceShadow swig_types[8] +#define SWIGTYPE_p_p_char swig_types[9] +#define SWIGTYPE_p_p_double swig_types[10] +#define SWIGTYPE_p_p_p_char swig_types[11] +static swig_type_info *swig_types[13]; +static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +/* header section */ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ +ZEND_BEGIN_MODULE_GLOBALS(osr) +char *error_msg; +int error_code; +ZEND_END_MODULE_GLOBALS(osr) +ZEND_DECLARE_MODULE_GLOBALS(osr) +#ifdef ZTS +#define ErrorMsg() TSRMG(osr_globals_id, zend_osr_globals *, error_msg ); +#define ErrorCode() TSRMG(osr_globals_id, zend_osr_globals *, error_code ); +#else +#define ErrorMsg() (osr_globals.error_msg) +#define ErrorCode() (osr_globals.error_code) +#endif + +static void osr_init_globals(zend_osr_globals *osr_globals ) { + osr_globals->error_msg = default_error_msg; + osr_globals->error_code = default_error_code; +} +static void osr_destroy_globals(zend_osr_globals *osr_globals) { } + +void SWIG_ResetError() { + ErrorMsg() = default_error_msg; + ErrorCode() = default_error_code; +} +#define SWIG_name "osr" +#ifdef __cplusplus +extern "C" { +#endif +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_osr.h" +#ifdef __cplusplus +} +#endif + + +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + + + +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} + + +void +t_output_helper( zval **target, zval *o) { + if ( (*target)->type == IS_ARRAY ) { + /* it's already an array, just append */ + add_next_index_zval( *target, o ); + return; + } + if ( (*target)->type == IS_NULL ) { + REPLACE_ZVAL_VALUE(target,o,1); + return; + } + zval *tmp; + tmp = *target; + zval_copy_ctor(tmp); + array_init(*target); + add_next_index_zval( *target, tmp); + add_next_index_zval( *target, o); + +} + + +static char * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error 0: None"; + case 1: + return "OGR Error 1: Not enough data"; + case 2: + return "OGR Error 2: Unsupported geometry type"; + case 3: + return "OGR Error 3: Unsupported operation"; + case 4: + return "OGR Error 4: Corrupt data"; + case 5: + return "OGR Error 5: General Error"; + case 6: + return "OGR Error 6: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +static OSRSpatialReferenceShadow *new_OSRSpatialReferenceShadow(char const *wkt=""){ + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } +static void delete_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *self){ + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } +static char *OSRSpatialReferenceShadow___str__(OSRSpatialReferenceShadow *self){ + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } +static int OSRSpatialReferenceShadow_IsSame(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSame( self, rhs ); + } +static int OSRSpatialReferenceShadow_IsSameGeogCS(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSameGeogCS( self, rhs ); + } +static int OSRSpatialReferenceShadow_IsGeographic(OSRSpatialReferenceShadow *self){ + return OSRIsGeographic(self); + } +static int OSRSpatialReferenceShadow_IsProjected(OSRSpatialReferenceShadow *self){ + return OSRIsProjected(self); + } +static char const *OSRSpatialReferenceShadow_GetAttrValue(OSRSpatialReferenceShadow *self,char const *name,int child=0){ + return OSRGetAttrValue( self, name, child ); + } +static OGRErr OSRSpatialReferenceShadow_SetAttrValue(OSRSpatialReferenceShadow *self,char const *name,char const *value){ + return OSRSetAttrValue( self, name, value ); + } +static OGRErr OSRSpatialReferenceShadow_SetAngularUnits(OSRSpatialReferenceShadow *self,char const *name,double to_radians){ + return OSRSetAngularUnits( self, name, to_radians ); + } +static double OSRSpatialReferenceShadow_GetAngularUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetLinearUnits(OSRSpatialReferenceShadow *self,char const *name,double to_meters){ + return OSRSetAngularUnits( self, name, to_meters ); + } +static double OSRSpatialReferenceShadow_GetLinearUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } +static char const *OSRSpatialReferenceShadow_GetLinearUnitsName(OSRSpatialReferenceShadow *self){ + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } +static char const *OSRSpatialReferenceShadow_GetAuthorityCode(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityCode( self, target_key ); + } +static char const *OSRSpatialReferenceShadow_GetAuthorityName(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityName( self, target_key ); + } +static OGRErr OSRSpatialReferenceShadow_SetUTM(OSRSpatialReferenceShadow *self,int zone,int north=1){ + return OSRSetUTM( self, zone, north ); + } +static OGRErr OSRSpatialReferenceShadow_SetStatePlane(OSRSpatialReferenceShadow *self,int zone,int is_nad83=1,char const *unitsname="",double units=0.0){ + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } +static OGRErr OSRSpatialReferenceShadow_AutoIdentifyEPSG(OSRSpatialReferenceShadow *self){ + return OSRAutoIdentifyEPSG( self ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjection(OSRSpatialReferenceShadow *self,char const *arg){ + return OSRSetProjection( self, arg ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetNormProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetACEA(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetAE(OSRSpatialReferenceShadow *self,double clat,double clon,double fe,double fn){ + return OSRSetAE( self, clat, clon, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetCS(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetCS( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetBonne(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetBonne( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEC(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertIV(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertIV( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertVI(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertVI( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEquirectangular(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetGS(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetGS( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetWellKnownGeogCS(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetWellKnownGeogCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_SetFromUserInput(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetFromUserInput( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_CopyGeogCSFrom(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRCopyGeogCSFrom( self, rhs ); + } +static OGRErr OSRSpatialReferenceShadow_SetTOWGS84(OSRSpatialReferenceShadow *self,double p1,double p2,double p3,double p4=0.0,double p5=0.0,double p6=0.0,double p7=0.0){ + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } + + zval * + CreateTupleFromDoubleArray( double *first, unsigned int size ) { + zval *tmp; + MAKE_STD_ZVAL(tmp); + array_init(tmp); + for( unsigned int i=0; i<size; i++ ) { + add_next_index_double( tmp, *first ); + ++first; + } + return tmp; + } + +static OGRErr OSRSpatialReferenceShadow_GetTOWGS84(OSRSpatialReferenceShadow *self,double argout[7]){ + return OSRGetTOWGS84( self, argout, 7 ); + } +static OGRErr OSRSpatialReferenceShadow_SetGeogCS(OSRSpatialReferenceShadow *self,char const *pszGeogName,char const *pszDatumName,char const *pszEllipsoidName,double dfSemiMajor,double dfInvFlattening,char const *pszPMName="Greenwich",double dfPMOffset=0.0,char const *pszUnits="degree",double dfConvertToRadians=0.0174532925199433){ + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjCS(OSRSpatialReferenceShadow *self,char const *name="unnamed"){ + return OSRSetProjCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromWkt(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromWkt( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromProj4(OSRSpatialReferenceShadow *self,char *ppszInput){ + return OSRImportFromProj4( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromESRI(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromESRI( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromEPSG(OSRSpatialReferenceShadow *self,int arg){ + return OSRImportFromEPSG(self, arg); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromPCI(OSRSpatialReferenceShadow *self,char const *proj,char const *units="METRE",double argin[17]=0){ + return OSRImportFromPCI( self, proj, units, argin ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromUSGS(OSRSpatialReferenceShadow *self,long proj_code,long zone=0,double argin[15]=0,long datum_code=0){ + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromXML(OSRSpatialReferenceShadow *self,char const *xmlString){ + return OSRImportFromXML( self, xmlString ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToWkt(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToWkt( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPrettyWkt(OSRSpatialReferenceShadow *self,char **argout,int simplify=0){ + return OSRExportToPrettyWkt( self, argout, simplify ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToProj4(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToProj4( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPCI(OSRSpatialReferenceShadow *self,char **proj,char **units,double *parms[17]){ + return OSRExportToPCI( self, proj, units, parms ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToUSGS(OSRSpatialReferenceShadow *self,long *code,long *zone,double *parms[15],long *datum){ + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToXML(OSRSpatialReferenceShadow *self,char **argout,char const *dialect=""){ + return OSRExportToXML( self, argout, dialect ); + } +static OSRSpatialReferenceShadow *OSRSpatialReferenceShadow_CloneGeogCS(OSRSpatialReferenceShadow *self){ + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } +static OGRErr OSRSpatialReferenceShadow_Validate(OSRSpatialReferenceShadow *self){ + return OSRValidate(self); + } +static OGRErr OSRSpatialReferenceShadow_StripCTParms(OSRSpatialReferenceShadow *self){ + return OSRStripCTParms(self); + } +static OGRErr OSRSpatialReferenceShadow_FixupOrdering(OSRSpatialReferenceShadow *self){ + return OSRFixupOrdering(self); + } +static OGRErr OSRSpatialReferenceShadow_Fixup(OSRSpatialReferenceShadow *self){ + return OSRFixup(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphToESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphToESRI(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphFromESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphFromESRI(self); + } +static int _wrap_propset_SpatialReference(zend_property_reference *property_reference, pval *value); +static int _propset_SpatialReference(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_SpatialReference(zend_property_reference *property_reference); +static int _propget_SpatialReference(zend_property_reference *property_reference, pval *value); +static OSRCoordinateTransformationShadow *new_OSRCoordinateTransformationShadow(OSRSpatialReferenceShadow *src,OSRSpatialReferenceShadow *dst){ + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } +static void delete_OSRCoordinateTransformationShadow(OSRCoordinateTransformationShadow *self){ + OCTDestroyCoordinateTransformation( self ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(OSRCoordinateTransformationShadow *self,double inout[3]){ + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(OSRCoordinateTransformationShadow *self,double argout[3],double x,double y,double z=0.0){ + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } +static int _wrap_propset_CoordinateTransformation(zend_property_reference *property_reference, pval *value); +static int _propset_CoordinateTransformation(zend_property_reference *property_reference, pval *value); +static pval _wrap_propget_CoordinateTransformation(zend_property_reference *property_reference); +static int _propget_CoordinateTransformation(zend_property_reference *property_reference, pval *value); +/* class entry subsection */ +/* Function entries for SpatialReference */ +static zend_function_entry SpatialReference_functions[] = { + ZEND_NAMED_FE(new_spatialreference,_wrap_new_SpatialReference, NULL) + ZEND_NAMED_FE(spatialreference,_wrap_new_SpatialReference, NULL) + ZEND_NAMED_FE(spatialreference___str__,_wrap_SpatialReference___str__, NULL) + ZEND_NAMED_FE(__str__,_wrap_SpatialReference___str__, NULL) + ZEND_NAMED_FE(spatialreference_issame,_wrap_SpatialReference_IsSame, NULL) + ZEND_NAMED_FE(issame,_wrap_SpatialReference_IsSame, NULL) + ZEND_NAMED_FE(spatialreference_issamegeogcs,_wrap_SpatialReference_IsSameGeogCS, NULL) + ZEND_NAMED_FE(issamegeogcs,_wrap_SpatialReference_IsSameGeogCS, NULL) + ZEND_NAMED_FE(spatialreference_isgeographic,_wrap_SpatialReference_IsGeographic, NULL) + ZEND_NAMED_FE(isgeographic,_wrap_SpatialReference_IsGeographic, NULL) + ZEND_NAMED_FE(spatialreference_isprojected,_wrap_SpatialReference_IsProjected, NULL) + ZEND_NAMED_FE(isprojected,_wrap_SpatialReference_IsProjected, NULL) + ZEND_NAMED_FE(spatialreference_getattrvalue,_wrap_SpatialReference_GetAttrValue, NULL) + ZEND_NAMED_FE(getattrvalue,_wrap_SpatialReference_GetAttrValue, NULL) + ZEND_NAMED_FE(spatialreference_setattrvalue,_wrap_SpatialReference_SetAttrValue, NULL) + ZEND_NAMED_FE(setattrvalue,_wrap_SpatialReference_SetAttrValue, NULL) + ZEND_NAMED_FE(spatialreference_setangularunits,_wrap_SpatialReference_SetAngularUnits, NULL) + ZEND_NAMED_FE(setangularunits,_wrap_SpatialReference_SetAngularUnits, NULL) + ZEND_NAMED_FE(spatialreference_getangularunits,_wrap_SpatialReference_GetAngularUnits, NULL) + ZEND_NAMED_FE(getangularunits,_wrap_SpatialReference_GetAngularUnits, NULL) + ZEND_NAMED_FE(spatialreference_setlinearunits,_wrap_SpatialReference_SetLinearUnits, NULL) + ZEND_NAMED_FE(setlinearunits,_wrap_SpatialReference_SetLinearUnits, NULL) + ZEND_NAMED_FE(spatialreference_getlinearunits,_wrap_SpatialReference_GetLinearUnits, NULL) + ZEND_NAMED_FE(getlinearunits,_wrap_SpatialReference_GetLinearUnits, NULL) + ZEND_NAMED_FE(spatialreference_getlinearunitsname,_wrap_SpatialReference_GetLinearUnitsName, NULL) + ZEND_NAMED_FE(getlinearunitsname,_wrap_SpatialReference_GetLinearUnitsName, NULL) + ZEND_NAMED_FE(spatialreference_getauthoritycode,_wrap_SpatialReference_GetAuthorityCode, NULL) + ZEND_NAMED_FE(getauthoritycode,_wrap_SpatialReference_GetAuthorityCode, NULL) + ZEND_NAMED_FE(spatialreference_getauthorityname,_wrap_SpatialReference_GetAuthorityName, NULL) + ZEND_NAMED_FE(getauthorityname,_wrap_SpatialReference_GetAuthorityName, NULL) + ZEND_NAMED_FE(spatialreference_setutm,_wrap_SpatialReference_SetUTM, NULL) + ZEND_NAMED_FE(setutm,_wrap_SpatialReference_SetUTM, NULL) + ZEND_NAMED_FE(spatialreference_setstateplane,_wrap_SpatialReference_SetStatePlane, NULL) + ZEND_NAMED_FE(setstateplane,_wrap_SpatialReference_SetStatePlane, NULL) + ZEND_NAMED_FE(spatialreference_autoidentifyepsg,_wrap_SpatialReference_AutoIdentifyEPSG, NULL) + ZEND_NAMED_FE(autoidentifyepsg,_wrap_SpatialReference_AutoIdentifyEPSG, NULL) + ZEND_NAMED_FE(spatialreference_setprojection,_wrap_SpatialReference_SetProjection, NULL) + ZEND_NAMED_FE(setprojection,_wrap_SpatialReference_SetProjection, NULL) + ZEND_NAMED_FE(spatialreference_setprojparm,_wrap_SpatialReference_SetProjParm, NULL) + ZEND_NAMED_FE(setprojparm,_wrap_SpatialReference_SetProjParm, NULL) + ZEND_NAMED_FE(spatialreference_getprojparm,_wrap_SpatialReference_GetProjParm, NULL) + ZEND_NAMED_FE(getprojparm,_wrap_SpatialReference_GetProjParm, NULL) + ZEND_NAMED_FE(spatialreference_setnormprojparm,_wrap_SpatialReference_SetNormProjParm, NULL) + ZEND_NAMED_FE(setnormprojparm,_wrap_SpatialReference_SetNormProjParm, NULL) + ZEND_NAMED_FE(spatialreference_getnormprojparm,_wrap_SpatialReference_GetNormProjParm, NULL) + ZEND_NAMED_FE(getnormprojparm,_wrap_SpatialReference_GetNormProjParm, NULL) + ZEND_NAMED_FE(spatialreference_setacea,_wrap_SpatialReference_SetACEA, NULL) + ZEND_NAMED_FE(setacea,_wrap_SpatialReference_SetACEA, NULL) + ZEND_NAMED_FE(spatialreference_setae,_wrap_SpatialReference_SetAE, NULL) + ZEND_NAMED_FE(setae,_wrap_SpatialReference_SetAE, NULL) + ZEND_NAMED_FE(spatialreference_setcs,_wrap_SpatialReference_SetCS, NULL) + ZEND_NAMED_FE(setcs,_wrap_SpatialReference_SetCS, NULL) + ZEND_NAMED_FE(spatialreference_setbonne,_wrap_SpatialReference_SetBonne, NULL) + ZEND_NAMED_FE(setbonne,_wrap_SpatialReference_SetBonne, NULL) + ZEND_NAMED_FE(spatialreference_setec,_wrap_SpatialReference_SetEC, NULL) + ZEND_NAMED_FE(setec,_wrap_SpatialReference_SetEC, NULL) + ZEND_NAMED_FE(spatialreference_seteckertiv,_wrap_SpatialReference_SetEckertIV, NULL) + ZEND_NAMED_FE(seteckertiv,_wrap_SpatialReference_SetEckertIV, NULL) + ZEND_NAMED_FE(spatialreference_seteckertvi,_wrap_SpatialReference_SetEckertVI, NULL) + ZEND_NAMED_FE(seteckertvi,_wrap_SpatialReference_SetEckertVI, NULL) + ZEND_NAMED_FE(spatialreference_setequirectangular,_wrap_SpatialReference_SetEquirectangular, NULL) + ZEND_NAMED_FE(setequirectangular,_wrap_SpatialReference_SetEquirectangular, NULL) + ZEND_NAMED_FE(spatialreference_setgs,_wrap_SpatialReference_SetGS, NULL) + ZEND_NAMED_FE(setgs,_wrap_SpatialReference_SetGS, NULL) + ZEND_NAMED_FE(spatialreference_setwellknowngeogcs,_wrap_SpatialReference_SetWellKnownGeogCS, NULL) + ZEND_NAMED_FE(setwellknowngeogcs,_wrap_SpatialReference_SetWellKnownGeogCS, NULL) + ZEND_NAMED_FE(spatialreference_setfromuserinput,_wrap_SpatialReference_SetFromUserInput, NULL) + ZEND_NAMED_FE(setfromuserinput,_wrap_SpatialReference_SetFromUserInput, NULL) + ZEND_NAMED_FE(spatialreference_copygeogcsfrom,_wrap_SpatialReference_CopyGeogCSFrom, NULL) + ZEND_NAMED_FE(copygeogcsfrom,_wrap_SpatialReference_CopyGeogCSFrom, NULL) + ZEND_NAMED_FE(spatialreference_settowgs84,_wrap_SpatialReference_SetTOWGS84, NULL) + ZEND_NAMED_FE(settowgs84,_wrap_SpatialReference_SetTOWGS84, NULL) + ZEND_NAMED_FE(spatialreference_gettowgs84,_wrap_SpatialReference_GetTOWGS84, NULL) + ZEND_NAMED_FE(gettowgs84,_wrap_SpatialReference_GetTOWGS84, NULL) + ZEND_NAMED_FE(spatialreference_setgeogcs,_wrap_SpatialReference_SetGeogCS, NULL) + ZEND_NAMED_FE(setgeogcs,_wrap_SpatialReference_SetGeogCS, NULL) + ZEND_NAMED_FE(spatialreference_setprojcs,_wrap_SpatialReference_SetProjCS, NULL) + ZEND_NAMED_FE(setprojcs,_wrap_SpatialReference_SetProjCS, NULL) + ZEND_NAMED_FE(spatialreference_importfromwkt,_wrap_SpatialReference_ImportFromWkt, NULL) + ZEND_NAMED_FE(importfromwkt,_wrap_SpatialReference_ImportFromWkt, NULL) + ZEND_NAMED_FE(spatialreference_importfromproj4,_wrap_SpatialReference_ImportFromProj4, NULL) + ZEND_NAMED_FE(importfromproj4,_wrap_SpatialReference_ImportFromProj4, NULL) + ZEND_NAMED_FE(spatialreference_importfromesri,_wrap_SpatialReference_ImportFromESRI, NULL) + ZEND_NAMED_FE(importfromesri,_wrap_SpatialReference_ImportFromESRI, NULL) + ZEND_NAMED_FE(spatialreference_importfromepsg,_wrap_SpatialReference_ImportFromEPSG, NULL) + ZEND_NAMED_FE(importfromepsg,_wrap_SpatialReference_ImportFromEPSG, NULL) + ZEND_NAMED_FE(spatialreference_importfrompci,_wrap_SpatialReference_ImportFromPCI, NULL) + ZEND_NAMED_FE(importfrompci,_wrap_SpatialReference_ImportFromPCI, NULL) + ZEND_NAMED_FE(spatialreference_importfromusgs,_wrap_SpatialReference_ImportFromUSGS, NULL) + ZEND_NAMED_FE(importfromusgs,_wrap_SpatialReference_ImportFromUSGS, NULL) + ZEND_NAMED_FE(spatialreference_importfromxml,_wrap_SpatialReference_ImportFromXML, NULL) + ZEND_NAMED_FE(importfromxml,_wrap_SpatialReference_ImportFromXML, NULL) + ZEND_NAMED_FE(spatialreference_exporttowkt,_wrap_SpatialReference_ExportToWkt, NULL) + ZEND_NAMED_FE(exporttowkt,_wrap_SpatialReference_ExportToWkt, NULL) + ZEND_NAMED_FE(spatialreference_exporttoprettywkt,_wrap_SpatialReference_ExportToPrettyWkt, NULL) + ZEND_NAMED_FE(exporttoprettywkt,_wrap_SpatialReference_ExportToPrettyWkt, NULL) + ZEND_NAMED_FE(spatialreference_exporttoproj4,_wrap_SpatialReference_ExportToProj4, NULL) + ZEND_NAMED_FE(exporttoproj4,_wrap_SpatialReference_ExportToProj4, NULL) + ZEND_NAMED_FE(spatialreference_exporttopci,_wrap_SpatialReference_ExportToPCI, NULL) + ZEND_NAMED_FE(exporttopci,_wrap_SpatialReference_ExportToPCI, NULL) + ZEND_NAMED_FE(spatialreference_exporttousgs,_wrap_SpatialReference_ExportToUSGS, NULL) + ZEND_NAMED_FE(exporttousgs,_wrap_SpatialReference_ExportToUSGS, NULL) + ZEND_NAMED_FE(spatialreference_exporttoxml,_wrap_SpatialReference_ExportToXML, NULL) + ZEND_NAMED_FE(exporttoxml,_wrap_SpatialReference_ExportToXML, NULL) + ZEND_NAMED_FE(spatialreference_clonegeogcs,_wrap_SpatialReference_CloneGeogCS, NULL) + ZEND_NAMED_FE(clonegeogcs,_wrap_SpatialReference_CloneGeogCS, NULL) + ZEND_NAMED_FE(spatialreference_validate,_wrap_SpatialReference_Validate, NULL) + ZEND_NAMED_FE(validate,_wrap_SpatialReference_Validate, NULL) + ZEND_NAMED_FE(spatialreference_stripctparms,_wrap_SpatialReference_StripCTParms, NULL) + ZEND_NAMED_FE(stripctparms,_wrap_SpatialReference_StripCTParms, NULL) + ZEND_NAMED_FE(spatialreference_fixupordering,_wrap_SpatialReference_FixupOrdering, NULL) + ZEND_NAMED_FE(fixupordering,_wrap_SpatialReference_FixupOrdering, NULL) + ZEND_NAMED_FE(spatialreference_fixup,_wrap_SpatialReference_Fixup, NULL) + ZEND_NAMED_FE(fixup,_wrap_SpatialReference_Fixup, NULL) + ZEND_NAMED_FE(spatialreference_morphtoesri,_wrap_SpatialReference_MorphToESRI, NULL) + ZEND_NAMED_FE(morphtoesri,_wrap_SpatialReference_MorphToESRI, NULL) + ZEND_NAMED_FE(spatialreference_morphfromesri,_wrap_SpatialReference_MorphFromESRI, NULL) + ZEND_NAMED_FE(morphfromesri,_wrap_SpatialReference_MorphFromESRI, NULL) + { NULL, NULL, NULL} +}; +/* Function entries for CoordinateTransformation */ +static zend_function_entry CoordinateTransformation_functions[] = { + ZEND_NAMED_FE(new_coordinatetransformation,_wrap_new_CoordinateTransformation, NULL) + ZEND_NAMED_FE(coordinatetransformation,_wrap_new_CoordinateTransformation, NULL) + ZEND_NAMED_FE(transformpoint,_wrap_CoordinateTransformation_TransformPoint, NULL) + ZEND_NAMED_FE(coordinatetransformation_transformpoint,_wrap_CoordinateTransformation_TransformPoint, NULL) + ZEND_NAMED_FE(transformpoint,_wrap_CoordinateTransformation_TransformPoint, NULL) + { NULL, NULL, NULL} +}; + + +/* entry subsection */ +/* Every non-class user visible function must have an entry here */ +function_entry osr_functions[] = { + ZEND_NAMED_FE(getwellknowngeogcsaswkt,_wrap_GetWellKnownGeogCSAsWKT, NULL) + ZEND_NAMED_FE(getprojectionmethods,_wrap_GetProjectionMethods, NULL) + ZEND_NAMED_FE(getprojectionmethodparameterlist,_wrap_GetProjectionMethodParameterList, NULL) + ZEND_NAMED_FE(getprojectionmethodparaminfo,_wrap_GetProjectionMethodParamInfo, NULL) + {NULL, NULL, NULL} +}; + +zend_module_entry osr_module_entry = { +#if ZEND_MODULE_API_NO > 20010900 + STANDARD_MODULE_HEADER, +#endif + "osr", + osr_functions, + PHP_MINIT(osr), + PHP_MSHUTDOWN(osr), + PHP_RINIT(osr), + PHP_RSHUTDOWN(osr), + PHP_MINFO(osr), +#if ZEND_MODULE_API_NO > 20010900 + NO_VERSION_YET, +#endif + STANDARD_MODULE_PROPERTIES +}; +zend_module_entry* SWIG_module_entry = &osr_module_entry; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__double = {"_double", "double", 0, 0, 0}; +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|OGRErr *", 0, 0, 0}; +static swig_type_info _swigt__p_long = {"_p_long", "long *", 0, 0, 0}; +static swig_type_info _swigt__p_p_OSRCoordinateTransformationShadow = {"_p_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_OSRSpatialReferenceShadow = {"_p_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow **", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; +static swig_type_info _swigt__p_p_double = {"_p_p_double", "double **", 0, 0, 0}; +static swig_type_info _swigt__p_p_p_char = {"_p_p_p_char", "char ***", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__double, + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_long, + &_swigt__p_p_OSRCoordinateTransformationShadow, + &_swigt__p_p_OSRSpatialReferenceShadow, + &_swigt__p_p_char, + &_swigt__p_p_double, + &_swigt__p_p_p_char, +}; + +static swig_cast_info _swigc__double[] = { {&_swigt__double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_OSRSpatialReferenceShadow[] = { {&_swigt__p_p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_double[] = { {&_swigt__p_p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_p_char[] = { {&_swigt__p_p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__double, + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_long, + _swigc__p_p_OSRCoordinateTransformationShadow, + _swigc__p_p_OSRSpatialReferenceShadow, + _swigc__p_p_char, + _swigc__p_p_double, + _swigc__p_p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/* end header section */ +/* vdecl subsection */ +static zend_class_entry ce_swig_SpatialReference; +static zend_class_entry* ptr_ce_swig_SpatialReference=NULL; +static zend_class_entry ce_swig_CoordinateTransformation; +static zend_class_entry* ptr_ce_swig_CoordinateTransformation=NULL; +static int le_swig__p_char=0; /* handle for */ +static int le_swig__double=0; /* handle for */ +static int le_swig__p_p_char=0; /* handle for */ +static int le_swig__p_p_p_char=0; /* handle for */ +static int le_swig__p_double=0; /* handle for */ +static int le_swig__p_p_double=0; /* handle for */ +static int le_swig__p_long=0; /* handle for */ +static int le_swig__p_OSRCoordinateTransformationShadow=0; /* handle for CoordinateTransformation */ +static int le_swig__p_p_OSRCoordinateTransformationShadow=0; /* handle for CoordinateTransformation */ +static int le_swig__p_int=0; /* handle for CoordinateTransformation */ +static int le_swig__p_OSRSpatialReferenceShadow=0; /* handle for SpatialReference */ +static int le_swig__p_p_OSRSpatialReferenceShadow=0; /* handle for SpatialReference */ +/* end vdecl subsection */ +/* wrapper section */ +ZEND_NAMED_FUNCTION(_wrap_GetWellKnownGeogCSAsWKT) { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + zval **args[1]; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethods) { + char **result; + zval **args[0]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + result = (char **)OPTGetProjectionMethods(); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_p_char, 0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethodParameterList) { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + char **result; + zval **args[2]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg2, SWIGTYPE_p_p_char, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of GetProjectionMethodParameterList. Expected SWIGTYPE_p_p_p_char"); + } + } + result = (char **)OPTGetParameterList(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_p_char, 0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethodParamInfo) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + char **arg4 = (char **) 0 ; + double *arg5 = (double *) 0 ; + zval **args[5]; + + SWIG_ResetError(); + if(((ZEND_NUM_ARGS() )!= 5) || (zend_get_parameters_array_ex(5, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg2 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[2], (void **) &arg3, SWIGTYPE_p_p_char, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 3 of GetProjectionMethodParamInfo. Expected SWIGTYPE_p_p_p_char"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[3], (void **) &arg4, SWIGTYPE_p_p_char, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 4 of GetProjectionMethodParamInfo. Expected SWIGTYPE_p_p_p_char"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[4], (void **) &arg5, SWIGTYPE_p_double, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 5 of GetProjectionMethodParamInfo. Expected SWIGTYPE_p_p_double"); + } + } + OPTGetParameterInfo(arg1,arg2,arg3,arg4,arg5); + + + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_new_SpatialReference) { + char *arg1 = (char *) "" ; + OSRSpatialReferenceShadow *result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* NATIVE Constructor */ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<0 || arg_count>1) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + if(arg_count > 0) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg1 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (OSRSpatialReferenceShadow *)new_OSRSpatialReferenceShadow((char const *)arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OSRSpatialReferenceShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_SpatialReference); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_SpatialReference(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OSRSpatialReferenceShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OSRSpatialReferenceShadow resource already free'd"); + delete_OSRSpatialReferenceShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference___str__) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference___str__. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (char *)OSRSpatialReferenceShadow___str__(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSame) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_IsSame. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of SpatialReference_IsSame. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (int)OSRSpatialReferenceShadow_IsSame(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSameGeogCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_IsSameGeogCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of SpatialReference_IsSameGeogCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (int)OSRSpatialReferenceShadow_IsSameGeogCS(arg1,arg2); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsGeographic) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_IsGeographic. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (int)OSRSpatialReferenceShadow_IsGeographic(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsProjected) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_IsProjected. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (int)OSRSpatialReferenceShadow_IsProjected(arg1); + + { + ZVAL_LONG(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAttrValue) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetAttrValue. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (char *)OSRSpatialReferenceShadow_GetAttrValue(arg1,(char const *)arg2,arg3); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAttrValue) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRErr result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetAttrValue. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAttrValue(arg1,(char const *)arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAngularUnits) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetAngularUnits. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAngularUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAngularUnits) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetAngularUnits. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (double)OSRSpatialReferenceShadow_GetAngularUnits(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetLinearUnits) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetLinearUnits. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetLinearUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnits) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetLinearUnits. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (double)OSRSpatialReferenceShadow_GetLinearUnits(arg1); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnitsName) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetLinearUnitsName. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (char *)OSRSpatialReferenceShadow_GetLinearUnitsName(arg1); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityCode) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetAuthorityCode. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityCode(arg1,(char const *)arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityName) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetAuthorityName. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityName(arg1,(char const *)arg2); + + { + if(!result) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value,result, 1); + } + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetUTM) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetUTM. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetUTM(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetStatePlane) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + char *arg4 = (char *) "" ; + double arg5 = (double) 0.0 ; + OGRErr result; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetStatePlane. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (int) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg4 = (char *) Z_STRVAL_PP(args[2]); + /*@@*/; + } + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetStatePlane(arg1,arg2,arg3,(char const *)arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_AutoIdentifyEPSG) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_AutoIdentifyEPSG. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_AutoIdentifyEPSG(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjection) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetProjection. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjection(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjParm) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetProjParm. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetProjParm) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetProjParm. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + } + result = (double)OSRSpatialReferenceShadow_GetProjParm(arg1,(char const *)arg2,arg3); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetNormProjParm) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + zval **args[2]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetNormProjParm. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetNormProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetNormProjParm) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + zval **args[2]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>3) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetNormProjParm. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + } + result = (double)OSRSpatialReferenceShadow_GetNormProjParm(arg1,(char const *)arg2,arg3); + + { + ZVAL_DOUBLE(return_value,result); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetACEA) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + zval **args[6]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 6) || (zend_get_parameters_array_ex(6, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetACEA. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg6 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[5]); + arg7 = (double) Z_DVAL_PP(args[5]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetACEA(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAE) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + zval **args[4]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 4) || (zend_get_parameters_array_ex(4, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetAE. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAE(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + zval **args[4]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 4) || (zend_get_parameters_array_ex(4, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetCS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetBonne) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + zval **args[4]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 4) || (zend_get_parameters_array_ex(4, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetBonne. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetBonne(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEC) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + zval **args[6]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 6) || (zend_get_parameters_array_ex(6, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetEC. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg6 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[5]); + arg7 = (double) Z_DVAL_PP(args[5]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEC(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertIV) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + zval **args[3]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 3) || (zend_get_parameters_array_ex(3, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetEckertIV. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertIV(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertVI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + zval **args[3]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 3) || (zend_get_parameters_array_ex(3, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetEckertVI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertVI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEquirectangular) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + zval **args[4]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 4) || (zend_get_parameters_array_ex(4, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetEquirectangular. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEquirectangular(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + zval **args[3]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 3) || (zend_get_parameters_array_ex(3, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetGS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetGS(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetWellKnownGeogCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetWellKnownGeogCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetWellKnownGeogCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetFromUserInput) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetFromUserInput. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetFromUserInput(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CopyGeogCSFrom) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_CopyGeogCSFrom. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of SpatialReference_CopyGeogCSFrom. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_CopyGeogCSFrom(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetTOWGS84) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double arg6 = (double) 0.0 ; + double arg7 = (double) 0.0 ; + double arg8 = (double) 0.0 ; + OGRErr result; + zval **args[7]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<4 || arg_count>8) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetTOWGS84. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg2 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg3 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg4 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + } + if(arg_count > 5) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg6 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + } + if(arg_count > 6) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[5]); + arg7 = (double) Z_DVAL_PP(args[5]); + /*@@*/; + } + } + if(arg_count > 7) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[6]); + arg8 = (double) Z_DVAL_PP(args[6]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetTOWGS84(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetTOWGS84) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double *arg2 ; + OGRErr result; + double argout2[7] ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_GetTOWGS84. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_GetTOWGS84(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 7 ); + t_output_helper( &return_value, t ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGeogCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + double arg5 ; + double arg6 ; + char *arg7 = (char *) "Greenwich" ; + double arg8 = (double) 0.0 ; + char *arg9 = (char *) "degree" ; + double arg10 = (double) 0.0174532925199433 ; + OGRErr result; + zval **args[9]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<6 || arg_count>10) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetGeogCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[2]); + arg4 = (char *) Z_STRVAL_PP(args[2]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[3]); + arg5 = (double) Z_DVAL_PP(args[3]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[4]); + arg6 = (double) Z_DVAL_PP(args[4]); + /*@@*/; + } + if(arg_count > 6) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[5]); + arg7 = (char *) Z_STRVAL_PP(args[5]); + /*@@*/; + } + } + if(arg_count > 7) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[6]); + arg8 = (double) Z_DVAL_PP(args[6]); + /*@@*/; + } + } + if(arg_count > 8) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[7]); + arg9 = (char *) Z_STRVAL_PP(args[7]); + /*@@*/; + } + } + if(arg_count > 9) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[8]); + arg10 = (double) Z_DVAL_PP(args[8]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetGeogCS(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,(char const *)arg7,arg8,(char const *)arg9,arg10); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) "unnamed" ; + OGRErr result; + zval **args[1]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_SetProjCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromWkt) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromWkt. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* %typemap(in) (char **ignorechange) */ + convert_to_string_ex( args[0] ); + arg2 = NULL; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromProj4) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromProj4. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromESRI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromESRI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* %typemap(in) (char **ignorechange) */ + convert_to_string_ex( args[0] ); + arg2 = NULL; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromESRI(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromEPSG) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromEPSG. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromEPSG(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromPCI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "METRE" ; + double *arg4 = (double *) (double *)0 ; + OGRErr result; + double argin4[17] ; + zval **args[3]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromPCI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[1]); + arg3 = (char *) Z_STRVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /* %typemap(in) (double argin4[ANY]) */ + arg4 = argin4; + for (unsigned int i=0; i<17; i++) { + double val = 0.0; /* extract val from i-th position of args[2] */ + arg4[i] = val; + } + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromPCI(arg1,(char const *)arg2,(char const *)arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromUSGS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long arg2 ; + long arg3 = (long) 0 ; + double *arg4 = (double *) (double *)0 ; + long arg5 = (long) 0 ; + OGRErr result; + double argin4[15] ; + zval **args[4]; + int arg_count; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<2 || arg_count>5) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromUSGS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg2 = (long) Z_LVAL_PP(args[0]); + /*@@*/; + } + if(arg_count > 2) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[1]); + arg3 = (long) Z_LVAL_PP(args[1]); + /*@@*/; + } + } + if(arg_count > 3) { + { + /* %typemap(in) (double argin4[ANY]) */ + arg4 = argin4; + for (unsigned int i=0; i<15; i++) { + double val = 0.0; /* extract val from i-th position of args[2] */ + arg4[i] = val; + } + } + } + if(arg_count > 4) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[3]); + arg5 = (long) Z_LVAL_PP(args[3]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromXML) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ImportFromXML. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg2 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromXML(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToWkt) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToWkt. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPrettyWkt) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + int arg3 = (int) 0 ; + OGRErr result; + char *argout2 = 0 ; + zval **args[1]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToPrettyWkt. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,4,CONVERT_INT_IN@*/ + convert_to_long_ex(args[0]); + arg3 = (int) Z_LVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPrettyWkt(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToProj4) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToProj4. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPCI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char **arg3 = (char **) 0 ; + double **arg4 ; + OGRErr result; + char *argout2 = 0 ; + char *argout3 = 0 ; + double *argout4 ; + zval **args[0]; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + { + /* %typemap(in,numinputs=0) (char **argout3) */ + arg3 = &argout3; + } + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToPCI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPCI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg3 ) { + ZVAL_STRING(t,*arg3,strlen(*arg3)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(argout) (double *argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( *arg4, 17 ); + t_output_helper( &return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToUSGS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + double **arg4 ; + long *arg5 = (long *) 0 ; + OGRErr result; + long temp2 ; + long temp3 ; + double *argout4 ; + long temp5 ; + zval **args[0]; + + { + arg2 = &temp2; + } + { + arg3 = &temp3; + } + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + { + arg5 = &temp5; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToUSGS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_LONG(o,temp2); + t_output_helper( &return_value, o ); + } + { + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_LONG(o,temp3); + t_output_helper( &return_value, o ); + } + { + /* %typemap(argout) (double *argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( *arg4, 15 ); + t_output_helper( &return_value, t); + } + { + zval *o; + MAKE_STD_ZVAL(o); + ZVAL_LONG(o,temp5); + t_output_helper( &return_value, o ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToXML) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + OGRErr result; + char *argout2 = 0 ; + zval **args[1]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<1 || arg_count>2) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_ExportToXML. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + if(arg_count > 1) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,23,CONVERT_STRING_IN@*/ + convert_to_string_ex(args[0]); + arg3 = (char *) Z_STRVAL_PP(args[0]); + /*@@*/; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToXML(arg1,arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + zval *t; + MAKE_STD_ZVAL(t); + if ( arg2 ) { + ZVAL_STRING(t,*arg2,strlen(*arg2)); + } + else { + ZVAL_NULL(t); + } + t_output_helper(&return_value, t); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CloneGeogCS) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_CloneGeogCS. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OSRSpatialReferenceShadow *)OSRSpatialReferenceShadow_CloneGeogCS(arg1); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OSRSpatialReferenceShadow, 1); + } + /* Wrap this return value */ + { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_SpatialReference); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Validate) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_Validate. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_Validate(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_StripCTParms) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_StripCTParms. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_StripCTParms(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_FixupOrdering) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_FixupOrdering. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_FixupOrdering(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Fixup) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_Fixup. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_Fixup(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphToESRI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_MorphToESRI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_MorphToESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphFromESRI) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + zval **args[0]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 0) || (zend_get_parameters_array_ex(0, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of SpatialReference_MorphFromESRI. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OGRErr)OSRSpatialReferenceShadow_MorphFromESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0 ) { + SWIG_PHP_Error(E_ERROR,OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + RETVAL_LONG(0); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* property handler for class SpatialReference */ +static pval _wrap_propget_SpatialReference(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_SpatialReference(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_SpatialReference(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_SpatialReference(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_SpatialReference(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is SpatialReference */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_SpatialReference(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +ZEND_NAMED_FUNCTION(_wrap_new_CoordinateTransformation) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OSRCoordinateTransformationShadow *result; + zval **args[2]; + + SWIG_ResetError(); + /* NATIVE Constructor */ + if(((ZEND_NUM_ARGS() )!= 2) || (zend_get_parameters_array_ex(2, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[0], (void **) &arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of new_CoordinateTransformation. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*args[1], (void **) &arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 2 of new_CoordinateTransformation. Expected SWIGTYPE_p_p_OSRSpatialReferenceShadow"); + } + } + result = (OSRCoordinateTransformationShadow *)new_OSRCoordinateTransformationShadow(arg1,arg2); + + { + SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_OSRCoordinateTransformationShadow, 1); + } + /* Wrap this return value */ + if (this_ptr) { + /* NATIVE Constructor, use this_ptr */ + zval *_cPtr; MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + add_property_zval(this_ptr,"_cPtr",_cPtr); + } else if (! this_ptr) { + /* ALTERNATIVE Constructor, make an object wrapper */ + zval *obj, *_cPtr; + MAKE_STD_ZVAL(obj); + MAKE_STD_ZVAL(_cPtr); + *_cPtr = *return_value; + INIT_ZVAL(*return_value); + object_init_ex(obj,ptr_ce_swig_CoordinateTransformation); + add_property_zval(obj,"_cPtr",_cPtr); + *return_value=*obj; + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +/* This function is designed to be called by the zend list destructors */ +/* to typecast and do the actual destruction */ +void __wrap_delete_CoordinateTransformation(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) { + swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr ; + void *ptr=value->ptr ; + int newobject=value->newobject ; + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + + efree(value); + if (! newobject) return; /* can't delete it! */ + SWIG_ZTS_ConvertResourceData(ptr,rsrc->type,type_name,(void **) &arg1,SWIGTYPE_p_OSRCoordinateTransformationShadow TSRMLS_CC); + if (! arg1) zend_error(E_ERROR, "OSRCoordinateTransformationShadow resource already free'd"); + delete_OSRCoordinateTransformationShadow(arg1); + +} + + +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint__SWIG_0) { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double argin2[3] ; + zval **args[1]; + + SWIG_ResetError(); + /* This function uses a this_ptr*/ + if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) { + WRONG_PARAM_COUNT; + } + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of CoordinateTransformation_TransformPoint. Expected SWIGTYPE_p_p_OSRCoordinateTransformationShadow"); + } + } + { + /* %typemap(in) (double argin2[ANY]) */ + arg2 = argin2; + for (unsigned int i=0; i<3; i++) { + double val = 0.0; /* extract val from i-th position of args[0] */ + arg2[i] = val; + } + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(arg1,arg2); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 3 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint__SWIG_1) { + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double argout2[3] ; + zval **args[3]; + int arg_count; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + SWIG_ResetError(); + /* This function uses a this_ptr*/ + arg_count = ZEND_NUM_ARGS(); + if(arg_count<3 || arg_count>4) + WRONG_PARAM_COUNT; + + if(zend_get_parameters_array_ex(arg_count,args)!=SUCCESS) + WRONG_PARAM_COUNT; + + { + /* typemap(in) SWIGTYPE * */ + if(SWIG_ConvertPtr(*&this_ptr, (void **) &arg1, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument 1 of CoordinateTransformation_TransformPoint. Expected SWIGTYPE_p_p_OSRCoordinateTransformationShadow"); + } + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[0]); + arg3 = (double) Z_DVAL_PP(args[0]); + /*@@*/; + } + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[1]); + arg4 = (double) Z_DVAL_PP(args[1]); + /*@@*/; + } + if(arg_count > 3) { + { + /*@/home/kruland/opt/share/swig/1.3.26/php4/utils.i,13,CONVERT_FLOAT_IN@*/ + convert_to_double_ex(args[2]); + arg5 = (double) Z_DVAL_PP(args[2]); + /*@@*/; + } + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(arg1,arg2,arg3,arg4,arg5); + + + { + /* %typemap(argout) (double argout[ANY]) */ + zval *t = CreateTupleFromDoubleArray( arg2, 3 ); + t_output_helper( &return_value, t ); + } + return; + fail: + zend_error(ErrorCode(),ErrorMsg()); +} + + +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint) { + int argc; + zval **argv[4]; + int ii; + + argc = ZEND_NUM_ARGS(); + zend_get_parameters_array_ex(argc,argv); + if (argc == 2) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) < 0)? 0:1; + } + if (_v) { + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[1], (void**)&tmp, SWIGTYPE_p_double, 0) < 0)? 0:1; + } + if (_v) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + if ((argc >= 3) && (argc <= 4)) { + int _v; + { + /* typecheck SWIGTYPE * */ + void *tmp; + _v = (SWIG_ConvertPtr( *argv[0], (void**)&tmp, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) < 0)? 0:1; + } + if (_v) { + _v = (Z_TYPE_PP(argv[1]) == IS_LONG || + Z_TYPE_PP(argv[1]) == IS_DOUBLE || + Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; + if (_v) { + _v = (Z_TYPE_PP(argv[2]) == IS_LONG || + Z_TYPE_PP(argv[2]) == IS_DOUBLE || + Z_TYPE_PP(argv[2]) == IS_STRING) ? 1 : 0; + if (_v) { + if (argc <= 3) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + _v = (Z_TYPE_PP(argv[3]) == IS_LONG || + Z_TYPE_PP(argv[3]) == IS_DOUBLE || + Z_TYPE_PP(argv[3]) == IS_STRING) ? 1 : 0; + if (_v) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU); + } + } + } + } + } + + /*No matching function for overloaded 'CoordinateTransformation_TransformPoint'*/ + +} + + +/* property handler for class CoordinateTransformation */ +static pval _wrap_propget_CoordinateTransformation(zend_property_reference *property_reference) { + pval result; + pval **_result; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + result.type = IS_NULL; + if (_propget_CoordinateTransformation(property_reference, &result)==SUCCESS) return result; + /* return it ourselves */ + if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) { + zval *_value; + MAKE_STD_ZVAL(_value); *_value=**_result; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return *_value; + } + result.type = IS_NULL; + return result; +} +static int _propget_CoordinateTransformation(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +static int _wrap_propset_CoordinateTransformation(zend_property_reference *property_reference, pval *value) { + zval * _value; + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + if (_propset_CoordinateTransformation(property_reference, value)==SUCCESS) return SUCCESS; + /* set it ourselves as it is CoordinateTransformation */ + MAKE_STD_ZVAL(_value); + *_value=*value; + INIT_PZVAL(_value); + zval_copy_ctor(_value); + return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value); +} +static int _propset_CoordinateTransformation(zend_property_reference *property_reference, pval *value) { + /* get the property name */ + zend_llist_element *element = property_reference->elements_list->head; + zend_overloaded_element *property=(zend_overloaded_element *)element->data; + char *propname=Z_STRVAL_P(&(property->element)); + return FAILURE; +} + +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_double) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_p_char) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_double) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_double) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_long) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OSRCoordinateTransformationShadow) { + /* has destructor: __wrap_delete_CoordinateTransformation */ + __wrap_delete_CoordinateTransformation(rsrc, SWIGTYPE_p_OSRCoordinateTransformationShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OSRCoordinateTransformationShadow) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_int) { + /* bah! No destructor for this simple type!! */ +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_OSRSpatialReferenceShadow) { + /* has destructor: __wrap_delete_SpatialReference */ + __wrap_delete_SpatialReference(rsrc, SWIGTYPE_p_OSRSpatialReferenceShadow->name TSRMLS_CC); +} +/* NEW Destructor style */ +static ZEND_RSRC_DTOR_FUNC(_wrap_destroy_p_p_OSRSpatialReferenceShadow) { + /* bah! No destructor for this simple type!! */ +} +/* end wrapper section */ +/* init section */ +#ifdef __cplusplus +extern "C" { +#endif +ZEND_GET_MODULE(osr) +#ifdef __cplusplus +} +#endif + +#define SWIG_php_minit PHP_MINIT_FUNCTION(osr) +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + + SWIG_php_minit { + SWIG_InitializeModule(0); + +/* oinit subsection */ +ZEND_INIT_MODULE_GLOBALS(osr, osr_init_globals, osr_destroy_globals); +/* Define class SpatialReference */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_SpatialReference,"spatialreference",SpatialReference_functions,NULL,_wrap_propget_SpatialReference,_wrap_propset_SpatialReference); +if (! (ptr_ce_swig_SpatialReference=zend_register_internal_class_ex(&ce_swig_SpatialReference,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class SpatialReference"); + +/* Define class CoordinateTransformation */ +INIT_OVERLOADED_CLASS_ENTRY(ce_swig_CoordinateTransformation,"coordinatetransformation",CoordinateTransformation_functions,NULL,_wrap_propget_CoordinateTransformation,_wrap_propset_CoordinateTransformation); +if (! (ptr_ce_swig_CoordinateTransformation=zend_register_internal_class_ex(&ce_swig_CoordinateTransformation,NULL,NULL))) zend_error(E_ERROR,"Error registering wrapper for class CoordinateTransformation"); + + +/* Register resource destructors for pointer types */ +le_swig__p_char=zend_register_list_destructors_ex(_wrap_destroy_p_char,NULL,(char *)(SWIGTYPE_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_char,&le_swig__p_char); +le_swig__double=zend_register_list_destructors_ex(_wrap_destroy_double,NULL,(char *)(SWIGTYPE_double->name),module_number); +SWIG_TypeClientData(SWIGTYPE_double,&le_swig__double); +le_swig__p_p_char=zend_register_list_destructors_ex(_wrap_destroy_p_p_char,NULL,(char *)(SWIGTYPE_p_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_char,&le_swig__p_p_char); +le_swig__p_p_p_char=zend_register_list_destructors_ex(_wrap_destroy_p_p_p_char,NULL,(char *)(SWIGTYPE_p_p_p_char->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_p_char,&le_swig__p_p_p_char); +le_swig__p_double=zend_register_list_destructors_ex(_wrap_destroy_p_double,NULL,(char *)(SWIGTYPE_p_double->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_double,&le_swig__p_double); +le_swig__p_p_double=zend_register_list_destructors_ex(_wrap_destroy_p_p_double,NULL,(char *)(SWIGTYPE_p_p_double->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_double,&le_swig__p_p_double); +le_swig__p_long=zend_register_list_destructors_ex(_wrap_destroy_p_long,NULL,(char *)(SWIGTYPE_p_long->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_long,&le_swig__p_long); +le_swig__p_OSRCoordinateTransformationShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OSRCoordinateTransformationShadow,NULL,(char *)(SWIGTYPE_p_OSRCoordinateTransformationShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OSRCoordinateTransformationShadow,&le_swig__p_OSRCoordinateTransformationShadow); +le_swig__p_p_OSRCoordinateTransformationShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OSRCoordinateTransformationShadow,NULL,(char *)(SWIGTYPE_p_p_OSRCoordinateTransformationShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OSRCoordinateTransformationShadow,&le_swig__p_p_OSRCoordinateTransformationShadow); +le_swig__p_int=zend_register_list_destructors_ex(_wrap_destroy_p_int,NULL,(char *)(SWIGTYPE_p_int->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_int,&le_swig__p_int); +le_swig__p_OSRSpatialReferenceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_OSRSpatialReferenceShadow,NULL,(char *)(SWIGTYPE_p_OSRSpatialReferenceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_OSRSpatialReferenceShadow,&le_swig__p_OSRSpatialReferenceShadow); +le_swig__p_p_OSRSpatialReferenceShadow=zend_register_list_destructors_ex(_wrap_destroy_p_p_OSRSpatialReferenceShadow,NULL,(char *)(SWIGTYPE_p_p_OSRSpatialReferenceShadow->name),module_number); +SWIG_TypeClientData(SWIGTYPE_p_p_OSRSpatialReferenceShadow,&le_swig__p_p_OSRSpatialReferenceShadow); +CG(active_class_entry) = NULL; +/* end oinit subsection */ + + return SUCCESS; +} +PHP_RINIT_FUNCTION(osr) +{ +/* rinit section */ + +/* cinit subsection */ +REGISTER_STRING_CONSTANT("SRS_PT_ALBERS_CONIC_EQUAL_AREA", SRS_PT_ALBERS_CONIC_EQUAL_AREA, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_AZIMUTHAL_EQUIDISTANT", SRS_PT_AZIMUTHAL_EQUIDISTANT, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_CASSINI_SOLDNER", SRS_PT_CASSINI_SOLDNER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_CYLINDRICAL_EQUAL_AREA", SRS_PT_CYLINDRICAL_EQUAL_AREA, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_ECKERT_IV", SRS_PT_ECKERT_IV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_ECKERT_VI", SRS_PT_ECKERT_VI, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_EQUIDISTANT_CONIC", SRS_PT_EQUIDISTANT_CONIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_EQUIRECTANGULAR", SRS_PT_EQUIRECTANGULAR, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_GALL_STEREOGRAPHIC", SRS_PT_GALL_STEREOGRAPHIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_GNOMONIC", SRS_PT_GNOMONIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_GOODE_HOMOLOSINE", SRS_PT_GOODE_HOMOLOSINE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_HOTINE_OBLIQUE_MERCATOR", SRS_PT_HOTINE_OBLIQUE_MERCATOR, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN", SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_LABORDE_OBLIQUE_MERCATOR", SRS_PT_LABORDE_OBLIQUE_MERCATOR, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP", SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP", SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM", SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA", SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_MERCATOR_1SP", SRS_PT_MERCATOR_1SP, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_MERCATOR_2SP", SRS_PT_MERCATOR_2SP, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_MILLER_CYLINDRICAL", SRS_PT_MILLER_CYLINDRICAL, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_MOLLWEIDE", SRS_PT_MOLLWEIDE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_NEW_ZEALAND_MAP_GRID", SRS_PT_NEW_ZEALAND_MAP_GRID, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_OBLIQUE_STEREOGRAPHIC", SRS_PT_OBLIQUE_STEREOGRAPHIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_ORTHOGRAPHIC", SRS_PT_ORTHOGRAPHIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_POLAR_STEREOGRAPHIC", SRS_PT_POLAR_STEREOGRAPHIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_POLYCONIC", SRS_PT_POLYCONIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_ROBINSON", SRS_PT_ROBINSON, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_SINUSOIDAL", SRS_PT_SINUSOIDAL, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_STEREOGRAPHIC", SRS_PT_STEREOGRAPHIC, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_SWISS_OBLIQUE_CYLINDRICAL", SRS_PT_SWISS_OBLIQUE_CYLINDRICAL, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR", SRS_PT_TRANSVERSE_MERCATOR, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED", SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR_MI_22", SRS_PT_TRANSVERSE_MERCATOR_MI_22, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR_MI_23", SRS_PT_TRANSVERSE_MERCATOR_MI_23, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR_MI_24", SRS_PT_TRANSVERSE_MERCATOR_MI_24, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TRANSVERSE_MERCATOR_MI_25", SRS_PT_TRANSVERSE_MERCATOR_MI_25, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_TUNISIA_MINING_GRID", SRS_PT_TUNISIA_MINING_GRID, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_VANDERGRINTEN", SRS_PT_VANDERGRINTEN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PT_KROVAK", SRS_PT_KROVAK, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_CENTRAL_MERIDIAN", SRS_PP_CENTRAL_MERIDIAN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_SCALE_FACTOR", SRS_PP_SCALE_FACTOR, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_STANDARD_PARALLEL_1", SRS_PP_STANDARD_PARALLEL_1, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_STANDARD_PARALLEL_2", SRS_PP_STANDARD_PARALLEL_2, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_PSEUDO_STD_PARALLEL_1", SRS_PP_PSEUDO_STD_PARALLEL_1, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LONGITUDE_OF_CENTER", SRS_PP_LONGITUDE_OF_CENTER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LATITUDE_OF_CENTER", SRS_PP_LATITUDE_OF_CENTER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LONGITUDE_OF_ORIGIN", SRS_PP_LONGITUDE_OF_ORIGIN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LATITUDE_OF_ORIGIN", SRS_PP_LATITUDE_OF_ORIGIN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_FALSE_EASTING", SRS_PP_FALSE_EASTING, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_FALSE_NORTHING", SRS_PP_FALSE_NORTHING, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_AZIMUTH", SRS_PP_AZIMUTH, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LONGITUDE_OF_POINT_1", SRS_PP_LONGITUDE_OF_POINT_1, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LATITUDE_OF_POINT_1", SRS_PP_LATITUDE_OF_POINT_1, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LONGITUDE_OF_POINT_2", SRS_PP_LONGITUDE_OF_POINT_2, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LATITUDE_OF_POINT_2", SRS_PP_LATITUDE_OF_POINT_2, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LONGITUDE_OF_POINT_3", SRS_PP_LONGITUDE_OF_POINT_3, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LATITUDE_OF_POINT_3", SRS_PP_LATITUDE_OF_POINT_3, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_RECTIFIED_GRID_ANGLE", SRS_PP_RECTIFIED_GRID_ANGLE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_LANDSAT_NUMBER", SRS_PP_LANDSAT_NUMBER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_PATH_NUMBER", SRS_PP_PATH_NUMBER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_PERSPECTIVE_POINT_HEIGHT", SRS_PP_PERSPECTIVE_POINT_HEIGHT, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_FIPSZONE", SRS_PP_FIPSZONE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_PP_ZONE", SRS_PP_ZONE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_METER", SRS_UL_METER, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_FOOT", SRS_UL_FOOT, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_FOOT_CONV", SRS_UL_FOOT_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_US_FOOT", SRS_UL_US_FOOT, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_US_FOOT_CONV", SRS_UL_US_FOOT_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_NAUTICAL_MILE", SRS_UL_NAUTICAL_MILE, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_NAUTICAL_MILE_CONV", SRS_UL_NAUTICAL_MILE_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_LINK", SRS_UL_LINK, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_LINK_CONV", SRS_UL_LINK_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_CHAIN", SRS_UL_CHAIN, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_CHAIN_CONV", SRS_UL_CHAIN_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_ROD", SRS_UL_ROD, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_UL_ROD_CONV", SRS_UL_ROD_CONV, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_DN_NAD27", SRS_DN_NAD27, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_DN_NAD83", SRS_DN_NAD83, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_DN_WGS72", SRS_DN_WGS72, CONST_CS | CONST_PERSISTENT); +REGISTER_STRING_CONSTANT("SRS_DN_WGS84", SRS_DN_WGS84, CONST_CS | CONST_PERSISTENT); +REGISTER_DOUBLE_CONSTANT("SRS_WGS84_SEMIMAJOR", SRS_WGS84_SEMIMAJOR, CONST_CS | CONST_PERSISTENT); +REGISTER_DOUBLE_CONSTANT("SRS_WGS84_INVFLATTENING", SRS_WGS84_INVFLATTENING, CONST_CS | CONST_PERSISTENT); +/* end cinit subsection */ + +/* vinit subsection */ +/* end vinit subsection */ + + return SUCCESS; +} +PHP_MSHUTDOWN_FUNCTION(osr) +{ +/* shutdown section */ + + return SUCCESS; +} +PHP_RSHUTDOWN_FUNCTION(osr) +{ +/* rshutdown section */ + + return SUCCESS; +} +PHP_MINFO_FUNCTION(osr) +{ +} +/* end init section */ diff --git a/Utilities/GDAL/swig/php/php_gdal.h b/Utilities/GDAL/swig/php/php_gdal.h new file mode 100644 index 0000000000..5541f67654 --- /dev/null +++ b/Utilities/GDAL/swig/php/php_gdal.h @@ -0,0 +1,212 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ + + +#ifndef PHP_GDAL_H +#define PHP_GDAL_H + +extern zend_module_entry gdal_module_entry; +#define phpext_gdal_ptr &gdal_module_entry + +#ifdef PHP_WIN32 +# define PHP_GDAL_API __declspec(dllexport) +#else +# define PHP_GDAL_API +#endif + +PHP_MINIT_FUNCTION(gdal); +PHP_MSHUTDOWN_FUNCTION(gdal); +PHP_RINIT_FUNCTION(gdal); +PHP_RSHUTDOWN_FUNCTION(gdal); +PHP_MINFO_FUNCTION(gdal); + +ZEND_NAMED_FUNCTION(_wrap_Debug); +ZEND_NAMED_FUNCTION(_wrap_Error); +ZEND_NAMED_FUNCTION(_wrap_PushErrorHandler); +ZEND_NAMED_FUNCTION(_wrap_PopErrorHandler); +ZEND_NAMED_FUNCTION(_wrap_ErrorReset); +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorNo); +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorType); +ZEND_NAMED_FUNCTION(_wrap_GetLastErrorMsg); +ZEND_NAMED_FUNCTION(_wrap_PushFinderLocation); +ZEND_NAMED_FUNCTION(_wrap_PopFinderLocation); +ZEND_NAMED_FUNCTION(_wrap_FinderClean); +ZEND_NAMED_FUNCTION(_wrap_FindFile); +ZEND_NAMED_FUNCTION(_wrap_SetConfigOption); +ZEND_NAMED_FUNCTION(_wrap_GetConfigOption); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetDescription); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetDescription); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetDescription); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetDescription); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_Dict); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_Dict); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_List); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_GetMetadata_List); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata); +ZEND_NAMED_FUNCTION(_wrap_MajorObject_SetMetadata); +ZEND_NAMED_FUNCTION(_wrap_Driver_Create); +ZEND_NAMED_FUNCTION(_wrap_Driver_Create); +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateCopy); +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateCopy); +ZEND_NAMED_FUNCTION(_wrap_Driver_Delete); +ZEND_NAMED_FUNCTION(_wrap_Driver_Delete); +ZEND_NAMED_FUNCTION(_wrap_new_GCP); +ZEND_NAMED_FUNCTION(_wrap_new_GCP); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPX_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPX_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPY_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPY_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPZ_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPZ_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPPixel_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPPixel_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPLine_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_GCPLine_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Info_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Info_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Id_get); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_Id_set); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPX); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPX); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPY); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPY); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPZ); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPZ); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPPixel); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPPixel); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_GCPLine); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_GCPLine); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_Info); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_Info); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_get_Id); +ZEND_NAMED_FUNCTION(_wrap_GDAL_GCP_set_Id); +ZEND_NAMED_FUNCTION(_wrap_GCPsToGeoTransform); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetDriver); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetDriver); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetRasterBand); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetRasterBand); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjectionRef); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetProjectionRef); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGeoTransform); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGeoTransform); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGeoTransform); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGeoTransform); +ZEND_NAMED_FUNCTION(_wrap_Dataset_BuildOverviews); +ZEND_NAMED_FUNCTION(_wrap_Dataset_BuildOverviews); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPCount); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPCount); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPProjection); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPs); +ZEND_NAMED_FUNCTION(_wrap_Dataset_GetGCPs); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGCPs); +ZEND_NAMED_FUNCTION(_wrap_Dataset_SetGCPs); +ZEND_NAMED_FUNCTION(_wrap_Dataset_FlushCache); +ZEND_NAMED_FUNCTION(_wrap_Dataset_FlushCache); +ZEND_NAMED_FUNCTION(_wrap_Dataset_AddBand); +ZEND_NAMED_FUNCTION(_wrap_Dataset_AddBand); +ZEND_NAMED_FUNCTION(_wrap_Dataset_WriteRaster); +ZEND_NAMED_FUNCTION(_wrap_Dataset_WriteRaster); +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorInterpretation); +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorInterpretation); +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorInterpretation); +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorInterpretation); +ZEND_NAMED_FUNCTION(_wrap_Band_GetNoDataValue); +ZEND_NAMED_FUNCTION(_wrap_Band_GetNoDataValue); +ZEND_NAMED_FUNCTION(_wrap_Band_SetNoDataValue); +ZEND_NAMED_FUNCTION(_wrap_Band_SetNoDataValue); +ZEND_NAMED_FUNCTION(_wrap_Band_GetMinimum); +ZEND_NAMED_FUNCTION(_wrap_Band_GetMinimum); +ZEND_NAMED_FUNCTION(_wrap_Band_GetMaximum); +ZEND_NAMED_FUNCTION(_wrap_Band_GetMaximum); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOffset); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOffset); +ZEND_NAMED_FUNCTION(_wrap_Band_GetScale); +ZEND_NAMED_FUNCTION(_wrap_Band_GetScale); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverviewCount); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverviewCount); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverview); +ZEND_NAMED_FUNCTION(_wrap_Band_GetOverview); +ZEND_NAMED_FUNCTION(_wrap_Band_Checksum); +ZEND_NAMED_FUNCTION(_wrap_Band_Checksum); +ZEND_NAMED_FUNCTION(_wrap_Band_ComputeRasterMinMax); +ZEND_NAMED_FUNCTION(_wrap_Band_ComputeRasterMinMax); +ZEND_NAMED_FUNCTION(_wrap_Band_Fill); +ZEND_NAMED_FUNCTION(_wrap_Band_Fill); +ZEND_NAMED_FUNCTION(_wrap_Band_ReadRaster); +ZEND_NAMED_FUNCTION(_wrap_Band_ReadRaster); +ZEND_NAMED_FUNCTION(_wrap_Band_WriteRaster); +ZEND_NAMED_FUNCTION(_wrap_Band_WriteRaster); +ZEND_NAMED_FUNCTION(_wrap_Band_FlushCache); +ZEND_NAMED_FUNCTION(_wrap_Band_FlushCache); +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorTable); +ZEND_NAMED_FUNCTION(_wrap_Band_GetRasterColorTable); +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorTable); +ZEND_NAMED_FUNCTION(_wrap_Band_SetRasterColorTable); +ZEND_NAMED_FUNCTION(_wrap_new_ColorTable); +ZEND_NAMED_FUNCTION(_wrap_new_ColorTable); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_Clone); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_Clone); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetPaletteInterpretation); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetPaletteInterpretation); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetCount); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetCount); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntry); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntry); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntryAsRGB); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_GetColorEntryAsRGB); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_SetColorEntry); +ZEND_NAMED_FUNCTION(_wrap_ColorTable_SetColorEntry); +ZEND_NAMED_FUNCTION(_wrap_AllRegister); +ZEND_NAMED_FUNCTION(_wrap_GetCacheMax); +ZEND_NAMED_FUNCTION(_wrap_SetCacheMax); +ZEND_NAMED_FUNCTION(_wrap_GetCacheUsed); +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeSize); +ZEND_NAMED_FUNCTION(_wrap_DataTypeIsComplex); +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeName); +ZEND_NAMED_FUNCTION(_wrap_GetDataTypeByName); +ZEND_NAMED_FUNCTION(_wrap_GetColorInterpretationName); +ZEND_NAMED_FUNCTION(_wrap_GetPaletteInterpretationName); +ZEND_NAMED_FUNCTION(_wrap_DecToDMS); +ZEND_NAMED_FUNCTION(_wrap_PackedDMSToDec); +ZEND_NAMED_FUNCTION(_wrap_DecToPackedDMS); +ZEND_NAMED_FUNCTION(_wrap_ParseXMLString); +ZEND_NAMED_FUNCTION(_wrap_SerializeXMLTree); +ZEND_NAMED_FUNCTION(_wrap_GetDriverCount); +ZEND_NAMED_FUNCTION(_wrap_GetDriverByName); +ZEND_NAMED_FUNCTION(_wrap_GetDriver); +ZEND_NAMED_FUNCTION(_wrap_Open); +ZEND_NAMED_FUNCTION(_wrap_OpenShared); +ZEND_NAMED_FUNCTION(_wrap_AutoCreateWarpedVRT); +#endif /* PHP_GDAL_H */ diff --git a/Utilities/GDAL/swig/php/php_gdalconst.h b/Utilities/GDAL/swig/php/php_gdalconst.h new file mode 100644 index 0000000000..88222ef8f2 --- /dev/null +++ b/Utilities/GDAL/swig/php/php_gdalconst.h @@ -0,0 +1,49 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ + + +#ifndef PHP_GDALCONST_H +#define PHP_GDALCONST_H + +extern zend_module_entry gdalconst_module_entry; +#define phpext_gdalconst_ptr &gdalconst_module_entry + +#ifdef PHP_WIN32 +# define PHP_GDALCONST_API __declspec(dllexport) +#else +# define PHP_GDALCONST_API +#endif + +PHP_MINIT_FUNCTION(gdalconst); +PHP_MSHUTDOWN_FUNCTION(gdalconst); +PHP_RINIT_FUNCTION(gdalconst); +PHP_RSHUTDOWN_FUNCTION(gdalconst); +PHP_MINFO_FUNCTION(gdalconst); + +#endif /* PHP_GDALCONST_H */ diff --git a/Utilities/GDAL/swig/php/php_ogr.h b/Utilities/GDAL/swig/php/php_ogr.h new file mode 100644 index 0000000000..6afd20be3c --- /dev/null +++ b/Utilities/GDAL/swig/php/php_ogr.h @@ -0,0 +1,335 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ + + +#ifndef PHP_OGR_H +#define PHP_OGR_H + +extern zend_module_entry ogr_module_entry; +#define phpext_ogr_ptr &ogr_module_entry + +#ifdef PHP_WIN32 +# define PHP_OGR_API __declspec(dllexport) +#else +# define PHP_OGR_API +#endif + +PHP_MINIT_FUNCTION(ogr); +PHP_MSHUTDOWN_FUNCTION(ogr); +PHP_RINIT_FUNCTION(ogr); +PHP_RSHUTDOWN_FUNCTION(ogr); +PHP_MINFO_FUNCTION(ogr); + +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_CreateDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_CopyDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_CopyDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_Open); +ZEND_NAMED_FUNCTION(_wrap_Driver_Open); +ZEND_NAMED_FUNCTION(_wrap_Driver_DeleteDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_DeleteDataSource); +ZEND_NAMED_FUNCTION(_wrap_Driver_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_Driver_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_Driver_GetName); +ZEND_NAMED_FUNCTION(_wrap_Driver_GetName); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetRefCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetRefCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetSummaryRefCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetSummaryRefCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerCount); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetName); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetName); +ZEND_NAMED_FUNCTION(_wrap_DataSource_DeleteLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_DeleteLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_CreateLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_CreateLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_CopyLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_CopyLayer); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByIndex); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByIndex); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByName); +ZEND_NAMED_FUNCTION(_wrap_DataSource_GetLayerByName); +ZEND_NAMED_FUNCTION(_wrap_DataSource_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_DataSource_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_DataSource_ExecuteSQL); +ZEND_NAMED_FUNCTION(_wrap_DataSource_ExecuteSQL); +ZEND_NAMED_FUNCTION(_wrap_DataSource_ReleaseResultSet); +ZEND_NAMED_FUNCTION(_wrap_DataSource_ReleaseResultSet); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetRefCount); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetRefCount); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilterRect); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetSpatialFilterRect); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetAttributeFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetAttributeFilter); +ZEND_NAMED_FUNCTION(_wrap_Layer_ResetReading); +ZEND_NAMED_FUNCTION(_wrap_Layer_ResetReading); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetName); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetName); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetNextFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetNextFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetNextByIndex); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetNextByIndex); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_SetFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_DeleteFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_DeleteFeature); +ZEND_NAMED_FUNCTION(_wrap_Layer_SyncToDisk); +ZEND_NAMED_FUNCTION(_wrap_Layer_SyncToDisk); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetLayerDefn); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetLayerDefn); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureCount); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureCount); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetExtent); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetExtent); +ZEND_NAMED_FUNCTION(_wrap_Layer_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_Layer_TestCapability); +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateField); +ZEND_NAMED_FUNCTION(_wrap_Layer_CreateField); +ZEND_NAMED_FUNCTION(_wrap_Layer_StartTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_StartTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_CommitTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_CommitTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_RollbackTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_RollbackTransaction); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialRef); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetSpatialRef); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureRead); +ZEND_NAMED_FUNCTION(_wrap_Layer_GetFeatureRead); +ZEND_NAMED_FUNCTION(_wrap_new_Feature); +ZEND_NAMED_FUNCTION(_wrap_new_Feature); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetDefnRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetDefnRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometry); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometry); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometryDirectly); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetGeometryDirectly); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetGeometryRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetGeometryRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_Clone); +ZEND_NAMED_FUNCTION(_wrap_Feature_Clone); +ZEND_NAMED_FUNCTION(_wrap_Feature_Equal); +ZEND_NAMED_FUNCTION(_wrap_Feature_Equal); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldCount); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldCount); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldDefnRef); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsString); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsInteger); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldAsDouble); +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet); +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet); +ZEND_NAMED_FUNCTION(_wrap_Feature_IsFieldSet); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldIndex); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldIndex); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFID); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFID); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFID); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFID); +ZEND_NAMED_FUNCTION(_wrap_Feature_DumpReadable); +ZEND_NAMED_FUNCTION(_wrap_Feature_DumpReadable); +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_UnsetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetField); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFrom); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetFrom); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetStyleString); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetStyleString); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetStyleString); +ZEND_NAMED_FUNCTION(_wrap_Feature_SetStyleString); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType); +ZEND_NAMED_FUNCTION(_wrap_Feature_GetFieldType); +ZEND_NAMED_FUNCTION(_wrap_new_FeatureDefn); +ZEND_NAMED_FUNCTION(_wrap_new_FeatureDefn); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetName); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetName); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldCount); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldCount); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldDefn); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldDefn); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldIndex); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetFieldIndex); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_AddFieldDefn); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_AddFieldDefn); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetGeomType); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetGeomType); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_SetGeomType); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_SetGeomType); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetReferenceCount); +ZEND_NAMED_FUNCTION(_wrap_FeatureDefn_GetReferenceCount); +ZEND_NAMED_FUNCTION(_wrap_new_FieldDefn); +ZEND_NAMED_FUNCTION(_wrap_new_FieldDefn); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetName); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetName); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetNameRef); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetNameRef); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetName); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetName); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetType); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetType); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetType); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetType); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetJustify); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetJustify); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetJustify); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetJustify); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetWidth); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetWidth); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetWidth); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetWidth); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetPrecision); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetPrecision); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetPrecision); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_SetPrecision); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetFieldTypeName); +ZEND_NAMED_FUNCTION(_wrap_FieldDefn_GetFieldTypeName); +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromWkb); +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromWkt); +ZEND_NAMED_FUNCTION(_wrap_CreateGeometryFromGML); +ZEND_NAMED_FUNCTION(_wrap_new_Geometry); +ZEND_NAMED_FUNCTION(_wrap_new_Geometry); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkt); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkt); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkb); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToWkb); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToGML); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ExportToGML); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddPoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddPoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometryDirectly); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometryDirectly); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometry); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AddGeometry); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Clone); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Clone); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryType); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryType); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryName); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryName); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetArea); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetArea); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetPointCount); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetPointCount); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetX); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetX); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetY); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetY); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetZ); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetZ); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryCount); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryCount); +ZEND_NAMED_FUNCTION(_wrap_Geometry_SetPoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_SetPoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryRef); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetGeometryRef); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetBoundary); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetBoundary); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ConvexHull); +ZEND_NAMED_FUNCTION(_wrap_Geometry_ConvexHull); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Buffer); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Buffer); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersection); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersection); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Union); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Union); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Difference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Difference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_SymmetricDifference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_SymmetricDifference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Distance); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Distance); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Empty); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Empty); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersect); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Intersect); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Equal); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Equal); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Disjoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Disjoint); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Touches); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Touches); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Crosses); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Crosses); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Within); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Within); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Contains); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Contains); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Overlaps); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Overlaps); +ZEND_NAMED_FUNCTION(_wrap_Geometry_TransformTo); +ZEND_NAMED_FUNCTION(_wrap_Geometry_TransformTo); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Transform); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Transform); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetSpatialReference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetSpatialReference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AssignSpatialReference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_AssignSpatialReference); +ZEND_NAMED_FUNCTION(_wrap_Geometry_CloseRings); +ZEND_NAMED_FUNCTION(_wrap_Geometry_CloseRings); +ZEND_NAMED_FUNCTION(_wrap_Geometry_FlattenTo2D); +ZEND_NAMED_FUNCTION(_wrap_Geometry_FlattenTo2D); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetEnvelope); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetEnvelope); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Centroid); +ZEND_NAMED_FUNCTION(_wrap_Geometry_Centroid); +ZEND_NAMED_FUNCTION(_wrap_Geometry_WkbSize); +ZEND_NAMED_FUNCTION(_wrap_Geometry_WkbSize); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetCoordinateDimension); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetCoordinateDimension); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetDimension); +ZEND_NAMED_FUNCTION(_wrap_Geometry_GetDimension); +ZEND_NAMED_FUNCTION(_wrap_OGRGetDriverCount); +ZEND_NAMED_FUNCTION(_wrap_OGRGetOpenDSCount); +ZEND_NAMED_FUNCTION(_wrap_OGRSetGenerate_DB2_V72_BYTE_ORDER); +ZEND_NAMED_FUNCTION(_wrap_OGRRegisterAll); +ZEND_NAMED_FUNCTION(_wrap_GetOpenDS); +ZEND_NAMED_FUNCTION(_wrap_Open); +ZEND_NAMED_FUNCTION(_wrap_OpenShared); +ZEND_NAMED_FUNCTION(_wrap_GetDriverByName); +ZEND_NAMED_FUNCTION(_wrap_GetDriver); +#endif /* PHP_OGR_H */ diff --git a/Utilities/GDAL/swig/php/php_osr.h b/Utilities/GDAL/swig/php/php_osr.h new file mode 100644 index 0000000000..65f4913a8c --- /dev/null +++ b/Utilities/GDAL/swig/php/php_osr.h @@ -0,0 +1,176 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.26 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: | + | | + +----------------------------------------------------------------------+ + */ + + +#ifndef PHP_OSR_H +#define PHP_OSR_H + +extern zend_module_entry osr_module_entry; +#define phpext_osr_ptr &osr_module_entry + +#ifdef PHP_WIN32 +# define PHP_OSR_API __declspec(dllexport) +#else +# define PHP_OSR_API +#endif + +PHP_MINIT_FUNCTION(osr); +PHP_MSHUTDOWN_FUNCTION(osr); +PHP_RINIT_FUNCTION(osr); +PHP_RSHUTDOWN_FUNCTION(osr); +PHP_MINFO_FUNCTION(osr); + +ZEND_NAMED_FUNCTION(_wrap_GetWellKnownGeogCSAsWKT); +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethods); +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethodParameterList); +ZEND_NAMED_FUNCTION(_wrap_GetProjectionMethodParamInfo); +ZEND_NAMED_FUNCTION(_wrap_new_SpatialReference); +ZEND_NAMED_FUNCTION(_wrap_new_SpatialReference); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference___str__); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference___str__); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSame); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSame); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSameGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsSameGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsGeographic); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsGeographic); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsProjected); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_IsProjected); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAttrValue); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAttrValue); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAttrValue); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAttrValue); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAngularUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAngularUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAngularUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAngularUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetLinearUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetLinearUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnits); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnitsName); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetLinearUnitsName); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityCode); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityCode); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityName); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetAuthorityName); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetUTM); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetUTM); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetStatePlane); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetStatePlane); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_AutoIdentifyEPSG); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_AutoIdentifyEPSG); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjection); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjection); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetNormProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetNormProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetNormProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetNormProjParm); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetACEA); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetACEA); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAE); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetAE); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetBonne); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetBonne); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEC); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEC); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertIV); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertIV); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertVI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEckertVI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEquirectangular); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetEquirectangular); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetWellKnownGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetWellKnownGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetFromUserInput); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetFromUserInput); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CopyGeogCSFrom); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CopyGeogCSFrom); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetTOWGS84); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetTOWGS84); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetTOWGS84); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_GetTOWGS84); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_SetProjCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromProj4); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromProj4); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromESRI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromESRI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromEPSG); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromEPSG); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromPCI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromPCI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromUSGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromUSGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromXML); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ImportFromXML); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPrettyWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPrettyWkt); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToProj4); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToProj4); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPCI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToPCI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToUSGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToUSGS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToXML); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_ExportToXML); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CloneGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_CloneGeogCS); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Validate); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Validate); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_StripCTParms); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_StripCTParms); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_FixupOrdering); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_FixupOrdering); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Fixup); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_Fixup); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphToESRI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphToESRI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphFromESRI); +ZEND_NAMED_FUNCTION(_wrap_SpatialReference_MorphFromESRI); +ZEND_NAMED_FUNCTION(_wrap_new_CoordinateTransformation); +ZEND_NAMED_FUNCTION(_wrap_new_CoordinateTransformation); +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint); +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint); +ZEND_NAMED_FUNCTION(_wrap_CoordinateTransformation_TransformPoint); +#endif /* PHP_OSR_H */ diff --git a/Utilities/GDAL/swig/python/.cvsignore b/Utilities/GDAL/swig/python/.cvsignore new file mode 100644 index 0000000000..27ffc2f17f --- /dev/null +++ b/Utilities/GDAL/swig/python/.cvsignore @@ -0,0 +1,2 @@ +*.pyc +build diff --git a/Utilities/GDAL/swig/python/GNUmakefile b/Utilities/GDAL/swig/python/GNUmakefile new file mode 100644 index 0000000000..b5305c0e72 --- /dev/null +++ b/Utilities/GDAL/swig/python/GNUmakefile @@ -0,0 +1,27 @@ + + +include ../../GDALmake.opt + +all: + +BINDING = python +include ../SWIGmake.base + +PY_COMMANDS = epsg_tr.py gdalchksum.py gdal2xyz.py gcps2wld.py \ + gdalimport.py gdal_merge.py pct2rgb.py rgb2pct.py \ + gcps2vec.py +PY_MODULES = gdal.py ogr.py osr.py gdalconst.py + +clean: + -rm -rf build + +veryclean: clean + -rm -f ${WRAPPERS} ${PY_MODULES} + +generate: ${WRAPPERS} + +build: + python setup.py build + +install: + python setup.py install --prefix=$(prefix) diff --git a/Utilities/GDAL/swig/python/gdal.py b/Utilities/GDAL/swig/python/gdal.py new file mode 100644 index 0000000000..aa9ac4eeff --- /dev/null +++ b/Utilities/GDAL/swig/python/gdal.py @@ -0,0 +1,730 @@ +# This file was created automatically by SWIG 1.3.27. +# Don't modify this file, modify the SWIG interface instead. + +import _gdal + +# This file is compatible with both classic and new-style classes. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "this"): + if isinstance(value, class_type): + self.__dict__[name] = value.this + if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown + del value.thisown + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name) or (name == "thisown"): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +from gdalconst import * + + +def UseExceptions(*args): + """UseExceptions()""" + return _gdal.UseExceptions(*args) + +def DontUseExceptions(*args): + """DontUseExceptions()""" + return _gdal.DontUseExceptions(*args) + +def Debug(*args): + """Debug(char msg_class, char message)""" + return _gdal.Debug(*args) + +def Error(*args): + """Error(CPLErr msg_class=CE_Failure, int err_code=0, char msg="error")""" + return _gdal.Error(*args) + +def PopErrorHandler(*args): + """PopErrorHandler()""" + return _gdal.PopErrorHandler(*args) + +def ErrorReset(*args): + """ErrorReset()""" + return _gdal.ErrorReset(*args) + +def GetLastErrorNo(*args): + """GetLastErrorNo() -> int""" + return _gdal.GetLastErrorNo(*args) + +def GetLastErrorType(*args): + """GetLastErrorType() -> CPLErr""" + return _gdal.GetLastErrorType(*args) + +def GetLastErrorMsg(*args): + """GetLastErrorMsg() -> char""" + return _gdal.GetLastErrorMsg(*args) + +def PushFinderLocation(*args): + """PushFinderLocation(char ??)""" + return _gdal.PushFinderLocation(*args) + +def PopFinderLocation(*args): + """PopFinderLocation()""" + return _gdal.PopFinderLocation(*args) + +def FinderClean(*args): + """FinderClean()""" + return _gdal.FinderClean(*args) + +def FindFile(*args): + """FindFile(char ??, char ??) -> char""" + return _gdal.FindFile(*args) + +def SetConfigOption(*args): + """SetConfigOption(char ??, char ??)""" + return _gdal.SetConfigOption(*args) + +def GetConfigOption(*args): + """GetConfigOption(char ??, char ??) -> char""" + return _gdal.GetConfigOption(*args) +class MajorObject(_object): + """Proxy of C++ MajorObject class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, MajorObject, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, MajorObject, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ GDALMajorObjectShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def GetDescription(*args): + """GetDescription(self) -> char""" + return _gdal.MajorObject_GetDescription(*args) + + def SetDescription(*args): + """SetDescription(self, char pszNewDesc)""" + return _gdal.MajorObject_SetDescription(*args) + + def GetMetadata_Dict(*args): + """GetMetadata_Dict(self, char pszDomain="") -> char""" + return _gdal.MajorObject_GetMetadata_Dict(*args) + + def GetMetadata_List(*args): + """GetMetadata_List(self, char pszDomain="") -> char""" + return _gdal.MajorObject_GetMetadata_List(*args) + + def SetMetadata(*args): + """ + SetMetadata(self, char papszMetadata, char pszDomain="") -> CPLErr + SetMetadata(self, char pszMetadataString, char pszDomain="") -> CPLErr + """ + return _gdal.MajorObject_SetMetadata(*args) + + def GetMetadata( self, domain = '' ): + if domain[:4] == 'xml:': + return self.GetMetadata_List( domain ) + return self.GetMetadata_Dict( domain ) + + +class MajorObjectPtr(MajorObject): + def __init__(self, this): + _swig_setattr(self, MajorObject, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, MajorObject, 'thisown', 0) + self.__class__ = MajorObject +_gdal.MajorObject_swigregister(MajorObjectPtr) + +def PushErrorHandler(*args): + """ + PushErrorHandler(char pszCallbackName="CPLQuietErrorHandler") -> CPLErr + PushErrorHandler(CPLErrorHandler ??) + """ + return _gdal.PushErrorHandler(*args) + +class Driver(MajorObject): + """Proxy of C++ Driver class""" + __swig_setmethods__ = {} + for _s in [MajorObject]: __swig_setmethods__.update(_s.__swig_setmethods__) + __setattr__ = lambda self, name, value: _swig_setattr(self, Driver, name, value) + __swig_getmethods__ = {} + for _s in [MajorObject]: __swig_getmethods__.update(_s.__swig_getmethods__) + __getattr__ = lambda self, name: _swig_getattr(self, Driver, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ GDALDriverShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_getmethods__["ShortName"] = _gdal.Driver_ShortName_get + if _newclass:ShortName = property(_gdal.Driver_ShortName_get) + __swig_getmethods__["LongName"] = _gdal.Driver_LongName_get + if _newclass:LongName = property(_gdal.Driver_LongName_get) + __swig_getmethods__["HelpTopic"] = _gdal.Driver_HelpTopic_get + if _newclass:HelpTopic = property(_gdal.Driver_HelpTopic_get) + def Create(*args, **kwargs): + """ + Create(self, char name, int xsize, int ysize, int bands=1, GDALDataType eType=GDT_Byte, + char options=0) -> Dataset + """ + return _gdal.Driver_Create(*args, **kwargs) + + def CreateCopy(*args, **kwargs): + """CreateCopy(self, char name, Dataset src, int strict=1, char options=0) -> Dataset""" + return _gdal.Driver_CreateCopy(*args, **kwargs) + + def Delete(*args): + """Delete(self, char name) -> int""" + return _gdal.Driver_Delete(*args) + + +class DriverPtr(Driver): + def __init__(self, this): + _swig_setattr(self, Driver, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Driver, 'thisown', 0) + self.__class__ = Driver +_gdal.Driver_swigregister(DriverPtr) + +class GCP(_object): + """Proxy of C++ GCP class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, GCP, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, GCP, name) + def __repr__(self): + return "<%s.%s; proxy of C++ GDAL_GCP instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_setmethods__["GCPX"] = _gdal.GCP_GCPX_set + __swig_getmethods__["GCPX"] = _gdal.GCP_GCPX_get + if _newclass:GCPX = property(_gdal.GCP_GCPX_get, _gdal.GCP_GCPX_set) + __swig_setmethods__["GCPY"] = _gdal.GCP_GCPY_set + __swig_getmethods__["GCPY"] = _gdal.GCP_GCPY_get + if _newclass:GCPY = property(_gdal.GCP_GCPY_get, _gdal.GCP_GCPY_set) + __swig_setmethods__["GCPZ"] = _gdal.GCP_GCPZ_set + __swig_getmethods__["GCPZ"] = _gdal.GCP_GCPZ_get + if _newclass:GCPZ = property(_gdal.GCP_GCPZ_get, _gdal.GCP_GCPZ_set) + __swig_setmethods__["GCPPixel"] = _gdal.GCP_GCPPixel_set + __swig_getmethods__["GCPPixel"] = _gdal.GCP_GCPPixel_get + if _newclass:GCPPixel = property(_gdal.GCP_GCPPixel_get, _gdal.GCP_GCPPixel_set) + __swig_setmethods__["GCPLine"] = _gdal.GCP_GCPLine_set + __swig_getmethods__["GCPLine"] = _gdal.GCP_GCPLine_get + if _newclass:GCPLine = property(_gdal.GCP_GCPLine_get, _gdal.GCP_GCPLine_set) + __swig_setmethods__["Info"] = _gdal.GCP_Info_set + __swig_getmethods__["Info"] = _gdal.GCP_Info_get + if _newclass:Info = property(_gdal.GCP_Info_get, _gdal.GCP_Info_set) + __swig_setmethods__["Id"] = _gdal.GCP_Id_set + __swig_getmethods__["Id"] = _gdal.GCP_Id_get + if _newclass:Id = property(_gdal.GCP_Id_get, _gdal.GCP_Id_set) + def __init__(self, *args): + """ + __init__(self, double x=0.0, double y=0.0, double z=0.0, double pixel=0.0, + double line=0.0, char info="", char id="") -> GCP + """ + _swig_setattr(self, GCP, 'this', _gdal.new_GCP(*args)) + _swig_setattr(self, GCP, 'thisown', 1) + def __del__(self, destroy=_gdal.delete_GCP): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __str__(self): + str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\ + % (self.Id, self.GCPPixel, self.GCPLine, + self.GCPX, self.GCPY, self.GCPZ, self.Info ) + return str + def serialize(self,with_Z=0): + base = [CXT_Element,'GCP'] + base.append([CXT_Attribute,'Id',[CXT_Text,self.Id]]) + pixval = '%0.15E' % self.GCPPixel + lineval = '%0.15E' % self.GCPLine + xval = '%0.15E' % self.GCPX + yval = '%0.15E' % self.GCPY + zval = '%0.15E' % self.GCPZ + base.append([CXT_Attribute,'Pixel',[CXT_Text,pixval]]) + base.append([CXT_Attribute,'Line',[CXT_Text,lineval]]) + base.append([CXT_Attribute,'X',[CXT_Text,xval]]) + base.append([CXT_Attribute,'Y',[CXT_Text,yval]]) + if with_Z: + base.append([CXT_Attribute,'Z',[CXT_Text,zval]]) + return base + + +class GCPPtr(GCP): + def __init__(self, this): + _swig_setattr(self, GCP, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, GCP, 'thisown', 0) + self.__class__ = GCP +_gdal.GCP_swigregister(GCPPtr) + + +def GDAL_GCP_GCPX_get(*args): + """GDAL_GCP_GCPX_get(GCP h) -> double""" + return _gdal.GDAL_GCP_GCPX_get(*args) + +def GDAL_GCP_GCPX_set(*args): + """GDAL_GCP_GCPX_set(GCP h, double val)""" + return _gdal.GDAL_GCP_GCPX_set(*args) + +def GDAL_GCP_GCPY_get(*args): + """GDAL_GCP_GCPY_get(GCP h) -> double""" + return _gdal.GDAL_GCP_GCPY_get(*args) + +def GDAL_GCP_GCPY_set(*args): + """GDAL_GCP_GCPY_set(GCP h, double val)""" + return _gdal.GDAL_GCP_GCPY_set(*args) + +def GDAL_GCP_GCPZ_get(*args): + """GDAL_GCP_GCPZ_get(GCP h) -> double""" + return _gdal.GDAL_GCP_GCPZ_get(*args) + +def GDAL_GCP_GCPZ_set(*args): + """GDAL_GCP_GCPZ_set(GCP h, double val)""" + return _gdal.GDAL_GCP_GCPZ_set(*args) + +def GDAL_GCP_GCPPixel_get(*args): + """GDAL_GCP_GCPPixel_get(GCP h) -> double""" + return _gdal.GDAL_GCP_GCPPixel_get(*args) + +def GDAL_GCP_GCPPixel_set(*args): + """GDAL_GCP_GCPPixel_set(GCP h, double val)""" + return _gdal.GDAL_GCP_GCPPixel_set(*args) + +def GDAL_GCP_GCPLine_get(*args): + """GDAL_GCP_GCPLine_get(GCP h) -> double""" + return _gdal.GDAL_GCP_GCPLine_get(*args) + +def GDAL_GCP_GCPLine_set(*args): + """GDAL_GCP_GCPLine_set(GCP h, double val)""" + return _gdal.GDAL_GCP_GCPLine_set(*args) + +def GDAL_GCP_Info_get(*args): + """GDAL_GCP_Info_get(GCP h) -> char""" + return _gdal.GDAL_GCP_Info_get(*args) + +def GDAL_GCP_Info_set(*args): + """GDAL_GCP_Info_set(GCP h, char val)""" + return _gdal.GDAL_GCP_Info_set(*args) + +def GDAL_GCP_Id_get(*args): + """GDAL_GCP_Id_get(GCP h) -> char""" + return _gdal.GDAL_GCP_Id_get(*args) + +def GDAL_GCP_Id_set(*args): + """GDAL_GCP_Id_set(GCP h, char val)""" + return _gdal.GDAL_GCP_Id_set(*args) + +def GDAL_GCP_get_GCPX(*args): + """GDAL_GCP_get_GCPX(GCP h) -> double""" + return _gdal.GDAL_GCP_get_GCPX(*args) + +def GDAL_GCP_set_GCPX(*args): + """GDAL_GCP_set_GCPX(GCP h, double val)""" + return _gdal.GDAL_GCP_set_GCPX(*args) + +def GDAL_GCP_get_GCPY(*args): + """GDAL_GCP_get_GCPY(GCP h) -> double""" + return _gdal.GDAL_GCP_get_GCPY(*args) + +def GDAL_GCP_set_GCPY(*args): + """GDAL_GCP_set_GCPY(GCP h, double val)""" + return _gdal.GDAL_GCP_set_GCPY(*args) + +def GDAL_GCP_get_GCPZ(*args): + """GDAL_GCP_get_GCPZ(GCP h) -> double""" + return _gdal.GDAL_GCP_get_GCPZ(*args) + +def GDAL_GCP_set_GCPZ(*args): + """GDAL_GCP_set_GCPZ(GCP h, double val)""" + return _gdal.GDAL_GCP_set_GCPZ(*args) + +def GDAL_GCP_get_GCPPixel(*args): + """GDAL_GCP_get_GCPPixel(GCP h) -> double""" + return _gdal.GDAL_GCP_get_GCPPixel(*args) + +def GDAL_GCP_set_GCPPixel(*args): + """GDAL_GCP_set_GCPPixel(GCP h, double val)""" + return _gdal.GDAL_GCP_set_GCPPixel(*args) + +def GDAL_GCP_get_GCPLine(*args): + """GDAL_GCP_get_GCPLine(GCP h) -> double""" + return _gdal.GDAL_GCP_get_GCPLine(*args) + +def GDAL_GCP_set_GCPLine(*args): + """GDAL_GCP_set_GCPLine(GCP h, double val)""" + return _gdal.GDAL_GCP_set_GCPLine(*args) + +def GDAL_GCP_get_Info(*args): + """GDAL_GCP_get_Info(GCP h) -> char""" + return _gdal.GDAL_GCP_get_Info(*args) + +def GDAL_GCP_set_Info(*args): + """GDAL_GCP_set_Info(GCP h, char val)""" + return _gdal.GDAL_GCP_set_Info(*args) + +def GDAL_GCP_get_Id(*args): + """GDAL_GCP_get_Id(GCP h) -> char""" + return _gdal.GDAL_GCP_get_Id(*args) + +def GDAL_GCP_set_Id(*args): + """GDAL_GCP_set_Id(GCP h, char val)""" + return _gdal.GDAL_GCP_set_Id(*args) + +def GCPsToGeoTransform(*args): + """GCPsToGeoTransform(int nGCPs, double argout, int bApproxOK=1) -> FALSE_IS_ERR""" + return _gdal.GCPsToGeoTransform(*args) +class Dataset(MajorObject): + """Proxy of C++ Dataset class""" + __swig_setmethods__ = {} + for _s in [MajorObject]: __swig_setmethods__.update(_s.__swig_setmethods__) + __setattr__ = lambda self, name, value: _swig_setattr(self, Dataset, name, value) + __swig_getmethods__ = {} + for _s in [MajorObject]: __swig_getmethods__.update(_s.__swig_getmethods__) + __getattr__ = lambda self, name: _swig_getattr(self, Dataset, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ GDALDatasetShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_getmethods__["RasterXSize"] = _gdal.Dataset_RasterXSize_get + if _newclass:RasterXSize = property(_gdal.Dataset_RasterXSize_get) + __swig_getmethods__["RasterYSize"] = _gdal.Dataset_RasterYSize_get + if _newclass:RasterYSize = property(_gdal.Dataset_RasterYSize_get) + __swig_getmethods__["RasterCount"] = _gdal.Dataset_RasterCount_get + if _newclass:RasterCount = property(_gdal.Dataset_RasterCount_get) + def __del__(self, destroy=_gdal.delete_Dataset): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def GetDriver(*args): + """GetDriver(self) -> Driver""" + return _gdal.Dataset_GetDriver(*args) + + def GetRasterBand(*args): + """GetRasterBand(self, int nBand) -> Band""" + return _gdal.Dataset_GetRasterBand(*args) + + def GetProjection(*args): + """GetProjection(self) -> char""" + return _gdal.Dataset_GetProjection(*args) + + def GetProjectionRef(*args): + """GetProjectionRef(self) -> char""" + return _gdal.Dataset_GetProjectionRef(*args) + + def SetProjection(*args): + """SetProjection(self, char prj) -> CPLErr""" + return _gdal.Dataset_SetProjection(*args) + + def GetGeoTransform(*args): + """GetGeoTransform(self, double argout)""" + return _gdal.Dataset_GetGeoTransform(*args) + + def SetGeoTransform(*args): + """SetGeoTransform(self, double argin) -> CPLErr""" + return _gdal.Dataset_SetGeoTransform(*args) + + def BuildOverviews(*args, **kwargs): + """BuildOverviews(self, char resampling="NEAREST", int overviewlist=0) -> int""" + return _gdal.Dataset_BuildOverviews(*args, **kwargs) + + def GetGCPCount(*args): + """GetGCPCount(self) -> int""" + return _gdal.Dataset_GetGCPCount(*args) + + def GetGCPProjection(*args): + """GetGCPProjection(self) -> char""" + return _gdal.Dataset_GetGCPProjection(*args) + + def GetGCPs(*args): + """GetGCPs(self, int nGCPs)""" + return _gdal.Dataset_GetGCPs(*args) + + def SetGCPs(*args): + """SetGCPs(self, int nGCPs, char pszGCPProjection) -> CPLErr""" + return _gdal.Dataset_SetGCPs(*args) + + def FlushCache(*args): + """FlushCache(self)""" + return _gdal.Dataset_FlushCache(*args) + + def AddBand(*args, **kwargs): + """AddBand(self, GDALDataType datatype=GDT_Byte, char options=0) -> CPLErr""" + return _gdal.Dataset_AddBand(*args, **kwargs) + + def WriteRaster(*args, **kwargs): + """ + WriteRaster(self, int xoff, int yoff, int xsize, int ysize, int buf_len, + int buf_xsize=0, int buf_ysize=0, GDALDataType buf_type=0, + int band_list=0) -> CPLErr + """ + return _gdal.Dataset_WriteRaster(*args, **kwargs) + + +class DatasetPtr(Dataset): + def __init__(self, this): + _swig_setattr(self, Dataset, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Dataset, 'thisown', 0) + self.__class__ = Dataset +_gdal.Dataset_swigregister(DatasetPtr) + +class Band(MajorObject): + """Proxy of C++ Band class""" + __swig_setmethods__ = {} + for _s in [MajorObject]: __swig_setmethods__.update(_s.__swig_setmethods__) + __setattr__ = lambda self, name, value: _swig_setattr(self, Band, name, value) + __swig_getmethods__ = {} + for _s in [MajorObject]: __swig_getmethods__.update(_s.__swig_getmethods__) + __getattr__ = lambda self, name: _swig_getattr(self, Band, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ GDALRasterBandShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_getmethods__["XSize"] = _gdal.Band_XSize_get + if _newclass:XSize = property(_gdal.Band_XSize_get) + __swig_getmethods__["YSize"] = _gdal.Band_YSize_get + if _newclass:YSize = property(_gdal.Band_YSize_get) + __swig_getmethods__["DataType"] = _gdal.Band_DataType_get + if _newclass:DataType = property(_gdal.Band_DataType_get) + def GetRasterColorInterpretation(*args): + """GetRasterColorInterpretation(self) -> GDALColorInterp""" + return _gdal.Band_GetRasterColorInterpretation(*args) + + def SetRasterColorInterpretation(*args): + """SetRasterColorInterpretation(self, GDALColorInterp val) -> CPLErr""" + return _gdal.Band_SetRasterColorInterpretation(*args) + + def GetNoDataValue(*args): + """GetNoDataValue(self, double val)""" + return _gdal.Band_GetNoDataValue(*args) + + def SetNoDataValue(*args): + """SetNoDataValue(self, double d) -> CPLErr""" + return _gdal.Band_SetNoDataValue(*args) + + def GetMinimum(*args): + """GetMinimum(self, double val)""" + return _gdal.Band_GetMinimum(*args) + + def GetMaximum(*args): + """GetMaximum(self, double val)""" + return _gdal.Band_GetMaximum(*args) + + def GetOffset(*args): + """GetOffset(self, double val)""" + return _gdal.Band_GetOffset(*args) + + def GetScale(*args): + """GetScale(self, double val)""" + return _gdal.Band_GetScale(*args) + + def GetOverviewCount(*args): + """GetOverviewCount(self) -> int""" + return _gdal.Band_GetOverviewCount(*args) + + def GetOverview(*args): + """GetOverview(self, int i) -> Band""" + return _gdal.Band_GetOverview(*args) + + def Checksum(*args, **kwargs): + """Checksum(self, int xoff=0, int yoff=0, int xsize=0, int ysize=0) -> int""" + return _gdal.Band_Checksum(*args, **kwargs) + + def ComputeRasterMinMax(*args): + """ComputeRasterMinMax(self, double argout, int approx_ok=0)""" + return _gdal.Band_ComputeRasterMinMax(*args) + + def Fill(*args): + """Fill(self, double real_fill, double imag_fill=0.0) -> CPLErr""" + return _gdal.Band_Fill(*args) + + def ReadRaster(*args, **kwargs): + """ + ReadRaster(self, int xoff, int yoff, int xsize, int ysize, int buf_len, + int buf_xsize=0, int buf_ysize=0, int buf_type=0) -> CPLErr + """ + return _gdal.Band_ReadRaster(*args, **kwargs) + + def WriteRaster(*args, **kwargs): + """ + WriteRaster(self, int xoff, int yoff, int xsize, int ysize, int buf_len, + int buf_xsize=0, int buf_ysize=0, int buf_type=0) -> CPLErr + """ + return _gdal.Band_WriteRaster(*args, **kwargs) + + def FlushCache(*args): + """FlushCache(self)""" + return _gdal.Band_FlushCache(*args) + + def GetRasterColorTable(*args): + """GetRasterColorTable(self) -> ColorTable""" + return _gdal.Band_GetRasterColorTable(*args) + + def SetRasterColorTable(*args): + """SetRasterColorTable(self, ColorTable arg) -> int""" + return _gdal.Band_SetRasterColorTable(*args) + + def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None, + buf_xsize=None, buf_ysize=None, buf_obj=None): + import gdalnumeric + + return gdalnumeric.BandReadAsArray( self, xoff, yoff, + win_xsize, win_ysize, + buf_xsize, buf_ysize, buf_obj ) + + def WriteArray(self, array, xoff=0, yoff=0): + import gdalnumeric + + return gdalnumeric.BandWriteArray( self, array, xoff, yoff ) + + + +class BandPtr(Band): + def __init__(self, this): + _swig_setattr(self, Band, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Band, 'thisown', 0) + self.__class__ = Band +_gdal.Band_swigregister(BandPtr) + +class ColorTable(_object): + """Proxy of C++ ColorTable class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, ColorTable, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, ColorTable, name) + def __repr__(self): + return "<%s.%s; proxy of C++ GDALColorTable instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __init__(self, *args): + """__init__(self, GDALPaletteInterp ??=GPI_RGB) -> ColorTable""" + _swig_setattr(self, ColorTable, 'this', _gdal.new_ColorTable(*args)) + _swig_setattr(self, ColorTable, 'thisown', 1) + def __del__(self, destroy=_gdal.delete_ColorTable): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def Clone(*args): + """Clone(self) -> ColorTable""" + return _gdal.ColorTable_Clone(*args) + + def GetPaletteInterpretation(*args): + """GetPaletteInterpretation(self) -> GDALPaletteInterp""" + return _gdal.ColorTable_GetPaletteInterpretation(*args) + + def GetCount(*args): + """GetCount(self) -> int""" + return _gdal.ColorTable_GetCount(*args) + + def GetColorEntry(*args): + """GetColorEntry(self, int ??) -> GDALColorEntry""" + return _gdal.ColorTable_GetColorEntry(*args) + + def GetColorEntryAsRGB(*args): + """GetColorEntryAsRGB(self, int ??, GDALColorEntry ??) -> int""" + return _gdal.ColorTable_GetColorEntryAsRGB(*args) + + def SetColorEntry(*args): + """SetColorEntry(self, int ??, GDALColorEntry ??)""" + return _gdal.ColorTable_SetColorEntry(*args) + + +class ColorTablePtr(ColorTable): + def __init__(self, this): + _swig_setattr(self, ColorTable, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, ColorTable, 'thisown', 0) + self.__class__ = ColorTable +_gdal.ColorTable_swigregister(ColorTablePtr) + + +def AllRegister(*args): + """AllRegister()""" + return _gdal.AllRegister(*args) + +def GetCacheMax(*args): + """GetCacheMax() -> int""" + return _gdal.GetCacheMax(*args) + +def SetCacheMax(*args): + """SetCacheMax(int nBytes)""" + return _gdal.SetCacheMax(*args) + +def GetCacheUsed(*args): + """GetCacheUsed() -> int""" + return _gdal.GetCacheUsed(*args) + +def GetDataTypeSize(*args): + """GetDataTypeSize(GDALDataType ??) -> int""" + return _gdal.GetDataTypeSize(*args) + +def DataTypeIsComplex(*args): + """DataTypeIsComplex(GDALDataType ??) -> int""" + return _gdal.DataTypeIsComplex(*args) + +def GetDataTypeName(*args): + """GetDataTypeName(GDALDataType ??) -> char""" + return _gdal.GetDataTypeName(*args) + +def GetDataTypeByName(*args): + """GetDataTypeByName(char ??) -> GDALDataType""" + return _gdal.GetDataTypeByName(*args) + +def GetColorInterpretationName(*args): + """GetColorInterpretationName(GDALColorInterp ??) -> char""" + return _gdal.GetColorInterpretationName(*args) + +def GetPaletteInterpretationName(*args): + """GetPaletteInterpretationName(GDALPaletteInterp ??) -> char""" + return _gdal.GetPaletteInterpretationName(*args) + +def DecToDMS(*args): + """DecToDMS(double ??, char ??, int ??=2) -> char""" + return _gdal.DecToDMS(*args) + +def PackedDMSToDec(*args): + """PackedDMSToDec(double ??) -> double""" + return _gdal.PackedDMSToDec(*args) + +def DecToPackedDMS(*args): + """DecToPackedDMS(double ??) -> double""" + return _gdal.DecToPackedDMS(*args) + +def ParseXMLString(*args): + """ParseXMLString(char ??) -> CPLXMLNode""" + return _gdal.ParseXMLString(*args) + +def SerializeXMLTree(*args): + """SerializeXMLTree(CPLXMLNode xmlnode) -> char""" + return _gdal.SerializeXMLTree(*args) + +def GetDriverCount(*args): + """GetDriverCount() -> int""" + return _gdal.GetDriverCount(*args) + +def GetDriverByName(*args): + """GetDriverByName(char name) -> Driver""" + return _gdal.GetDriverByName(*args) + +def GetDriver(*args): + """GetDriver(int i) -> Driver""" + return _gdal.GetDriver(*args) + +def Open(*args): + """Open(char name, GDALAccess eAccess=GA_ReadOnly) -> Dataset""" + return _gdal.Open(*args) + +def OpenShared(*args): + """OpenShared(char name, GDALAccess eAccess=GA_ReadOnly) -> Dataset""" + return _gdal.OpenShared(*args) + +def AutoCreateWarpedVRT(*args): + """ + AutoCreateWarpedVRT(Dataset src_ds, char src_wkt=0, char dst_wkt=0, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, + double maxerror=0.0) -> Dataset + """ + return _gdal.AutoCreateWarpedVRT(*args) + + diff --git a/Utilities/GDAL/swig/python/gdal_py.h b/Utilities/GDAL/swig/python/gdal_py.h new file mode 100644 index 0000000000..49b8947c3c --- /dev/null +++ b/Utilities/GDAL/swig/python/gdal_py.h @@ -0,0 +1,113 @@ +/****************************************************************************** + * $Id$ + * + * Project: GDAL Python Bindings + * Purpose: Declarations of entry points in source files other than that + * generated from gdal.i. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 2000, 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: gdal_py.h,v $ + * Revision 1.1 2005/02/14 20:38:10 fwarmerdam + * New + * + * Revision 1.3 2003/09/26 15:58:58 warmerda + * keep track if we used internal defs + * + * Revision 1.2 2000/12/23 02:11:50 warmerda + * moved Python.h include outside CPL_C_START brackets + * + * Revision 1.1 2000/07/19 19:42:54 warmerda + * New + * + */ + + +#ifndef _GDAL_PY_INCLUDED +#define _GDAL_PY_INCLUDED + +#include "Python.h" + +CPL_C_START + +void GDALRegister_NUMPY(void); +PyObject *py_NumPyArrayToGDALFilename( PyObject *, PyObject * ); + +#ifdef HAVE_NUMPY +# define NO_IMPORT +# include "Numeric/arrayobject.h" +#endif + +/* -------------------------------------------------------------------- */ +/* If we don't appear to have the arrayobject include file, */ +/* then just declare the numeric types as we last knew them. */ +/* -------------------------------------------------------------------- */ + +#ifndef HAVE_NUMPY + +#define NUMPY_DEFS_WRONG + +enum PyArray_TYPES { PyArray_CHAR, PyArray_UBYTE, PyArray_SBYTE, + PyArray_SHORT, PyArray_USHORT, + PyArray_INT, PyArray_UINT, + PyArray_LONG, + PyArray_FLOAT, PyArray_DOUBLE, + PyArray_CFLOAT, PyArray_CDOUBLE, + PyArray_OBJECT, + PyArray_NTYPES, PyArray_NOTYPE}; + +typedef void (PyArray_VectorUnaryFunc) Py_FPROTO((char *, int, char *, int, int)); +typedef PyObject * (PyArray_GetItemFunc) Py_FPROTO((char *)); +typedef int (PyArray_SetItemFunc) Py_FPROTO((PyObject *, char *)); + +typedef struct { + PyArray_VectorUnaryFunc *cast[PyArray_NTYPES]; /* Functions to cast to */ + /* all other types */ + PyArray_GetItemFunc *getitem; + PyArray_SetItemFunc *setitem; + + int type_num, elsize; + char *one, *zero; + char type; + +} PyArray_Descr; + +typedef struct { + PyObject_HEAD + char *data; + int nd; + int *dimensions, *strides; + PyObject *base; + PyArray_Descr *descr; + int flags; +#ifndef NUMPY_NOEXTRA + PyObject* attributes; /* for user-defined information */ +#endif +} PyArrayObject; + +#endif /* ndef HAVE_NUMPY */ + +CPL_C_END + +#endif /* ndef _GDAL_PY_INCLUDED */ diff --git a/Utilities/GDAL/swig/python/gdal_wrap.cpp b/Utilities/GDAL/swig/python/gdal_wrap.cpp new file mode 100644 index 0000000000..5cd6727357 --- /dev/null +++ b/Utilities/GDAL/swig/python/gdal_wrap.cpp @@ -0,0 +1,8577 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +#include <Python.h> + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * SWIG API. Portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * for internal method declarations + * ----------------------------------------------------------------------------- */ + +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* + Exception handling in wrappers +*/ +#define SWIG_fail goto fail +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) +#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) +#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) +#define SWIG_null_ref(type) SWIG_Python_NullRef(type) + +/* + Contract support +*/ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_INT 1 +#define SWIG_PY_FLOAT 2 +#define SWIG_PY_STRING 3 +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Alloc. memory flags + * ----------------------------------------------------------------------------- */ +#define SWIG_OLDOBJ 1 +#define SWIG_NEWOBJ SWIG_OLDOBJ + 1 +#define SWIG_PYSTR SWIG_NEWOBJ + 1 + +#ifdef __cplusplus +} +#endif + + +/*********************************************************************** + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * Author : David Beazley (beazley@cs.uchicago.edu) + ************************************************************************/ + +/* Common SWIG API */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + + +/* Python-specific SWIG API */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ +/* + Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent + C/C++ pointers in the python side. Very useful for debugging, but + not always safe. +*/ +#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) +# define SWIG_COBJECT_TYPES +#endif + +/* Flags for pointer conversion */ +#define SWIG_POINTER_EXCEPTION 0x1 +#define SWIG_POINTER_DISOWN 0x2 + + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +#define PyOS_snprintf snprintf +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Create a new pointer string + * ----------------------------------------------------------------------------- */ +#ifndef SWIG_BUFFER_SIZE +#define SWIG_BUFFER_SIZE 1024 +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_BUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +#if PY_VERSION_HEX < 0x01060000 +#define PyObject_Del(op) PyMem_DEL((op)) +#endif + +#if defined(SWIG_COBJECT_TYPES) +#if !defined(SWIG_COBJECT_PYTHON) +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Object type, and use it instead of PyCObject + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *ptr; + const char *desc; +} PySwigObject; + +/* Declarations for objects of type PySwigObject */ + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { + fputs("<Swig Object at ", fp); fputs(result, fp); fputs(">", fp); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_repr(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromFormat("<Swig Object at %s>", result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); + } +} + +SWIGRUNTIME void +PySwigObject_dealloc(PySwigObject *self) +{ + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static char pyswigobject_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigObject", /*tp_name*/ + sizeof(PySwigObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigObject_dealloc, /*tp_dealloc*/ + (printfunc)PySwigObject_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigObject_compare, /*tp_compare*/ + (reprfunc)PySwigObject_repr, /*tp_repr*/ + &PySwigObject_as_number, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigObject_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigobject_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigobject_type = tmp; + type_init = 1; + } +#endif + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) +{ + PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (self) { + self->ptr = ptr; + self->desc = desc; + } + return (PyObject *)self; +} + +SWIGRUNTIMEINLINE void * +PySwigObject_AsVoidPtr(PyObject *self) +{ + return ((PySwigObject *)self)->ptr; +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + return ((PySwigObject *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + const char *desc; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->desc,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->desc); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->desc); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->desc); + } else { + return PyString_FromString(v->desc); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + } +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PySwigPacked *self) +{ + free(self->pack); + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static char pyswigpacked_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigPacked", /*tp_name*/ + sizeof(PySwigPacked), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ + (printfunc)PySwigPacked_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigPacked_compare, /*tp_compare*/ + (reprfunc)PySwigPacked_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigPacked_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigpacked_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigpacked_type = tmp; + type_init = 1; + } +#endif + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) +{ + PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (self == NULL) { + return NULL; + } else { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + self->pack = pack; + self->desc = desc; + self->size = size; + return (PyObject *) self; + } + return NULL; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + PySwigPacked *self = (PySwigPacked *)obj; + if (self->size != size) return 0; + memcpy(ptr, self->pack, size); + return self->desc; +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_GetDesc(PyObject *self) +{ + return ((PySwigPacked *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +#else +/* ----------------------------------------------------------------------------- + * Use the old Python PyCObject instead of PySwigObject + * ----------------------------------------------------------------------------- */ + +#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) +#define PySwigObject_Check(obj) PyCObject_Check(obj) +#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) +#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) + +#endif + +#endif + +/* ----------------------------------------------------------------------------- + * errors manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + +SWIGRUNTIMEINLINE void +SWIG_Python_NullRef(const char *type) +{ + if (type) { + PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); + } else { + PyErr_Format(PyExc_TypeError, "null reference was received"); + } +} + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + static PyObject *SWIG_this = 0; + int newref = 0; + PyObject *pyobj = 0; + void *vptr; + + if (!obj) return 0; + if (obj == Py_None) { + *ptr = 0; + return 0; + } + +#ifdef SWIG_COBJECT_TYPES + if (!(PySwigObject_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PySwigObject_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + vptr = PySwigObject_AsVoidPtr(obj); + c = (const char *) PySwigObject_GetDesc(obj); + if (newref) { Py_DECREF(obj); } + goto type_check; +#else + if (!(PyString_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PyString_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); + if (newref) { Py_DECREF(obj); } + if (!c) goto type_error; +#endif + +type_check: + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + *ptr = SWIG_TypeCast(tc,vptr); + } else { + *ptr = vptr; + } + if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { + PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); + } + return 0; + +type_error: + PyErr_Clear(); + if (pyobj && !obj) { + obj = pyobj; + if (PyCFunction_Check(obj)) { + /* here we get the method pointer for callbacks */ + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + c = doc ? strstr(doc, "swig_ptr: ") : 0; + if (c) { + c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; + if (!c) goto type_error; + goto type_check; + } + } + } + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ pointer", obj); + } + } + return -1; +} + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + c = PySwigPacked_UnpackData(obj, ptr, sz); +#else + if ((!obj) || (!PyString_Check(obj))) goto type_error; + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackDataName(c, ptr, sz, ty->name); +#endif + if (!c) goto type_error; + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + } + return 0; + +type_error: + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ packed data", obj); + } + } + return -1; +} + +/* Create a new array object */ +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { + PyObject *robj = 0; + if (!type) { + if (!PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj"); + } + return robj; + } + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#ifdef SWIG_COBJECT_TYPES + robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + if (!robj || (robj == Py_None)) return robj; + if (type->clientdata) { + PyObject *inst; + PyObject *args = Py_BuildValue((char*)"(O)", robj); + Py_DECREF(robj); + inst = PyObject_CallObject((PyObject *) type->clientdata, args); + Py_DECREF(args); + if (inst) { + if (own) { + PyObject_SetAttrString(inst,(char*)"thisown",Py_True); + } + robj = inst; + } + } + return robj; +} + +SWIGRUNTIME PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + PyObject *robj = 0; + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + return robj; +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function +is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return -1; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return -1; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return -1; + } + if (PyDict_SetItemString(dict, name, o)) + return -1; + Py_DECREF(o); + return 0; +} +#endif + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } +} + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_CPLErrorHandler swig_types[0] +#define SWIGTYPE_p_CPLXMLNode swig_types[1] +#define SWIGTYPE_p_GDALColorEntry swig_types[2] +#define SWIGTYPE_p_GDALColorTable swig_types[3] +#define SWIGTYPE_p_GDALDatasetShadow swig_types[4] +#define SWIGTYPE_p_GDALDriverShadow swig_types[5] +#define SWIGTYPE_p_GDALMajorObjectShadow swig_types[6] +#define SWIGTYPE_p_GDALRasterBandShadow swig_types[7] +#define SWIGTYPE_p_GDAL_GCP swig_types[8] +#define SWIGTYPE_p_char swig_types[9] +#define SWIGTYPE_p_double swig_types[10] +#define SWIGTYPE_p_int swig_types[11] +#define SWIGTYPE_p_p_GDAL_GCP swig_types[12] +#define SWIGTYPE_p_p_char swig_types[13] +#define SWIGTYPE_ptrdiff_t swig_types[14] +#define SWIGTYPE_size_t swig_types[15] +#define SWIGTYPE_std__ptrdiff_t swig_types[16] +#define SWIGTYPE_std__size_t swig_types[17] +static swig_type_info *swig_types[19]; +static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + + +/*----------------------------------------------- + @(target):= _gdal.so + ------------------------------------------------*/ +#define SWIG_init init_gdal + +#define SWIG_name "_gdal" + +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + + + +int bUseExceptions=0; + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} + + +void UseExceptions() { + bUseExceptions = 1; + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + bUseExceptions = 0; + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} + + +#define SWIG_MemoryError 1 +#define SWIG_IOError 2 +#define SWIG_RuntimeError 3 +#define SWIG_IndexError 4 +#define SWIG_TypeError 5 +#define SWIG_DivisionByZero 6 +#define SWIG_OverflowError 7 +#define SWIG_SyntaxError 8 +#define SWIG_ValueError 9 +#define SWIG_SystemError 10 +#define SWIG_UnknownError 99 + + +SWIGINTERN void SWIG_exception_(int code, const char *msg) { + switch(code) { + case SWIG_MemoryError: + PyErr_SetString(PyExc_MemoryError,msg); + break; + case SWIG_IOError: + PyErr_SetString(PyExc_IOError,msg); + break; + case SWIG_RuntimeError: + PyErr_SetString(PyExc_RuntimeError,msg); + break; + case SWIG_IndexError: + PyErr_SetString(PyExc_IndexError,msg); + break; + case SWIG_TypeError: + PyErr_SetString(PyExc_TypeError,msg); + break; + case SWIG_DivisionByZero: + PyErr_SetString(PyExc_ZeroDivisionError,msg); + break; + case SWIG_OverflowError: + PyErr_SetString(PyExc_OverflowError,msg); + break; + case SWIG_SyntaxError: + PyErr_SetString(PyExc_SyntaxError,msg); + break; + case SWIG_ValueError: + PyErr_SetString(PyExc_ValueError,msg); + break; + case SWIG_SystemError: + PyErr_SetString(PyExc_SystemError,msg); + break; + default: + PyErr_SetString(PyExc_RuntimeError,msg); + break; + } +} + +#define SWIG_exception(a,b) { SWIG_exception_(a,b); SWIG_fail; } + + +#include <stdexcept> + + + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + + + +/* returns SWIG_OLDOBJ if the input is a raw char*, SWIG_PYSTR if is a PyString */ +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize) +{ + static swig_type_info* pchar_info = 0; + char* vptr = 0; + if (!pchar_info) pchar_info = SWIG_TypeQuery("char *"); + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) != -1) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + if (PyString_Check(obj)) { + if (cptr) { + *cptr = PyString_AS_STRING(obj); + if (psize) { + *psize = PyString_GET_SIZE(obj) + 1; + } + } + return SWIG_PYSTR; + } + } + if (cptr) { + SWIG_type_error("char *", obj); + } + return 0; +} + + +SWIGINTERNINLINE int +SWIG_AsCharPtr(PyObject *obj, char **val) +{ + if (SWIG_AsCharPtrAndSize(obj, val, (size_t*)(0))) { + return 1; + } + if (val) { + PyErr_Clear(); + SWIG_type_error("char *", obj); + } + return 0; +} + + +#include <limits.h> + + +SWIGINTERN int + SWIG_CheckLongInRange(long value, long min_value, long max_value, + const char *errmsg) +{ + if (value < min_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is less than '%s' minimum %ld", + value, errmsg, min_value); + } + return 0; + } else if (value > max_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is greater than '%s' maximum %ld", + value, errmsg, max_value); + } + return 0; + } + return 1; +} + + +SWIGINTERN int + SWIG_AsVal_long(PyObject * obj, long* val) +{ + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (val) { + SWIG_type_error("long", obj); + } + return 0; + } + + +#if INT_MAX != LONG_MAX +SWIGINTERN int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + const char* errmsg = val ? "int" : (char*)0; + long v; + if (SWIG_AsVal_long(obj, &v)) { + if (SWIG_CheckLongInRange(v, INT_MIN,INT_MAX, errmsg)) { + if (val) *val = static_cast<int >(v); + return 1; + } else { + return 0; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_type_error(errmsg, obj); + } + return 0; +} +#else +SWIGINTERNINLINE int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + return SWIG_AsVal_long(obj,(long*)val); +} +#endif + + +SWIGINTERNINLINE int +SWIG_As_int(PyObject* obj) +{ + int v; + if (!SWIG_AsVal_int(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(int)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_int(PyObject* obj) +{ + return SWIG_AsVal_int(obj, (int*)0); +} + + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_int PyInt_FromLong +/*@@*/ + + +SWIGINTERN PyObject * +SWIG_FromCharPtr(const char* cptr) +{ + if (cptr) { + size_t size = strlen(cptr); + if (size > INT_MAX) { + return SWIG_NewPointerObj(const_cast<char* >(cptr), + SWIG_TypeQuery("char *"), 0); + } else { + if (size != 0) { + return PyString_FromStringAndSize(cptr, size); + } else { + return PyString_FromString(cptr); + } + } + } + Py_INCREF(Py_None); + return Py_None; +} + +static char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){ + return GDALGetDescription( self ); + } +static void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){ + GDALSetDescription( self, pszNewDesc ); + } +static char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static char **GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){ + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +static CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){ + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } +static GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *name,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){ + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } +static GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *name,GDALDatasetShadow *src,int strict=1,char **options=0){ + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } +static int GDALDriverShadow_Delete(GDALDriverShadow *self,char const *name){ + return GDALDeleteDataset( self, name ); + } + +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} + + +SWIGINTERN int + SWIG_AsVal_double(PyObject *obj, double *val) +{ + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return 1; + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (val) { + SWIG_type_error("double", obj); + } + return 0; +} + + +SWIGINTERNINLINE double +SWIG_As_double(PyObject* obj) +{ + double v; + if (!SWIG_AsVal_double(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(double)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_double(PyObject* obj) +{ + return SWIG_AsVal_double(obj, (double*)0); +} + + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_double PyFloat_FromDouble +/*@@*/ + +static GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){ + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } +static void delete_GDAL_GCP(GDAL_GCP *self){ + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } + + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +SWIGINTERN PyObject* +t_output_helper(PyObject* target, PyObject* o) { + if (!target) { + target = o; + } else if (target == Py_None) { + Py_DECREF(target); + target = o; + } else { + if (!PyList_Check(target)) { + PyObject *o2 = target; + target = PyList_New(1); + PyList_SetItem(target, 0, o2); + } + PyList_Append(target,o); + Py_DECREF(o); + } + return target; +} + + +static PyObject * +CreateTupleFromDoubleArray( double *first, unsigned int size ) { + PyObject *out = PyTuple_New( size ); + for( unsigned int i=0; i<size; i++ ) { + PyObject *val = PyFloat_FromDouble( *first ); + ++first; + PyTuple_SetItem( out, i, val ); + } + return out; +} + +static void delete_GDALDatasetShadow(GDALDatasetShadow *self){ + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } +static GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){ + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } +static GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){ + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } +static char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +static CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){ + return GDALSetProjection( self, prj ); + } +static void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6]){ + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } +static CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){ + return GDALSetGeoTransform( self, argin ); + } +static int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0){ + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +static int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){ + return GDALGetGCPCount( self ); + } +static char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){ + return GDALGetGCPProjection( self ); + } +static void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){ + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } +static CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){ + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } +static void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){ + GDALFlushCache( self ); + } +static CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){ + return GDALAddBand( self, datatype, options ); + } +static CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } + +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} + + +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} + +static GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){ + return GDALGetRasterColorInterpretation( self ); + } +static CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){ + return GDALSetRasterColorInterpretation( self, val ); + } +static void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterNoDataValue( self, hasval ); + } +static CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){ + return GDALSetRasterNoDataValue( self, d ); + } +static void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMinimum( self, hasval ); + } +static void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMaximum( self, hasval ); + } +static void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterOffset( self, hasval ); + } +static void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterScale( self, hasval ); + } +static int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){ + return GDALGetOverviewCount( self ); + } +static GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){ + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } +static int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){ + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +static void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){ + GDALComputeRasterMinMax( self, approx_ok, argout ); + } +static CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){ + return GDALFillRaster( self, real_fill, imag_fill ); + } +static CPLErr GDALRasterBandShadow_ReadRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_len,char **buf,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +static CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +static void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){ + GDALFlushRasterCache( self ); + } +static GDALColorTable *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){ + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } +static int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTable *arg){ + return GDALSetRasterColorTable( self, arg ); + } + +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} + + +/************************************************************************/ +/* XMLTreeToPyList() */ +/************************************************************************/ +static PyObject *XMLTreeToPyList( CPLXMLNode *psTree ) +{ + PyObject *pyList; + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + pyList = PyList_New(nChildCount+2); + + PyList_SetItem( pyList, 0, Py_BuildValue( "i", (int) psTree->eType ) ); + PyList_SetItem( pyList, 1, Py_BuildValue( "s", psTree->pszValue ) ); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + PyList_SetItem( pyList, iChild, XMLTreeToPyList( psChild ) ); + } + + return pyList; +} + + +/************************************************************************/ +/* PyListToXMLTree() */ +/************************************************************************/ +static CPLXMLNode *PyListToXMLTree( PyObject *pyList ) + +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = PyList_Size(pyList) - 2; + if( nChildCount < 0 ) + { + PyErr_SetString(PyExc_TypeError,"Error in input XMLTree." ); + return NULL; + } + + PyArg_Parse( PyList_GET_ITEM(pyList,0), "i", &nType ); + PyArg_Parse( PyList_GET_ITEM(pyList,1), "s", &pszText ); + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = PyListToXMLTree( PyList_GET_ITEM(pyList,iChild+2) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} + + +int GetDriverCount() { + return GDALGetDriverCount(); +} + + +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} + + +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} + + +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} + +#ifdef __cplusplus +extern "C" { +#endif +static PyObject *_wrap_UseExceptions(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":UseExceptions")) goto fail; + UseExceptions(); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DontUseExceptions(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":DontUseExceptions")) goto fail; + DontUseExceptions(); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Debug(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Debug",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + Debug((char const *)arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Error(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + CPLErr arg1 = (CPLErr) CE_Failure ; + int arg2 = (int) 0 ; + char *arg3 = (char *) "error" ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"|OOO:Error",&obj0,&obj1,&obj2)) goto fail; + if (obj0) { + { + arg1 = static_cast<CPLErr >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + } + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + if (obj2) { + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + { + CPLErrorReset(); + Error(arg1,arg2,(char const *)arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PushErrorHandler__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) "CPLQuietErrorHandler" ; + CPLErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"|O:PushErrorHandler",&obj0)) goto fail; + if (obj0) { + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (CPLErr)PushErrorHandler((char const *)arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PushErrorHandler__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + CPLErrorHandler arg1 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:PushErrorHandler",&obj0)) goto fail; + { + CPLErrorHandler * argp; + SWIG_Python_ConvertPtr(obj0, (void **)&argp, SWIGTYPE_p_CPLErrorHandler, SWIG_POINTER_EXCEPTION); + if (SWIG_arg_fail(1)) SWIG_fail; + if (argp == NULL) { + SWIG_null_ref("CPLErrorHandler"); + } + if (SWIG_arg_fail(1)) SWIG_fail; + arg1 = *argp; + } + { + CPLErrorReset(); + CPLPushErrorHandler(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PushErrorHandler(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[2]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 1); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if ((argc >= 0) && (argc <= 1)) { + int _v; + if (argc <= 0) { + return _wrap_PushErrorHandler__SWIG_0(self,args); + } + _v = SWIG_AsCharPtr(argv[0], (char **)(0)); + if (_v) { + return _wrap_PushErrorHandler__SWIG_0(self,args); + } + } + if (argc == 1) { + int _v; + { + void *ptr = 0; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_CPLErrorHandler, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = (ptr != 0); + } + } + if (_v) { + return _wrap_PushErrorHandler__SWIG_1(self,args); + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'PushErrorHandler'"); + return NULL; +} + + +static PyObject *_wrap_PopErrorHandler(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":PopErrorHandler")) goto fail; + { + CPLErrorReset(); + CPLPopErrorHandler(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ErrorReset(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":ErrorReset")) goto fail; + { + CPLErrorReset(); + CPLErrorReset(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetLastErrorNo(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetLastErrorNo")) goto fail; + { + CPLErrorReset(); + result = (int)CPLGetLastErrorNo(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetLastErrorType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + CPLErr result; + + if(!PyArg_ParseTuple(args,(char *)":GetLastErrorType")) goto fail; + { + CPLErrorReset(); + result = (CPLErr)CPLGetLastErrorType(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetLastErrorMsg(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *result; + + if(!PyArg_ParseTuple(args,(char *)":GetLastErrorMsg")) goto fail; + { + CPLErrorReset(); + result = (char *)CPLGetLastErrorMsg(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PushFinderLocation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:PushFinderLocation",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + { + CPLErrorReset(); + CPLPushFinderLocation((char const *)arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PopFinderLocation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":PopFinderLocation")) goto fail; + { + CPLErrorReset(); + CPLPopFinderLocation(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FinderClean(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":FinderClean")) goto fail; + { + CPLErrorReset(); + CPLFinderClean(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FindFile(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FindFile",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)CPLFindFile((char const *)arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SetConfigOption(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SetConfigOption",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + CPLSetConfigOption((char const *)arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetConfigOption(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GetConfigOption",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)CPLGetConfigOption((char const *)arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_GetDescription(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:MajorObject_GetDescription",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALMajorObjectShadow_GetDescription(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_SetDescription(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:MajorObject_SetDescription",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDALMajorObjectShadow_SetDescription(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_GetMetadata_Dict(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|O:MajorObject_GetMetadata_Dict",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (char **)GDALMajorObjectShadow_GetMetadata_Dict(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + /* %typemap(out) char **dict */ + char **stringarray = result; + resultobj = PyDict_New(); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + if ( valptr != 0 ) { + PyObject *nm = PyString_FromString( keyptr ); + PyObject *val = PyString_FromString( valptr ); + PyDict_SetItem(resultobj, nm, val ); + CPLFree( keyptr ); + } + stringarray++; + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_GetMetadata_List(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|O:MajorObject_GetMetadata_List",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (char **)GDALMajorObjectShadow_GetMetadata_List(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + /* %typemap(out) char ** -> ( string ) */ + char **stringarray = result; + if ( stringarray == NULL ) { + resultobj = Py_None; + Py_INCREF( resultobj ); + } + else { + int len = CSLCount( stringarray ); + resultobj = PyList_New( len ); + for ( int i = 0; i < len; ++i, ++stringarray ) { + PyObject *o = PyString_FromString( *stringarray ); + PyList_SetItem(resultobj, i, o ); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_SetMetadata__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:MajorObject_SetMetadata",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in) char **dict */ + arg2 = NULL; + if ( PySequence_Check( obj1 ) ) { + int size = PySequence_Size(obj1); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj1,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg2 = CSLAddString( arg2, pszItem ); + } + } + else if ( PyMapping_Check( obj1 ) ) { + /* We need to use the dictionary form. */ + int size = PyMapping_Length( obj1 ); + if ( size > 0 ) { + PyObject *item_list = PyMapping_Items( obj1 ); + for( int i=0; i<size; i++ ) { + PyObject *it = PySequence_GetItem( item_list, i ); + char *nm; + char *val; + PyArg_ParseTuple( it, "ss", &nm, &val ); + arg2 = CSLAddNameValue( arg2, nm, val ); + } + } + } + else { + PyErr_SetString(PyExc_TypeError,"Argument must be dictionary or sequence of strings"); + SWIG_fail; + } + } + if (obj2) { + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_0(arg1,arg2,(char const *)arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_MajorObject_SetMetadata__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:MajorObject_SetMetadata",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALMajorObjectShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_1(arg1,arg2,(char const *)arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_MajorObject_SetMetadata(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 3); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if ((argc >= 2) && (argc <= 3)) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_GDALMajorObjectShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + { + /* %typecheck(SWIG_TYPECHECK_POINTER) (char **dict) */ + _v = (PyMapping_Check(argv[1]) || PySequence_Check(argv[1]) ) ? 1 : 0; + } + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_SetMetadata__SWIG_0(self,args); + } + _v = SWIG_AsCharPtr(argv[2], (char **)(0)); + if (_v) { + return _wrap_MajorObject_SetMetadata__SWIG_0(self,args); + } + } + } + } + if ((argc >= 2) && (argc <= 3)) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_GDALMajorObjectShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_SetMetadata__SWIG_1(self,args); + } + _v = SWIG_AsCharPtr(argv[2], (char **)(0)); + if (_v) { + return _wrap_MajorObject_SetMetadata__SWIG_1(self,args); + } + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'MajorObject_SetMetadata'"); + return NULL; +} + + +static PyObject * MajorObject_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDALMajorObjectShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_Driver_ShortName_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Driver_ShortName_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_ShortName_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_LongName_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Driver_LongName_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_LongName_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_HelpTopic_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Driver_HelpTopic_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_HelpTopic_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_Create(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 = (int) 1 ; + GDALDataType arg6 = (GDALDataType) GDT_Byte ; + char **arg7 = (char **) 0 ; + GDALDatasetShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "name",(char *) "xsize",(char *) "ysize",(char *) "bands",(char *) "eType",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO|OOO:Driver_Create",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<int >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + if (obj4) { + { + arg5 = static_cast<int >(SWIG_As_int(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + if (obj5) { + { + arg6 = static_cast<GDALDataType >(SWIG_As_int(obj5)); + if (SWIG_arg_fail(6)) SWIG_fail; + } + } + if (obj6) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj6)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj6); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj6,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg7 = CSLAddString( arg7, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_Create(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDatasetShadow, 1); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg7 ); + } + return NULL; +} + + +static PyObject *_wrap_Driver_CreateCopy(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + GDALDatasetShadow *arg3 = (GDALDatasetShadow *) 0 ; + int arg4 = (int) 1 ; + char **arg5 = (char **) 0 ; + GDALDatasetShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "name",(char *) "src",(char *) "strict",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|OO:Driver_CreateCopy",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + SWIG_Python_ConvertPtr(obj2, (void **)&arg3, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(3)) SWIG_fail; + if (obj3) { + { + arg4 = static_cast<int >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + if (obj4) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj4)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj4); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj4,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_CreateCopy(arg1,(char const *)arg2,arg3,arg4,arg5); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDatasetShadow, 1); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return NULL; +} + + +static PyObject *_wrap_Driver_Delete(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Driver_Delete",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GDALDriverShadow_Delete(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * Driver_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDALDriverShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_GCP_GCPX_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_GCPX_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPX_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_GCPX_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPY_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_GCPY_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPY_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_GCPY_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPZ_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_GCPZ_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPZ_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_GCPZ_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPPixel_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_GCPPixel_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPPixel_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_GCPPixel_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPLine_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_GCPLine_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_GCPLine_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_GCPLine_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_Info_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_Info_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_Info_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_Info_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_Id_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GCP_Id_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCP_Id_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GCP_Id_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_new_GCP(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + double arg1 = (double) 0.0 ; + double arg2 = (double) 0.0 ; + double arg3 = (double) 0.0 ; + double arg4 = (double) 0.0 ; + double arg5 = (double) 0.0 ; + char *arg6 = (char *) "" ; + char *arg7 = (char *) "" ; + GDAL_GCP *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"|OOOOOOO:new_GCP",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; + if (obj0) { + { + arg1 = static_cast<double >(SWIG_As_double(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + } + if (obj1) { + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + if (obj2) { + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + if (obj3) { + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + if (obj4) { + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + if (obj5) { + if (!SWIG_AsCharPtr(obj5, (char**)&arg6)) { + SWIG_arg_fail(6);SWIG_fail; + } + } + if (obj6) { + if (!SWIG_AsCharPtr(obj6, (char**)&arg7)) { + SWIG_arg_fail(7);SWIG_fail; + } + } + { + CPLErrorReset(); + result = (GDAL_GCP *)new_GDAL_GCP(arg1,arg2,arg3,arg4,arg5,(char const *)arg6,(char const *)arg7); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDAL_GCP, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_GCP(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_GCP",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + delete_GDAL_GCP(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject * GCP_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDAL_GCP, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_GDAL_GCP_GCPX_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_GCPX_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPX_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_GCPX_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPY_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_GCPY_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPY_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_GCPY_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPZ_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_GCPZ_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPZ_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_GCPZ_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPPixel_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_GCPPixel_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPPixel_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_GCPPixel_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPLine_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_GCPLine_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_GCPLine_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_GCPLine_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_Info_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_Info_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_Info_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_Info_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_Id_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_Id_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_Id_set(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_Id_set",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_GCPX(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_GCPX",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPX(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_GCPX(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_GCPX",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_GCPX(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_GCPY(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_GCPY",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPY(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_GCPY(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_GCPY",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_GCPY(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_GCPZ(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_GCPZ",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPZ(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_GCPZ(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_GCPZ",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_GCPZ(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_GCPPixel(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_GCPPixel",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPPixel(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_GCPPixel(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_GCPPixel",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_GCPPixel(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_GCPLine(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_GCPLine",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPLine(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_GCPLine(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_GCPLine",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_GCPLine(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_Info(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_Info",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Info(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_Info(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_Info",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_Info(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_get_Id(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GDAL_GCP_get_Id",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Id(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GDAL_GCP_set_Id(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:GDAL_GCP_set_Id",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + GDAL_GCP_set_Id(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GCPsToGeoTransform(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + GDAL_GCP *arg2 = (GDAL_GCP *) 0 ; + double *arg3 ; + int arg4 = (int) 1 ; + FALSE_IS_ERR result; + GDAL_GCP *tmpGCPList1 ; + double argout3[6] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout3[ANY]) */ + arg3 = argout3; + } + if(!PyArg_ParseTuple(args,(char *)"O|O:GCPsToGeoTransform",&obj0,&obj1)) goto fail; + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + /* check if is List */ + if ( !PySequence_Check(obj0) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + arg1 = PySequence_Size(obj0); + tmpGCPList1 = (GDAL_GCP*) malloc(arg1*sizeof(GDAL_GCP)); + arg2 = tmpGCPList1; + for( int i = 0; i<arg1; i++ ) { + PyObject *o = PySequence_GetItem(obj0,i); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( o, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList1, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList1; + } + } + if (obj1) { + { + arg4 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = GDALGCPsToGeoTransform(arg1,(GDAL_GCP const *)arg2,arg3,arg4); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + /*%typemap(out) IF_FALSE_RETURN_NONE */ + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg3, 6 ); + resultobj = t_output_helper(resultobj,out); + } + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + { + /* %typemap(ret) IF_FALSE_RETURN_NONE */ + if (result == 0 ) { + Py_XDECREF( resultobj ); + resultobj = Py_None; + Py_INCREF(resultobj); + } + if (resultobj == 0) { + resultobj = Py_None; + Py_INCREF(resultobj); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + return NULL; +} + + +static PyObject *_wrap_Dataset_RasterXSize_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_RasterXSize_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterXSize_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_RasterYSize_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_RasterYSize_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterYSize_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_RasterCount_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_RasterCount_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterCount_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_Dataset(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_Dataset",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + delete_GDALDatasetShadow(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetDriver(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetDriver",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALDriverShadow *)GDALDatasetShadow_GetDriver(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetRasterBand(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Dataset_GetRasterBand",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALDatasetShadow_GetRasterBand(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALRasterBandShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetProjection(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetProjection",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjection(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetProjectionRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetProjectionRef",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjectionRef(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_SetProjection(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Dataset_SetProjection",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetProjection(arg1,(char const *)arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetGeoTransform(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + double argout2[6] ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetGeoTransform",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALDatasetShadow_GetGeoTransform(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 6 ); + resultobj = t_output_helper(resultobj,out); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_SetGeoTransform(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + CPLErr result; + double argin2[6] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Dataset_SetGeoTransform",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in) (double argin2[ANY]) */ + arg2 = argin2; + if (! PySequence_Check(obj1) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + int seq_size = PySequence_Size(obj1); + if ( seq_size != 6 ) { + PyErr_SetString(PyExc_TypeError, "sequence must have length ##size"); + SWIG_fail; + } + for (unsigned int i=0; i<6; i++) { + PyObject *o = PySequence_GetItem(obj1,i); + double val; + PyArg_Parse(o, "d", &val ); + arg2[i] = val; + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGeoTransform(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_BuildOverviews(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) "NEAREST" ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "resampling",(char *) "overviewlist", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OO:Dataset_BuildOverviews",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + if (obj2) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + /* check if is List */ + if ( !PySequence_Check(obj2) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + arg3 = PySequence_Size(obj2); + arg4 = (int*) malloc(arg3*sizeof(int)); + for( int i = 0; i<arg3; i++ ) { + PyObject *o = PySequence_GetItem(obj2,i); + if ( !PyArg_Parse(o,"i",&arg4[i]) ) { + SWIG_fail; + } + } + } + } + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_BuildOverviews(arg1,(char const *)arg2,arg3,arg4); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return NULL; +} + + +static PyObject *_wrap_Dataset_GetGCPCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetGCPCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_GetGCPCount(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetGCPProjection(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetGCPProjection",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetGCPProjection(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_GetGCPs(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int *arg2 = (int *) 0 ; + GDAL_GCP **arg3 = (GDAL_GCP **) 0 ; + int nGCPs2 = 0 ; + GDAL_GCP *pGCPs2 = 0 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (int *nGCPs2, GDAL_GCP const **pGCPs2 ) */ + arg2 = &nGCPs2; + arg3 = &pGCPs2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_GetGCPs",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALDatasetShadow_GetGCPs(arg1,arg2,(GDAL_GCP const **)arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + PyObject *dict = PyTuple_New( *arg2 ); + for( int i = 0; i < *arg2; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*arg3)[i].dfGCPX, + (*arg3)[i].dfGCPY, + (*arg3)[i].dfGCPZ, + (*arg3)[i].dfGCPPixel, + (*arg3)[i].dfGCPLine, + (*arg3)[i].pszInfo, + (*arg3)[i].pszId ); + + PyTuple_SetItem(dict, i, + SWIG_NewPointerObj((void*)o,SWIGTYPE_p_GDAL_GCP,1) ); + } + Py_DECREF(resultobj); + resultobj = dict; + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_SetGCPs(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDAL_GCP *arg3 = (GDAL_GCP *) 0 ; + char *arg4 = (char *) 0 ; + CPLErr result; + GDAL_GCP *tmpGCPList2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:Dataset_SetGCPs",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + /* check if is List */ + if ( !PySequence_Check(obj1) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + arg2 = PySequence_Size(obj1); + tmpGCPList2 = (GDAL_GCP*) malloc(arg2*sizeof(GDAL_GCP)); + arg3 = tmpGCPList2; + for( int i = 0; i<arg2; i++ ) { + PyObject *o = PySequence_GetItem(obj1,i); + GDAL_GCP *item = 0; + SWIG_ConvertPtr( o, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + if ( ! item ) { + SWIG_fail; + } + memcpy( (void*) tmpGCPList2, (void*) item, sizeof( GDAL_GCP ) ); + ++tmpGCPList2; + } + } + if (!SWIG_AsCharPtr(obj2, (char**)&arg4)) { + SWIG_arg_fail(4);SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGCPs(arg1,arg2,(GDAL_GCP const *)arg3,(char const *)arg4); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + return NULL; +} + + +static PyObject *_wrap_Dataset_FlushCache(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Dataset_FlushCache",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALDatasetShadow_FlushCache(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Dataset_AddBand(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDataType arg2 = (GDALDataType) GDT_Byte ; + char **arg3 = (char **) 0 ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "datatype",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OO:Dataset_AddBand",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<GDALDataType >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + if (obj2) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj2)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj2); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj2,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_AddBand(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return NULL; +} + + +static PyObject *_wrap_Dataset_WriteRaster(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + GDALDataType *arg10 = (GDALDataType *) 0 ; + int arg11 = (int) 0 ; + int *arg12 = (int *) 0 ; + CPLErr result; + int val8 ; + int val9 ; + int val10 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "xoff",(char *) "yoff",(char *) "xsize",(char *) "ysize",(char *) "buf_len",(char *) "buf_xsize",(char *) "buf_ysize",(char *) "buf_type",(char *) "band_list", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO|OOOO:Dataset_WriteRaster",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<int >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<int >(SWIG_As_int(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + PyString_AsStringAndSize(obj5, &arg7, &arg6 ); + } + if (obj6) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj6 == Py_None ) { + arg8 = 0; + } + else if ( PyArg_Parse( obj6,"i" ,&val8 ) ) { + arg8 = (int *) &val8; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj7) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj7 == Py_None ) { + arg9 = 0; + } + else if ( PyArg_Parse( obj7,"i" ,&val9 ) ) { + arg9 = (int *) &val9; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj8) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj8 == Py_None ) { + arg10 = 0; + } + else if ( PyArg_Parse( obj8,"i" ,&val10 ) ) { + arg10 = (GDALDataType *) &val10; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj9) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList)*/ + /* check if is List */ + if ( !PySequence_Check(obj9) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + arg11 = PySequence_Size(obj9); + arg12 = (int*) malloc(arg11*sizeof(int)); + for( int i = 0; i<arg11; i++ ) { + PyObject *o = PySequence_GetItem(obj9,i); + if ( !PyArg_Parse(o,"i",&arg12[i]) ) { + SWIG_fail; + } + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + return NULL; +} + + +static PyObject * Dataset_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDALDatasetShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_Band_XSize_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_XSize_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_XSize_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_YSize_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_YSize_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_YSize_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_DataType_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALDataType result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_DataType_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALDataType)GDALRasterBandShadow_DataType_get(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetRasterColorInterpretation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetRasterColorInterpretation",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALColorInterp)GDALRasterBandShadow_GetRasterColorInterpretation(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_SetRasterColorInterpretation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp arg2 ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Band_SetRasterColorInterpretation",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<GDALColorInterp >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetRasterColorInterpretation(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetNoDataValue(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetNoDataValue",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_GetNoDataValue(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*arg3 ) { + Py_INCREF(Py_None); + r = Py_None; + resultobj = t_output_helper(resultobj,r); + } + else { + r = PyFloat_FromDouble( *arg2 ); + resultobj = t_output_helper(resultobj,r); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_SetNoDataValue(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Band_SetNoDataValue",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetNoDataValue(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetMinimum(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetMinimum",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_GetMinimum(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*arg3 ) { + Py_INCREF(Py_None); + r = Py_None; + resultobj = t_output_helper(resultobj,r); + } + else { + r = PyFloat_FromDouble( *arg2 ); + resultobj = t_output_helper(resultobj,r); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetMaximum(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetMaximum",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_GetMaximum(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*arg3 ) { + Py_INCREF(Py_None); + r = Py_None; + resultobj = t_output_helper(resultobj,r); + } + else { + r = PyFloat_FromDouble( *arg2 ); + resultobj = t_output_helper(resultobj,r); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetOffset(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetOffset",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_GetOffset(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*arg3 ) { + Py_INCREF(Py_None); + r = Py_None; + resultobj = t_output_helper(resultobj,r); + } + else { + r = PyFloat_FromDouble( *arg2 ); + resultobj = t_output_helper(resultobj,r); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetScale(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + double tmpval2 ; + int tmphasval2 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(python,in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetScale",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_GetScale(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(python,argout) (double *val, int*hasval) */ + PyObject *r; + if ( !*arg3 ) { + Py_INCREF(Py_None); + r = Py_None; + resultobj = t_output_helper(resultobj,r); + } + else { + r = PyFloat_FromDouble( *arg2 ); + resultobj = t_output_helper(resultobj,r); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetOverviewCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetOverviewCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_GetOverviewCount(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetOverview(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Band_GetOverview",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALRasterBandShadow_GetOverview(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALRasterBandShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_Checksum(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 = (int) 0 ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int result; + int val4 ; + int val5 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "xoff",(char *) "yoff",(char *) "xsize",(char *) "ysize", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:Band_Checksum",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + if (obj3) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj3 == Py_None ) { + arg4 = 0; + } + else if ( PyArg_Parse( obj3,"i" ,&val4 ) ) { + arg4 = (int *) &val4; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj4) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj4 == Py_None ) { + arg5 = 0; + } + else if ( PyArg_Parse( obj4,"i" ,&val5 ) ) { + arg5 = (int *) &val5; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_Checksum(arg1,arg2,arg3,arg4,arg5); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_ComputeRasterMinMax(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 0 ; + double argout2[2] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O|O:Band_ComputeRasterMinMax",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg3 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + { + CPLErrorReset(); + GDALRasterBandShadow_ComputeRasterMinMax(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 2 ); + resultobj = t_output_helper(resultobj,out); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_Fill(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + double arg3 = (double) 0.0 ; + CPLErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:Band_Fill",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_Fill(arg1,arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_ReadRaster(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 = (int *) 0 ; + char **arg7 = (char **) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + int nLen6 = 0 ; + char *pBuf6 = 0 ; + int val8 ; + int val9 ; + int val10 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "xoff",(char *) "yoff",(char *) "xsize",(char *) "ysize",(char *) "buf_xsize",(char *) "buf_ysize",(char *) "buf_type", NULL + }; + + { + /* %typemap(in,numinputs=0) (int *nLen6, char **pBuf6 ) */ + arg6 = &nLen6; + arg7 = &pBuf6; + } + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO|OOO:Band_ReadRaster",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<int >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<int >(SWIG_As_int(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + if (obj5) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj5 == Py_None ) { + arg8 = 0; + } + else if ( PyArg_Parse( obj5,"i" ,&val8 ) ) { + arg8 = (int *) &val8; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj6) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj6 == Py_None ) { + arg9 = 0; + } + else if ( PyArg_Parse( obj6,"i" ,&val9 ) ) { + arg9 = (int *) &val9; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj7) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj7 == Py_None ) { + arg10 = 0; + } + else if ( PyArg_Parse( obj7,"i" ,&val10 ) ) { + arg10 = (int *) &val10; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_ReadRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + Py_XDECREF(resultobj); + resultobj = PyString_FromStringAndSize( *arg7, *arg6 ); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg6 ) { + free( *arg7 ); + } + } + return NULL; +} + + +static PyObject *_wrap_Band_WriteRaster(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + int val8 ; + int val9 ; + int val10 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "xoff",(char *) "yoff",(char *) "xsize",(char *) "ysize",(char *) "buf_len",(char *) "buf_xsize",(char *) "buf_ysize",(char *) "buf_type", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOO|OOO:Band_WriteRaster",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<int >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<int >(SWIG_As_int(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + PyString_AsStringAndSize(obj5, &arg7, &arg6 ); + } + if (obj6) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj6 == Py_None ) { + arg8 = 0; + } + else if ( PyArg_Parse( obj6,"i" ,&val8 ) ) { + arg8 = (int *) &val8; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj7) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj7 == Py_None ) { + arg9 = 0; + } + else if ( PyArg_Parse( obj7,"i" ,&val9 ) ) { + arg9 = (int *) &val9; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + if (obj8) { + { + /* %typemap(in) (int *optional_##int) */ + if ( obj8 == Py_None ) { + arg10 = 0; + } + else if ( PyArg_Parse( obj8,"i" ,&val10 ) ) { + arg10 = (int *) &val10; + } + else { + PyErr_SetString( PyExc_TypeError, "Invalid Parameter" ); + SWIG_fail; + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + { + /* %typemap(ret) CPLErr */ + if ( bUseExceptions == 0 ) { + /* We're not using exceptions. And no error has occurred */ + if ( resultobj == 0 ) { + /* No other return values set so return ErrorCode */ + resultobj = PyInt_FromLong(result); + } + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_FlushCache(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_FlushCache",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + GDALRasterBandShadow_FlushCache(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_GetRasterColorTable(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Band_GetRasterColorTable",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALColorTable *)GDALRasterBandShadow_GetRasterColorTable(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALColorTable, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Band_SetRasterColorTable(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *arg2 = (GDALColorTable *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Band_SetRasterColorTable",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALRasterBandShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_SetRasterColorTable(arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * Band_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDALRasterBandShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_new_ColorTable(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALPaletteInterp arg1 = (GDALPaletteInterp) GPI_RGB ; + GDALColorTable *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"|O:new_ColorTable",&obj0)) goto fail; + if (obj0) { + { + arg1 = static_cast<GDALPaletteInterp >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (GDALColorTable *)new GDALColorTable(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALColorTable, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_ColorTable(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_ColorTable",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + delete arg1; + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_Clone(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALColorTable *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:ColorTable_Clone",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALColorTable *)((GDALColorTable const *)arg1)->Clone(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALColorTable, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_GetPaletteInterpretation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALPaletteInterp result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:ColorTable_GetPaletteInterpretation",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (GDALPaletteInterp)((GDALColorTable const *)arg1)->GetPaletteInterpretation(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_GetCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:ColorTable_GetCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryCount(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_GetColorEntry(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:ColorTable_GetColorEntry",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALColorEntry *)(arg1)->GetColorEntry(arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + /* %typemap(out) GDALColorEntry* */ + resultobj = Py_BuildValue( "(hhhh)", (*result).c1,(*result).c2,(*result).c3,(*result).c4); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_GetColorEntryAsRGB(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + int result; + GDALColorEntry ce3 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:ColorTable_GetColorEntryAsRGB",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + /* %typemap(in) GDALColorEntry* */ + ce3.c4 = 255; + int size = PySequence_Size(obj2); + if ( size > 4 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too long"); + SWIG_fail; + } + if ( size < 3 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too short"); + SWIG_fail; + } + PyArg_ParseTuple( obj2,"hhh|h", &ce3.c1, &ce3.c2, &ce3.c3, &ce3.c4 ); + arg3 = &ce3; + } + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryAsRGB(arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ColorTable_SetColorEntry(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + GDALColorEntry ce3 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:ColorTable_SetColorEntry",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALColorTable, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + /* %typemap(in) GDALColorEntry* */ + ce3.c4 = 255; + int size = PySequence_Size(obj2); + if ( size > 4 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too long"); + SWIG_fail; + } + if ( size < 3 ) { + PyErr_SetString(PyExc_TypeError, "ColorEntry sequence too short"); + SWIG_fail; + } + PyArg_ParseTuple( obj2,"hhh|h", &ce3.c1, &ce3.c2, &ce3.c3, &ce3.c4 ); + arg3 = &ce3; + } + { + CPLErrorReset(); + (arg1)->SetColorEntry(arg2,(GDALColorEntry const *)arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject * ColorTable_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_GDALColorTable, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_AllRegister(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":AllRegister")) goto fail; + { + CPLErrorReset(); + GDALAllRegister(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetCacheMax(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetCacheMax")) goto fail; + { + CPLErrorReset(); + result = (int)GDALGetCacheMax(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SetCacheMax(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SetCacheMax",&obj0)) goto fail; + { + arg1 = static_cast<int >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + GDALSetCacheMax(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetCacheUsed(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetCacheUsed")) goto fail; + { + CPLErrorReset(); + result = (int)GDALGetCacheUsed(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDataTypeSize(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDataType arg1 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDataTypeSize",&obj0)) goto fail; + { + arg1 = static_cast<GDALDataType >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GDALGetDataTypeSize(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataTypeIsComplex(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDataType arg1 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataTypeIsComplex",&obj0)) goto fail; + { + arg1 = static_cast<GDALDataType >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GDALDataTypeIsComplex(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDataTypeName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDataType arg1 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDataTypeName",&obj0)) goto fail; + { + arg1 = static_cast<GDALDataType >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)GDALGetDataTypeName(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDataTypeByName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + GDALDataType result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDataTypeByName",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALDataType)GDALGetDataTypeByName((char const *)arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetColorInterpretationName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALColorInterp arg1 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetColorInterpretationName",&obj0)) goto fail; + { + arg1 = static_cast<GDALColorInterp >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)GDALGetColorInterpretationName(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetPaletteInterpretationName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALPaletteInterp arg1 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetPaletteInterpretationName",&obj0)) goto fail; + { + arg1 = static_cast<GDALPaletteInterp >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)GDALGetPaletteInterpretationName(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DecToDMS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + double arg1 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 2 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:DecToDMS",&obj0,&obj1,&obj2)) goto fail; + { + arg1 = static_cast<double >(SWIG_As_double(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (char *)GDALDecToDMS(arg1,(char const *)arg2,arg3); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_PackedDMSToDec(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + double arg1 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:PackedDMSToDec",&obj0)) goto fail; + { + arg1 = static_cast<double >(SWIG_As_double(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (double)GDALPackedDMSToDec(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DecToPackedDMS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + double arg1 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DecToPackedDMS",&obj0)) goto fail; + { + arg1 = static_cast<double >(SWIG_As_double(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (double)GDALDecToPackedDMS(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_ParseXMLString(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + CPLXMLNode *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:ParseXMLString",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLXMLNode *)CPLParseXMLString(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + /* %typemap(python,out) (CPLXMLNode*) */ + resultobj = XMLTreeToPyList( result ); + } + { + /* %typemap(python,ret) (CPLXMLNode*) */ + if ( result ) CPLDestroyXMLNode( result ); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SerializeXMLTree(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + CPLXMLNode *arg1 = (CPLXMLNode *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SerializeXMLTree",&obj0)) goto fail; + { + /* %typemap(python,in) (CPLXMLNode* xmlnode ) */ + arg1 = PyListToXMLTree( obj0 ); + if ( !arg1 ) SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)CPLSerializeXMLTree(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_FromCharPtr(result); + { + /* %typemap(python,freearg) (CPLXMLNode *xmlnode) */ + if ( arg1 ) CPLDestroyXMLNode( arg1 ); + } + return resultobj; + fail: + { + /* %typemap(python,freearg) (CPLXMLNode *xmlnode) */ + if ( arg1 ) CPLDestroyXMLNode( arg1 ); + } + return NULL; +} + + +static PyObject *_wrap_GetDriverCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetDriverCount")) goto fail; + { + CPLErrorReset(); + result = (int)GetDriverCount(); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDriverByName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + GDALDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDriverByName",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriverByName((char const *)arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDriver(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + GDALDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDriver",&obj0)) goto fail; + { + arg1 = static_cast<int >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriver(arg1); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Open(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|O:Open",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (obj1) { + { + arg2 = static_cast<GDALAccess >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)Open((char const *)arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDatasetShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_OpenShared(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|O:OpenShared",&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (obj1) { + { + arg2 = static_cast<GDALAccess >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)OpenShared((char const *)arg1,arg2); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDatasetShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_AutoCreateWarpedVRT(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + GDALResampleAlg arg4 = (GDALResampleAlg) GRA_NearestNeighbour ; + double arg5 = (double) 0.0 ; + GDALDatasetShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|OOOO:AutoCreateWarpedVRT",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + if (obj2) { + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + if (obj3) { + { + arg4 = static_cast<GDALResampleAlg >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + if (obj4) { + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)AutoCreateWarpedVRT(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + + if ( bUseExceptions ) { + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + } + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_GDALDatasetShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"UseExceptions", _wrap_UseExceptions, METH_VARARGS, NULL}, + { (char *)"DontUseExceptions", _wrap_DontUseExceptions, METH_VARARGS, NULL}, + { (char *)"Debug", _wrap_Debug, METH_VARARGS, NULL}, + { (char *)"Error", _wrap_Error, METH_VARARGS, NULL}, + { (char *)"PushErrorHandler", _wrap_PushErrorHandler, METH_VARARGS, NULL}, + { (char *)"PopErrorHandler", _wrap_PopErrorHandler, METH_VARARGS, NULL}, + { (char *)"ErrorReset", _wrap_ErrorReset, METH_VARARGS, NULL}, + { (char *)"GetLastErrorNo", _wrap_GetLastErrorNo, METH_VARARGS, NULL}, + { (char *)"GetLastErrorType", _wrap_GetLastErrorType, METH_VARARGS, NULL}, + { (char *)"GetLastErrorMsg", _wrap_GetLastErrorMsg, METH_VARARGS, NULL}, + { (char *)"PushFinderLocation", _wrap_PushFinderLocation, METH_VARARGS, NULL}, + { (char *)"PopFinderLocation", _wrap_PopFinderLocation, METH_VARARGS, NULL}, + { (char *)"FinderClean", _wrap_FinderClean, METH_VARARGS, NULL}, + { (char *)"FindFile", _wrap_FindFile, METH_VARARGS, NULL}, + { (char *)"SetConfigOption", _wrap_SetConfigOption, METH_VARARGS, NULL}, + { (char *)"GetConfigOption", _wrap_GetConfigOption, METH_VARARGS, NULL}, + { (char *)"MajorObject_GetDescription", _wrap_MajorObject_GetDescription, METH_VARARGS, NULL}, + { (char *)"MajorObject_SetDescription", _wrap_MajorObject_SetDescription, METH_VARARGS, NULL}, + { (char *)"MajorObject_GetMetadata_Dict", _wrap_MajorObject_GetMetadata_Dict, METH_VARARGS, NULL}, + { (char *)"MajorObject_GetMetadata_List", _wrap_MajorObject_GetMetadata_List, METH_VARARGS, NULL}, + { (char *)"MajorObject_SetMetadata", _wrap_MajorObject_SetMetadata, METH_VARARGS, NULL}, + { (char *)"MajorObject_swigregister", MajorObject_swigregister, METH_VARARGS, NULL}, + { (char *)"Driver_ShortName_get", _wrap_Driver_ShortName_get, METH_VARARGS, NULL}, + { (char *)"Driver_LongName_get", _wrap_Driver_LongName_get, METH_VARARGS, NULL}, + { (char *)"Driver_HelpTopic_get", _wrap_Driver_HelpTopic_get, METH_VARARGS, NULL}, + { (char *)"Driver_Create", (PyCFunction) _wrap_Driver_Create, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Driver_CreateCopy", (PyCFunction) _wrap_Driver_CreateCopy, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Driver_Delete", _wrap_Driver_Delete, METH_VARARGS, NULL}, + { (char *)"Driver_swigregister", Driver_swigregister, METH_VARARGS, NULL}, + { (char *)"GCP_GCPX_set", _wrap_GCP_GCPX_set, METH_VARARGS, NULL}, + { (char *)"GCP_GCPX_get", _wrap_GCP_GCPX_get, METH_VARARGS, NULL}, + { (char *)"GCP_GCPY_set", _wrap_GCP_GCPY_set, METH_VARARGS, NULL}, + { (char *)"GCP_GCPY_get", _wrap_GCP_GCPY_get, METH_VARARGS, NULL}, + { (char *)"GCP_GCPZ_set", _wrap_GCP_GCPZ_set, METH_VARARGS, NULL}, + { (char *)"GCP_GCPZ_get", _wrap_GCP_GCPZ_get, METH_VARARGS, NULL}, + { (char *)"GCP_GCPPixel_set", _wrap_GCP_GCPPixel_set, METH_VARARGS, NULL}, + { (char *)"GCP_GCPPixel_get", _wrap_GCP_GCPPixel_get, METH_VARARGS, NULL}, + { (char *)"GCP_GCPLine_set", _wrap_GCP_GCPLine_set, METH_VARARGS, NULL}, + { (char *)"GCP_GCPLine_get", _wrap_GCP_GCPLine_get, METH_VARARGS, NULL}, + { (char *)"GCP_Info_set", _wrap_GCP_Info_set, METH_VARARGS, NULL}, + { (char *)"GCP_Info_get", _wrap_GCP_Info_get, METH_VARARGS, NULL}, + { (char *)"GCP_Id_set", _wrap_GCP_Id_set, METH_VARARGS, NULL}, + { (char *)"GCP_Id_get", _wrap_GCP_Id_get, METH_VARARGS, NULL}, + { (char *)"new_GCP", _wrap_new_GCP, METH_VARARGS, NULL}, + { (char *)"delete_GCP", _wrap_delete_GCP, METH_VARARGS, NULL}, + { (char *)"GCP_swigregister", GCP_swigregister, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPX_get", _wrap_GDAL_GCP_GCPX_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPX_set", _wrap_GDAL_GCP_GCPX_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPY_get", _wrap_GDAL_GCP_GCPY_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPY_set", _wrap_GDAL_GCP_GCPY_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPZ_get", _wrap_GDAL_GCP_GCPZ_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPZ_set", _wrap_GDAL_GCP_GCPZ_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPPixel_get", _wrap_GDAL_GCP_GCPPixel_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPPixel_set", _wrap_GDAL_GCP_GCPPixel_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPLine_get", _wrap_GDAL_GCP_GCPLine_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_GCPLine_set", _wrap_GDAL_GCP_GCPLine_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_Info_get", _wrap_GDAL_GCP_Info_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_Info_set", _wrap_GDAL_GCP_Info_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_Id_get", _wrap_GDAL_GCP_Id_get, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_Id_set", _wrap_GDAL_GCP_Id_set, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_GCPX", _wrap_GDAL_GCP_get_GCPX, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_GCPX", _wrap_GDAL_GCP_set_GCPX, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_GCPY", _wrap_GDAL_GCP_get_GCPY, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_GCPY", _wrap_GDAL_GCP_set_GCPY, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_GCPZ", _wrap_GDAL_GCP_get_GCPZ, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_GCPZ", _wrap_GDAL_GCP_set_GCPZ, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_GCPPixel", _wrap_GDAL_GCP_get_GCPPixel, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_GCPPixel", _wrap_GDAL_GCP_set_GCPPixel, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_GCPLine", _wrap_GDAL_GCP_get_GCPLine, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_GCPLine", _wrap_GDAL_GCP_set_GCPLine, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_Info", _wrap_GDAL_GCP_get_Info, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_Info", _wrap_GDAL_GCP_set_Info, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_get_Id", _wrap_GDAL_GCP_get_Id, METH_VARARGS, NULL}, + { (char *)"GDAL_GCP_set_Id", _wrap_GDAL_GCP_set_Id, METH_VARARGS, NULL}, + { (char *)"GCPsToGeoTransform", _wrap_GCPsToGeoTransform, METH_VARARGS, NULL}, + { (char *)"Dataset_RasterXSize_get", _wrap_Dataset_RasterXSize_get, METH_VARARGS, NULL}, + { (char *)"Dataset_RasterYSize_get", _wrap_Dataset_RasterYSize_get, METH_VARARGS, NULL}, + { (char *)"Dataset_RasterCount_get", _wrap_Dataset_RasterCount_get, METH_VARARGS, NULL}, + { (char *)"delete_Dataset", _wrap_delete_Dataset, METH_VARARGS, NULL}, + { (char *)"Dataset_GetDriver", _wrap_Dataset_GetDriver, METH_VARARGS, NULL}, + { (char *)"Dataset_GetRasterBand", _wrap_Dataset_GetRasterBand, METH_VARARGS, NULL}, + { (char *)"Dataset_GetProjection", _wrap_Dataset_GetProjection, METH_VARARGS, NULL}, + { (char *)"Dataset_GetProjectionRef", _wrap_Dataset_GetProjectionRef, METH_VARARGS, NULL}, + { (char *)"Dataset_SetProjection", _wrap_Dataset_SetProjection, METH_VARARGS, NULL}, + { (char *)"Dataset_GetGeoTransform", _wrap_Dataset_GetGeoTransform, METH_VARARGS, NULL}, + { (char *)"Dataset_SetGeoTransform", _wrap_Dataset_SetGeoTransform, METH_VARARGS, NULL}, + { (char *)"Dataset_BuildOverviews", (PyCFunction) _wrap_Dataset_BuildOverviews, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Dataset_GetGCPCount", _wrap_Dataset_GetGCPCount, METH_VARARGS, NULL}, + { (char *)"Dataset_GetGCPProjection", _wrap_Dataset_GetGCPProjection, METH_VARARGS, NULL}, + { (char *)"Dataset_GetGCPs", _wrap_Dataset_GetGCPs, METH_VARARGS, NULL}, + { (char *)"Dataset_SetGCPs", _wrap_Dataset_SetGCPs, METH_VARARGS, NULL}, + { (char *)"Dataset_FlushCache", _wrap_Dataset_FlushCache, METH_VARARGS, NULL}, + { (char *)"Dataset_AddBand", (PyCFunction) _wrap_Dataset_AddBand, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Dataset_WriteRaster", (PyCFunction) _wrap_Dataset_WriteRaster, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Dataset_swigregister", Dataset_swigregister, METH_VARARGS, NULL}, + { (char *)"Band_XSize_get", _wrap_Band_XSize_get, METH_VARARGS, NULL}, + { (char *)"Band_YSize_get", _wrap_Band_YSize_get, METH_VARARGS, NULL}, + { (char *)"Band_DataType_get", _wrap_Band_DataType_get, METH_VARARGS, NULL}, + { (char *)"Band_GetRasterColorInterpretation", _wrap_Band_GetRasterColorInterpretation, METH_VARARGS, NULL}, + { (char *)"Band_SetRasterColorInterpretation", _wrap_Band_SetRasterColorInterpretation, METH_VARARGS, NULL}, + { (char *)"Band_GetNoDataValue", _wrap_Band_GetNoDataValue, METH_VARARGS, NULL}, + { (char *)"Band_SetNoDataValue", _wrap_Band_SetNoDataValue, METH_VARARGS, NULL}, + { (char *)"Band_GetMinimum", _wrap_Band_GetMinimum, METH_VARARGS, NULL}, + { (char *)"Band_GetMaximum", _wrap_Band_GetMaximum, METH_VARARGS, NULL}, + { (char *)"Band_GetOffset", _wrap_Band_GetOffset, METH_VARARGS, NULL}, + { (char *)"Band_GetScale", _wrap_Band_GetScale, METH_VARARGS, NULL}, + { (char *)"Band_GetOverviewCount", _wrap_Band_GetOverviewCount, METH_VARARGS, NULL}, + { (char *)"Band_GetOverview", _wrap_Band_GetOverview, METH_VARARGS, NULL}, + { (char *)"Band_Checksum", (PyCFunction) _wrap_Band_Checksum, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Band_ComputeRasterMinMax", _wrap_Band_ComputeRasterMinMax, METH_VARARGS, NULL}, + { (char *)"Band_Fill", _wrap_Band_Fill, METH_VARARGS, NULL}, + { (char *)"Band_ReadRaster", (PyCFunction) _wrap_Band_ReadRaster, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Band_WriteRaster", (PyCFunction) _wrap_Band_WriteRaster, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Band_FlushCache", _wrap_Band_FlushCache, METH_VARARGS, NULL}, + { (char *)"Band_GetRasterColorTable", _wrap_Band_GetRasterColorTable, METH_VARARGS, NULL}, + { (char *)"Band_SetRasterColorTable", _wrap_Band_SetRasterColorTable, METH_VARARGS, NULL}, + { (char *)"Band_swigregister", Band_swigregister, METH_VARARGS, NULL}, + { (char *)"new_ColorTable", _wrap_new_ColorTable, METH_VARARGS, NULL}, + { (char *)"delete_ColorTable", _wrap_delete_ColorTable, METH_VARARGS, NULL}, + { (char *)"ColorTable_Clone", _wrap_ColorTable_Clone, METH_VARARGS, NULL}, + { (char *)"ColorTable_GetPaletteInterpretation", _wrap_ColorTable_GetPaletteInterpretation, METH_VARARGS, NULL}, + { (char *)"ColorTable_GetCount", _wrap_ColorTable_GetCount, METH_VARARGS, NULL}, + { (char *)"ColorTable_GetColorEntry", _wrap_ColorTable_GetColorEntry, METH_VARARGS, NULL}, + { (char *)"ColorTable_GetColorEntryAsRGB", _wrap_ColorTable_GetColorEntryAsRGB, METH_VARARGS, NULL}, + { (char *)"ColorTable_SetColorEntry", _wrap_ColorTable_SetColorEntry, METH_VARARGS, NULL}, + { (char *)"ColorTable_swigregister", ColorTable_swigregister, METH_VARARGS, NULL}, + { (char *)"AllRegister", _wrap_AllRegister, METH_VARARGS, NULL}, + { (char *)"GetCacheMax", _wrap_GetCacheMax, METH_VARARGS, NULL}, + { (char *)"SetCacheMax", _wrap_SetCacheMax, METH_VARARGS, NULL}, + { (char *)"GetCacheUsed", _wrap_GetCacheUsed, METH_VARARGS, NULL}, + { (char *)"GetDataTypeSize", _wrap_GetDataTypeSize, METH_VARARGS, NULL}, + { (char *)"DataTypeIsComplex", _wrap_DataTypeIsComplex, METH_VARARGS, NULL}, + { (char *)"GetDataTypeName", _wrap_GetDataTypeName, METH_VARARGS, NULL}, + { (char *)"GetDataTypeByName", _wrap_GetDataTypeByName, METH_VARARGS, NULL}, + { (char *)"GetColorInterpretationName", _wrap_GetColorInterpretationName, METH_VARARGS, NULL}, + { (char *)"GetPaletteInterpretationName", _wrap_GetPaletteInterpretationName, METH_VARARGS, NULL}, + { (char *)"DecToDMS", _wrap_DecToDMS, METH_VARARGS, NULL}, + { (char *)"PackedDMSToDec", _wrap_PackedDMSToDec, METH_VARARGS, NULL}, + { (char *)"DecToPackedDMS", _wrap_DecToPackedDMS, METH_VARARGS, NULL}, + { (char *)"ParseXMLString", _wrap_ParseXMLString, METH_VARARGS, NULL}, + { (char *)"SerializeXMLTree", _wrap_SerializeXMLTree, METH_VARARGS, NULL}, + { (char *)"GetDriverCount", _wrap_GetDriverCount, METH_VARARGS, NULL}, + { (char *)"GetDriverByName", _wrap_GetDriverByName, METH_VARARGS, NULL}, + { (char *)"GetDriver", _wrap_GetDriver, METH_VARARGS, NULL}, + { (char *)"Open", _wrap_Open, METH_VARARGS, NULL}, + { (char *)"OpenShared", _wrap_OpenShared, METH_VARARGS, NULL}, + { (char *)"AutoCreateWarpedVRT", _wrap_AutoCreateWarpedVRT, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static void *_p_GDALDriverShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDriverShadow *) x)); +} +static void *_p_GDALDatasetShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDatasetShadow *) x)); +} +static void *_p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALRasterBandShadow *) x)); +} +static swig_type_info _swigt__p_CPLErrorHandler = {"_p_CPLErrorHandler", "CPLErrorHandler *", 0, 0, 0}; +static swig_type_info _swigt__p_CPLXMLNode = {"_p_CPLXMLNode", "CPLXMLNode *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALColorEntry = {"_p_GDALColorEntry", "GDALColorEntry *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALColorTable = {"_p_GDALColorTable", "GDALColorTable *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALDriverShadow = {"_p_GDALDriverShadow", "GDALDriverShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALMajorObjectShadow = {"_p_GDALMajorObjectShadow", "GDALMajorObjectShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_GDAL_GCP = {"_p_GDAL_GCP", "GDAL_GCP *", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|GDALPaletteInterp *", 0, 0, 0}; +static swig_type_info _swigt__p_p_GDAL_GCP = {"_p_p_GDAL_GCP", "GDAL_GCP **", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; +static swig_type_info _swigt__ptrdiff_t = {"_ptrdiff_t", "ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__size_t = {"_size_t", "size_t", 0, 0, 0}; +static swig_type_info _swigt__std__ptrdiff_t = {"_std__ptrdiff_t", "std::ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__std__size_t = {"_std__size_t", "std::size_t", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_CPLErrorHandler, + &_swigt__p_CPLXMLNode, + &_swigt__p_GDALColorEntry, + &_swigt__p_GDALColorTable, + &_swigt__p_GDALDatasetShadow, + &_swigt__p_GDALDriverShadow, + &_swigt__p_GDALMajorObjectShadow, + &_swigt__p_GDALRasterBandShadow, + &_swigt__p_GDAL_GCP, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_GDAL_GCP, + &_swigt__p_p_char, + &_swigt__ptrdiff_t, + &_swigt__size_t, + &_swigt__std__ptrdiff_t, + &_swigt__std__size_t, +}; + +static swig_cast_info _swigc__p_CPLErrorHandler[] = { {&_swigt__p_CPLErrorHandler, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_CPLXMLNode[] = { {&_swigt__p_CPLXMLNode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorEntry[] = { {&_swigt__p_GDALColorEntry, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorTable[] = { {&_swigt__p_GDALColorTable, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDriverShadow[] = { {&_swigt__p_GDALDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALMajorObjectShadow[] = { {&_swigt__p_GDALMajorObjectShadow, 0, 0, 0}, {&_swigt__p_GDALDriverShadow, _p_GDALDriverShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALDatasetShadow, _p_GDALDatasetShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALRasterBandShadow, _p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDAL_GCP[] = { {&_swigt__p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDAL_GCP[] = { {&_swigt__p_p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__ptrdiff_t[] = { {&_swigt__std__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__size_t[] = { {&_swigt__std__size_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_CPLErrorHandler, + _swigc__p_CPLXMLNode, + _swigc__p_GDALColorEntry, + _swigc__p_GDALColorTable, + _swigc__p_GDALDatasetShadow, + _swigc__p_GDALDriverShadow, + _swigc__p_GDALMajorObjectShadow, + _swigc__p_GDALRasterBandShadow, + _swigc__p_GDAL_GCP, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_GDAL_GCP, + _swigc__p_p_char, + _swigc__ptrdiff_t, + _swigc__size_t, + _swigc__std__ptrdiff_t, + _swigc__std__size_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + + SWIGRUNTIME void + SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + } + + /* This function will propagate the clientdata field of type to + * any new swig_type_info structures that have been added into the list + * of equivalent types. It is like calling + * SWIG_TypeClientData(type, clientdata) a second time. + */ + SWIGRUNTIME void + SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } + } + +#ifdef __cplusplus +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *v) { + v = v; + return PyString_FromString("<Swig global variables>"); + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { + swig_globalvar *var; + flags = flags; + fprintf(fp,"Swig global variables { "); + for (var = v->vars; var; var=var->next) { + fprintf(fp,"%s", var->name); + if (var->next) fprintf(fp,", "); + } + fprintf(fp," }\n"); + return 0; + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->get_attr)(); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return NULL; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->set_attr)(p); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return 1; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + 0, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + varlink_type = tmp; + type_init = 1; + } +#endif + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_INT: + obj = PyInt_FromLong(constants[i].lvalue); + break; + case SWIG_PY_FLOAT: + obj = PyFloat_FromDouble(constants[i].dvalue); + break; + case SWIG_PY_STRING: + if (constants[i].pvalue) { + obj = PyString_FromString((char *) constants[i].pvalue); + } else { + Py_INCREF(Py_None); + obj = Py_None; + } + break; + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d,constants[i].name,obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* -----------------------------------------------------------------------------* + * Initialize type list + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + static PyObject *SWIG_globals = 0; + PyObject *m, *d; + if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + + /* gdal_python.i %init code */ + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } + +} + diff --git a/Utilities/GDAL/swig/python/gdalconst.py b/Utilities/GDAL/swig/python/gdalconst.py new file mode 100644 index 0000000000..447f1f981f --- /dev/null +++ b/Utilities/GDAL/swig/python/gdalconst.py @@ -0,0 +1,112 @@ +# This file was created automatically by SWIG 1.3.27. +# Don't modify this file, modify the SWIG interface instead. + +import _gdalconst + +# This file is compatible with both classic and new-style classes. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "this"): + if isinstance(value, class_type): + self.__dict__[name] = value.this + if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown + del value.thisown + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name) or (name == "thisown"): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +GDT_Unknown = _gdalconst.GDT_Unknown +GDT_Byte = _gdalconst.GDT_Byte +GDT_UInt16 = _gdalconst.GDT_UInt16 +GDT_Int16 = _gdalconst.GDT_Int16 +GDT_UInt32 = _gdalconst.GDT_UInt32 +GDT_Int32 = _gdalconst.GDT_Int32 +GDT_Float32 = _gdalconst.GDT_Float32 +GDT_Float64 = _gdalconst.GDT_Float64 +GDT_CInt16 = _gdalconst.GDT_CInt16 +GDT_CInt32 = _gdalconst.GDT_CInt32 +GDT_CFloat32 = _gdalconst.GDT_CFloat32 +GDT_CFloat64 = _gdalconst.GDT_CFloat64 +GDT_TypeCount = _gdalconst.GDT_TypeCount +GA_ReadOnly = _gdalconst.GA_ReadOnly +GA_Update = _gdalconst.GA_Update +GF_Read = _gdalconst.GF_Read +GF_Write = _gdalconst.GF_Write +GCI_Undefined = _gdalconst.GCI_Undefined +GCI_GrayIndex = _gdalconst.GCI_GrayIndex +GCI_PaletteIndex = _gdalconst.GCI_PaletteIndex +GCI_RedBand = _gdalconst.GCI_RedBand +GCI_GreenBand = _gdalconst.GCI_GreenBand +GCI_BlueBand = _gdalconst.GCI_BlueBand +GCI_AlphaBand = _gdalconst.GCI_AlphaBand +GCI_HueBand = _gdalconst.GCI_HueBand +GCI_SaturationBand = _gdalconst.GCI_SaturationBand +GCI_LightnessBand = _gdalconst.GCI_LightnessBand +GCI_CyanBand = _gdalconst.GCI_CyanBand +GCI_MagentaBand = _gdalconst.GCI_MagentaBand +GCI_YellowBand = _gdalconst.GCI_YellowBand +GCI_BlackBand = _gdalconst.GCI_BlackBand +GRA_NearestNeighbour = _gdalconst.GRA_NearestNeighbour +GRA_Bilinear = _gdalconst.GRA_Bilinear +GRA_Cubic = _gdalconst.GRA_Cubic +GRA_CubicSpline = _gdalconst.GRA_CubicSpline +GPI_Gray = _gdalconst.GPI_Gray +GPI_RGB = _gdalconst.GPI_RGB +GPI_CMYK = _gdalconst.GPI_CMYK +GPI_HLS = _gdalconst.GPI_HLS +CXT_Element = _gdalconst.CXT_Element +CXT_Text = _gdalconst.CXT_Text +CXT_Attribute = _gdalconst.CXT_Attribute +CXT_Comment = _gdalconst.CXT_Comment +CXT_Literal = _gdalconst.CXT_Literal +CE_None = _gdalconst.CE_None +CE_Debug = _gdalconst.CE_Debug +CE_Warning = _gdalconst.CE_Warning +CE_Failure = _gdalconst.CE_Failure +CE_Fatal = _gdalconst.CE_Fatal +CPLE_None = _gdalconst.CPLE_None +CPLE_AppDefined = _gdalconst.CPLE_AppDefined +CPLE_OutOfMemory = _gdalconst.CPLE_OutOfMemory +CPLE_FileIO = _gdalconst.CPLE_FileIO +CPLE_OpenFailed = _gdalconst.CPLE_OpenFailed +CPLE_IllegalArg = _gdalconst.CPLE_IllegalArg +CPLE_NotSupported = _gdalconst.CPLE_NotSupported +CPLE_AssertionFailed = _gdalconst.CPLE_AssertionFailed +CPLE_NoWriteAccess = _gdalconst.CPLE_NoWriteAccess +CPLE_UserInterrupt = _gdalconst.CPLE_UserInterrupt +DMD_LONGNAME = _gdalconst.DMD_LONGNAME +DMD_HELPTOPIC = _gdalconst.DMD_HELPTOPIC +DMD_MIMETYPE = _gdalconst.DMD_MIMETYPE +DMD_EXTENSION = _gdalconst.DMD_EXTENSION +DMD_CREATIONOPTIONLIST = _gdalconst.DMD_CREATIONOPTIONLIST +DMD_CREATIONDATATYPES = _gdalconst.DMD_CREATIONDATATYPES +DCAP_CREATE = _gdalconst.DCAP_CREATE +DCAP_CREATECOPY = _gdalconst.DCAP_CREATECOPY +CPLES_BackslashQuotable = _gdalconst.CPLES_BackslashQuotable +CPLES_XML = _gdalconst.CPLES_XML +CPLES_URL = _gdalconst.CPLES_URL +CPLES_SQL = _gdalconst.CPLES_SQL +CPLES_CSV = _gdalconst.CPLES_CSV + + diff --git a/Utilities/GDAL/swig/python/gdalconst_wrap.c b/Utilities/GDAL/swig/python/gdalconst_wrap.c new file mode 100644 index 0000000000..90e00680b2 --- /dev/null +++ b/Utilities/GDAL/swig/python/gdalconst_wrap.c @@ -0,0 +1,2139 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +#include <Python.h> + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * SWIG API. Portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * for internal method declarations + * ----------------------------------------------------------------------------- */ + +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* + Exception handling in wrappers +*/ +#define SWIG_fail goto fail +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) +#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) +#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) +#define SWIG_null_ref(type) SWIG_Python_NullRef(type) + +/* + Contract support +*/ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_INT 1 +#define SWIG_PY_FLOAT 2 +#define SWIG_PY_STRING 3 +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Alloc. memory flags + * ----------------------------------------------------------------------------- */ +#define SWIG_OLDOBJ 1 +#define SWIG_NEWOBJ SWIG_OLDOBJ + 1 +#define SWIG_PYSTR SWIG_NEWOBJ + 1 + +#ifdef __cplusplus +} +#endif + + +/*********************************************************************** + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * Author : David Beazley (beazley@cs.uchicago.edu) + ************************************************************************/ + +/* Common SWIG API */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + + +/* Python-specific SWIG API */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ +/* + Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent + C/C++ pointers in the python side. Very useful for debugging, but + not always safe. +*/ +#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) +# define SWIG_COBJECT_TYPES +#endif + +/* Flags for pointer conversion */ +#define SWIG_POINTER_EXCEPTION 0x1 +#define SWIG_POINTER_DISOWN 0x2 + + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +#define PyOS_snprintf snprintf +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Create a new pointer string + * ----------------------------------------------------------------------------- */ +#ifndef SWIG_BUFFER_SIZE +#define SWIG_BUFFER_SIZE 1024 +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_BUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +#if PY_VERSION_HEX < 0x01060000 +#define PyObject_Del(op) PyMem_DEL((op)) +#endif + +#if defined(SWIG_COBJECT_TYPES) +#if !defined(SWIG_COBJECT_PYTHON) +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Object type, and use it instead of PyCObject + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *ptr; + const char *desc; +} PySwigObject; + +/* Declarations for objects of type PySwigObject */ + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { + fputs("<Swig Object at ", fp); fputs(result, fp); fputs(">", fp); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_repr(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromFormat("<Swig Object at %s>", result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); + } +} + +SWIGRUNTIME void +PySwigObject_dealloc(PySwigObject *self) +{ + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static char pyswigobject_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigObject", /*tp_name*/ + sizeof(PySwigObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigObject_dealloc, /*tp_dealloc*/ + (printfunc)PySwigObject_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigObject_compare, /*tp_compare*/ + (reprfunc)PySwigObject_repr, /*tp_repr*/ + &PySwigObject_as_number, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigObject_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigobject_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigobject_type = tmp; + type_init = 1; + } +#endif + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) +{ + PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (self) { + self->ptr = ptr; + self->desc = desc; + } + return (PyObject *)self; +} + +SWIGRUNTIMEINLINE void * +PySwigObject_AsVoidPtr(PyObject *self) +{ + return ((PySwigObject *)self)->ptr; +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + return ((PySwigObject *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + const char *desc; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->desc,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->desc); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->desc); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->desc); + } else { + return PyString_FromString(v->desc); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + } +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PySwigPacked *self) +{ + free(self->pack); + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static char pyswigpacked_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigPacked", /*tp_name*/ + sizeof(PySwigPacked), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ + (printfunc)PySwigPacked_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigPacked_compare, /*tp_compare*/ + (reprfunc)PySwigPacked_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigPacked_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigpacked_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigpacked_type = tmp; + type_init = 1; + } +#endif + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) +{ + PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (self == NULL) { + return NULL; + } else { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + self->pack = pack; + self->desc = desc; + self->size = size; + return (PyObject *) self; + } + return NULL; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + PySwigPacked *self = (PySwigPacked *)obj; + if (self->size != size) return 0; + memcpy(ptr, self->pack, size); + return self->desc; +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_GetDesc(PyObject *self) +{ + return ((PySwigPacked *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +#else +/* ----------------------------------------------------------------------------- + * Use the old Python PyCObject instead of PySwigObject + * ----------------------------------------------------------------------------- */ + +#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) +#define PySwigObject_Check(obj) PyCObject_Check(obj) +#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) +#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) + +#endif + +#endif + +/* ----------------------------------------------------------------------------- + * errors manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + +SWIGRUNTIMEINLINE void +SWIG_Python_NullRef(const char *type) +{ + if (type) { + PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); + } else { + PyErr_Format(PyExc_TypeError, "null reference was received"); + } +} + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + static PyObject *SWIG_this = 0; + int newref = 0; + PyObject *pyobj = 0; + void *vptr; + + if (!obj) return 0; + if (obj == Py_None) { + *ptr = 0; + return 0; + } + +#ifdef SWIG_COBJECT_TYPES + if (!(PySwigObject_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PySwigObject_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + vptr = PySwigObject_AsVoidPtr(obj); + c = (const char *) PySwigObject_GetDesc(obj); + if (newref) { Py_DECREF(obj); } + goto type_check; +#else + if (!(PyString_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PyString_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); + if (newref) { Py_DECREF(obj); } + if (!c) goto type_error; +#endif + +type_check: + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + *ptr = SWIG_TypeCast(tc,vptr); + } else { + *ptr = vptr; + } + if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { + PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); + } + return 0; + +type_error: + PyErr_Clear(); + if (pyobj && !obj) { + obj = pyobj; + if (PyCFunction_Check(obj)) { + /* here we get the method pointer for callbacks */ + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + c = doc ? strstr(doc, "swig_ptr: ") : 0; + if (c) { + c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; + if (!c) goto type_error; + goto type_check; + } + } + } + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ pointer", obj); + } + } + return -1; +} + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + c = PySwigPacked_UnpackData(obj, ptr, sz); +#else + if ((!obj) || (!PyString_Check(obj))) goto type_error; + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackDataName(c, ptr, sz, ty->name); +#endif + if (!c) goto type_error; + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + } + return 0; + +type_error: + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ packed data", obj); + } + } + return -1; +} + +/* Create a new array object */ +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { + PyObject *robj = 0; + if (!type) { + if (!PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj"); + } + return robj; + } + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#ifdef SWIG_COBJECT_TYPES + robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + if (!robj || (robj == Py_None)) return robj; + if (type->clientdata) { + PyObject *inst; + PyObject *args = Py_BuildValue((char*)"(O)", robj); + Py_DECREF(robj); + inst = PyObject_CallObject((PyObject *) type->clientdata, args); + Py_DECREF(args); + if (inst) { + if (own) { + PyObject_SetAttrString(inst,(char*)"thisown",Py_True); + } + robj = inst; + } + } + return robj; +} + +SWIGRUNTIME PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + PyObject *robj = 0; + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + return robj; +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function +is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return -1; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return -1; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return -1; + } + if (PyDict_SetItemString(dict, name, o)) + return -1; + Py_DECREF(o); + return 0; +} +#endif + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } +} + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +#define SWIGTYPE_ptrdiff_t swig_types[1] +#define SWIGTYPE_size_t swig_types[2] +static swig_type_info *swig_types[4]; +static swig_module_info swig_module = {swig_types, 3, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + + +/*----------------------------------------------- + @(target):= _gdalconst.so + ------------------------------------------------*/ +#define SWIG_init init_gdalconst + +#define SWIG_name "_gdalconst" + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_int PyInt_FromLong +/*@@*/ + + +SWIGINTERN PyObject * +SWIG_FromCharPtr(const char* cptr) +{ + if (cptr) { + size_t size = strlen(cptr); + if (size > INT_MAX) { + return SWIG_NewPointerObj((char*)(cptr), + SWIG_TypeQuery("char *"), 0); + } else { + if (size != 0) { + return PyString_FromStringAndSize(cptr, size); + } else { + return PyString_FromString(cptr); + } + } + } + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef __cplusplus +extern "C" { +#endif +static PyMethodDef SwigMethods[] = { + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__ptrdiff_t = {"_ptrdiff_t", "ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__size_t = {"_size_t", "size_t", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, + &_swigt__ptrdiff_t, + &_swigt__size_t, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, + _swigc__ptrdiff_t, + _swigc__size_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{ SWIG_PY_POINTER, (char*)"DMD_LONGNAME", 0, 0, (void *)GDAL_DMD_LONGNAME, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DMD_HELPTOPIC", 0, 0, (void *)GDAL_DMD_HELPTOPIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DMD_MIMETYPE", 0, 0, (void *)GDAL_DMD_MIMETYPE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DMD_EXTENSION", 0, 0, (void *)GDAL_DMD_EXTENSION, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DMD_CREATIONOPTIONLIST", 0, 0, (void *)GDAL_DMD_CREATIONOPTIONLIST, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DMD_CREATIONDATATYPES", 0, 0, (void *)GDAL_DMD_CREATIONDATATYPES, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DCAP_CREATE", 0, 0, (void *)GDAL_DCAP_CREATE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"DCAP_CREATECOPY", 0, 0, (void *)GDAL_DCAP_CREATECOPY, &SWIGTYPE_p_char}, +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + + SWIGRUNTIME void + SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + } + + /* This function will propagate the clientdata field of type to + * any new swig_type_info structures that have been added into the list + * of equivalent types. It is like calling + * SWIG_TypeClientData(type, clientdata) a second time. + */ + SWIGRUNTIME void + SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } + } + +#ifdef __cplusplus +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *v) { + v = v; + return PyString_FromString("<Swig global variables>"); + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { + swig_globalvar *var; + flags = flags; + fprintf(fp,"Swig global variables { "); + for (var = v->vars; var; var=var->next) { + fprintf(fp,"%s", var->name); + if (var->next) fprintf(fp,", "); + } + fprintf(fp," }\n"); + return 0; + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->get_attr)(); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return NULL; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->set_attr)(p); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return 1; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + 0, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + varlink_type = tmp; + type_init = 1; + } +#endif + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_INT: + obj = PyInt_FromLong(constants[i].lvalue); + break; + case SWIG_PY_FLOAT: + obj = PyFloat_FromDouble(constants[i].dvalue); + break; + case SWIG_PY_STRING: + if (constants[i].pvalue) { + obj = PyString_FromString((char *) constants[i].pvalue); + } else { + Py_INCREF(Py_None); + obj = Py_None; + } + break; + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d,constants[i].name,obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* -----------------------------------------------------------------------------* + * Initialize type list + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + static PyObject *SWIG_globals = 0; + PyObject *m, *d; + if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + { + PyDict_SetItemString(d,"GDT_Unknown", SWIG_From_int((int)(GDT_Unknown))); + } + { + PyDict_SetItemString(d,"GDT_Byte", SWIG_From_int((int)(GDT_Byte))); + } + { + PyDict_SetItemString(d,"GDT_UInt16", SWIG_From_int((int)(GDT_UInt16))); + } + { + PyDict_SetItemString(d,"GDT_Int16", SWIG_From_int((int)(GDT_Int16))); + } + { + PyDict_SetItemString(d,"GDT_UInt32", SWIG_From_int((int)(GDT_UInt32))); + } + { + PyDict_SetItemString(d,"GDT_Int32", SWIG_From_int((int)(GDT_Int32))); + } + { + PyDict_SetItemString(d,"GDT_Float32", SWIG_From_int((int)(GDT_Float32))); + } + { + PyDict_SetItemString(d,"GDT_Float64", SWIG_From_int((int)(GDT_Float64))); + } + { + PyDict_SetItemString(d,"GDT_CInt16", SWIG_From_int((int)(GDT_CInt16))); + } + { + PyDict_SetItemString(d,"GDT_CInt32", SWIG_From_int((int)(GDT_CInt32))); + } + { + PyDict_SetItemString(d,"GDT_CFloat32", SWIG_From_int((int)(GDT_CFloat32))); + } + { + PyDict_SetItemString(d,"GDT_CFloat64", SWIG_From_int((int)(GDT_CFloat64))); + } + { + PyDict_SetItemString(d,"GDT_TypeCount", SWIG_From_int((int)(GDT_TypeCount))); + } + { + PyDict_SetItemString(d,"GA_ReadOnly", SWIG_From_int((int)(GA_ReadOnly))); + } + { + PyDict_SetItemString(d,"GA_Update", SWIG_From_int((int)(GA_Update))); + } + { + PyDict_SetItemString(d,"GF_Read", SWIG_From_int((int)(GF_Read))); + } + { + PyDict_SetItemString(d,"GF_Write", SWIG_From_int((int)(GF_Write))); + } + { + PyDict_SetItemString(d,"GCI_Undefined", SWIG_From_int((int)(GCI_Undefined))); + } + { + PyDict_SetItemString(d,"GCI_GrayIndex", SWIG_From_int((int)(GCI_GrayIndex))); + } + { + PyDict_SetItemString(d,"GCI_PaletteIndex", SWIG_From_int((int)(GCI_PaletteIndex))); + } + { + PyDict_SetItemString(d,"GCI_RedBand", SWIG_From_int((int)(GCI_RedBand))); + } + { + PyDict_SetItemString(d,"GCI_GreenBand", SWIG_From_int((int)(GCI_GreenBand))); + } + { + PyDict_SetItemString(d,"GCI_BlueBand", SWIG_From_int((int)(GCI_BlueBand))); + } + { + PyDict_SetItemString(d,"GCI_AlphaBand", SWIG_From_int((int)(GCI_AlphaBand))); + } + { + PyDict_SetItemString(d,"GCI_HueBand", SWIG_From_int((int)(GCI_HueBand))); + } + { + PyDict_SetItemString(d,"GCI_SaturationBand", SWIG_From_int((int)(GCI_SaturationBand))); + } + { + PyDict_SetItemString(d,"GCI_LightnessBand", SWIG_From_int((int)(GCI_LightnessBand))); + } + { + PyDict_SetItemString(d,"GCI_CyanBand", SWIG_From_int((int)(GCI_CyanBand))); + } + { + PyDict_SetItemString(d,"GCI_MagentaBand", SWIG_From_int((int)(GCI_MagentaBand))); + } + { + PyDict_SetItemString(d,"GCI_YellowBand", SWIG_From_int((int)(GCI_YellowBand))); + } + { + PyDict_SetItemString(d,"GCI_BlackBand", SWIG_From_int((int)(GCI_BlackBand))); + } + { + PyDict_SetItemString(d,"GRA_NearestNeighbour", SWIG_From_int((int)(GRA_NearestNeighbour))); + } + { + PyDict_SetItemString(d,"GRA_Bilinear", SWIG_From_int((int)(GRA_Bilinear))); + } + { + PyDict_SetItemString(d,"GRA_Cubic", SWIG_From_int((int)(GRA_Cubic))); + } + { + PyDict_SetItemString(d,"GRA_CubicSpline", SWIG_From_int((int)(GRA_CubicSpline))); + } + { + PyDict_SetItemString(d,"GPI_Gray", SWIG_From_int((int)(GPI_Gray))); + } + { + PyDict_SetItemString(d,"GPI_RGB", SWIG_From_int((int)(GPI_RGB))); + } + { + PyDict_SetItemString(d,"GPI_CMYK", SWIG_From_int((int)(GPI_CMYK))); + } + { + PyDict_SetItemString(d,"GPI_HLS", SWIG_From_int((int)(GPI_HLS))); + } + { + PyDict_SetItemString(d,"CXT_Element", SWIG_From_int((int)(CXT_Element))); + } + { + PyDict_SetItemString(d,"CXT_Text", SWIG_From_int((int)(CXT_Text))); + } + { + PyDict_SetItemString(d,"CXT_Attribute", SWIG_From_int((int)(CXT_Attribute))); + } + { + PyDict_SetItemString(d,"CXT_Comment", SWIG_From_int((int)(CXT_Comment))); + } + { + PyDict_SetItemString(d,"CXT_Literal", SWIG_From_int((int)(CXT_Literal))); + } + { + PyDict_SetItemString(d,"CE_None", SWIG_From_int((int)(CE_None))); + } + { + PyDict_SetItemString(d,"CE_Debug", SWIG_From_int((int)(CE_Debug))); + } + { + PyDict_SetItemString(d,"CE_Warning", SWIG_From_int((int)(CE_Warning))); + } + { + PyDict_SetItemString(d,"CE_Failure", SWIG_From_int((int)(CE_Failure))); + } + { + PyDict_SetItemString(d,"CE_Fatal", SWIG_From_int((int)(CE_Fatal))); + } + { + PyDict_SetItemString(d,"CPLE_None", SWIG_From_int((int)(CPLE_None))); + } + { + PyDict_SetItemString(d,"CPLE_AppDefined", SWIG_From_int((int)(CPLE_AppDefined))); + } + { + PyDict_SetItemString(d,"CPLE_OutOfMemory", SWIG_From_int((int)(CPLE_OutOfMemory))); + } + { + PyDict_SetItemString(d,"CPLE_FileIO", SWIG_From_int((int)(CPLE_FileIO))); + } + { + PyDict_SetItemString(d,"CPLE_OpenFailed", SWIG_From_int((int)(CPLE_OpenFailed))); + } + { + PyDict_SetItemString(d,"CPLE_IllegalArg", SWIG_From_int((int)(CPLE_IllegalArg))); + } + { + PyDict_SetItemString(d,"CPLE_NotSupported", SWIG_From_int((int)(CPLE_NotSupported))); + } + { + PyDict_SetItemString(d,"CPLE_AssertionFailed", SWIG_From_int((int)(CPLE_AssertionFailed))); + } + { + PyDict_SetItemString(d,"CPLE_NoWriteAccess", SWIG_From_int((int)(CPLE_NoWriteAccess))); + } + { + PyDict_SetItemString(d,"CPLE_UserInterrupt", SWIG_From_int((int)(CPLE_UserInterrupt))); + } + PyDict_SetItemString(d,"DMD_LONGNAME", SWIG_FromCharPtr(GDAL_DMD_LONGNAME)); + PyDict_SetItemString(d,"DMD_HELPTOPIC", SWIG_FromCharPtr(GDAL_DMD_HELPTOPIC)); + PyDict_SetItemString(d,"DMD_MIMETYPE", SWIG_FromCharPtr(GDAL_DMD_MIMETYPE)); + PyDict_SetItemString(d,"DMD_EXTENSION", SWIG_FromCharPtr(GDAL_DMD_EXTENSION)); + PyDict_SetItemString(d,"DMD_CREATIONOPTIONLIST", SWIG_FromCharPtr(GDAL_DMD_CREATIONOPTIONLIST)); + PyDict_SetItemString(d,"DMD_CREATIONDATATYPES", SWIG_FromCharPtr(GDAL_DMD_CREATIONDATATYPES)); + PyDict_SetItemString(d,"DCAP_CREATE", SWIG_FromCharPtr(GDAL_DCAP_CREATE)); + PyDict_SetItemString(d,"DCAP_CREATECOPY", SWIG_FromCharPtr(GDAL_DCAP_CREATECOPY)); + { + PyDict_SetItemString(d,"CPLES_BackslashQuotable", SWIG_From_int((int)(CPLES_BackslashQuotable))); + } + { + PyDict_SetItemString(d,"CPLES_XML", SWIG_From_int((int)(CPLES_XML))); + } + { + PyDict_SetItemString(d,"CPLES_URL", SWIG_From_int((int)(CPLES_URL))); + } + { + PyDict_SetItemString(d,"CPLES_SQL", SWIG_From_int((int)(CPLES_SQL))); + } + { + PyDict_SetItemString(d,"CPLES_CSV", SWIG_From_int((int)(CPLES_CSV))); + } +} + diff --git a/Utilities/GDAL/swig/python/gdalnumeric.cpp b/Utilities/GDAL/swig/python/gdalnumeric.cpp new file mode 100644 index 0000000000..043407bc77 --- /dev/null +++ b/Utilities/GDAL/swig/python/gdalnumeric.cpp @@ -0,0 +1,63 @@ +/****************************************************************************** + * $Id: gdalnumeric.cpp,v 1.1 2005/02/14 20:37:58 fwarmerdam Exp $ + * + * Project: GDAL Python Bindings + * Purpose: GDAL/numpy bindings (all custom) + * Author: Frank Warmerdam, warmerda@home.com + * + ********************************************************************** + * Copyright (c) 2000, 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: gdalnumeric.cpp,v $ + * Revision 1.1 2005/02/14 20:37:58 fwarmerdam + * New + * + * Revision 1.2 2001/07/18 04:45:29 warmerda + * added CPL_CVSID + * + * Revision 1.1 2000/07/19 19:42:54 warmerda + * New + * + */ + +#include "gdal.h" +#include "Python.h" +#include "gdal_py.h" + +CPL_CVSID("$Id: gdalnumeric.cpp,v 1.1 2005/02/14 20:37:58 fwarmerdam Exp $"); + +PyObject *py_NumPyArrayToGDALFilename( PyObject *self, PyObject *args ) + +{ + PyObject *psArray; + char szString[128]; + + self = self; + if(!PyArg_ParseTuple(args,"O:NumPyArrayToGDALFilename",&psArray) ) + return NULL; + + /* I wish I had a safe way of checking the type */ + sprintf( szString, "NUMPY:::%p", psArray ); + + return Py_BuildValue( "s", szString ); +} + diff --git a/Utilities/GDAL/swig/python/numpydataset.cpp b/Utilities/GDAL/swig/python/numpydataset.cpp new file mode 100644 index 0000000000..f09c0629ea --- /dev/null +++ b/Utilities/GDAL/swig/python/numpydataset.cpp @@ -0,0 +1,427 @@ +/****************************************************************************** + * $Id: numpydataset.cpp,v 1.1 2005/02/14 20:37:58 fwarmerdam Exp $ + * + * Project: GDAL Python Bindings + * Purpose: Implementation of NumPy arrays as a GDALDataset. + * Author: Frank Warmerdam, warmerda@home.com + * + ****************************************************************************** + * Copyright (c) 2000, 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: numpydataset.cpp,v $ + * Revision 1.1 2005/02/14 20:37:58 fwarmerdam + * New + * + * Revision 1.10 2003/12/11 17:20:44 gwalter + * Added UInt16 and UInt32 to list of recognized NumPy types. + * + * Revision 1.9 2003/09/26 15:59:51 warmerda + * warn if opening an array with internal definitions + * + * Revision 1.8 2002/09/04 06:59:44 warmerda + * get rid of static driver pointer + * + * Revision 1.7 2002/06/12 21:08:28 warmerda + * update to metadata based driver info + * + * Revision 1.6 2001/10/26 20:02:54 warmerda + * use indirect allocation for MEMRasterBand + * + * Revision 1.5 2001/10/19 15:44:59 warmerda + * added get/set gcps support + * + * Revision 1.4 2001/07/18 04:45:29 warmerda + * added CPL_CVSID + * + * Revision 1.3 2001/03/08 18:42:06 warmerda + * implement projection, and geotransform holding support + * + * Revision 1.2 2001/02/06 16:16:28 warmerda + * fixed numpydataset.cpp to use sscanf to parse pointer + * + * Revision 1.1 2000/07/20 00:33:37 warmerda + * New + * + */ + +#include "gdal_priv.h" +#include "../frmts/mem/memdataset.h" +#include "gdal_py.h" + +CPL_CVSID("$Id: numpydataset.cpp,v 1.1 2005/02/14 20:37:58 fwarmerdam Exp $"); + +/************************************************************************/ +/* NUMPYDataset */ +/************************************************************************/ + +class NUMPYDataset : public GDALDataset +{ + PyArrayObject *psArray; + + double adfGeoTransform[6]; + char *pszProjection; + + int nGCPCount; + GDAL_GCP *pasGCPList; + char *pszGCPProjection; + + public: + NUMPYDataset(); + ~NUMPYDataset(); + + virtual const char *GetProjectionRef(void); + virtual CPLErr SetProjection( const char * ); + virtual CPLErr GetGeoTransform( double * ); + virtual CPLErr SetGeoTransform( double * ); + + virtual int GetGCPCount(); + virtual const char *GetGCPProjection(); + virtual const GDAL_GCP *GetGCPs(); + virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ); + + static GDALDataset *Open( GDALOpenInfo * ); +}; + +/************************************************************************/ +/* NUMPYDataset() */ +/************************************************************************/ + +NUMPYDataset::NUMPYDataset() + +{ + pszProjection = CPLStrdup(""); + adfGeoTransform[0] = 0.0; + adfGeoTransform[1] = 1.0; + adfGeoTransform[2] = 0.0; + adfGeoTransform[3] = 0.0; + adfGeoTransform[4] = 0.0; + adfGeoTransform[5] = 1.0; + + nGCPCount = 0; + pasGCPList = NULL; + pszGCPProjection = CPLStrdup(""); +} + +/************************************************************************/ +/* ~NUMPYDataset() */ +/************************************************************************/ + +NUMPYDataset::~NUMPYDataset() + +{ + CPLFree( pszProjection ); + + CPLFree( pszGCPProjection ); + if( nGCPCount > 0 ) + { + GDALDeinitGCPs( nGCPCount, pasGCPList ); + CPLFree( pasGCPList ); + } + + FlushCache(); + Py_DECREF( psArray ); +} + +/************************************************************************/ +/* GetProjectionRef() */ +/************************************************************************/ + +const char *NUMPYDataset::GetProjectionRef() + +{ + return( pszProjection ); +} + +/************************************************************************/ +/* SetProjection() */ +/************************************************************************/ + +CPLErr NUMPYDataset::SetProjection( const char * pszNewProjection ) + +{ + CPLFree( pszProjection ); + pszProjection = CPLStrdup( pszNewProjection ); + + return CE_None; +} + +/************************************************************************/ +/* GetGeoTransform() */ +/************************************************************************/ + +CPLErr NUMPYDataset::GetGeoTransform( double * padfTransform ) + +{ + memcpy( padfTransform, adfGeoTransform, sizeof(double)*6 ); + return CE_None; +} + +/************************************************************************/ +/* SetGeoTransform() */ +/************************************************************************/ + +CPLErr NUMPYDataset::SetGeoTransform( double * padfTransform ) + +{ + memcpy( adfGeoTransform, padfTransform, sizeof(double)*6 ); + return( CE_None ); +} + +/************************************************************************/ +/* GetGCPCount() */ +/************************************************************************/ + +int NUMPYDataset::GetGCPCount() + +{ + return nGCPCount; +} + +/************************************************************************/ +/* GetGCPProjection() */ +/************************************************************************/ + +const char *NUMPYDataset::GetGCPProjection() + +{ + return pszGCPProjection; +} + +/************************************************************************/ +/* GetGCPs() */ +/************************************************************************/ + +const GDAL_GCP *NUMPYDataset::GetGCPs() + +{ + return pasGCPList; +} + +/************************************************************************/ +/* SetGCPs() */ +/************************************************************************/ + +CPLErr NUMPYDataset::SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, + const char *pszGCPProjection ) + +{ + CPLFree( this->pszGCPProjection ); + if( this->nGCPCount > 0 ) + { + GDALDeinitGCPs( this->nGCPCount, this->pasGCPList ); + CPLFree( this->pasGCPList ); + } + + this->pszGCPProjection = CPLStrdup(pszGCPProjection); + + this->nGCPCount = nGCPCount; + + this->pasGCPList = GDALDuplicateGCPs( nGCPCount, pasGCPList ); + + return CE_None; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +GDALDataset *NUMPYDataset::Open( GDALOpenInfo * poOpenInfo ) + +{ + PyArrayObject *psArray; + GDALDataType eType; + int nBands; + +/* -------------------------------------------------------------------- */ +/* Is this a numpy dataset name? */ +/* -------------------------------------------------------------------- */ + if( !EQUALN(poOpenInfo->pszFilename,"NUMPY:::",8) + || poOpenInfo->fp != NULL ) + return NULL; + + psArray = NULL; + sscanf( poOpenInfo->pszFilename+8, "%p", &psArray ); + if( psArray == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to parse meaningful pointer value from NUMPY name\n" + "string: %s\n", + poOpenInfo->pszFilename ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* If we likely have corrupt definitions of the NUMPY stuff, */ +/* then warn now. */ +/* -------------------------------------------------------------------- */ +#ifdef NUMPY_DEFS_WRONG + CPLError( CE_Warning, CPLE_AppDefined, + "It would appear you have built GDAL without having it use\n" + "the Numeric python include files. Old definitions have\n" + "been used instead at build time, and it is quite possible that\n" + "the things will shortly fail or crash if they are wrong.\n" + "Consider installing Numeric, and rebuilding with HAVE_NUMPY\n" + "enabled in gdal\nmake.opt." ); +#endif + +/* -------------------------------------------------------------------- */ +/* Is this a directly mappable Python array? Verify rank, and */ +/* data type. */ +/* -------------------------------------------------------------------- */ + if( psArray->nd < 2 || psArray->nd > 3 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Illegal numpy array rank %d.\n", + psArray->nd ); + return NULL; + } + + switch( psArray->descr->type ) + { + case 'D': + eType = GDT_CFloat64; + break; + + case 'F': + eType = GDT_CFloat32; + break; + + case 'd': + eType = GDT_Float64; + break; + + case 'f': + eType = GDT_Float32; + break; + + case 'l': + case 'i': + eType = GDT_Int32; + break; + + case 'u': + eType = GDT_UInt32; + break; + + case 's': + eType = GDT_Int16; + break; + + case 'w': + eType = GDT_UInt16; + break; + + case 'b': + eType = GDT_Byte; + break; + + default: + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to access numpy arrays of typecode `%c'.\n", + psArray->descr->type ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Create the new NUMPYDataset object. */ +/* -------------------------------------------------------------------- */ + NUMPYDataset *poDS; + + poDS = new NUMPYDataset(); + + poDS->psArray = psArray; + + poDS->eAccess = GA_ReadOnly; + +/* -------------------------------------------------------------------- */ +/* Add a reference to the array. */ +/* -------------------------------------------------------------------- */ + Py_INCREF( psArray ); + +/* -------------------------------------------------------------------- */ +/* Workout the data layout. */ +/* -------------------------------------------------------------------- */ + int nBandOffset; + int nPixelOffset; + int nLineOffset; + + if( psArray->nd == 3 ) + { + nBands = psArray->dimensions[0]; + nBandOffset = psArray->strides[0]; + poDS->nRasterXSize = psArray->dimensions[2]; + nPixelOffset = psArray->strides[2]; + poDS->nRasterYSize = psArray->dimensions[1]; + nLineOffset = psArray->strides[1]; + } + else + { + nBands = 1; + nBandOffset = 0; + poDS->nRasterXSize = psArray->dimensions[1]; + nPixelOffset = psArray->strides[1]; + poDS->nRasterYSize = psArray->dimensions[0]; + nLineOffset = psArray->strides[0]; + } + +/* -------------------------------------------------------------------- */ +/* Create band information objects. */ +/* -------------------------------------------------------------------- */ + for( int iBand = 0; iBand < nBands; iBand++ ) + { + poDS->SetBand( iBand+1, + (GDALRasterBand *) + MEMCreateRasterBand( poDS, iBand+1, + (GByte *) psArray->data + nBandOffset*iBand, + eType, nPixelOffset, nLineOffset, + FALSE ) ); + } + +/* -------------------------------------------------------------------- */ +/* Try to return a regular handle on the file. */ +/* -------------------------------------------------------------------- */ + return poDS; +} + +/************************************************************************/ +/* GDALRegister_NUMPY() */ +/************************************************************************/ + +void GDALRegister_NUMPY() + +{ + GDALDriver *poDriver; + + if( GDALGetDriverByName( "NUMPY" ) == NULL ) + { + poDriver = new GDALDriver(); + + poDriver->SetDescription( "NUMPY" ); + poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, + "Numeric Python Array" ); + + poDriver->pfnOpen = NUMPYDataset::Open; + + GetGDALDriverManager()->RegisterDriver( poDriver ); + } +} diff --git a/Utilities/GDAL/swig/python/ogr.py b/Utilities/GDAL/swig/python/ogr.py new file mode 100644 index 0000000000..bfe47ee4ae --- /dev/null +++ b/Utilities/GDAL/swig/python/ogr.py @@ -0,0 +1,1029 @@ +# This file was created automatically by SWIG 1.3.27. +# Don't modify this file, modify the SWIG interface instead. +import osr + +import _ogr + +# This file is compatible with both classic and new-style classes. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "this"): + if isinstance(value, class_type): + self.__dict__[name] = value.this + if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown + del value.thisown + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name) or (name == "thisown"): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +wkb25Bit = _ogr.wkb25Bit +wkbUnknown = _ogr.wkbUnknown +wkbPoint = _ogr.wkbPoint +wkbLineString = _ogr.wkbLineString +wkbPolygon = _ogr.wkbPolygon +wkbMultiPoint = _ogr.wkbMultiPoint +wkbMultiLineString = _ogr.wkbMultiLineString +wkbMultiPolygon = _ogr.wkbMultiPolygon +wkbGeometryCollection = _ogr.wkbGeometryCollection +wkbNone = _ogr.wkbNone +wkbLinearRing = _ogr.wkbLinearRing +wkbPoint25D = _ogr.wkbPoint25D +wkbLineString25D = _ogr.wkbLineString25D +wkbPolygon25D = _ogr.wkbPolygon25D +wkbMultiPoint25D = _ogr.wkbMultiPoint25D +wkbMultiLineString25D = _ogr.wkbMultiLineString25D +wkbMultiPolygon25D = _ogr.wkbMultiPolygon25D +wkbGeometryCollection25D = _ogr.wkbGeometryCollection25D +OFTInteger = _ogr.OFTInteger +OFTIntegerList = _ogr.OFTIntegerList +OFTReal = _ogr.OFTReal +OFTRealList = _ogr.OFTRealList +OFTString = _ogr.OFTString +OFTStringList = _ogr.OFTStringList +OFTWideString = _ogr.OFTWideString +OFTWideStringList = _ogr.OFTWideStringList +OFTBinary = _ogr.OFTBinary +OJUndefined = _ogr.OJUndefined +OJLeft = _ogr.OJLeft +OJRight = _ogr.OJRight +wkbXDR = _ogr.wkbXDR +wkbNDR = _ogr.wkbNDR +OLCRandomRead = _ogr.OLCRandomRead +OLCSequentialWrite = _ogr.OLCSequentialWrite +OLCRandomWrite = _ogr.OLCRandomWrite +OLCFastSpatialFilter = _ogr.OLCFastSpatialFilter +OLCFastFeatureCount = _ogr.OLCFastFeatureCount +OLCFastGetExtent = _ogr.OLCFastGetExtent +OLCCreateField = _ogr.OLCCreateField +OLCTransactions = _ogr.OLCTransactions +OLCDeleteFeature = _ogr.OLCDeleteFeature +OLCFastSetNextByIndex = _ogr.OLCFastSetNextByIndex +ODsCCreateLayer = _ogr.ODsCCreateLayer +ODsCDeleteLayer = _ogr.ODsCDeleteLayer +ODrCCreateDataSource = _ogr.ODrCCreateDataSource +ODrCDeleteDataSource = _ogr.ODrCDeleteDataSource +class Driver(_object): + """Proxy of C++ Driver class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Driver, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Driver, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ OGRDriverShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_getmethods__["name"] = _ogr.Driver_name_get + if _newclass:name = property(_ogr.Driver_name_get) + def CreateDataSource(*args, **kwargs): + """CreateDataSource(self, char name, char options=0) -> DataSource""" + return _ogr.Driver_CreateDataSource(*args, **kwargs) + + def CopyDataSource(*args, **kwargs): + """CopyDataSource(self, DataSource copy_ds, char name, char options=0) -> DataSource""" + return _ogr.Driver_CopyDataSource(*args, **kwargs) + + def Open(*args, **kwargs): + """Open(self, char name, int update=0) -> DataSource""" + return _ogr.Driver_Open(*args, **kwargs) + + def DeleteDataSource(*args): + """DeleteDataSource(self, char name) -> int""" + return _ogr.Driver_DeleteDataSource(*args) + + def TestCapability(*args): + """TestCapability(self, char cap) -> bool""" + return _ogr.Driver_TestCapability(*args) + + def GetName(*args): + """GetName(self) -> char""" + return _ogr.Driver_GetName(*args) + + +class DriverPtr(Driver): + def __init__(self, this): + _swig_setattr(self, Driver, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Driver, 'thisown', 0) + self.__class__ = Driver +_ogr.Driver_swigregister(DriverPtr) + +class DataSource(_object): + """Proxy of C++ DataSource class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, DataSource, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, DataSource, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ OGRDataSourceShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + __swig_getmethods__["name"] = _ogr.DataSource_name_get + if _newclass:name = property(_ogr.DataSource_name_get) + def __del__(self, destroy=_ogr.delete_DataSource): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def GetRefCount(*args): + """GetRefCount(self) -> int""" + return _ogr.DataSource_GetRefCount(*args) + + def GetSummaryRefCount(*args): + """GetSummaryRefCount(self) -> int""" + return _ogr.DataSource_GetSummaryRefCount(*args) + + def GetLayerCount(*args): + """GetLayerCount(self) -> int""" + return _ogr.DataSource_GetLayerCount(*args) + + def GetDriver(*args): + """GetDriver(self) -> Driver""" + return _ogr.DataSource_GetDriver(*args) + + def GetName(*args): + """GetName(self) -> char""" + return _ogr.DataSource_GetName(*args) + + def DeleteLayer(*args): + """DeleteLayer(self, int index) -> OGRErr""" + return _ogr.DataSource_DeleteLayer(*args) + + def CreateLayer(*args, **kwargs): + """ + CreateLayer(self, char name, SpatialReference reference=None, OGRwkbGeometryType geom_type=wkbUnknown, + char options=0) -> Layer + """ + return _ogr.DataSource_CreateLayer(*args, **kwargs) + + def CopyLayer(*args, **kwargs): + """CopyLayer(self, Layer src_layer, char new_name, char options=0) -> Layer""" + return _ogr.DataSource_CopyLayer(*args, **kwargs) + + def GetLayerByIndex(*args, **kwargs): + """GetLayerByIndex(self, int index=0) -> Layer""" + return _ogr.DataSource_GetLayerByIndex(*args, **kwargs) + + def GetLayerByName(*args): + """GetLayerByName(self, char layer_name) -> Layer""" + return _ogr.DataSource_GetLayerByName(*args) + + def TestCapability(*args): + """TestCapability(self, char cap) -> bool""" + return _ogr.DataSource_TestCapability(*args) + + def ExecuteSQL(*args, **kwargs): + """ExecuteSQL(self, char statement, Geometry geom=None, char dialect="") -> Layer""" + return _ogr.DataSource_ExecuteSQL(*args, **kwargs) + + def ReleaseResultSet(*args): + """ReleaseResultSet(self, Layer layer)""" + return _ogr.DataSource_ReleaseResultSet(*args) + + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def Release(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def Reference(self): + "For backwards compatibility only." + pass + + def Dereference(self): + "For backwards compatibility only." + pass + + def __len__(self): + """Returns the number of layers on the datasource""" + return self.GetLayerCount() + + def __getitem__(self, value): + """Support dictionary, list, and slice -like access to the datasource. + ] would return the first layer on the datasource. + aname'] would return the layer named "aname". + :4] would return a list of the first four layers.""" + import types + if isinstance(value, types.SliceType): + output = [] + for i in xrange(value.start,value.stop,step=value.step): + try: + output.append(self.GetLayer(i)) + except OGRError: #we're done because we're off the end + return output + return output + if isinstance(value, types.IntType): + if value > len(self)-1: + raise IndexError + return self.GetLayer(value) + elif isinstance(value,types.StringType): + return self.GetLayer(value) + else: + raise TypeError, 'Input %s is not of String or Int type' % type(value) + + def GetLayer(self,iLayer=0): + """Return the layer given an index or a name""" + import types + if isinstance(iLayer, types.StringType): + return self.GetLayerByName(iLayer) + elif isinstance(iLayer, types.IntType): + return self.GetLayerByIndex(iLayer) + else: + raise TypeError, "Input %s is not of String or Int type" % type(iLayer) + + +class DataSourcePtr(DataSource): + def __init__(self, this): + _swig_setattr(self, DataSource, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, DataSource, 'thisown', 0) + self.__class__ = DataSource +_ogr.DataSource_swigregister(DataSourcePtr) + +class Layer(_object): + """Proxy of C++ Layer class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Layer, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Layer, name) + def __init__(self): raise RuntimeError, "No constructor defined" + def __repr__(self): + return "<%s.%s; proxy of C++ OGRLayerShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def GetRefCount(*args): + """GetRefCount(self) -> int""" + return _ogr.Layer_GetRefCount(*args) + + def SetSpatialFilter(*args): + """SetSpatialFilter(self, Geometry filter)""" + return _ogr.Layer_SetSpatialFilter(*args) + + def SetSpatialFilterRect(*args): + """SetSpatialFilterRect(self, double minx, double miny, double maxx, double maxy)""" + return _ogr.Layer_SetSpatialFilterRect(*args) + + def GetSpatialFilter(*args): + """GetSpatialFilter(self) -> Geometry""" + return _ogr.Layer_GetSpatialFilter(*args) + + def SetAttributeFilter(*args): + """SetAttributeFilter(self, char filter_string) -> OGRErr""" + return _ogr.Layer_SetAttributeFilter(*args) + + def ResetReading(*args): + """ResetReading(self)""" + return _ogr.Layer_ResetReading(*args) + + def GetName(*args): + """GetName(self) -> char""" + return _ogr.Layer_GetName(*args) + + def GetFeature(*args): + """GetFeature(self, long fid) -> Feature""" + return _ogr.Layer_GetFeature(*args) + + def GetNextFeature(*args): + """GetNextFeature(self) -> Feature""" + return _ogr.Layer_GetNextFeature(*args) + + def SetNextByIndex(*args): + """SetNextByIndex(self, long new_index) -> OGRErr""" + return _ogr.Layer_SetNextByIndex(*args) + + def SetFeature(*args): + """SetFeature(self, Feature feature) -> OGRErr""" + return _ogr.Layer_SetFeature(*args) + + def CreateFeature(*args): + """CreateFeature(self, Feature feature) -> OGRErr""" + return _ogr.Layer_CreateFeature(*args) + + def DeleteFeature(*args): + """DeleteFeature(self, long fid) -> OGRErr""" + return _ogr.Layer_DeleteFeature(*args) + + def SyncToDisk(*args): + """SyncToDisk(self) -> OGRErr""" + return _ogr.Layer_SyncToDisk(*args) + + def GetLayerDefn(*args): + """GetLayerDefn(self) -> FeatureDefn""" + return _ogr.Layer_GetLayerDefn(*args) + + def GetFeatureCount(*args, **kwargs): + """GetFeatureCount(self, int force=1) -> int""" + return _ogr.Layer_GetFeatureCount(*args, **kwargs) + + def GetExtent(*args, **kwargs): + """GetExtent(self, double argout, int force=1) -> OGRErr""" + return _ogr.Layer_GetExtent(*args, **kwargs) + + def TestCapability(*args): + """TestCapability(self, char cap) -> bool""" + return _ogr.Layer_TestCapability(*args) + + def CreateField(*args, **kwargs): + """CreateField(self, FieldDefn field_def, int approx_ok=1) -> OGRErr""" + return _ogr.Layer_CreateField(*args, **kwargs) + + def StartTransaction(*args): + """StartTransaction(self) -> OGRErr""" + return _ogr.Layer_StartTransaction(*args) + + def CommitTransaction(*args): + """CommitTransaction(self) -> OGRErr""" + return _ogr.Layer_CommitTransaction(*args) + + def RollbackTransaction(*args): + """RollbackTransaction(self) -> OGRErr""" + return _ogr.Layer_RollbackTransaction(*args) + + def GetSpatialRef(*args): + """GetSpatialRef(self) -> SpatialReference""" + return _ogr.Layer_GetSpatialRef(*args) + + def GetFeatureRead(*args): + """GetFeatureRead(self) -> GIntBig""" + return _ogr.Layer_GetFeatureRead(*args) + + def Reference(self): + "For backwards compatibility only." + pass + + def Dereference(self): + "For backwards compatibility only." + pass + + def __len__(self): + """Returns the number of features in the layer""" + return self.GetFeatureCount() + + def __getitem__(self, value): + """Support list and slice -like access to the layer. + r[0] would return the first feature on the layer. + r[0:4] would return a list of the first four features.""" + if isinstance(value, types.SliceType): + output = [] + if value.stop == sys.maxint: + + + + stop = len(self) - 1 + else: + stop = value.stop + for i in xrange(value.start,stop,step=value.step): + feature = self.GetFeature(i) + if feature: + output.append(feature) + else: + return output + return output + if isinstance(value, types.IntType): + if value > len(self)-1: + raise IndexError + return self.GetFeature(value) + else: + raise TypeError,"Input %s is not of IntType or SliceType" % type(value) + + def CreateFields(fields): + """Create a list of fields on the Layer""" + for i in fields: + self.CreateField(i) + + def __iter__(self): + return self + + def next(self): + feature = self.GetNextFeature() + if not feature: + raise StopIteration + else: + return feature + + +class LayerPtr(Layer): + def __init__(self, this): + _swig_setattr(self, Layer, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Layer, 'thisown', 0) + self.__class__ = Layer +_ogr.Layer_swigregister(LayerPtr) + +class Feature(_object): + """Proxy of C++ Feature class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Feature, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Feature, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OGRFeatureShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __del__(self, destroy=_ogr.delete_Feature): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __init__(self, *args, **kwargs): + """__init__(self, FeatureDefn feature_def=0) -> Feature""" + _swig_setattr(self, Feature, 'this', _ogr.new_Feature(*args, **kwargs)) + _swig_setattr(self, Feature, 'thisown', 1) + def GetDefnRef(*args): + """GetDefnRef(self) -> FeatureDefn""" + return _ogr.Feature_GetDefnRef(*args) + + def SetGeometry(*args): + """SetGeometry(self, Geometry geom) -> OGRErr""" + return _ogr.Feature_SetGeometry(*args) + + def SetGeometryDirectly(*args): + """SetGeometryDirectly(self, Geometry geom) -> OGRErr""" + return _ogr.Feature_SetGeometryDirectly(*args) + + def GetGeometryRef(*args): + """GetGeometryRef(self) -> Geometry""" + return _ogr.Feature_GetGeometryRef(*args) + + def Clone(*args): + """Clone(self) -> Feature""" + return _ogr.Feature_Clone(*args) + + def Equal(*args): + """Equal(self, Feature feature) -> bool""" + return _ogr.Feature_Equal(*args) + + def GetFieldCount(*args): + """GetFieldCount(self) -> int""" + return _ogr.Feature_GetFieldCount(*args) + + def GetFieldDefnRef(*args): + """ + GetFieldDefnRef(self, int id) -> FieldDefn + GetFieldDefnRef(self, char name) -> FieldDefn + """ + return _ogr.Feature_GetFieldDefnRef(*args) + + def GetFieldAsString(*args): + """ + GetFieldAsString(self, int id) -> char + GetFieldAsString(self, char name) -> char + """ + return _ogr.Feature_GetFieldAsString(*args) + + def GetFieldAsInteger(*args): + """ + GetFieldAsInteger(self, int id) -> int + GetFieldAsInteger(self, char name) -> int + """ + return _ogr.Feature_GetFieldAsInteger(*args) + + def GetFieldAsDouble(*args): + """ + GetFieldAsDouble(self, int id) -> double + GetFieldAsDouble(self, char name) -> double + """ + return _ogr.Feature_GetFieldAsDouble(*args) + + def IsFieldSet(*args): + """ + IsFieldSet(self, int id) -> bool + IsFieldSet(self, char name) -> bool + """ + return _ogr.Feature_IsFieldSet(*args) + + def GetFieldIndex(*args): + """GetFieldIndex(self, char name) -> int""" + return _ogr.Feature_GetFieldIndex(*args) + + def GetFID(*args): + """GetFID(self) -> int""" + return _ogr.Feature_GetFID(*args) + + def SetFID(*args): + """SetFID(self, int fid) -> OGRErr""" + return _ogr.Feature_SetFID(*args) + + def DumpReadable(*args): + """DumpReadable(self)""" + return _ogr.Feature_DumpReadable(*args) + + def UnsetField(*args): + """ + UnsetField(self, int id) + UnsetField(self, char name) + """ + return _ogr.Feature_UnsetField(*args) + + def SetField(*args): + """ + SetField(self, int id, char value) + SetField(self, char name, char value) + """ + return _ogr.Feature_SetField(*args) + + def SetFrom(*args, **kwargs): + """SetFrom(self, Feature other, int forgiving=1) -> OGRErr""" + return _ogr.Feature_SetFrom(*args, **kwargs) + + def GetStyleString(*args): + """GetStyleString(self) -> char""" + return _ogr.Feature_GetStyleString(*args) + + def SetStyleString(*args): + """SetStyleString(self, char the_string)""" + return _ogr.Feature_SetStyleString(*args) + + def GetFieldType(*args): + """ + GetFieldType(self, int id) -> OGRFieldType + GetFieldType(self, char name, char value) -> OGRFieldType + """ + return _ogr.Feature_GetFieldType(*args) + + def Reference(self): + pass + + def Dereference(self): + pass + + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + def __cmp__(self, other): + """Compares a feature to another for equality""" + return self.Equal(other) + + def __copy__(self): + return self.Clone() + + def __getattr__(self, name): + """Returns the values of fields by the given name""" + try: + names = [] + for i in range(self.GetFieldCount()): + names.append(self.GetFieldDefnRef_ByID(i).GetName()) + if name in names: + return self.GetField(name) + else: + raise + except: + raise AttributeError, name + def GetField(self, fld_index): + import types + if isinstance(fld_index, types.StringType): + fld_index = self.GetFieldIndex(fld_index) + if (fld_index < 0) or (fld_index > self.GetFieldCount()): + raise ValueError, "Illegal field requested in GetField()" + if not (self.IsFieldSet(fld_index)): + return None + fld_type = self.GetFieldType(fld_index) + if fld_type == OFTInteger: + return self.GetFieldAsInteger(fld_index) + if fld_type == OFTReal: + return self.GetFieldAsDouble(fld_index) + if fld_type == OFTString: + return self.GetFieldAsString(fld_index) + + + +class FeaturePtr(Feature): + def __init__(self, this): + _swig_setattr(self, Feature, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Feature, 'thisown', 0) + self.__class__ = Feature +_ogr.Feature_swigregister(FeaturePtr) + +class FeatureDefn(_object): + """Proxy of C++ FeatureDefn class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, FeatureDefn, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, FeatureDefn, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OGRFeatureDefnShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __del__(self, destroy=_ogr.delete_FeatureDefn): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __init__(self, *args, **kwargs): + """__init__(self, char name=None) -> FeatureDefn""" + _swig_setattr(self, FeatureDefn, 'this', _ogr.new_FeatureDefn(*args, **kwargs)) + _swig_setattr(self, FeatureDefn, 'thisown', 1) + def GetName(*args): + """GetName(self) -> char""" + return _ogr.FeatureDefn_GetName(*args) + + def GetFieldCount(*args): + """GetFieldCount(self) -> int""" + return _ogr.FeatureDefn_GetFieldCount(*args) + + def GetFieldDefn(*args): + """GetFieldDefn(self, int i) -> FieldDefn""" + return _ogr.FeatureDefn_GetFieldDefn(*args) + + def GetFieldIndex(*args): + """GetFieldIndex(self, char name) -> int""" + return _ogr.FeatureDefn_GetFieldIndex(*args) + + def AddFieldDefn(*args): + """AddFieldDefn(self, FieldDefn defn)""" + return _ogr.FeatureDefn_AddFieldDefn(*args) + + def GetGeomType(*args): + """GetGeomType(self) -> OGRwkbGeometryType""" + return _ogr.FeatureDefn_GetGeomType(*args) + + def SetGeomType(*args): + """SetGeomType(self, OGRwkbGeometryType geom_type)""" + return _ogr.FeatureDefn_SetGeomType(*args) + + def GetReferenceCount(*args): + """GetReferenceCount(self) -> int""" + return _ogr.FeatureDefn_GetReferenceCount(*args) + + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + +class FeatureDefnPtr(FeatureDefn): + def __init__(self, this): + _swig_setattr(self, FeatureDefn, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, FeatureDefn, 'thisown', 0) + self.__class__ = FeatureDefn +_ogr.FeatureDefn_swigregister(FeatureDefnPtr) + +class FieldDefn(_object): + """Proxy of C++ FieldDefn class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, FieldDefn, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, FieldDefn, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OGRFieldDefnShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __del__(self, destroy=_ogr.delete_FieldDefn): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __init__(self, *args, **kwargs): + """__init__(self, char name="unnamed", OGRFieldType field_type=OFTString) -> FieldDefn""" + _swig_setattr(self, FieldDefn, 'this', _ogr.new_FieldDefn(*args, **kwargs)) + _swig_setattr(self, FieldDefn, 'thisown', 1) + def GetName(*args): + """GetName(self) -> char""" + return _ogr.FieldDefn_GetName(*args) + + def GetNameRef(*args): + """GetNameRef(self) -> char""" + return _ogr.FieldDefn_GetNameRef(*args) + + def SetName(*args): + """SetName(self, char name)""" + return _ogr.FieldDefn_SetName(*args) + + def GetType(*args): + """GetType(self) -> OGRFieldType""" + return _ogr.FieldDefn_GetType(*args) + + def SetType(*args): + """SetType(self, OGRFieldType type)""" + return _ogr.FieldDefn_SetType(*args) + + def GetJustify(*args): + """GetJustify(self) -> OGRJustification""" + return _ogr.FieldDefn_GetJustify(*args) + + def SetJustify(*args): + """SetJustify(self, OGRJustification justify)""" + return _ogr.FieldDefn_SetJustify(*args) + + def GetWidth(*args): + """GetWidth(self) -> int""" + return _ogr.FieldDefn_GetWidth(*args) + + def SetWidth(*args): + """SetWidth(self, int width)""" + return _ogr.FieldDefn_SetWidth(*args) + + def GetPrecision(*args): + """GetPrecision(self) -> int""" + return _ogr.FieldDefn_GetPrecision(*args) + + def SetPrecision(*args): + """SetPrecision(self, int precision)""" + return _ogr.FieldDefn_SetPrecision(*args) + + def GetFieldTypeName(*args): + """GetFieldTypeName(self, OGRFieldType type) -> char""" + return _ogr.FieldDefn_GetFieldTypeName(*args) + + width = property(GetWidth, SetWidth) + type = property(GetType, SetType) + precision = property(GetPrecision, SetPrecision) + name = property(GetName, SetName) + justify = property(GetJustify, SetJustify) + + def Destroy(self): + "Once called, self has effectively been destroyed. Do not access. For backwards compatiblity only" + self.__del__() + self.thisown = 0 + + +class FieldDefnPtr(FieldDefn): + def __init__(self, this): + _swig_setattr(self, FieldDefn, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, FieldDefn, 'thisown', 0) + self.__class__ = FieldDefn +_ogr.FieldDefn_swigregister(FieldDefnPtr) + + +def CreateGeometryFromWkb(*args, **kwargs): + """CreateGeometryFromWkb(int len, SpatialReference reference=None) -> Geometry""" + return _ogr.CreateGeometryFromWkb(*args, **kwargs) + +def CreateGeometryFromWkt(*args, **kwargs): + """CreateGeometryFromWkt(char val, SpatialReference reference=None) -> Geometry""" + return _ogr.CreateGeometryFromWkt(*args, **kwargs) + +def CreateGeometryFromGML(*args): + """CreateGeometryFromGML(char input_string) -> Geometry""" + return _ogr.CreateGeometryFromGML(*args) +class Geometry(_object): + """Proxy of C++ Geometry class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, Geometry, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, Geometry, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OGRGeometryShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __del__(self, destroy=_ogr.delete_Geometry): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __init__(self, *args, **kwargs): + """ + __init__(self, OGRwkbGeometryType type=wkbUnknown, char wkt=0, int wkb=0, + char wkb_buf=0, char gml=0) -> Geometry + """ + _swig_setattr(self, Geometry, 'this', _ogr.new_Geometry(*args, **kwargs)) + _swig_setattr(self, Geometry, 'thisown', 1) + def ExportToWkt(*args): + """ExportToWkt(self, char argout) -> OGRErr""" + return _ogr.Geometry_ExportToWkt(*args) + + def ExportToWkb(*args, **kwargs): + """ExportToWkb(self, int nLen, OGRwkbByteOrder byte_order=wkbXDR) -> OGRErr""" + return _ogr.Geometry_ExportToWkb(*args, **kwargs) + + def ExportToGML(*args): + """ExportToGML(self) -> char""" + return _ogr.Geometry_ExportToGML(*args) + + def AddPoint(*args, **kwargs): + """AddPoint(self, double x, double y, double z=0)""" + return _ogr.Geometry_AddPoint(*args, **kwargs) + + def AddGeometryDirectly(*args): + """AddGeometryDirectly(self, Geometry other) -> OGRErr""" + return _ogr.Geometry_AddGeometryDirectly(*args) + + def AddGeometry(*args): + """AddGeometry(self, Geometry other) -> OGRErr""" + return _ogr.Geometry_AddGeometry(*args) + + def Clone(*args): + """Clone(self) -> Geometry""" + return _ogr.Geometry_Clone(*args) + + def GetGeometryType(*args): + """GetGeometryType(self) -> OGRwkbGeometryType""" + return _ogr.Geometry_GetGeometryType(*args) + + def GetGeometryName(*args): + """GetGeometryName(self) -> char""" + return _ogr.Geometry_GetGeometryName(*args) + + def GetArea(*args): + """GetArea(self) -> double""" + return _ogr.Geometry_GetArea(*args) + + def GetPointCount(*args): + """GetPointCount(self) -> int""" + return _ogr.Geometry_GetPointCount(*args) + + def GetX(*args, **kwargs): + """GetX(self, int point=0) -> double""" + return _ogr.Geometry_GetX(*args, **kwargs) + + def GetY(*args, **kwargs): + """GetY(self, int point=0) -> double""" + return _ogr.Geometry_GetY(*args, **kwargs) + + def GetZ(*args, **kwargs): + """GetZ(self, int point=0) -> double""" + return _ogr.Geometry_GetZ(*args, **kwargs) + + def GetGeometryCount(*args): + """GetGeometryCount(self) -> int""" + return _ogr.Geometry_GetGeometryCount(*args) + + def SetPoint(*args, **kwargs): + """SetPoint(self, int point, double x, double y, double z=0)""" + return _ogr.Geometry_SetPoint(*args, **kwargs) + + def GetGeometryRef(*args): + """GetGeometryRef(self, int geom) -> Geometry""" + return _ogr.Geometry_GetGeometryRef(*args) + + def GetBoundary(*args): + """GetBoundary(self) -> Geometry""" + return _ogr.Geometry_GetBoundary(*args) + + def ConvexHull(*args): + """ConvexHull(self) -> Geometry""" + return _ogr.Geometry_ConvexHull(*args) + + def Buffer(*args, **kwargs): + """Buffer(self, double distance, int quadsecs=30) -> Geometry""" + return _ogr.Geometry_Buffer(*args, **kwargs) + + def Intersection(*args): + """Intersection(self, Geometry other) -> Geometry""" + return _ogr.Geometry_Intersection(*args) + + def Union(*args): + """Union(self, Geometry other) -> Geometry""" + return _ogr.Geometry_Union(*args) + + def Difference(*args): + """Difference(self, Geometry other) -> Geometry""" + return _ogr.Geometry_Difference(*args) + + def SymmetricDifference(*args): + """SymmetricDifference(self, Geometry other) -> Geometry""" + return _ogr.Geometry_SymmetricDifference(*args) + + def Distance(*args): + """Distance(self, Geometry other) -> double""" + return _ogr.Geometry_Distance(*args) + + def Empty(*args): + """Empty(self)""" + return _ogr.Geometry_Empty(*args) + + def Intersect(*args): + """Intersect(self, Geometry other) -> bool""" + return _ogr.Geometry_Intersect(*args) + + def Equal(*args): + """Equal(self, Geometry other) -> bool""" + return _ogr.Geometry_Equal(*args) + + def Disjoint(*args): + """Disjoint(self, Geometry other) -> bool""" + return _ogr.Geometry_Disjoint(*args) + + def Touches(*args): + """Touches(self, Geometry other) -> bool""" + return _ogr.Geometry_Touches(*args) + + def Crosses(*args): + """Crosses(self, Geometry other) -> bool""" + return _ogr.Geometry_Crosses(*args) + + def Within(*args): + """Within(self, Geometry other) -> bool""" + return _ogr.Geometry_Within(*args) + + def Contains(*args): + """Contains(self, Geometry other) -> bool""" + return _ogr.Geometry_Contains(*args) + + def Overlaps(*args): + """Overlaps(self, Geometry other) -> bool""" + return _ogr.Geometry_Overlaps(*args) + + def TransformTo(*args): + """TransformTo(self, SpatialReference reference) -> OGRErr""" + return _ogr.Geometry_TransformTo(*args) + + def Transform(*args): + """Transform(self, CoordinateTransformation trans) -> OGRErr""" + return _ogr.Geometry_Transform(*args) + + def GetSpatialReference(*args): + """GetSpatialReference(self) -> SpatialReference""" + return _ogr.Geometry_GetSpatialReference(*args) + + def AssignSpatialReference(*args): + """AssignSpatialReference(self, SpatialReference reference)""" + return _ogr.Geometry_AssignSpatialReference(*args) + + def CloseRings(*args): + """CloseRings(self)""" + return _ogr.Geometry_CloseRings(*args) + + def FlattenTo2D(*args): + """FlattenTo2D(self)""" + return _ogr.Geometry_FlattenTo2D(*args) + + def GetEnvelope(*args): + """GetEnvelope(self, double argout)""" + return _ogr.Geometry_GetEnvelope(*args) + + def Centroid(*args): + """Centroid(self) -> Geometry""" + return _ogr.Geometry_Centroid(*args) + + def WkbSize(*args): + """WkbSize(self) -> int""" + return _ogr.Geometry_WkbSize(*args) + + def GetCoordinateDimension(*args): + """GetCoordinateDimension(self) -> int""" + return _ogr.Geometry_GetCoordinateDimension(*args) + + def GetDimension(*args): + """GetDimension(self) -> int""" + return _ogr.Geometry_GetDimension(*args) + + def Destroy(self): + self.__del__() + self.thisown = 0 + + def __str__(self): + return self.ExportToWkt() + + +class GeometryPtr(Geometry): + def __init__(self, this): + _swig_setattr(self, Geometry, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, Geometry, 'thisown', 0) + self.__class__ = Geometry +_ogr.Geometry_swigregister(GeometryPtr) + + +def GetDriverCount(*args): + """GetDriverCount() -> int""" + return _ogr.GetDriverCount(*args) + +def GetOpenDSCount(*args): + """GetOpenDSCount() -> int""" + return _ogr.GetOpenDSCount(*args) + +def SetGenerate_DB2_V72_BYTE_ORDER(*args): + """SetGenerate_DB2_V72_BYTE_ORDER(int bGenerate_DB2_V72_BYTE_ORDER) -> OGRErr""" + return _ogr.SetGenerate_DB2_V72_BYTE_ORDER(*args) + +def RegisterAll(*args): + """RegisterAll()""" + return _ogr.RegisterAll(*args) + +def GetOpenDS(*args): + """GetOpenDS(int ds_number) -> DataSource""" + return _ogr.GetOpenDS(*args) + +def Open(*args, **kwargs): + """Open(char filename, int update=0) -> DataSource""" + return _ogr.Open(*args, **kwargs) + +def OpenShared(*args, **kwargs): + """OpenShared(char filename, int update=0) -> DataSource""" + return _ogr.OpenShared(*args, **kwargs) + +def GetDriverByName(*args): + """GetDriverByName(char name) -> Driver""" + return _ogr.GetDriverByName(*args) + +def GetDriver(*args): + """GetDriver(int driver_number) -> Driver""" + return _ogr.GetDriver(*args) + + diff --git a/Utilities/GDAL/swig/python/ogr_wrap.cpp b/Utilities/GDAL/swig/python/ogr_wrap.cpp new file mode 100644 index 0000000000..6cfce6f3bd --- /dev/null +++ b/Utilities/GDAL/swig/python/ogr_wrap.cpp @@ -0,0 +1,8007 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +#include <Python.h> + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * SWIG API. Portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * for internal method declarations + * ----------------------------------------------------------------------------- */ + +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* + Exception handling in wrappers +*/ +#define SWIG_fail goto fail +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) +#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) +#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) +#define SWIG_null_ref(type) SWIG_Python_NullRef(type) + +/* + Contract support +*/ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_INT 1 +#define SWIG_PY_FLOAT 2 +#define SWIG_PY_STRING 3 +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Alloc. memory flags + * ----------------------------------------------------------------------------- */ +#define SWIG_OLDOBJ 1 +#define SWIG_NEWOBJ SWIG_OLDOBJ + 1 +#define SWIG_PYSTR SWIG_NEWOBJ + 1 + +#ifdef __cplusplus +} +#endif + + +/*********************************************************************** + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * Author : David Beazley (beazley@cs.uchicago.edu) + ************************************************************************/ + +/* Common SWIG API */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + + +/* Python-specific SWIG API */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ +/* + Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent + C/C++ pointers in the python side. Very useful for debugging, but + not always safe. +*/ +#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) +# define SWIG_COBJECT_TYPES +#endif + +/* Flags for pointer conversion */ +#define SWIG_POINTER_EXCEPTION 0x1 +#define SWIG_POINTER_DISOWN 0x2 + + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +#define PyOS_snprintf snprintf +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Create a new pointer string + * ----------------------------------------------------------------------------- */ +#ifndef SWIG_BUFFER_SIZE +#define SWIG_BUFFER_SIZE 1024 +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_BUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +#if PY_VERSION_HEX < 0x01060000 +#define PyObject_Del(op) PyMem_DEL((op)) +#endif + +#if defined(SWIG_COBJECT_TYPES) +#if !defined(SWIG_COBJECT_PYTHON) +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Object type, and use it instead of PyCObject + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *ptr; + const char *desc; +} PySwigObject; + +/* Declarations for objects of type PySwigObject */ + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { + fputs("<Swig Object at ", fp); fputs(result, fp); fputs(">", fp); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_repr(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromFormat("<Swig Object at %s>", result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); + } +} + +SWIGRUNTIME void +PySwigObject_dealloc(PySwigObject *self) +{ + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static char pyswigobject_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigObject", /*tp_name*/ + sizeof(PySwigObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigObject_dealloc, /*tp_dealloc*/ + (printfunc)PySwigObject_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigObject_compare, /*tp_compare*/ + (reprfunc)PySwigObject_repr, /*tp_repr*/ + &PySwigObject_as_number, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigObject_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigobject_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigobject_type = tmp; + type_init = 1; + } +#endif + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) +{ + PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (self) { + self->ptr = ptr; + self->desc = desc; + } + return (PyObject *)self; +} + +SWIGRUNTIMEINLINE void * +PySwigObject_AsVoidPtr(PyObject *self) +{ + return ((PySwigObject *)self)->ptr; +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + return ((PySwigObject *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + const char *desc; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->desc,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->desc); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->desc); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->desc); + } else { + return PyString_FromString(v->desc); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + } +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PySwigPacked *self) +{ + free(self->pack); + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static char pyswigpacked_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigPacked", /*tp_name*/ + sizeof(PySwigPacked), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ + (printfunc)PySwigPacked_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigPacked_compare, /*tp_compare*/ + (reprfunc)PySwigPacked_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigPacked_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigpacked_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigpacked_type = tmp; + type_init = 1; + } +#endif + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) +{ + PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (self == NULL) { + return NULL; + } else { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + self->pack = pack; + self->desc = desc; + self->size = size; + return (PyObject *) self; + } + return NULL; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + PySwigPacked *self = (PySwigPacked *)obj; + if (self->size != size) return 0; + memcpy(ptr, self->pack, size); + return self->desc; +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_GetDesc(PyObject *self) +{ + return ((PySwigPacked *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +#else +/* ----------------------------------------------------------------------------- + * Use the old Python PyCObject instead of PySwigObject + * ----------------------------------------------------------------------------- */ + +#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) +#define PySwigObject_Check(obj) PyCObject_Check(obj) +#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) +#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) + +#endif + +#endif + +/* ----------------------------------------------------------------------------- + * errors manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + +SWIGRUNTIMEINLINE void +SWIG_Python_NullRef(const char *type) +{ + if (type) { + PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); + } else { + PyErr_Format(PyExc_TypeError, "null reference was received"); + } +} + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + static PyObject *SWIG_this = 0; + int newref = 0; + PyObject *pyobj = 0; + void *vptr; + + if (!obj) return 0; + if (obj == Py_None) { + *ptr = 0; + return 0; + } + +#ifdef SWIG_COBJECT_TYPES + if (!(PySwigObject_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PySwigObject_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + vptr = PySwigObject_AsVoidPtr(obj); + c = (const char *) PySwigObject_GetDesc(obj); + if (newref) { Py_DECREF(obj); } + goto type_check; +#else + if (!(PyString_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PyString_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); + if (newref) { Py_DECREF(obj); } + if (!c) goto type_error; +#endif + +type_check: + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + *ptr = SWIG_TypeCast(tc,vptr); + } else { + *ptr = vptr; + } + if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { + PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); + } + return 0; + +type_error: + PyErr_Clear(); + if (pyobj && !obj) { + obj = pyobj; + if (PyCFunction_Check(obj)) { + /* here we get the method pointer for callbacks */ + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + c = doc ? strstr(doc, "swig_ptr: ") : 0; + if (c) { + c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; + if (!c) goto type_error; + goto type_check; + } + } + } + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ pointer", obj); + } + } + return -1; +} + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + c = PySwigPacked_UnpackData(obj, ptr, sz); +#else + if ((!obj) || (!PyString_Check(obj))) goto type_error; + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackDataName(c, ptr, sz, ty->name); +#endif + if (!c) goto type_error; + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + } + return 0; + +type_error: + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ packed data", obj); + } + } + return -1; +} + +/* Create a new array object */ +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { + PyObject *robj = 0; + if (!type) { + if (!PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj"); + } + return robj; + } + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#ifdef SWIG_COBJECT_TYPES + robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + if (!robj || (robj == Py_None)) return robj; + if (type->clientdata) { + PyObject *inst; + PyObject *args = Py_BuildValue((char*)"(O)", robj); + Py_DECREF(robj); + inst = PyObject_CallObject((PyObject *) type->clientdata, args); + Py_DECREF(args); + if (inst) { + if (own) { + PyObject_SetAttrString(inst,(char*)"thisown",Py_True); + } + robj = inst; + } + } + return robj; +} + +SWIGRUNTIME PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + PyObject *robj = 0; + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + return robj; +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function +is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return -1; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return -1; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return -1; + } + if (PyDict_SetItemString(dict, name, o)) + return -1; + Py_DECREF(o); + return 0; +} +#endif + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } +} + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_GIntBig swig_types[0] +#define SWIGTYPE_p_OGRDataSourceShadow swig_types[1] +#define SWIGTYPE_p_OGRDriverShadow swig_types[2] +#define SWIGTYPE_p_OGRFeatureDefnShadow swig_types[3] +#define SWIGTYPE_p_OGRFeatureShadow swig_types[4] +#define SWIGTYPE_p_OGRFieldDefnShadow swig_types[5] +#define SWIGTYPE_p_OGRGeometryShadow swig_types[6] +#define SWIGTYPE_p_OGRLayerShadow swig_types[7] +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[8] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[9] +#define SWIGTYPE_p_char swig_types[10] +#define SWIGTYPE_p_double swig_types[11] +#define SWIGTYPE_p_int swig_types[12] +#define SWIGTYPE_p_p_char swig_types[13] +#define SWIGTYPE_ptrdiff_t swig_types[14] +#define SWIGTYPE_size_t swig_types[15] +#define SWIGTYPE_std__ptrdiff_t swig_types[16] +#define SWIGTYPE_std__size_t swig_types[17] +static swig_type_info *swig_types[19]; +static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + + +/*----------------------------------------------- + @(target):= _ogr.so + ------------------------------------------------*/ +#define SWIG_init init_ogr + +#define SWIG_name "_ogr" + +#define SWIG_MemoryError 1 +#define SWIG_IOError 2 +#define SWIG_RuntimeError 3 +#define SWIG_IndexError 4 +#define SWIG_TypeError 5 +#define SWIG_DivisionByZero 6 +#define SWIG_OverflowError 7 +#define SWIG_SyntaxError 8 +#define SWIG_ValueError 9 +#define SWIG_SystemError 10 +#define SWIG_UnknownError 99 + + +SWIGINTERN void SWIG_exception_(int code, const char *msg) { + switch(code) { + case SWIG_MemoryError: + PyErr_SetString(PyExc_MemoryError,msg); + break; + case SWIG_IOError: + PyErr_SetString(PyExc_IOError,msg); + break; + case SWIG_RuntimeError: + PyErr_SetString(PyExc_RuntimeError,msg); + break; + case SWIG_IndexError: + PyErr_SetString(PyExc_IndexError,msg); + break; + case SWIG_TypeError: + PyErr_SetString(PyExc_TypeError,msg); + break; + case SWIG_DivisionByZero: + PyErr_SetString(PyExc_ZeroDivisionError,msg); + break; + case SWIG_OverflowError: + PyErr_SetString(PyExc_OverflowError,msg); + break; + case SWIG_SyntaxError: + PyErr_SetString(PyExc_SyntaxError,msg); + break; + case SWIG_ValueError: + PyErr_SetString(PyExc_ValueError,msg); + break; + case SWIG_SystemError: + PyErr_SetString(PyExc_SystemError,msg); + break; + default: + PyErr_SetString(PyExc_RuntimeError,msg); + break; + } +} + +#define SWIG_exception(a,b) { SWIG_exception_(a,b); SWIG_fail; } + + +#include <stdexcept> + + +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; + + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_int PyInt_FromLong +/*@@*/ + + +SWIGINTERN PyObject * +SWIG_FromCharPtr(const char* cptr) +{ + if (cptr) { + size_t size = strlen(cptr); + if (size > INT_MAX) { + return SWIG_NewPointerObj(const_cast<char* >(cptr), + SWIG_TypeQuery("char *"), 0); + } else { + if (size != 0) { + return PyString_FromStringAndSize(cptr, size); + } else { + return PyString_FromString(cptr); + } + } + } + Py_INCREF(Py_None); + return Py_None; +} + + +/* returns SWIG_OLDOBJ if the input is a raw char*, SWIG_PYSTR if is a PyString */ +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize) +{ + static swig_type_info* pchar_info = 0; + char* vptr = 0; + if (!pchar_info) pchar_info = SWIG_TypeQuery("char *"); + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) != -1) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + if (PyString_Check(obj)) { + if (cptr) { + *cptr = PyString_AS_STRING(obj); + if (psize) { + *psize = PyString_GET_SIZE(obj) + 1; + } + } + return SWIG_PYSTR; + } + } + if (cptr) { + SWIG_type_error("char *", obj); + } + return 0; +} + + +SWIGINTERNINLINE int +SWIG_AsCharPtr(PyObject *obj, char **val) +{ + if (SWIG_AsCharPtrAndSize(obj, val, (size_t*)(0))) { + return 1; + } + if (val) { + PyErr_Clear(); + SWIG_type_error("char *", obj); + } + return 0; +} + +static OGRDataSourceShadow *OGRDriverShadow_CreateDataSource(OGRDriverShadow *self,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } +static OGRDataSourceShadow *OGRDriverShadow_CopyDataSource(OGRDriverShadow *self,OGRDataSourceShadow *copy_ds,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } + +#include <limits.h> + + +SWIGINTERN int + SWIG_CheckLongInRange(long value, long min_value, long max_value, + const char *errmsg) +{ + if (value < min_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is less than '%s' minimum %ld", + value, errmsg, min_value); + } + return 0; + } else if (value > max_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is greater than '%s' maximum %ld", + value, errmsg, max_value); + } + return 0; + } + return 1; +} + + +SWIGINTERN int + SWIG_AsVal_long(PyObject * obj, long* val) +{ + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (val) { + SWIG_type_error("long", obj); + } + return 0; + } + + +#if INT_MAX != LONG_MAX +SWIGINTERN int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + const char* errmsg = val ? "int" : (char*)0; + long v; + if (SWIG_AsVal_long(obj, &v)) { + if (SWIG_CheckLongInRange(v, INT_MIN,INT_MAX, errmsg)) { + if (val) *val = static_cast<int >(v); + return 1; + } else { + return 0; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_type_error(errmsg, obj); + } + return 0; +} +#else +SWIGINTERNINLINE int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + return SWIG_AsVal_long(obj,(long*)val); +} +#endif + + +SWIGINTERNINLINE int +SWIG_As_int(PyObject* obj) +{ + int v; + if (!SWIG_AsVal_int(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(int)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_int(PyObject* obj) +{ + return SWIG_AsVal_int(obj, (int*)0); +} + +static OGRDataSourceShadow *OGRDriverShadow_Open(OGRDriverShadow *self,char const *name,int update=0){ + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } +static int OGRDriverShadow_DeleteDataSource(OGRDriverShadow *self,char const *name){ + return OGR_Dr_DeleteDataSource( self, name ); + } +static bool OGRDriverShadow_TestCapability(OGRDriverShadow *self,char const *cap){ + return OGR_Dr_TestCapability(self, cap); + } + +SWIGINTERNINLINE PyObject* + SWIG_From_bool(bool value) +{ + PyObject *obj = value ? Py_True : Py_False; + Py_INCREF(obj); + return obj; +} + +static char const *OGRDriverShadow_GetName(OGRDriverShadow *self){ + return OGR_Dr_GetName( self ); + } +static void delete_OGRDataSourceShadow(OGRDataSourceShadow *self){ + OGRReleaseDataSource(self); + } +static int OGRDataSourceShadow_GetRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetRefCount(self); + } +static int OGRDataSourceShadow_GetSummaryRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetSummaryRefCount(self); + } +static int OGRDataSourceShadow_GetLayerCount(OGRDataSourceShadow *self){ + return OGR_DS_GetLayerCount(self); + } +static OGRDriverShadow *OGRDataSourceShadow_GetDriver(OGRDataSourceShadow *self){ + OGRDriverShadow* driver; + OGRDataSourceShadow* ds; + ds = (OGRDataSourceShadow*)OGROpen((const char *) OGR_DS_GetName(self),0,&driver); + OGRReleaseDataSource(ds); + return driver; + } +static char const *OGRDataSourceShadow_GetName(OGRDataSourceShadow *self){ + return OGR_DS_GetName(self); + } +static OGRErr OGRDataSourceShadow_DeleteLayer(OGRDataSourceShadow *self,int index){ + return OGR_DS_DeleteLayer(self, index); + } + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +static OGRLayerShadow *OGRDataSourceShadow_CreateLayer(OGRDataSourceShadow *self,char const *name,OSRSpatialReferenceShadow *reference=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_CopyLayer(OGRDataSourceShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByIndex(OGRDataSourceShadow *self,int index=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayer(self, index); + return layer; + } +static OGRLayerShadow *OGRDataSourceShadow_GetLayerByName(OGRDataSourceShadow *self,char const *layer_name){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_GetLayerByName(self, layer_name); + return layer; + } +static bool OGRDataSourceShadow_TestCapability(OGRDataSourceShadow *self,char const *cap){ + return OGR_DS_TestCapability(self, cap); + } +static OGRLayerShadow *OGRDataSourceShadow_ExecuteSQL(OGRDataSourceShadow *self,char const *statement,OGRGeometryShadow *geom=NULL,char const *dialect=""){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } +static void OGRDataSourceShadow_ReleaseResultSet(OGRDataSourceShadow *self,OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +static int OGRLayerShadow_GetRefCount(OGRLayerShadow *self){ + return OGR_L_GetRefCount(self); + } +static void OGRLayerShadow_SetSpatialFilter(OGRLayerShadow *self,OGRGeometryShadow *filter){ + OGR_L_SetSpatialFilter (self, filter); + } + +SWIGINTERN int + SWIG_AsVal_double(PyObject *obj, double *val) +{ + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return 1; + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (val) { + SWIG_type_error("double", obj); + } + return 0; +} + + +SWIGINTERNINLINE double +SWIG_As_double(PyObject* obj) +{ + double v; + if (!SWIG_AsVal_double(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(double)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_double(PyObject* obj) +{ + return SWIG_AsVal_double(obj, (double*)0); +} + +static void OGRLayerShadow_SetSpatialFilterRect(OGRLayerShadow *self,double minx,double miny,double maxx,double maxy){ + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } +static OGRGeometryShadow *OGRLayerShadow_GetSpatialFilter(OGRLayerShadow *self){ + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } +static OGRErr OGRLayerShadow_SetAttributeFilter(OGRLayerShadow *self,char *filter_string){ + return OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + } +static void OGRLayerShadow_ResetReading(OGRLayerShadow *self){ + OGR_L_ResetReading(self); + } +static char const *OGRLayerShadow_GetName(OGRLayerShadow *self){ + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } + +SWIGINTERNINLINE long +SWIG_As_long(PyObject* obj) +{ + long v; + if (!SWIG_AsVal_long(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(long)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_long(PyObject* obj) +{ + return SWIG_AsVal_long(obj, (long*)0); +} + +static OGRFeatureShadow *OGRLayerShadow_GetFeature(OGRLayerShadow *self,long fid){ + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } +static OGRFeatureShadow *OGRLayerShadow_GetNextFeature(OGRLayerShadow *self){ + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } +static OGRErr OGRLayerShadow_SetNextByIndex(OGRLayerShadow *self,long new_index){ + return OGR_L_SetNextByIndex(self, new_index); + } +static OGRErr OGRLayerShadow_SetFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_SetFeature(self, feature); + } +static OGRErr OGRLayerShadow_CreateFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_CreateFeature(self, feature); + } +static OGRErr OGRLayerShadow_DeleteFeature(OGRLayerShadow *self,long fid){ + return OGR_L_DeleteFeature(self, fid); + } +static OGRErr OGRLayerShadow_SyncToDisk(OGRLayerShadow *self){ + return OGR_L_SyncToDisk(self); + } +static OGRFeatureDefnShadow *OGRLayerShadow_GetLayerDefn(OGRLayerShadow *self){ + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } +static int OGRLayerShadow_GetFeatureCount(OGRLayerShadow *self,int force=1){ + return OGR_L_GetFeatureCount(self, force); + } + +SWIGINTERN PyObject* +t_output_helper(PyObject* target, PyObject* o) { + if (!target) { + target = o; + } else if (target == Py_None) { + Py_DECREF(target); + target = o; + } else { + if (!PyList_Check(target)) { + PyObject *o2 = target; + target = PyList_New(1); + PyList_SetItem(target, 0, o2); + } + PyList_Append(target,o); + Py_DECREF(o); + } + return target; +} + + +static PyObject * +CreateTupleFromDoubleArray( double *first, unsigned int size ) { + PyObject *out = PyTuple_New( size ); + for( unsigned int i=0; i<size; i++ ) { + PyObject *val = PyFloat_FromDouble( *first ); + ++first; + PyTuple_SetItem( out, i, val ); + } + return out; +} + +static OGRErr OGRLayerShadow_GetExtent(OGRLayerShadow *self,double argout[4],int force=1){ + return OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + } +static bool OGRLayerShadow_TestCapability(OGRLayerShadow *self,char const *cap){ + return OGR_L_TestCapability(self, cap); + } +static OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){ + return OGR_L_CreateField(self, field_def, approx_ok); + } +static OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){ + return OGR_L_StartTransaction(self); + } +static OGRErr OGRLayerShadow_CommitTransaction(OGRLayerShadow *self){ + return OGR_L_CommitTransaction(self); + } +static OGRErr OGRLayerShadow_RollbackTransaction(OGRLayerShadow *self){ + return OGR_L_RollbackTransaction(self); + } +static OSRSpatialReferenceShadow *OGRLayerShadow_GetSpatialRef(OGRLayerShadow *self){ + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } +static GIntBig OGRLayerShadow_GetFeatureRead(OGRLayerShadow *self){ + return OGR_L_GetFeaturesRead(self); + } +static void delete_OGRFeatureShadow(OGRFeatureShadow *self){ + OGR_F_Destroy(self); + } +static OGRFeatureShadow *new_OGRFeatureShadow(OGRFeatureDefnShadow *feature_def=0){ + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } +static OGRFeatureDefnShadow *OGRFeatureShadow_GetDefnRef(OGRFeatureShadow *self){ + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } +static OGRErr OGRFeatureShadow_SetGeometry(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometry(self, geom); + } +static OGRErr OGRFeatureShadow_SetGeometryDirectly(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometryDirectly(self, geom); + } +static OGRGeometryShadow *OGRFeatureShadow_GetGeometryRef(OGRFeatureShadow *self){ + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } +static OGRFeatureShadow *OGRFeatureShadow_Clone(OGRFeatureShadow *self){ + return (OGRFeatureShadow*) OGR_F_Clone(self); + } +static bool OGRFeatureShadow_Equal(OGRFeatureShadow *self,OGRFeatureShadow *feature){ + return OGR_F_Equal(self, feature); + } +static int OGRFeatureShadow_GetFieldCount(OGRFeatureShadow *self){ + return OGR_F_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } +static OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_0(OGRFeatureShadow *self,int id){ + return (const char *) OGR_F_GetFieldAsString(self, id); + } +static char const *OGRFeatureShadow_GetFieldAsString__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsInteger(self, id); + } +static int OGRFeatureShadow_GetFieldAsInteger__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsDouble(self, id); + } + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_double PyFloat_FromDouble +/*@@*/ + +static double OGRFeatureShadow_GetFieldAsDouble__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } +static bool OGRFeatureShadow_IsFieldSet__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_IsFieldSet(self, id); + } +static bool OGRFeatureShadow_IsFieldSet__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } +static int OGRFeatureShadow_GetFieldIndex(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldIndex(self, name); + } +static int OGRFeatureShadow_GetFID(OGRFeatureShadow *self){ + return OGR_F_GetFID(self); + } +static OGRErr OGRFeatureShadow_SetFID(OGRFeatureShadow *self,int fid){ + return OGR_F_SetFID(self, fid); + } +static void OGRFeatureShadow_DumpReadable(OGRFeatureShadow *self){ + OGR_F_DumpReadable(self, NULL); + } +static void OGRFeatureShadow_UnsetField__SWIG_0(OGRFeatureShadow *self,int id){ + OGR_F_UnsetField(self, id); + } +static void OGRFeatureShadow_UnsetField__SWIG_1(OGRFeatureShadow *self,char const *name){ + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } +static void OGRFeatureShadow_SetField__SWIG_0(OGRFeatureShadow *self,int id,char const *value){ + OGR_F_SetFieldString(self, id, value); + } +static void OGRFeatureShadow_SetField__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } +static OGRErr OGRFeatureShadow_SetFrom(OGRFeatureShadow *self,OGRFeatureShadow *other,int forgiving=1){ + return OGR_F_SetFrom(self, other, forgiving); + } +static char const *OGRFeatureShadow_GetStyleString(OGRFeatureShadow *self){ + return (const char*) OGR_F_GetStyleString(self); + } +static void OGRFeatureShadow_SetStyleString(OGRFeatureShadow *self,char const *the_string){ + OGR_F_SetStyleString(self, the_string); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } +static OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } +static void delete_OGRFeatureDefnShadow(OGRFeatureDefnShadow *self){ + OGR_FD_Destroy(self); + } +static OGRFeatureDefnShadow *new_OGRFeatureDefnShadow(char const *name=NULL){ + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } +static char const *OGRFeatureDefnShadow_GetName(OGRFeatureDefnShadow *self){ + return OGR_FD_GetName(self); + } +static int OGRFeatureDefnShadow_GetFieldCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetFieldCount(self); + } +static OGRFieldDefnShadow *OGRFeatureDefnShadow_GetFieldDefn(OGRFeatureDefnShadow *self,int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } +static int OGRFeatureDefnShadow_GetFieldIndex(OGRFeatureDefnShadow *self,char const *name){ + return OGR_FD_GetFieldIndex(self, name); + } +static void OGRFeatureDefnShadow_AddFieldDefn(OGRFeatureDefnShadow *self,OGRFieldDefnShadow *defn){ + OGR_FD_AddFieldDefn(self, defn); + } +static OGRwkbGeometryType OGRFeatureDefnShadow_GetGeomType(OGRFeatureDefnShadow *self){ + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } +static void OGRFeatureDefnShadow_SetGeomType(OGRFeatureDefnShadow *self,OGRwkbGeometryType geom_type){ + OGR_FD_SetGeomType(self, geom_type); + } +static int OGRFeatureDefnShadow_GetReferenceCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetReferenceCount(self); + } +static void delete_OGRFieldDefnShadow(OGRFieldDefnShadow *self){ + OGR_Fld_Destroy(self); + } +static OGRFieldDefnShadow *new_OGRFieldDefnShadow(char const *name="unnamed",OGRFieldType field_type=OFTString){ + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } +static char const *OGRFieldDefnShadow_GetName(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static char const *OGRFieldDefnShadow_GetNameRef(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +static void OGRFieldDefnShadow_SetName(OGRFieldDefnShadow *self,char const *name){ + OGR_Fld_SetName(self, name); + } +static OGRFieldType OGRFieldDefnShadow_GetType(OGRFieldDefnShadow *self){ + return OGR_Fld_GetType(self); + } +static void OGRFieldDefnShadow_SetType(OGRFieldDefnShadow *self,OGRFieldType type){ + OGR_Fld_SetType(self, type); + } +static OGRJustification OGRFieldDefnShadow_GetJustify(OGRFieldDefnShadow *self){ + return OGR_Fld_GetJustify(self); + } +static void OGRFieldDefnShadow_SetJustify(OGRFieldDefnShadow *self,OGRJustification justify){ + OGR_Fld_SetJustify(self, justify); + } +static int OGRFieldDefnShadow_GetWidth(OGRFieldDefnShadow *self){ + return OGR_Fld_GetWidth(self); + } +static void OGRFieldDefnShadow_SetWidth(OGRFieldDefnShadow *self,int width){ + OGR_Fld_SetWidth(self, width); + } +static int OGRFieldDefnShadow_GetPrecision(OGRFieldDefnShadow *self){ + return OGR_Fld_GetPrecision(self); + } +static void OGRFieldDefnShadow_SetPrecision(OGRFieldDefnShadow *self,int precision){ + OGR_Fld_SetPrecision(self, precision); + } +static char const *OGRFieldDefnShadow_GetFieldTypeName(OGRFieldDefnShadow *self,OGRFieldType type){ + return OGR_GetFieldTypeName(type); + } + + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + + +static void delete_OGRGeometryShadow(OGRGeometryShadow *self){ + OGR_G_DestroyGeometry( self ); + } +static OGRGeometryShadow *new_OGRGeometryShadow(OGRwkbGeometryType type=wkbUnknown,char *wkt=0,int wkb=0,char *wkb_buf=0,char *gml=0){ + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } +static OGRErr OGRGeometryShadow_ExportToWkt(OGRGeometryShadow *self,char **argout){ + return OGR_G_ExportToWkt(self, argout); + } +static OGRErr OGRGeometryShadow_ExportToWkb(OGRGeometryShadow *self,int *nLen,char **pBuf,OGRwkbByteOrder byte_order=wkbXDR){ + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } +static char const *OGRGeometryShadow_ExportToGML(OGRGeometryShadow *self){ + return (const char *) OGR_G_ExportToGML(self); + } +static void OGRGeometryShadow_AddPoint(OGRGeometryShadow *self,double x,double y,double z=0){ + OGR_G_AddPoint( self, x, y, z ); + } +static OGRErr OGRGeometryShadow_AddGeometryDirectly(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometryDirectly( self, other ); + } +static OGRErr OGRGeometryShadow_AddGeometry(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometry( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Clone(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_Clone(self); + } +static OGRwkbGeometryType OGRGeometryShadow_GetGeometryType(OGRGeometryShadow *self){ + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } +static char const *OGRGeometryShadow_GetGeometryName(OGRGeometryShadow *self){ + return (const char *) OGR_G_GetGeometryName(self); + } +static double OGRGeometryShadow_GetArea(OGRGeometryShadow *self){ + return OGR_G_GetArea(self); + } +static int OGRGeometryShadow_GetPointCount(OGRGeometryShadow *self){ + return OGR_G_GetPointCount(self); + } +static double OGRGeometryShadow_GetX(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetX(self, point); + } +static double OGRGeometryShadow_GetY(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetY(self, point); + } +static double OGRGeometryShadow_GetZ(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetZ(self, point); + } +static int OGRGeometryShadow_GetGeometryCount(OGRGeometryShadow *self){ + return OGR_G_GetGeometryCount(self); + } +static void OGRGeometryShadow_SetPoint(OGRGeometryShadow *self,int point,double x,double y,double z=0){ + OGR_G_SetPoint(self, point, x, y, z); + } +static OGRGeometryShadow *OGRGeometryShadow_GetGeometryRef(OGRGeometryShadow *self,int geom){ + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } +static OGRGeometryShadow *OGRGeometryShadow_GetBoundary(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } +static OGRGeometryShadow *OGRGeometryShadow_ConvexHull(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } +static OGRGeometryShadow *OGRGeometryShadow_Buffer(OGRGeometryShadow *self,double distance,int quadsecs=30){ + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } +static OGRGeometryShadow *OGRGeometryShadow_Intersection(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Union(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_Difference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } +static OGRGeometryShadow *OGRGeometryShadow_SymmetricDifference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } +static double OGRGeometryShadow_Distance(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Distance(self, other); + } +static void OGRGeometryShadow_Empty(OGRGeometryShadow *self){ + OGR_G_Empty(self); + } +static bool OGRGeometryShadow_Intersect(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Intersect(self, other); + } +static bool OGRGeometryShadow_Equal(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Equal(self, other); + } +static bool OGRGeometryShadow_Disjoint(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Disjoint(self, other); + } +static bool OGRGeometryShadow_Touches(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Touches(self, other); + } +static bool OGRGeometryShadow_Crosses(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Crosses(self, other); + } +static bool OGRGeometryShadow_Within(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Within(self, other); + } +static bool OGRGeometryShadow_Contains(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Contains(self, other); + } +static bool OGRGeometryShadow_Overlaps(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Overlaps(self, other); + } +static OGRErr OGRGeometryShadow_TransformTo(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + return OGR_G_TransformTo(self, reference); + } +static OGRErr OGRGeometryShadow_Transform(OGRGeometryShadow *self,OSRCoordinateTransformationShadow *trans){ + return OGR_G_Transform(self, trans); + } +static OSRSpatialReferenceShadow *OGRGeometryShadow_GetSpatialReference(OGRGeometryShadow *self){ + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } +static void OGRGeometryShadow_AssignSpatialReference(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + OGR_G_AssignSpatialReference(self, reference); + } +static void OGRGeometryShadow_CloseRings(OGRGeometryShadow *self){ + OGR_G_CloseRings(self); + } +static void OGRGeometryShadow_FlattenTo2D(OGRGeometryShadow *self){ + OGR_G_FlattenTo2D(self); + } +static void OGRGeometryShadow_GetEnvelope(OGRGeometryShadow *self,double argout[4]){ + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } +static OGRGeometryShadow *OGRGeometryShadow_Centroid(OGRGeometryShadow *self){ + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } +static int OGRGeometryShadow_WkbSize(OGRGeometryShadow *self){ + return OGR_G_WkbSize(self); + } +static int OGRGeometryShadow_GetCoordinateDimension(OGRGeometryShadow *self){ + return OGR_G_GetCoordinateDimension(self); + } +static int OGRGeometryShadow_GetDimension(OGRGeometryShadow *self){ + return OGR_G_GetDimension(self); + } + +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + + + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } + + + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } + + + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } + + +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} + +#ifdef __cplusplus +extern "C" { +#endif +static PyObject *_wrap_Driver_name_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Driver_name_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRDriverShadow_name_get(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_CreateDataSource(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "name",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:Driver_CreateDataSource",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj2)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj2); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj2,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CreateDataSource(arg1,(char const *)arg2,arg3); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 1); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg3 ); + } + return NULL; +} + + +static PyObject *_wrap_Driver_CopyDataSource(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + OGRDataSourceShadow *arg2 = (OGRDataSourceShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "copy_ds",(char *) "name",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Driver_CopyDataSource",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + if (obj3) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj3)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj3); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj3,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_CopyDataSource(arg1,arg2,(char const *)arg3,arg4); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 1); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return NULL; +} + + +static PyObject *_wrap_Driver_Open(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "name",(char *) "update", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:Driver_Open",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRDataSourceShadow *)OGRDriverShadow_Open(arg1,(char const *)arg2,arg3); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_DeleteDataSource(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Driver_DeleteDataSource",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (int)OGRDriverShadow_DeleteDataSource(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_TestCapability(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Driver_TestCapability",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (bool)OGRDriverShadow_TestCapability(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Driver_GetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Driver_GetName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDriverShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRDriverShadow_GetName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject * Driver_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRDriverShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_DataSource_name_get(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_name_get",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRDataSourceShadow_name_get(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_DataSource(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_DataSource",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OGRDataSourceShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetRefCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_GetRefCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRDataSourceShadow_GetRefCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetSummaryRefCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_GetSummaryRefCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRDataSourceShadow_GetSummaryRefCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetLayerCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_GetLayerCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRDataSourceShadow_GetLayerCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetDriver(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_GetDriver",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRDriverShadow *)OGRDataSourceShadow_GetDriver(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:DataSource_GetName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRDataSourceShadow_GetName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_DeleteLayer(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:DataSource_DeleteLayer",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRErr)OGRDataSourceShadow_DeleteLayer(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_CreateLayer(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRwkbGeometryType arg4 = (OGRwkbGeometryType) wkbUnknown ; + char **arg5 = (char **) 0 ; + OGRLayerShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "name",(char *) "reference",(char *) "geom_type",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|OOO:DataSource_CreateLayer",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + SWIG_Python_ConvertPtr(obj2, (void **)&arg3, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(3)) SWIG_fail; + } + if (obj3) { + { + arg4 = static_cast<OGRwkbGeometryType >(SWIG_As_int(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + if (obj4) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj4)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj4); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj4,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CreateLayer(arg1,(char const *)arg2,arg3,arg4,arg5); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRLayerShadow, 0); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg5 ); + } + return NULL; +} + + +static PyObject *_wrap_DataSource_CopyLayer(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRLayerShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "src_layer",(char *) "new_name",(char *) "options", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:DataSource_CopyLayer",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + if (obj3) { + { + /* %typemap(in) char **options */ + /* Check if is a list */ + if ( ! PySequence_Check(obj3)) { + PyErr_SetString(PyExc_TypeError,"not a sequence"); + SWIG_fail; + } + + int size = PySequence_Size(obj3); + for (int i = 0; i < size; i++) { + char *pszItem = NULL; + if ( ! PyArg_Parse( PySequence_GetItem(obj3,i), "s", &pszItem ) ) { + PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); + SWIG_fail; + } + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_CopyLayer(arg1,arg2,(char const *)arg3,arg4); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRLayerShadow, 0); + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return resultobj; + fail: + { + /* %typemap(freearg) char **options */ + CSLDestroy( arg4 ); + } + return NULL; +} + + +static PyObject *_wrap_DataSource_GetLayerByIndex(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 = (int) 0 ; + OGRLayerShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "index", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:DataSource_GetLayerByIndex",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByIndex(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRLayerShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_GetLayerByName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRLayerShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:DataSource_GetLayerByName",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayerByName(arg1,(char const *)arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRLayerShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_TestCapability(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:DataSource_TestCapability",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (bool)OGRDataSourceShadow_TestCapability(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_ExecuteSQL(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRGeometryShadow *arg3 = (OGRGeometryShadow *) NULL ; + char *arg4 = (char *) "" ; + OGRLayerShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "statement",(char *) "geom",(char *) "dialect", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|OO:DataSource_ExecuteSQL",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + SWIG_Python_ConvertPtr(obj2, (void **)&arg3, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(3)) SWIG_fail; + } + if (obj3) { + if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) { + SWIG_arg_fail(4);SWIG_fail; + } + } + result = (OGRLayerShadow *)OGRDataSourceShadow_ExecuteSQL(arg1,(char const *)arg2,arg3,(char const *)arg4); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRLayerShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_DataSource_ReleaseResultSet(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:DataSource_ReleaseResultSet",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN); + if (SWIG_arg_fail(2)) SWIG_fail; + OGRDataSourceShadow_ReleaseResultSet(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject * DataSource_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRDataSourceShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_Layer_GetRefCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetRefCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRLayerShadow_GetRefCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SetSpatialFilter(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_SetSpatialFilter",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + OGRLayerShadow_SetSpatialFilter(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SetSpatialFilterRect(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOO:Layer_SetSpatialFilterRect",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + OGRLayerShadow_SetSpatialFilterRect(arg1,arg2,arg3,arg4,arg5); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetSpatialFilter(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetSpatialFilter",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRLayerShadow_GetSpatialFilter(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SetAttributeFilter(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_SetAttributeFilter",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OGRLayerShadow_SetAttributeFilter(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_ResetReading(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_ResetReading",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRLayerShadow_ResetReading(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRLayerShadow_GetName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetFeature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRFeatureShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_GetFeature",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<long >(SWIG_As_long(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRFeatureShadow *)OGRLayerShadow_GetFeature(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetNextFeature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetNextFeature",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRFeatureShadow *)OGRLayerShadow_GetNextFeature(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SetNextByIndex(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_SetNextByIndex",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<long >(SWIG_As_long(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRErr)OGRLayerShadow_SetNextByIndex(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SetFeature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_SetFeature",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_SetFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_CreateFeature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_CreateFeature",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_CreateFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_DeleteFeature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_DeleteFeature",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<long >(SWIG_As_long(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRErr)OGRLayerShadow_DeleteFeature(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_SyncToDisk(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_SyncToDisk",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_SyncToDisk(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetLayerDefn(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureDefnShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetLayerDefn",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRFeatureDefnShadow *)OGRLayerShadow_GetLayerDefn(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetFeatureCount(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int arg2 = (int) 1 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "force", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Layer_GetFeatureCount",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (int)OGRLayerShadow_GetFeatureCount(arg1,arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetExtent(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + double argout2[4] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "force", NULL + }; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Layer_GetExtent",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg3 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRErr)OGRLayerShadow_GetExtent(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 4 ); + resultobj = t_output_helper(resultobj,out); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_TestCapability(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Layer_TestCapability",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (bool)OGRLayerShadow_TestCapability(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_CreateField(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "field_def",(char *) "approx_ok", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:Layer_CreateField",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRErr)OGRLayerShadow_CreateField(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_StartTransaction(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_StartTransaction",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_StartTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_CommitTransaction(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_CommitTransaction",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_CommitTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_RollbackTransaction(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_RollbackTransaction",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OGRLayerShadow_RollbackTransaction(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetSpatialRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OSRSpatialReferenceShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetSpatialRef",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OSRSpatialReferenceShadow *)OGRLayerShadow_GetSpatialRef(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Layer_GetFeatureRead(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + GIntBig result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Layer_GetFeatureRead",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = OGRLayerShadow_GetFeatureRead(arg1); + + { + GIntBig * resultptr; + resultptr = new GIntBig(static_cast<GIntBig & >(result)); + resultobj = SWIG_NewPointerObj((void *)(resultptr), SWIGTYPE_p_GIntBig, 1); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * Layer_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRLayerShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_delete_Feature(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_Feature",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OGRFeatureShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_new_Feature(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFeatureShadow *result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "feature_def", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:new_Feature",kwnames,&obj0)) goto fail; + if (obj0) { + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + } + result = (OGRFeatureShadow *)new_OGRFeatureShadow(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetDefnRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureDefnShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_GetDefnRef",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRFeatureDefnShadow *)OGRFeatureShadow_GetDefnRef(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_SetGeometry(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_SetGeometry",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_SetGeometryDirectly(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_SetGeometryDirectly",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRFeatureShadow_SetGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetGeometryRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_GetGeometryRef",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRFeatureShadow_GetGeometryRef(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_Clone(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_Clone",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRFeatureShadow *)OGRFeatureShadow_Clone(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_Equal(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_Equal",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRFeatureShadow_Equal(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_GetFieldCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFeatureShadow_GetFieldCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldDefnRef__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldDefnRef",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_0(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFieldDefnShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldDefnRef__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRFieldDefnShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldDefnRef",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_1(arg1,(char const *)arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFieldDefnShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldDefnRef(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_GetFieldDefnRef__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_GetFieldDefnRef__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_GetFieldDefnRef'"); + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsString__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsString",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_0(arg1,arg2); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsString__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsString",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_1(arg1,(char const *)arg2); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsString(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_GetFieldAsString__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_GetFieldAsString__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_GetFieldAsString'"); + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsInteger__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsInteger",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_0(arg1,arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsInteger__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsInteger",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_1(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsInteger(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_GetFieldAsInteger__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_GetFieldAsInteger__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_GetFieldAsInteger'"); + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsDouble__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsDouble",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_0(arg1,arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsDouble__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldAsDouble",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_1(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldAsDouble(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_GetFieldAsDouble__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_GetFieldAsDouble__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_GetFieldAsDouble'"); + return NULL; +} + + +static PyObject *_wrap_Feature_IsFieldSet__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_IsFieldSet",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_0(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_IsFieldSet__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_IsFieldSet",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_1(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_IsFieldSet(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_IsFieldSet__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_IsFieldSet__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_IsFieldSet'"); + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldIndex(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldIndex",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (int)OGRFeatureShadow_GetFieldIndex(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFID(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_GetFID",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFeatureShadow_GetFID(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_SetFID(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_SetFID",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRErr)OGRFeatureShadow_SetFID(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_DumpReadable(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_DumpReadable",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRFeatureShadow_DumpReadable(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_UnsetField__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_UnsetField",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFeatureShadow_UnsetField__SWIG_0(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_UnsetField__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_UnsetField",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + OGRFeatureShadow_UnsetField__SWIG_1(arg1,(char const *)arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_UnsetField(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[3]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 2); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_UnsetField__SWIG_0(self,args); + } + } + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + return _wrap_Feature_UnsetField__SWIG_1(self,args); + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_UnsetField'"); + return NULL; +} + + +static PyObject *_wrap_Feature_SetField__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + PyObject *str3 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:Feature_SetField",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + /* %typemap(in) (tostring argin) */ + str3 = PyObject_Str( obj2 ); + if ( str3 == 0 ) { + PyErr_SetString( PyExc_RuntimeError, "Unable to format argument as string"); + SWIG_fail; + } + + arg3 = PyString_AsString(str3); + } + OGRFeatureShadow_SetField__SWIG_0(arg1,arg2,(char const *)arg3); + + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(freearg) (tostring argin) */ + Py_DECREF(str3); + } + return resultobj; + fail: + { + /* %typemap(freearg) (tostring argin) */ + Py_DECREF(str3); + } + return NULL; +} + + +static PyObject *_wrap_Feature_SetField__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + PyObject *str3 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:Feature_SetField",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + /* %typemap(in) (tostring argin) */ + str3 = PyObject_Str( obj2 ); + if ( str3 == 0 ) { + PyErr_SetString( PyExc_RuntimeError, "Unable to format argument as string"); + SWIG_fail; + } + + arg3 = PyString_AsString(str3); + } + OGRFeatureShadow_SetField__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(freearg) (tostring argin) */ + Py_DECREF(str3); + } + return resultobj; + fail: + { + /* %typemap(freearg) (tostring argin) */ + Py_DECREF(str3); + } + return NULL; +} + + +static PyObject *_wrap_Feature_SetField(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 3); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 3) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + if (_v) { + return _wrap_Feature_SetField__SWIG_0(self,args); + } + } + } + } + if (argc == 3) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (tostring argin) */ + _v = 1; + } + if (_v) { + return _wrap_Feature_SetField__SWIG_1(self,args); + } + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_SetField'"); + return NULL; +} + + +static PyObject *_wrap_Feature_SetFrom(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "other",(char *) "forgiving", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:Feature_SetFrom",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRErr)OGRFeatureShadow_SetFrom(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetStyleString(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Feature_GetStyleString",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRFeatureShadow_GetStyleString(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_SetStyleString(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_SetStyleString",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + OGRFeatureShadow_SetStyleString(arg1,(char const *)arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldType__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldType result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Feature_GetFieldType",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_0(arg1,arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldType__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRFieldType result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:Feature_GetFieldType",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Feature_GetFieldType(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[4]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 3); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_int(argv[1]); + if (_v) { + return _wrap_Feature_GetFieldType__SWIG_0(self,args); + } + } + } + if (argc == 3) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OGRFeatureShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_AsCharPtr(argv[1], (char **)(0)); + if (_v) { + _v = SWIG_AsCharPtr(argv[2], (char **)(0)); + if (_v) { + return _wrap_Feature_GetFieldType__SWIG_1(self,args); + } + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'Feature_GetFieldType'"); + return NULL; +} + + +static PyObject * Feature_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_delete_FeatureDefn(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_FeatureDefn",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OGRFeatureDefnShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_new_FeatureDefn(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char *arg1 = (char *) NULL ; + OGRFeatureDefnShadow *result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "name", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:new_FeatureDefn",kwnames,&obj0)) goto fail; + if (obj0) { + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + } + result = (OGRFeatureDefnShadow *)new_OGRFeatureDefnShadow((char const *)arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFeatureDefnShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FeatureDefn_GetName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRFeatureDefnShadow_GetName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetFieldCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FeatureDefn_GetFieldCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFeatureDefnShadow_GetFieldCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetFieldDefn(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FeatureDefn_GetFieldDefn",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRFieldDefnShadow *)OGRFeatureDefnShadow_GetFieldDefn(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFieldDefnShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetFieldIndex(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FeatureDefn_GetFieldIndex",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (int)OGRFeatureDefnShadow_GetFieldIndex(arg1,(char const *)arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_AddFieldDefn(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FeatureDefn_AddFieldDefn",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + OGRFeatureDefnShadow_AddFieldDefn(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetGeomType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FeatureDefn_GetGeomType",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRwkbGeometryType)OGRFeatureDefnShadow_GetGeomType(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_SetGeomType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FeatureDefn_SetGeomType",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<OGRwkbGeometryType >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFeatureDefnShadow_SetGeomType(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FeatureDefn_GetReferenceCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FeatureDefn_GetReferenceCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFeatureDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFeatureDefnShadow_GetReferenceCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * FeatureDefn_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureDefnShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_delete_FieldDefn(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_FieldDefn",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OGRFieldDefnShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_new_FieldDefn(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char *arg1 = (char *) "unnamed" ; + OGRFieldType arg2 = (OGRFieldType) OFTString ; + OGRFieldDefnShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "name",(char *) "field_type", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:new_FieldDefn",kwnames,&obj0,&obj1)) goto fail; + if (obj0) { + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + } + if (obj1) { + { + arg2 = static_cast<OGRFieldType >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (OGRFieldDefnShadow *)new_OGRFieldDefnShadow((char const *)arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRFieldDefnShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRFieldDefnShadow_GetName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetNameRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetNameRef",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRFieldDefnShadow_GetNameRef(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_SetName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_SetName",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + OGRFieldDefnShadow_SetName(arg1,(char const *)arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetType",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRFieldType)OGRFieldDefnShadow_GetType(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_SetType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_SetType",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<OGRFieldType >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFieldDefnShadow_SetType(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetJustify(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetJustify",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRJustification)OGRFieldDefnShadow_GetJustify(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_SetJustify(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_SetJustify",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<OGRJustification >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFieldDefnShadow_SetJustify(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetWidth(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetWidth",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFieldDefnShadow_GetWidth(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_SetWidth(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_SetWidth",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFieldDefnShadow_SetWidth(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetPrecision(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:FieldDefn_GetPrecision",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRFieldDefnShadow_GetPrecision(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_SetPrecision(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_SetPrecision",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + OGRFieldDefnShadow_SetPrecision(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_FieldDefn_GetFieldTypeName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:FieldDefn_GetFieldTypeName",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRFieldDefnShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<OGRFieldType >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (char *)OGRFieldDefnShadow_GetFieldTypeName(arg1,arg2); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject * FieldDefn_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRFieldDefnShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_CreateGeometryFromWkb(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + int arg1 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "len",(char *) "reference", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:CreateGeometryFromWkb",kwnames,&obj0,&obj1)) goto fail; + { + /* %typemap(in,numinputs=1) (int nLen, char *pBuf ) */ + PyString_AsStringAndSize(obj0, &arg2, &arg1 ); + } + if (obj1) { + SWIG_Python_ConvertPtr(obj1, (void **)&arg3, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(3)) SWIG_fail; + } + result = (OGRGeometryShadow *)CreateGeometryFromWkb(arg1,arg2,arg3); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_CreateGeometryFromWkt(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char **arg1 = (char **) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result; + char *val1 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "val",(char *) "reference", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:CreateGeometryFromWkt",kwnames,&obj0,&obj1)) goto fail; + { + /* %typemap(in) (char **ignorechange) */ + PyArg_Parse( obj0, "s", &val1 ); + arg1 = &val1; + } + if (obj1) { + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRGeometryShadow *)CreateGeometryFromWkt(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_CreateGeometryFromGML(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:CreateGeometryFromGML",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + result = (OGRGeometryShadow *)CreateGeometryFromGML((char const *)arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_Geometry(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_Geometry",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OGRGeometryShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_new_Geometry(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRwkbGeometryType arg1 = (OGRwkbGeometryType) wkbUnknown ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char *kwnames[] = { + (char *) "type",(char *) "wkt",(char *) "wkb",(char *) "wkb_buf",(char *) "gml", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOOOO:new_Geometry",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + if (obj0) { + { + arg1 = static_cast<OGRwkbGeometryType >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + } + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + if (obj3) { + if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) { + SWIG_arg_fail(4);SWIG_fail; + } + } + if (obj4) { + if (!SWIG_AsCharPtr(obj4, (char**)&arg5)) { + SWIG_arg_fail(5);SWIG_fail; + } + } + result = (OGRGeometryShadow *)new_OGRGeometryShadow(arg1,arg2,arg3,arg4,arg5); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_ExportToWkt(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_ExportToWkt",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OGRGeometryShadow_ExportToWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_Geometry_ExportToWkb(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int *arg2 = (int *) 0 ; + char **arg3 = (char **) 0 ; + OGRwkbByteOrder arg4 = (OGRwkbByteOrder) wkbXDR ; + OGRErr result; + int nLen2 = 0 ; + char *pBuf2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "byte_order", NULL + }; + + { + /* %typemap(in,numinputs=0) (int *nLen2, char **pBuf2 ) */ + arg2 = &nLen2; + arg3 = &pBuf2; + } + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Geometry_ExportToWkb",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg4 = static_cast<OGRwkbByteOrder >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + result = (OGRErr)OGRGeometryShadow_ExportToWkb(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + Py_XDECREF(resultobj); + resultobj = PyString_FromStringAndSize( *arg3, *arg2 ); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg2 ) { + free( *arg3 ); + } + } + return NULL; +} + + +static PyObject *_wrap_Geometry_ExportToGML(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_ExportToGML",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRGeometryShadow_ExportToGML(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_AddPoint(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 = (double) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "x",(char *) "y",(char *) "z", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Geometry_AddPoint",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + if (obj3) { + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + } + OGRGeometryShadow_AddPoint(arg1,arg2,arg3,arg4); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_AddGeometryDirectly(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_AddGeometryDirectly",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRGeometryShadow_AddGeometryDirectly(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_AddGeometry(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_AddGeometry",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRGeometryShadow_AddGeometry(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Clone(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_Clone",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_Clone(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetGeometryType(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRwkbGeometryType result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetGeometryType",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRwkbGeometryType)OGRGeometryShadow_GetGeometryType(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetGeometryName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetGeometryName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OGRGeometryShadow_GetGeometryName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetArea(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetArea",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (double)OGRGeometryShadow_GetArea(arg1); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetPointCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetPointCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRGeometryShadow_GetPointCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetX(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "point", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Geometry_GetX",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (double)OGRGeometryShadow_GetX(arg1,arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetY(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "point", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Geometry_GetY",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (double)OGRGeometryShadow_GetY(arg1,arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetZ(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "point", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Geometry_GetZ",kwnames,&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (double)OGRGeometryShadow_GetZ(arg1,arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetGeometryCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetGeometryCount",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRGeometryShadow_GetGeometryCount(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_SetPoint(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "point",(char *) "x",(char *) "y",(char *) "z", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO|O:Geometry_SetPoint",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + if (obj4) { + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + OGRGeometryShadow_SetPoint(arg1,arg2,arg3,arg4,arg5); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetGeometryRef(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_GetGeometryRef",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRGeometryShadow *)OGRGeometryShadow_GetGeometryRef(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetBoundary(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetBoundary",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_GetBoundary(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_ConvexHull(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_ConvexHull",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_ConvexHull(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Buffer(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + int arg3 = (int) 30 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "distance",(char *) "quadsecs", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:Geometry_Buffer",kwnames,&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRGeometryShadow *)OGRGeometryShadow_Buffer(arg1,arg2,arg3); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Intersection(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Intersection",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_Intersection(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Union(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Union",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_Union(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Difference(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Difference",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_Difference(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_SymmetricDifference(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_SymmetricDifference",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_SymmetricDifference(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Distance(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Distance",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (double)OGRGeometryShadow_Distance(arg1,arg2); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Empty(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_Empty",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRGeometryShadow_Empty(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Intersect(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Intersect",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Intersect(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Equal(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Equal",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Equal(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Disjoint(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Disjoint",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Disjoint(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Touches(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Touches",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Touches(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Crosses(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Crosses",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Crosses(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Within(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Within",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Within(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Contains(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Contains",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Contains(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Overlaps(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Overlaps",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (bool)OGRGeometryShadow_Overlaps(arg1,arg2); + + { + resultobj = SWIG_From_bool(static_cast<bool >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_TransformTo(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_TransformTo",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRGeometryShadow_TransformTo(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Transform(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRCoordinateTransformationShadow *arg2 = (OSRCoordinateTransformationShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_Transform",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OGRGeometryShadow_Transform(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetSpatialReference(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetSpatialReference",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OSRSpatialReferenceShadow *)OGRGeometryShadow_GetSpatialReference(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_AssignSpatialReference(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:Geometry_AssignSpatialReference",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + OGRGeometryShadow_AssignSpatialReference(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_CloseRings(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_CloseRings",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRGeometryShadow_CloseRings(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_FlattenTo2D(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_FlattenTo2D",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRGeometryShadow_FlattenTo2D(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetEnvelope(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double *arg2 ; + double argout2[4] ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetEnvelope",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + OGRGeometryShadow_GetEnvelope(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 4 ); + resultobj = t_output_helper(resultobj,out); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_Centroid(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_Centroid",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRGeometryShadow *)OGRGeometryShadow_Centroid(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRGeometryShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_WkbSize(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_WkbSize",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRGeometryShadow_WkbSize(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetCoordinateDimension(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetCoordinateDimension",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRGeometryShadow_GetCoordinateDimension(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Geometry_GetDimension(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:Geometry_GetDimension",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OGRGeometryShadow_GetDimension(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * Geometry_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OGRGeometryShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_GetDriverCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetDriverCount")) goto fail; + result = (int)OGRGetDriverCount(); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetOpenDSCount(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int result; + + if(!PyArg_ParseTuple(args,(char *)":GetOpenDSCount")) goto fail; + result = (int)OGRGetOpenDSCount(); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SetGenerate_DB2_V72_BYTE_ORDER(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SetGenerate_DB2_V72_BYTE_ORDER",&obj0)) goto fail; + { + arg1 = static_cast<int >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + result = (OGRErr)OGRSetGenerate_DB2_V72_BYTE_ORDER(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_RegisterAll(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + + if(!PyArg_ParseTuple(args,(char *)":RegisterAll")) goto fail; + OGRRegisterAll(); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetOpenDS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetOpenDS",&obj0)) goto fail; + { + arg1 = static_cast<int >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + result = (OGRDataSourceShadow *)GetOpenDS(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_Open(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "filename",(char *) "update", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:Open",kwnames,&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (OGRDataSourceShadow *)Open((char const *)arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_OpenShared(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char *kwnames[] = { + (char *) "filename",(char *) "update", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|O:OpenShared",kwnames,&obj0,&obj1)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + if (obj1) { + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + } + result = (OGRDataSourceShadow *)OpenShared((char const *)arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDataSourceShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDriverByName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + OGRDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDriverByName",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + result = (OGRDriverShadow *)GetDriverByName((char const *)arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_GetDriver(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + int arg1 ; + OGRDriverShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:GetDriver",&obj0)) goto fail; + { + arg1 = static_cast<int >(SWIG_As_int(obj0)); + if (SWIG_arg_fail(1)) SWIG_fail; + } + result = (OGRDriverShadow *)GetDriver(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OGRDriverShadow, 0); + return resultobj; + fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"Driver_name_get", _wrap_Driver_name_get, METH_VARARGS, NULL}, + { (char *)"Driver_CreateDataSource", (PyCFunction) _wrap_Driver_CreateDataSource, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Driver_CopyDataSource", (PyCFunction) _wrap_Driver_CopyDataSource, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Driver_Open", (PyCFunction) _wrap_Driver_Open, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Driver_DeleteDataSource", _wrap_Driver_DeleteDataSource, METH_VARARGS, NULL}, + { (char *)"Driver_TestCapability", _wrap_Driver_TestCapability, METH_VARARGS, NULL}, + { (char *)"Driver_GetName", _wrap_Driver_GetName, METH_VARARGS, NULL}, + { (char *)"Driver_swigregister", Driver_swigregister, METH_VARARGS, NULL}, + { (char *)"DataSource_name_get", _wrap_DataSource_name_get, METH_VARARGS, NULL}, + { (char *)"delete_DataSource", _wrap_delete_DataSource, METH_VARARGS, NULL}, + { (char *)"DataSource_GetRefCount", _wrap_DataSource_GetRefCount, METH_VARARGS, NULL}, + { (char *)"DataSource_GetSummaryRefCount", _wrap_DataSource_GetSummaryRefCount, METH_VARARGS, NULL}, + { (char *)"DataSource_GetLayerCount", _wrap_DataSource_GetLayerCount, METH_VARARGS, NULL}, + { (char *)"DataSource_GetDriver", _wrap_DataSource_GetDriver, METH_VARARGS, NULL}, + { (char *)"DataSource_GetName", _wrap_DataSource_GetName, METH_VARARGS, NULL}, + { (char *)"DataSource_DeleteLayer", _wrap_DataSource_DeleteLayer, METH_VARARGS, NULL}, + { (char *)"DataSource_CreateLayer", (PyCFunction) _wrap_DataSource_CreateLayer, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"DataSource_CopyLayer", (PyCFunction) _wrap_DataSource_CopyLayer, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"DataSource_GetLayerByIndex", (PyCFunction) _wrap_DataSource_GetLayerByIndex, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"DataSource_GetLayerByName", _wrap_DataSource_GetLayerByName, METH_VARARGS, NULL}, + { (char *)"DataSource_TestCapability", _wrap_DataSource_TestCapability, METH_VARARGS, NULL}, + { (char *)"DataSource_ExecuteSQL", (PyCFunction) _wrap_DataSource_ExecuteSQL, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"DataSource_ReleaseResultSet", _wrap_DataSource_ReleaseResultSet, METH_VARARGS, NULL}, + { (char *)"DataSource_swigregister", DataSource_swigregister, METH_VARARGS, NULL}, + { (char *)"Layer_GetRefCount", _wrap_Layer_GetRefCount, METH_VARARGS, NULL}, + { (char *)"Layer_SetSpatialFilter", _wrap_Layer_SetSpatialFilter, METH_VARARGS, NULL}, + { (char *)"Layer_SetSpatialFilterRect", _wrap_Layer_SetSpatialFilterRect, METH_VARARGS, NULL}, + { (char *)"Layer_GetSpatialFilter", _wrap_Layer_GetSpatialFilter, METH_VARARGS, NULL}, + { (char *)"Layer_SetAttributeFilter", _wrap_Layer_SetAttributeFilter, METH_VARARGS, NULL}, + { (char *)"Layer_ResetReading", _wrap_Layer_ResetReading, METH_VARARGS, NULL}, + { (char *)"Layer_GetName", _wrap_Layer_GetName, METH_VARARGS, NULL}, + { (char *)"Layer_GetFeature", _wrap_Layer_GetFeature, METH_VARARGS, NULL}, + { (char *)"Layer_GetNextFeature", _wrap_Layer_GetNextFeature, METH_VARARGS, NULL}, + { (char *)"Layer_SetNextByIndex", _wrap_Layer_SetNextByIndex, METH_VARARGS, NULL}, + { (char *)"Layer_SetFeature", _wrap_Layer_SetFeature, METH_VARARGS, NULL}, + { (char *)"Layer_CreateFeature", _wrap_Layer_CreateFeature, METH_VARARGS, NULL}, + { (char *)"Layer_DeleteFeature", _wrap_Layer_DeleteFeature, METH_VARARGS, NULL}, + { (char *)"Layer_SyncToDisk", _wrap_Layer_SyncToDisk, METH_VARARGS, NULL}, + { (char *)"Layer_GetLayerDefn", _wrap_Layer_GetLayerDefn, METH_VARARGS, NULL}, + { (char *)"Layer_GetFeatureCount", (PyCFunction) _wrap_Layer_GetFeatureCount, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Layer_GetExtent", (PyCFunction) _wrap_Layer_GetExtent, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Layer_TestCapability", _wrap_Layer_TestCapability, METH_VARARGS, NULL}, + { (char *)"Layer_CreateField", (PyCFunction) _wrap_Layer_CreateField, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Layer_StartTransaction", _wrap_Layer_StartTransaction, METH_VARARGS, NULL}, + { (char *)"Layer_CommitTransaction", _wrap_Layer_CommitTransaction, METH_VARARGS, NULL}, + { (char *)"Layer_RollbackTransaction", _wrap_Layer_RollbackTransaction, METH_VARARGS, NULL}, + { (char *)"Layer_GetSpatialRef", _wrap_Layer_GetSpatialRef, METH_VARARGS, NULL}, + { (char *)"Layer_GetFeatureRead", _wrap_Layer_GetFeatureRead, METH_VARARGS, NULL}, + { (char *)"Layer_swigregister", Layer_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_Feature", _wrap_delete_Feature, METH_VARARGS, NULL}, + { (char *)"new_Feature", (PyCFunction) _wrap_new_Feature, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Feature_GetDefnRef", _wrap_Feature_GetDefnRef, METH_VARARGS, NULL}, + { (char *)"Feature_SetGeometry", _wrap_Feature_SetGeometry, METH_VARARGS, NULL}, + { (char *)"Feature_SetGeometryDirectly", _wrap_Feature_SetGeometryDirectly, METH_VARARGS, NULL}, + { (char *)"Feature_GetGeometryRef", _wrap_Feature_GetGeometryRef, METH_VARARGS, NULL}, + { (char *)"Feature_Clone", _wrap_Feature_Clone, METH_VARARGS, NULL}, + { (char *)"Feature_Equal", _wrap_Feature_Equal, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldCount", _wrap_Feature_GetFieldCount, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldDefnRef", _wrap_Feature_GetFieldDefnRef, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldAsString", _wrap_Feature_GetFieldAsString, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldAsInteger", _wrap_Feature_GetFieldAsInteger, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldAsDouble", _wrap_Feature_GetFieldAsDouble, METH_VARARGS, NULL}, + { (char *)"Feature_IsFieldSet", _wrap_Feature_IsFieldSet, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldIndex", _wrap_Feature_GetFieldIndex, METH_VARARGS, NULL}, + { (char *)"Feature_GetFID", _wrap_Feature_GetFID, METH_VARARGS, NULL}, + { (char *)"Feature_SetFID", _wrap_Feature_SetFID, METH_VARARGS, NULL}, + { (char *)"Feature_DumpReadable", _wrap_Feature_DumpReadable, METH_VARARGS, NULL}, + { (char *)"Feature_UnsetField", _wrap_Feature_UnsetField, METH_VARARGS, NULL}, + { (char *)"Feature_SetField", _wrap_Feature_SetField, METH_VARARGS, NULL}, + { (char *)"Feature_SetFrom", (PyCFunction) _wrap_Feature_SetFrom, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Feature_GetStyleString", _wrap_Feature_GetStyleString, METH_VARARGS, NULL}, + { (char *)"Feature_SetStyleString", _wrap_Feature_SetStyleString, METH_VARARGS, NULL}, + { (char *)"Feature_GetFieldType", _wrap_Feature_GetFieldType, METH_VARARGS, NULL}, + { (char *)"Feature_swigregister", Feature_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_FeatureDefn", _wrap_delete_FeatureDefn, METH_VARARGS, NULL}, + { (char *)"new_FeatureDefn", (PyCFunction) _wrap_new_FeatureDefn, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"FeatureDefn_GetName", _wrap_FeatureDefn_GetName, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_GetFieldCount", _wrap_FeatureDefn_GetFieldCount, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_GetFieldDefn", _wrap_FeatureDefn_GetFieldDefn, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_GetFieldIndex", _wrap_FeatureDefn_GetFieldIndex, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_AddFieldDefn", _wrap_FeatureDefn_AddFieldDefn, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_GetGeomType", _wrap_FeatureDefn_GetGeomType, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_SetGeomType", _wrap_FeatureDefn_SetGeomType, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_GetReferenceCount", _wrap_FeatureDefn_GetReferenceCount, METH_VARARGS, NULL}, + { (char *)"FeatureDefn_swigregister", FeatureDefn_swigregister, METH_VARARGS, NULL}, + { (char *)"delete_FieldDefn", _wrap_delete_FieldDefn, METH_VARARGS, NULL}, + { (char *)"new_FieldDefn", (PyCFunction) _wrap_new_FieldDefn, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"FieldDefn_GetName", _wrap_FieldDefn_GetName, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetNameRef", _wrap_FieldDefn_GetNameRef, METH_VARARGS, NULL}, + { (char *)"FieldDefn_SetName", _wrap_FieldDefn_SetName, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetType", _wrap_FieldDefn_GetType, METH_VARARGS, NULL}, + { (char *)"FieldDefn_SetType", _wrap_FieldDefn_SetType, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetJustify", _wrap_FieldDefn_GetJustify, METH_VARARGS, NULL}, + { (char *)"FieldDefn_SetJustify", _wrap_FieldDefn_SetJustify, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetWidth", _wrap_FieldDefn_GetWidth, METH_VARARGS, NULL}, + { (char *)"FieldDefn_SetWidth", _wrap_FieldDefn_SetWidth, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetPrecision", _wrap_FieldDefn_GetPrecision, METH_VARARGS, NULL}, + { (char *)"FieldDefn_SetPrecision", _wrap_FieldDefn_SetPrecision, METH_VARARGS, NULL}, + { (char *)"FieldDefn_GetFieldTypeName", _wrap_FieldDefn_GetFieldTypeName, METH_VARARGS, NULL}, + { (char *)"FieldDefn_swigregister", FieldDefn_swigregister, METH_VARARGS, NULL}, + { (char *)"CreateGeometryFromWkb", (PyCFunction) _wrap_CreateGeometryFromWkb, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"CreateGeometryFromWkt", (PyCFunction) _wrap_CreateGeometryFromWkt, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"CreateGeometryFromGML", _wrap_CreateGeometryFromGML, METH_VARARGS, NULL}, + { (char *)"delete_Geometry", _wrap_delete_Geometry, METH_VARARGS, NULL}, + { (char *)"new_Geometry", (PyCFunction) _wrap_new_Geometry, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_ExportToWkt", _wrap_Geometry_ExportToWkt, METH_VARARGS, NULL}, + { (char *)"Geometry_ExportToWkb", (PyCFunction) _wrap_Geometry_ExportToWkb, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_ExportToGML", _wrap_Geometry_ExportToGML, METH_VARARGS, NULL}, + { (char *)"Geometry_AddPoint", (PyCFunction) _wrap_Geometry_AddPoint, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_AddGeometryDirectly", _wrap_Geometry_AddGeometryDirectly, METH_VARARGS, NULL}, + { (char *)"Geometry_AddGeometry", _wrap_Geometry_AddGeometry, METH_VARARGS, NULL}, + { (char *)"Geometry_Clone", _wrap_Geometry_Clone, METH_VARARGS, NULL}, + { (char *)"Geometry_GetGeometryType", _wrap_Geometry_GetGeometryType, METH_VARARGS, NULL}, + { (char *)"Geometry_GetGeometryName", _wrap_Geometry_GetGeometryName, METH_VARARGS, NULL}, + { (char *)"Geometry_GetArea", _wrap_Geometry_GetArea, METH_VARARGS, NULL}, + { (char *)"Geometry_GetPointCount", _wrap_Geometry_GetPointCount, METH_VARARGS, NULL}, + { (char *)"Geometry_GetX", (PyCFunction) _wrap_Geometry_GetX, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_GetY", (PyCFunction) _wrap_Geometry_GetY, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_GetZ", (PyCFunction) _wrap_Geometry_GetZ, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_GetGeometryCount", _wrap_Geometry_GetGeometryCount, METH_VARARGS, NULL}, + { (char *)"Geometry_SetPoint", (PyCFunction) _wrap_Geometry_SetPoint, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_GetGeometryRef", _wrap_Geometry_GetGeometryRef, METH_VARARGS, NULL}, + { (char *)"Geometry_GetBoundary", _wrap_Geometry_GetBoundary, METH_VARARGS, NULL}, + { (char *)"Geometry_ConvexHull", _wrap_Geometry_ConvexHull, METH_VARARGS, NULL}, + { (char *)"Geometry_Buffer", (PyCFunction) _wrap_Geometry_Buffer, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Geometry_Intersection", _wrap_Geometry_Intersection, METH_VARARGS, NULL}, + { (char *)"Geometry_Union", _wrap_Geometry_Union, METH_VARARGS, NULL}, + { (char *)"Geometry_Difference", _wrap_Geometry_Difference, METH_VARARGS, NULL}, + { (char *)"Geometry_SymmetricDifference", _wrap_Geometry_SymmetricDifference, METH_VARARGS, NULL}, + { (char *)"Geometry_Distance", _wrap_Geometry_Distance, METH_VARARGS, NULL}, + { (char *)"Geometry_Empty", _wrap_Geometry_Empty, METH_VARARGS, NULL}, + { (char *)"Geometry_Intersect", _wrap_Geometry_Intersect, METH_VARARGS, NULL}, + { (char *)"Geometry_Equal", _wrap_Geometry_Equal, METH_VARARGS, NULL}, + { (char *)"Geometry_Disjoint", _wrap_Geometry_Disjoint, METH_VARARGS, NULL}, + { (char *)"Geometry_Touches", _wrap_Geometry_Touches, METH_VARARGS, NULL}, + { (char *)"Geometry_Crosses", _wrap_Geometry_Crosses, METH_VARARGS, NULL}, + { (char *)"Geometry_Within", _wrap_Geometry_Within, METH_VARARGS, NULL}, + { (char *)"Geometry_Contains", _wrap_Geometry_Contains, METH_VARARGS, NULL}, + { (char *)"Geometry_Overlaps", _wrap_Geometry_Overlaps, METH_VARARGS, NULL}, + { (char *)"Geometry_TransformTo", _wrap_Geometry_TransformTo, METH_VARARGS, NULL}, + { (char *)"Geometry_Transform", _wrap_Geometry_Transform, METH_VARARGS, NULL}, + { (char *)"Geometry_GetSpatialReference", _wrap_Geometry_GetSpatialReference, METH_VARARGS, NULL}, + { (char *)"Geometry_AssignSpatialReference", _wrap_Geometry_AssignSpatialReference, METH_VARARGS, NULL}, + { (char *)"Geometry_CloseRings", _wrap_Geometry_CloseRings, METH_VARARGS, NULL}, + { (char *)"Geometry_FlattenTo2D", _wrap_Geometry_FlattenTo2D, METH_VARARGS, NULL}, + { (char *)"Geometry_GetEnvelope", _wrap_Geometry_GetEnvelope, METH_VARARGS, NULL}, + { (char *)"Geometry_Centroid", _wrap_Geometry_Centroid, METH_VARARGS, NULL}, + { (char *)"Geometry_WkbSize", _wrap_Geometry_WkbSize, METH_VARARGS, NULL}, + { (char *)"Geometry_GetCoordinateDimension", _wrap_Geometry_GetCoordinateDimension, METH_VARARGS, NULL}, + { (char *)"Geometry_GetDimension", _wrap_Geometry_GetDimension, METH_VARARGS, NULL}, + { (char *)"Geometry_swigregister", Geometry_swigregister, METH_VARARGS, NULL}, + { (char *)"GetDriverCount", _wrap_GetDriverCount, METH_VARARGS, NULL}, + { (char *)"GetOpenDSCount", _wrap_GetOpenDSCount, METH_VARARGS, NULL}, + { (char *)"SetGenerate_DB2_V72_BYTE_ORDER", _wrap_SetGenerate_DB2_V72_BYTE_ORDER, METH_VARARGS, NULL}, + { (char *)"RegisterAll", _wrap_RegisterAll, METH_VARARGS, NULL}, + { (char *)"GetOpenDS", _wrap_GetOpenDS, METH_VARARGS, NULL}, + { (char *)"Open", (PyCFunction) _wrap_Open, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"OpenShared", (PyCFunction) _wrap_OpenShared, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"GetDriverByName", _wrap_GetDriverByName, METH_VARARGS, NULL}, + { (char *)"GetDriver", _wrap_GetDriver, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRDataSourceShadow = {"_p_OGRDataSourceShadow", "OGRDataSourceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRDriverShadow = {"_p_OGRDriverShadow", "OGRDriverShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFeatureDefnShadow = {"_p_OGRFeatureDefnShadow", "OGRFeatureDefnShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFeatureShadow = {"_p_OGRFeatureShadow", "OGRFeatureShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRFieldDefnShadow = {"_p_OGRFieldDefnShadow", "OGRFieldDefnShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRGeometryShadow = {"_p_OGRGeometryShadow", "OGRGeometryShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OGRLayerShadow = {"_p_OGRLayerShadow", "OGRLayerShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; +static swig_type_info _swigt__ptrdiff_t = {"_ptrdiff_t", "ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__size_t = {"_size_t", "size_t", 0, 0, 0}; +static swig_type_info _swigt__std__ptrdiff_t = {"_std__ptrdiff_t", "std::ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__std__size_t = {"_std__size_t", "std::size_t", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_GIntBig, + &_swigt__p_OGRDataSourceShadow, + &_swigt__p_OGRDriverShadow, + &_swigt__p_OGRFeatureDefnShadow, + &_swigt__p_OGRFeatureShadow, + &_swigt__p_OGRFieldDefnShadow, + &_swigt__p_OGRGeometryShadow, + &_swigt__p_OGRLayerShadow, + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_char, + &_swigt__ptrdiff_t, + &_swigt__size_t, + &_swigt__std__ptrdiff_t, + &_swigt__std__size_t, +}; + +static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDataSourceShadow[] = { {&_swigt__p_OGRDataSourceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDriverShadow[] = { {&_swigt__p_OGRDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureDefnShadow[] = { {&_swigt__p_OGRFeatureDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureShadow[] = { {&_swigt__p_OGRFeatureShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFieldDefnShadow[] = { {&_swigt__p_OGRFieldDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRGeometryShadow[] = { {&_swigt__p_OGRGeometryShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRLayerShadow[] = { {&_swigt__p_OGRLayerShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__ptrdiff_t[] = { {&_swigt__std__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__size_t[] = { {&_swigt__std__size_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_GIntBig, + _swigc__p_OGRDataSourceShadow, + _swigc__p_OGRDriverShadow, + _swigc__p_OGRFeatureDefnShadow, + _swigc__p_OGRFeatureShadow, + _swigc__p_OGRFieldDefnShadow, + _swigc__p_OGRGeometryShadow, + _swigc__p_OGRLayerShadow, + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_char, + _swigc__ptrdiff_t, + _swigc__size_t, + _swigc__std__ptrdiff_t, + _swigc__std__size_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{ SWIG_PY_POINTER, (char*)"OLCRandomRead", 0, 0, (void *)"RandomRead", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCSequentialWrite", 0, 0, (void *)"SequentialWrite", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCRandomWrite", 0, 0, (void *)"RandomWrite", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCFastSpatialFilter", 0, 0, (void *)"FastSpatialFilter", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCFastFeatureCount", 0, 0, (void *)"FastFeatureCount", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCFastGetExtent", 0, 0, (void *)"FastGetExtent", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCCreateField", 0, 0, (void *)"CreateField", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCTransactions", 0, 0, (void *)"Transactions", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCDeleteFeature", 0, 0, (void *)"DeleteFeature", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"OLCFastSetNextByIndex", 0, 0, (void *)"FastSetNextByIndex", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"ODsCCreateLayer", 0, 0, (void *)"CreateLayer", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"ODsCDeleteLayer", 0, 0, (void *)"DeleteLayer", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"ODrCCreateDataSource", 0, 0, (void *)"CreateDataSource", &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"ODrCDeleteDataSource", 0, 0, (void *)"DeleteDataSource", &SWIGTYPE_p_char}, +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + + SWIGRUNTIME void + SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + } + + /* This function will propagate the clientdata field of type to + * any new swig_type_info structures that have been added into the list + * of equivalent types. It is like calling + * SWIG_TypeClientData(type, clientdata) a second time. + */ + SWIGRUNTIME void + SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } + } + +#ifdef __cplusplus +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *v) { + v = v; + return PyString_FromString("<Swig global variables>"); + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { + swig_globalvar *var; + flags = flags; + fprintf(fp,"Swig global variables { "); + for (var = v->vars; var; var=var->next) { + fprintf(fp,"%s", var->name); + if (var->next) fprintf(fp,", "); + } + fprintf(fp," }\n"); + return 0; + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->get_attr)(); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return NULL; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->set_attr)(p); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return 1; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + 0, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + varlink_type = tmp; + type_init = 1; + } +#endif + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_INT: + obj = PyInt_FromLong(constants[i].lvalue); + break; + case SWIG_PY_FLOAT: + obj = PyFloat_FromDouble(constants[i].dvalue); + break; + case SWIG_PY_STRING: + if (constants[i].pvalue) { + obj = PyString_FromString((char *) constants[i].pvalue); + } else { + Py_INCREF(Py_None); + obj = Py_None; + } + break; + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d,constants[i].name,obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* -----------------------------------------------------------------------------* + * Initialize type list + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + static PyObject *SWIG_globals = 0; + PyObject *m, *d; + if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + { + PyDict_SetItemString(d,"wkb25Bit", SWIG_From_int(static_cast<int >(wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbUnknown", SWIG_From_int(static_cast<int >(0))); + } + { + PyDict_SetItemString(d,"wkbPoint", SWIG_From_int(static_cast<int >(1))); + } + { + PyDict_SetItemString(d,"wkbLineString", SWIG_From_int(static_cast<int >(2))); + } + { + PyDict_SetItemString(d,"wkbPolygon", SWIG_From_int(static_cast<int >(3))); + } + { + PyDict_SetItemString(d,"wkbMultiPoint", SWIG_From_int(static_cast<int >(4))); + } + { + PyDict_SetItemString(d,"wkbMultiLineString", SWIG_From_int(static_cast<int >(5))); + } + { + PyDict_SetItemString(d,"wkbMultiPolygon", SWIG_From_int(static_cast<int >(6))); + } + { + PyDict_SetItemString(d,"wkbGeometryCollection", SWIG_From_int(static_cast<int >(7))); + } + { + PyDict_SetItemString(d,"wkbNone", SWIG_From_int(static_cast<int >(100))); + } + { + PyDict_SetItemString(d,"wkbLinearRing", SWIG_From_int(static_cast<int >(101))); + } + { + PyDict_SetItemString(d,"wkbPoint25D", SWIG_From_int(static_cast<int >(wkbPoint+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbLineString25D", SWIG_From_int(static_cast<int >(wkbLineString+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbPolygon25D", SWIG_From_int(static_cast<int >(wkbPolygon+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbMultiPoint25D", SWIG_From_int(static_cast<int >(wkbMultiPoint+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbMultiLineString25D", SWIG_From_int(static_cast<int >(wkbMultiLineString+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbMultiPolygon25D", SWIG_From_int(static_cast<int >(wkbMultiPolygon+wkb25DBit))); + } + { + PyDict_SetItemString(d,"wkbGeometryCollection25D", SWIG_From_int(static_cast<int >(wkbGeometryCollection+wkb25DBit))); + } + { + PyDict_SetItemString(d,"OFTInteger", SWIG_From_int(static_cast<int >(0))); + } + { + PyDict_SetItemString(d,"OFTIntegerList", SWIG_From_int(static_cast<int >(1))); + } + { + PyDict_SetItemString(d,"OFTReal", SWIG_From_int(static_cast<int >(2))); + } + { + PyDict_SetItemString(d,"OFTRealList", SWIG_From_int(static_cast<int >(3))); + } + { + PyDict_SetItemString(d,"OFTString", SWIG_From_int(static_cast<int >(4))); + } + { + PyDict_SetItemString(d,"OFTStringList", SWIG_From_int(static_cast<int >(5))); + } + { + PyDict_SetItemString(d,"OFTWideString", SWIG_From_int(static_cast<int >(6))); + } + { + PyDict_SetItemString(d,"OFTWideStringList", SWIG_From_int(static_cast<int >(7))); + } + { + PyDict_SetItemString(d,"OFTBinary", SWIG_From_int(static_cast<int >(8))); + } + { + PyDict_SetItemString(d,"OJUndefined", SWIG_From_int(static_cast<int >(0))); + } + { + PyDict_SetItemString(d,"OJLeft", SWIG_From_int(static_cast<int >(1))); + } + { + PyDict_SetItemString(d,"OJRight", SWIG_From_int(static_cast<int >(2))); + } + { + PyDict_SetItemString(d,"wkbXDR", SWIG_From_int(static_cast<int >(0))); + } + { + PyDict_SetItemString(d,"wkbNDR", SWIG_From_int(static_cast<int >(1))); + } + PyDict_SetItemString(d,"OLCRandomRead", SWIG_FromCharPtr("RandomRead")); + PyDict_SetItemString(d,"OLCSequentialWrite", SWIG_FromCharPtr("SequentialWrite")); + PyDict_SetItemString(d,"OLCRandomWrite", SWIG_FromCharPtr("RandomWrite")); + PyDict_SetItemString(d,"OLCFastSpatialFilter", SWIG_FromCharPtr("FastSpatialFilter")); + PyDict_SetItemString(d,"OLCFastFeatureCount", SWIG_FromCharPtr("FastFeatureCount")); + PyDict_SetItemString(d,"OLCFastGetExtent", SWIG_FromCharPtr("FastGetExtent")); + PyDict_SetItemString(d,"OLCCreateField", SWIG_FromCharPtr("CreateField")); + PyDict_SetItemString(d,"OLCTransactions", SWIG_FromCharPtr("Transactions")); + PyDict_SetItemString(d,"OLCDeleteFeature", SWIG_FromCharPtr("DeleteFeature")); + PyDict_SetItemString(d,"OLCFastSetNextByIndex", SWIG_FromCharPtr("FastSetNextByIndex")); + PyDict_SetItemString(d,"ODsCCreateLayer", SWIG_FromCharPtr("CreateLayer")); + PyDict_SetItemString(d,"ODsCDeleteLayer", SWIG_FromCharPtr("DeleteLayer")); + PyDict_SetItemString(d,"ODrCCreateDataSource", SWIG_FromCharPtr("CreateDataSource")); + PyDict_SetItemString(d,"ODrCDeleteDataSource", SWIG_FromCharPtr("DeleteDataSource")); + + + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + + +} + diff --git a/Utilities/GDAL/swig/python/osr.py b/Utilities/GDAL/swig/python/osr.py new file mode 100644 index 0000000000..8e0f42a02c --- /dev/null +++ b/Utilities/GDAL/swig/python/osr.py @@ -0,0 +1,434 @@ +# This file was created automatically by SWIG 1.3.27. +# Don't modify this file, modify the SWIG interface instead. + +import _osr + +# This file is compatible with both classic and new-style classes. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "this"): + if isinstance(value, class_type): + self.__dict__[name] = value.this + if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown + del value.thisown + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name) or (name == "thisown"): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +SRS_PT_ALBERS_CONIC_EQUAL_AREA = _osr.SRS_PT_ALBERS_CONIC_EQUAL_AREA +SRS_PT_AZIMUTHAL_EQUIDISTANT = _osr.SRS_PT_AZIMUTHAL_EQUIDISTANT +SRS_PT_CASSINI_SOLDNER = _osr.SRS_PT_CASSINI_SOLDNER +SRS_PT_CYLINDRICAL_EQUAL_AREA = _osr.SRS_PT_CYLINDRICAL_EQUAL_AREA +SRS_PT_ECKERT_IV = _osr.SRS_PT_ECKERT_IV +SRS_PT_ECKERT_VI = _osr.SRS_PT_ECKERT_VI +SRS_PT_EQUIDISTANT_CONIC = _osr.SRS_PT_EQUIDISTANT_CONIC +SRS_PT_EQUIRECTANGULAR = _osr.SRS_PT_EQUIRECTANGULAR +SRS_PT_GALL_STEREOGRAPHIC = _osr.SRS_PT_GALL_STEREOGRAPHIC +SRS_PT_GNOMONIC = _osr.SRS_PT_GNOMONIC +SRS_PT_GOODE_HOMOLOSINE = _osr.SRS_PT_GOODE_HOMOLOSINE +SRS_PT_HOTINE_OBLIQUE_MERCATOR = _osr.SRS_PT_HOTINE_OBLIQUE_MERCATOR +SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN = _osr.SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN +SRS_PT_LABORDE_OBLIQUE_MERCATOR = _osr.SRS_PT_LABORDE_OBLIQUE_MERCATOR +SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP = _osr.SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP +SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP = _osr.SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP +SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM = _osr.SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM +SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA = _osr.SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA +SRS_PT_MERCATOR_1SP = _osr.SRS_PT_MERCATOR_1SP +SRS_PT_MERCATOR_2SP = _osr.SRS_PT_MERCATOR_2SP +SRS_PT_MILLER_CYLINDRICAL = _osr.SRS_PT_MILLER_CYLINDRICAL +SRS_PT_MOLLWEIDE = _osr.SRS_PT_MOLLWEIDE +SRS_PT_NEW_ZEALAND_MAP_GRID = _osr.SRS_PT_NEW_ZEALAND_MAP_GRID +SRS_PT_OBLIQUE_STEREOGRAPHIC = _osr.SRS_PT_OBLIQUE_STEREOGRAPHIC +SRS_PT_ORTHOGRAPHIC = _osr.SRS_PT_ORTHOGRAPHIC +SRS_PT_POLAR_STEREOGRAPHIC = _osr.SRS_PT_POLAR_STEREOGRAPHIC +SRS_PT_POLYCONIC = _osr.SRS_PT_POLYCONIC +SRS_PT_ROBINSON = _osr.SRS_PT_ROBINSON +SRS_PT_SINUSOIDAL = _osr.SRS_PT_SINUSOIDAL +SRS_PT_STEREOGRAPHIC = _osr.SRS_PT_STEREOGRAPHIC +SRS_PT_SWISS_OBLIQUE_CYLINDRICAL = _osr.SRS_PT_SWISS_OBLIQUE_CYLINDRICAL +SRS_PT_TRANSVERSE_MERCATOR = _osr.SRS_PT_TRANSVERSE_MERCATOR +SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED = _osr.SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED +SRS_PT_TRANSVERSE_MERCATOR_MI_22 = _osr.SRS_PT_TRANSVERSE_MERCATOR_MI_22 +SRS_PT_TRANSVERSE_MERCATOR_MI_23 = _osr.SRS_PT_TRANSVERSE_MERCATOR_MI_23 +SRS_PT_TRANSVERSE_MERCATOR_MI_24 = _osr.SRS_PT_TRANSVERSE_MERCATOR_MI_24 +SRS_PT_TRANSVERSE_MERCATOR_MI_25 = _osr.SRS_PT_TRANSVERSE_MERCATOR_MI_25 +SRS_PT_TUNISIA_MINING_GRID = _osr.SRS_PT_TUNISIA_MINING_GRID +SRS_PT_VANDERGRINTEN = _osr.SRS_PT_VANDERGRINTEN +SRS_PT_KROVAK = _osr.SRS_PT_KROVAK +SRS_PP_CENTRAL_MERIDIAN = _osr.SRS_PP_CENTRAL_MERIDIAN +SRS_PP_SCALE_FACTOR = _osr.SRS_PP_SCALE_FACTOR +SRS_PP_STANDARD_PARALLEL_1 = _osr.SRS_PP_STANDARD_PARALLEL_1 +SRS_PP_STANDARD_PARALLEL_2 = _osr.SRS_PP_STANDARD_PARALLEL_2 +SRS_PP_PSEUDO_STD_PARALLEL_1 = _osr.SRS_PP_PSEUDO_STD_PARALLEL_1 +SRS_PP_LONGITUDE_OF_CENTER = _osr.SRS_PP_LONGITUDE_OF_CENTER +SRS_PP_LATITUDE_OF_CENTER = _osr.SRS_PP_LATITUDE_OF_CENTER +SRS_PP_LONGITUDE_OF_ORIGIN = _osr.SRS_PP_LONGITUDE_OF_ORIGIN +SRS_PP_LATITUDE_OF_ORIGIN = _osr.SRS_PP_LATITUDE_OF_ORIGIN +SRS_PP_FALSE_EASTING = _osr.SRS_PP_FALSE_EASTING +SRS_PP_FALSE_NORTHING = _osr.SRS_PP_FALSE_NORTHING +SRS_PP_AZIMUTH = _osr.SRS_PP_AZIMUTH +SRS_PP_LONGITUDE_OF_POINT_1 = _osr.SRS_PP_LONGITUDE_OF_POINT_1 +SRS_PP_LATITUDE_OF_POINT_1 = _osr.SRS_PP_LATITUDE_OF_POINT_1 +SRS_PP_LONGITUDE_OF_POINT_2 = _osr.SRS_PP_LONGITUDE_OF_POINT_2 +SRS_PP_LATITUDE_OF_POINT_2 = _osr.SRS_PP_LATITUDE_OF_POINT_2 +SRS_PP_LONGITUDE_OF_POINT_3 = _osr.SRS_PP_LONGITUDE_OF_POINT_3 +SRS_PP_LATITUDE_OF_POINT_3 = _osr.SRS_PP_LATITUDE_OF_POINT_3 +SRS_PP_RECTIFIED_GRID_ANGLE = _osr.SRS_PP_RECTIFIED_GRID_ANGLE +SRS_PP_LANDSAT_NUMBER = _osr.SRS_PP_LANDSAT_NUMBER +SRS_PP_PATH_NUMBER = _osr.SRS_PP_PATH_NUMBER +SRS_PP_PERSPECTIVE_POINT_HEIGHT = _osr.SRS_PP_PERSPECTIVE_POINT_HEIGHT +SRS_PP_FIPSZONE = _osr.SRS_PP_FIPSZONE +SRS_PP_ZONE = _osr.SRS_PP_ZONE +SRS_UL_METER = _osr.SRS_UL_METER +SRS_UL_FOOT = _osr.SRS_UL_FOOT +SRS_UL_FOOT_CONV = _osr.SRS_UL_FOOT_CONV +SRS_UL_US_FOOT = _osr.SRS_UL_US_FOOT +SRS_UL_US_FOOT_CONV = _osr.SRS_UL_US_FOOT_CONV +SRS_UL_NAUTICAL_MILE = _osr.SRS_UL_NAUTICAL_MILE +SRS_UL_NAUTICAL_MILE_CONV = _osr.SRS_UL_NAUTICAL_MILE_CONV +SRS_UL_LINK = _osr.SRS_UL_LINK +SRS_UL_LINK_CONV = _osr.SRS_UL_LINK_CONV +SRS_UL_CHAIN = _osr.SRS_UL_CHAIN +SRS_UL_CHAIN_CONV = _osr.SRS_UL_CHAIN_CONV +SRS_UL_ROD = _osr.SRS_UL_ROD +SRS_UL_ROD_CONV = _osr.SRS_UL_ROD_CONV +SRS_DN_NAD27 = _osr.SRS_DN_NAD27 +SRS_DN_NAD83 = _osr.SRS_DN_NAD83 +SRS_DN_WGS72 = _osr.SRS_DN_WGS72 +SRS_DN_WGS84 = _osr.SRS_DN_WGS84 +SRS_WGS84_SEMIMAJOR = _osr.SRS_WGS84_SEMIMAJOR +SRS_WGS84_INVFLATTENING = _osr.SRS_WGS84_INVFLATTENING + +def GetWellKnownGeogCSAsWKT(*args): + """GetWellKnownGeogCSAsWKT(char name, char argout) -> OGRErr""" + return _osr.GetWellKnownGeogCSAsWKT(*args) +class SpatialReference(_object): + """Proxy of C++ SpatialReference class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, SpatialReference, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, SpatialReference, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OSRSpatialReferenceShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __init__(self, *args, **kwargs): + """__init__(self, char wkt="") -> SpatialReference""" + _swig_setattr(self, SpatialReference, 'this', _osr.new_SpatialReference(*args, **kwargs)) + _swig_setattr(self, SpatialReference, 'thisown', 1) + def __del__(self, destroy=_osr.delete_SpatialReference): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def __str__(*args): + """__str__(self) -> char""" + return _osr.SpatialReference___str__(*args) + + def IsSame(*args): + """IsSame(self, SpatialReference rhs) -> int""" + return _osr.SpatialReference_IsSame(*args) + + def IsSameGeogCS(*args): + """IsSameGeogCS(self, SpatialReference rhs) -> int""" + return _osr.SpatialReference_IsSameGeogCS(*args) + + def IsGeographic(*args): + """IsGeographic(self) -> int""" + return _osr.SpatialReference_IsGeographic(*args) + + def IsProjected(*args): + """IsProjected(self) -> int""" + return _osr.SpatialReference_IsProjected(*args) + + def GetAttrValue(*args): + """GetAttrValue(self, char name, int child=0) -> char""" + return _osr.SpatialReference_GetAttrValue(*args) + + def SetAttrValue(*args): + """SetAttrValue(self, char name, char value) -> OGRErr""" + return _osr.SpatialReference_SetAttrValue(*args) + + def SetAngularUnits(*args): + """SetAngularUnits(self, char name, double to_radians) -> OGRErr""" + return _osr.SpatialReference_SetAngularUnits(*args) + + def GetAngularUnits(*args): + """GetAngularUnits(self) -> double""" + return _osr.SpatialReference_GetAngularUnits(*args) + + def SetLinearUnits(*args): + """SetLinearUnits(self, char name, double to_meters) -> OGRErr""" + return _osr.SpatialReference_SetLinearUnits(*args) + + def GetLinearUnits(*args): + """GetLinearUnits(self) -> double""" + return _osr.SpatialReference_GetLinearUnits(*args) + + def GetLinearUnitsName(*args): + """GetLinearUnitsName(self) -> char""" + return _osr.SpatialReference_GetLinearUnitsName(*args) + + def GetAuthorityCode(*args): + """GetAuthorityCode(self, char target_key) -> char""" + return _osr.SpatialReference_GetAuthorityCode(*args) + + def GetAuthorityName(*args): + """GetAuthorityName(self, char target_key) -> char""" + return _osr.SpatialReference_GetAuthorityName(*args) + + def SetUTM(*args): + """SetUTM(self, int zone, int north=1) -> OGRErr""" + return _osr.SpatialReference_SetUTM(*args) + + def SetStatePlane(*args): + """SetStatePlane(self, int zone, int is_nad83=1, char unitsname="", double units=0.0) -> OGRErr""" + return _osr.SpatialReference_SetStatePlane(*args) + + def AutoIdentifyEPSG(*args): + """AutoIdentifyEPSG(self) -> OGRErr""" + return _osr.SpatialReference_AutoIdentifyEPSG(*args) + + def SetProjection(*args): + """SetProjection(self, char arg) -> OGRErr""" + return _osr.SpatialReference_SetProjection(*args) + + def SetProjParm(*args): + """SetProjParm(self, char name, double val) -> OGRErr""" + return _osr.SpatialReference_SetProjParm(*args) + + def GetProjParm(*args): + """GetProjParm(self, char name, double default_val=0.0) -> double""" + return _osr.SpatialReference_GetProjParm(*args) + + def SetNormProjParm(*args): + """SetNormProjParm(self, char name, double val) -> OGRErr""" + return _osr.SpatialReference_SetNormProjParm(*args) + + def GetNormProjParm(*args): + """GetNormProjParm(self, char name, double default_val=0.0) -> double""" + return _osr.SpatialReference_GetNormProjParm(*args) + + def SetACEA(*args): + """ + SetACEA(self, double stdp1, double stdp2, double clat, double clong, + double fe, double fn) -> OGRErr + """ + return _osr.SpatialReference_SetACEA(*args) + + def SetAE(*args): + """SetAE(self, double clat, double clon, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetAE(*args) + + def SetCS(*args): + """SetCS(self, double clat, double clong, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetCS(*args) + + def SetBonne(*args): + """SetBonne(self, double clat, double clong, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetBonne(*args) + + def SetEC(*args): + """ + SetEC(self, double stdp1, double stdp2, double clat, double clong, + double fe, double fn) -> OGRErr + """ + return _osr.SpatialReference_SetEC(*args) + + def SetEckertIV(*args): + """SetEckertIV(self, double cm, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetEckertIV(*args) + + def SetEckertVI(*args): + """SetEckertVI(self, double cm, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetEckertVI(*args) + + def SetEquirectangular(*args): + """SetEquirectangular(self, double clat, double clong, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetEquirectangular(*args) + + def SetGS(*args, **kwargs): + """SetGS(self, double cm, double fe, double fn) -> OGRErr""" + return _osr.SpatialReference_SetGS(*args, **kwargs) + + def SetWellKnownGeogCS(*args): + """SetWellKnownGeogCS(self, char name) -> OGRErr""" + return _osr.SpatialReference_SetWellKnownGeogCS(*args) + + def SetFromUserInput(*args): + """SetFromUserInput(self, char name) -> OGRErr""" + return _osr.SpatialReference_SetFromUserInput(*args) + + def CopyGeogCSFrom(*args): + """CopyGeogCSFrom(self, SpatialReference rhs) -> OGRErr""" + return _osr.SpatialReference_CopyGeogCSFrom(*args) + + def SetTOWGS84(*args): + """ + SetTOWGS84(self, double p1, double p2, double p3, double p4=0.0, double p5=0.0, + double p6=0.0, double p7=0.0) -> OGRErr + """ + return _osr.SpatialReference_SetTOWGS84(*args) + + def GetTOWGS84(*args): + """GetTOWGS84(self, double argout) -> OGRErr""" + return _osr.SpatialReference_GetTOWGS84(*args) + + def SetGeogCS(*args): + """ + SetGeogCS(self, char pszGeogName, char pszDatumName, char pszEllipsoidName, + double dfSemiMajor, double dfInvFlattening, + char pszPMName="Greenwich", double dfPMOffset=0.0, + char pszUnits="degree", double dfConvertToRadians=0.0174532925199433) -> OGRErr + """ + return _osr.SpatialReference_SetGeogCS(*args) + + def SetProjCS(*args): + """SetProjCS(self, char name="unnamed") -> OGRErr""" + return _osr.SpatialReference_SetProjCS(*args) + + def ImportFromWkt(*args): + """ImportFromWkt(self, char ppszInput) -> OGRErr""" + return _osr.SpatialReference_ImportFromWkt(*args) + + def ImportFromProj4(*args): + """ImportFromProj4(self, char ppszInput) -> OGRErr""" + return _osr.SpatialReference_ImportFromProj4(*args) + + def ImportFromESRI(*args): + """ImportFromESRI(self, char ppszInput) -> OGRErr""" + return _osr.SpatialReference_ImportFromESRI(*args) + + def ImportFromEPSG(*args): + """ImportFromEPSG(self, int arg) -> OGRErr""" + return _osr.SpatialReference_ImportFromEPSG(*args) + + def ImportFromPCI(*args): + """ImportFromPCI(self, char proj, char units="METRE", double argin=0) -> OGRErr""" + return _osr.SpatialReference_ImportFromPCI(*args) + + def ImportFromUSGS(*args): + """ImportFromUSGS(self, long proj_code, long zone=0, double argin=0, long datum_code=0) -> OGRErr""" + return _osr.SpatialReference_ImportFromUSGS(*args) + + def ImportFromXML(*args): + """ImportFromXML(self, char xmlString) -> OGRErr""" + return _osr.SpatialReference_ImportFromXML(*args) + + def ExportToWkt(*args): + """ExportToWkt(self, char argout) -> OGRErr""" + return _osr.SpatialReference_ExportToWkt(*args) + + def ExportToPrettyWkt(*args): + """ExportToPrettyWkt(self, char argout, int simplify=0) -> OGRErr""" + return _osr.SpatialReference_ExportToPrettyWkt(*args) + + def ExportToProj4(*args): + """ExportToProj4(self, char argout) -> OGRErr""" + return _osr.SpatialReference_ExportToProj4(*args) + + def ExportToPCI(*args): + """ExportToPCI(self, char proj, char units, double parms) -> OGRErr""" + return _osr.SpatialReference_ExportToPCI(*args) + + def ExportToUSGS(*args): + """ExportToUSGS(self, long code, long zone, double parms, long datum) -> OGRErr""" + return _osr.SpatialReference_ExportToUSGS(*args) + + def ExportToXML(*args): + """ExportToXML(self, char argout, char dialect="") -> OGRErr""" + return _osr.SpatialReference_ExportToXML(*args) + + def CloneGeogCS(*args): + """CloneGeogCS(self) -> SpatialReference""" + return _osr.SpatialReference_CloneGeogCS(*args) + + def Validate(*args): + """Validate(self) -> OGRErr""" + return _osr.SpatialReference_Validate(*args) + + def StripCTParms(*args): + """StripCTParms(self) -> OGRErr""" + return _osr.SpatialReference_StripCTParms(*args) + + def FixupOrdering(*args): + """FixupOrdering(self) -> OGRErr""" + return _osr.SpatialReference_FixupOrdering(*args) + + def Fixup(*args): + """Fixup(self) -> OGRErr""" + return _osr.SpatialReference_Fixup(*args) + + def MorphToESRI(*args): + """MorphToESRI(self) -> OGRErr""" + return _osr.SpatialReference_MorphToESRI(*args) + + def MorphFromESRI(*args): + """MorphFromESRI(self) -> OGRErr""" + return _osr.SpatialReference_MorphFromESRI(*args) + + +class SpatialReferencePtr(SpatialReference): + def __init__(self, this): + _swig_setattr(self, SpatialReference, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, SpatialReference, 'thisown', 0) + self.__class__ = SpatialReference +_osr.SpatialReference_swigregister(SpatialReferencePtr) +GetProjectionMethods = _osr.GetProjectionMethods + + +class CoordinateTransformation(_object): + """Proxy of C++ CoordinateTransformation class""" + __swig_setmethods__ = {} + __setattr__ = lambda self, name, value: _swig_setattr(self, CoordinateTransformation, name, value) + __swig_getmethods__ = {} + __getattr__ = lambda self, name: _swig_getattr(self, CoordinateTransformation, name) + def __repr__(self): + return "<%s.%s; proxy of C++ OSRCoordinateTransformationShadow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) + def __init__(self, *args): + """__init__(self, SpatialReference src, SpatialReference dst) -> CoordinateTransformation""" + _swig_setattr(self, CoordinateTransformation, 'this', _osr.new_CoordinateTransformation(*args)) + _swig_setattr(self, CoordinateTransformation, 'thisown', 1) + def __del__(self, destroy=_osr.delete_CoordinateTransformation): + """__del__(self)""" + try: + if self.thisown: destroy(self) + except: pass + + def TransformPoint(*args): + """ + TransformPoint(self, double inout) + TransformPoint(self, double argout, double x, double y, double z=0.0) + """ + return _osr.CoordinateTransformation_TransformPoint(*args) + + +class CoordinateTransformationPtr(CoordinateTransformation): + def __init__(self, this): + _swig_setattr(self, CoordinateTransformation, 'this', this) + if not hasattr(self,"thisown"): _swig_setattr(self, CoordinateTransformation, 'thisown', 0) + self.__class__ = CoordinateTransformation +_osr.CoordinateTransformation_swigregister(CoordinateTransformationPtr) + + + diff --git a/Utilities/GDAL/swig/python/osr_wrap.cpp b/Utilities/GDAL/swig/python/osr_wrap.cpp new file mode 100644 index 0000000000..bb48139f4a --- /dev/null +++ b/Utilities/GDAL/swig/python/osr_wrap.cpp @@ -0,0 +1,5768 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.27 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) || defined(__ICC) +# define SWIGUNUSED __attribute__ ((unused)) +# else +# define SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + + +#include <Python.h> + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu = 0; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* ----------------------------------------------------------------------------- + * SWIG API. Portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * for internal method declarations + * ----------------------------------------------------------------------------- */ + +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* + Exception handling in wrappers +*/ +#define SWIG_fail goto fail +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) +#define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) +#define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) +#define SWIG_null_ref(type) SWIG_Python_NullRef(type) + +/* + Contract support +*/ +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_INT 1 +#define SWIG_PY_FLOAT 2 +#define SWIG_PY_STRING 3 +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Alloc. memory flags + * ----------------------------------------------------------------------------- */ +#define SWIG_OLDOBJ 1 +#define SWIG_NEWOBJ SWIG_OLDOBJ + 1 +#define SWIG_PYSTR SWIG_NEWOBJ + 1 + +#ifdef __cplusplus +} +#endif + + +/*********************************************************************** + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * Author : David Beazley (beazley@cs.uchicago.edu) + ************************************************************************/ + +/* Common SWIG API */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + + +/* Python-specific SWIG API */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* Runtime API */ +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ +/* + Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent + C/C++ pointers in the python side. Very useful for debugging, but + not always safe. +*/ +#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) +# define SWIG_COBJECT_TYPES +#endif + +/* Flags for pointer conversion */ +#define SWIG_POINTER_EXCEPTION 0x1 +#define SWIG_POINTER_DISOWN 0x2 + + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +#define PyOS_snprintf snprintf +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Create a new pointer string + * ----------------------------------------------------------------------------- */ +#ifndef SWIG_BUFFER_SIZE +#define SWIG_BUFFER_SIZE 1024 +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_BUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +#if PY_VERSION_HEX < 0x01060000 +#define PyObject_Del(op) PyMem_DEL((op)) +#endif + +#if defined(SWIG_COBJECT_TYPES) +#if !defined(SWIG_COBJECT_PYTHON) +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Object type, and use it instead of PyCObject + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *ptr; + const char *desc; +} PySwigObject; + +/* Declarations for objects of type PySwigObject */ + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { + fputs("<Swig Object at ", fp); fputs(result, fp); fputs(">", fp); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_repr(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromFormat("<Swig Object at %s>", result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); + } +} + +SWIGRUNTIME void +PySwigObject_dealloc(PySwigObject *self) +{ + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static char pyswigobject_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigObject", /*tp_name*/ + sizeof(PySwigObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigObject_dealloc, /*tp_dealloc*/ + (printfunc)PySwigObject_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigObject_compare, /*tp_compare*/ + (reprfunc)PySwigObject_repr, /*tp_repr*/ + &PySwigObject_as_number, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigObject_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigobject_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigobject_type = tmp; + type_init = 1; + } +#endif + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) +{ + PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (self) { + self->ptr = ptr; + self->desc = desc; + } + return (PyObject *)self; +} + +SWIGRUNTIMEINLINE void * +PySwigObject_AsVoidPtr(PyObject *self) +{ + return ((PySwigObject *)self)->ptr; +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + return ((PySwigObject *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + const char *desc; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) +{ + char result[SWIG_BUFFER_SIZE]; + flags = flags; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->desc,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->desc); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->desc); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->desc); + } else { + return PyString_FromString(v->desc); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + int c = strcmp(v->desc, w->desc); + if (c) { + return (c > 0) ? 1 : -1; + } else { + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + } +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PySwigPacked *self) +{ + free(self->pack); + PyObject_Del(self); +} + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static char pyswigpacked_type__doc__[] = + "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /*ob_size*/ + (char *)"PySwigPacked", /*tp_name*/ + sizeof(PySwigPacked), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ + (printfunc)PySwigPacked_print, /*tp_print*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ + (cmpfunc)PySwigPacked_compare, /*tp_compare*/ + (reprfunc)PySwigPacked_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + (hashfunc)0, /*tp_hash*/ + (ternaryfunc)0, /*tp_call*/ + (reprfunc)PySwigPacked_str, /*tp_str*/ + /* Space for future expansion */ + 0,0,0,0, + pyswigpacked_type__doc__, /* Documentation string */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + pyswigpacked_type = tmp; + type_init = 1; + } +#endif + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) +{ + PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (self == NULL) { + return NULL; + } else { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + self->pack = pack; + self->desc = desc; + self->size = size; + return (PyObject *) self; + } + return NULL; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + PySwigPacked *self = (PySwigPacked *)obj; + if (self->size != size) return 0; + memcpy(ptr, self->pack, size); + return self->desc; +} + +SWIGRUNTIMEINLINE const char * +PySwigPacked_GetDesc(PyObject *self) +{ + return ((PySwigPacked *)self)->desc; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +#else +/* ----------------------------------------------------------------------------- + * Use the old Python PyCObject instead of PySwigObject + * ----------------------------------------------------------------------------- */ + +#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) +#define PySwigObject_Check(obj) PyCObject_Check(obj) +#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) +#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) + +#endif + +#endif + +/* ----------------------------------------------------------------------------- + * errors manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + +SWIGRUNTIMEINLINE void +SWIG_Python_NullRef(const char *type) +{ + if (type) { + PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); + } else { + PyErr_Format(PyExc_TypeError, "null reference was received"); + } +} + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + static PyObject *SWIG_this = 0; + int newref = 0; + PyObject *pyobj = 0; + void *vptr; + + if (!obj) return 0; + if (obj == Py_None) { + *ptr = 0; + return 0; + } + +#ifdef SWIG_COBJECT_TYPES + if (!(PySwigObject_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PySwigObject_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + vptr = PySwigObject_AsVoidPtr(obj); + c = (const char *) PySwigObject_GetDesc(obj); + if (newref) { Py_DECREF(obj); } + goto type_check; +#else + if (!(PyString_Check(obj))) { + if (!SWIG_this) + SWIG_this = PyString_FromString("this"); + pyobj = obj; + obj = PyObject_GetAttr(obj,SWIG_this); + newref = 1; + if (!obj) goto type_error; + if (!PyString_Check(obj)) { + Py_DECREF(obj); + goto type_error; + } + } + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); + if (newref) { Py_DECREF(obj); } + if (!c) goto type_error; +#endif + +type_check: + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + *ptr = SWIG_TypeCast(tc,vptr); + } else { + *ptr = vptr; + } + if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { + PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); + } + return 0; + +type_error: + PyErr_Clear(); + if (pyobj && !obj) { + obj = pyobj; + if (PyCFunction_Check(obj)) { + /* here we get the method pointer for callbacks */ + char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + c = doc ? strstr(doc, "swig_ptr: ") : 0; + if (c) { + c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; + if (!c) goto type_error; + goto type_check; + } + } + } + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ pointer", obj); + } + } + return -1; +} + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { + swig_cast_info *tc; + const char *c = 0; + +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + c = PySwigPacked_UnpackData(obj, ptr, sz); +#else + if ((!obj) || (!PyString_Check(obj))) goto type_error; + c = PyString_AsString(obj); + /* Pointer values must start with leading underscore */ + c = SWIG_UnpackDataName(c, ptr, sz, ty->name); +#endif + if (!c) goto type_error; + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) goto type_error; + } + return 0; + +type_error: + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + if (ty) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + } else { + SWIG_Python_TypeError("C/C++ packed data", obj); + } + } + return -1; +} + +/* Create a new array object */ +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { + PyObject *robj = 0; + if (!type) { + if (!PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj"); + } + return robj; + } + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#ifdef SWIG_COBJECT_TYPES + robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + if (!robj || (robj == Py_None)) return robj; + if (type->clientdata) { + PyObject *inst; + PyObject *args = Py_BuildValue((char*)"(O)", robj); + Py_DECREF(robj); + inst = PyObject_CallObject((PyObject *) type->clientdata, args); + Py_DECREF(args); + if (inst) { + if (own) { + PyObject_SetAttrString(inst,(char*)"thisown",Py_True); + } + robj = inst; + } + } + return robj; +} + +SWIGRUNTIME PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + PyObject *robj = 0; + if (!ptr) { + Py_INCREF(Py_None); + return Py_None; + } +#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) + robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); +#else + { + char result[SWIG_BUFFER_SIZE]; + robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? + PyString_FromString(result) : 0; + } +#endif + return robj; +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function +is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return -1; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return -1; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return -1; + } + if (PyDict_SetItemString(dict, name, o)) + return -1; + Py_DECREF(o); + return 0; +} +#endif + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } +} + +#ifdef __cplusplus +} +#endif + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[0] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_double swig_types[3] +#define SWIGTYPE_p_int swig_types[4] +#define SWIGTYPE_p_long swig_types[5] +#define SWIGTYPE_p_p_char swig_types[6] +#define SWIGTYPE_p_p_double swig_types[7] +#define SWIGTYPE_ptrdiff_t swig_types[8] +#define SWIGTYPE_size_t swig_types[9] +#define SWIGTYPE_std__ptrdiff_t swig_types[10] +#define SWIGTYPE_std__size_t swig_types[11] +static swig_type_info *swig_types[13]; +static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + + +/*----------------------------------------------- + @(target):= _osr.so + ------------------------------------------------*/ +#define SWIG_init init_osr + +#define SWIG_name "_osr" + +SWIGINTERN PyObject * +SWIG_FromCharPtr(const char* cptr) +{ + if (cptr) { + size_t size = strlen(cptr); + if (size > INT_MAX) { + return SWIG_NewPointerObj(const_cast<char* >(cptr), + SWIG_TypeQuery("char *"), 0); + } else { + if (size != 0) { + return PyString_FromStringAndSize(cptr, size); + } else { + return PyString_FromString(cptr); + } + } + } + Py_INCREF(Py_None); + return Py_None; +} + + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_double PyFloat_FromDouble +/*@@*/ + + +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + + + +static PyObject * +py_OPTGetProjectionMethods(PyObject *self, PyObject *args) { + + PyObject *py_MList; + char **papszMethods; + int iMethod; + + self = self; + args = args; + + papszMethods = OPTGetProjectionMethods(); + py_MList = PyList_New(CSLCount(papszMethods)); + + for( iMethod = 0; papszMethods[iMethod] != NULL; iMethod++ ) + { + char *pszUserMethodName; + char **papszParameters; + PyObject *py_PList; + int iParam; + + papszParameters = OPTGetParameterList( papszMethods[iMethod], + &pszUserMethodName ); + if( papszParameters == NULL ) + return NULL; + + py_PList = PyList_New(CSLCount(papszParameters)); + for( iParam = 0; papszParameters[iParam] != NULL; iParam++ ) + { + char *pszType; + char *pszUserParamName; + double dfDefault; + + OPTGetParameterInfo( papszMethods[iMethod], + papszParameters[iParam], + &pszUserParamName, + &pszType, &dfDefault ); + PyList_SetItem(py_PList, iParam, + Py_BuildValue("(sssd)", + papszParameters[iParam], + pszUserParamName, + pszType, dfDefault )); + } + + CSLDestroy( papszParameters ); + + PyList_SetItem(py_MList, iMethod, + Py_BuildValue("(ssO)", + papszMethods[iMethod], + pszUserMethodName, + py_PList)); + } + + CSLDestroy( papszMethods ); + + return py_MList; +} + + +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} + + +/* returns SWIG_OLDOBJ if the input is a raw char*, SWIG_PYSTR if is a PyString */ +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize) +{ + static swig_type_info* pchar_info = 0; + char* vptr = 0; + if (!pchar_info) pchar_info = SWIG_TypeQuery("char *"); + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_info, 0) != -1) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + if (PyString_Check(obj)) { + if (cptr) { + *cptr = PyString_AS_STRING(obj); + if (psize) { + *psize = PyString_GET_SIZE(obj) + 1; + } + } + return SWIG_PYSTR; + } + } + if (cptr) { + SWIG_type_error("char *", obj); + } + return 0; +} + + +SWIGINTERNINLINE int +SWIG_AsCharPtr(PyObject *obj, char **val) +{ + if (SWIG_AsCharPtrAndSize(obj, val, (size_t*)(0))) { + return 1; + } + if (val) { + PyErr_Clear(); + SWIG_type_error("char *", obj); + } + return 0; +} + + +SWIGINTERN PyObject* +t_output_helper(PyObject* target, PyObject* o) { + if (!target) { + target = o; + } else if (target == Py_None) { + Py_DECREF(target); + target = o; + } else { + if (!PyList_Check(target)) { + PyObject *o2 = target; + target = PyList_New(1); + PyList_SetItem(target, 0, o2); + } + PyList_Append(target,o); + Py_DECREF(o); + } + return target; +} + + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + +static OSRSpatialReferenceShadow *new_OSRSpatialReferenceShadow(char const *wkt=""){ + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } +static void delete_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *self){ + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } +static char *OSRSpatialReferenceShadow___str__(OSRSpatialReferenceShadow *self){ + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } +static int OSRSpatialReferenceShadow_IsSame(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSame( self, rhs ); + } + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_int PyInt_FromLong +/*@@*/ + +static int OSRSpatialReferenceShadow_IsSameGeogCS(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSameGeogCS( self, rhs ); + } +static int OSRSpatialReferenceShadow_IsGeographic(OSRSpatialReferenceShadow *self){ + return OSRIsGeographic(self); + } +static int OSRSpatialReferenceShadow_IsProjected(OSRSpatialReferenceShadow *self){ + return OSRIsProjected(self); + } + +#include <limits.h> + + +SWIGINTERN int + SWIG_CheckLongInRange(long value, long min_value, long max_value, + const char *errmsg) +{ + if (value < min_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is less than '%s' minimum %ld", + value, errmsg, min_value); + } + return 0; + } else if (value > max_value) { + if (errmsg) { + PyErr_Format(PyExc_OverflowError, + "value %ld is greater than '%s' maximum %ld", + value, errmsg, max_value); + } + return 0; + } + return 1; +} + + +SWIGINTERN int + SWIG_AsVal_long(PyObject * obj, long* val) +{ + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (val) { + SWIG_type_error("long", obj); + } + return 0; + } + + +#if INT_MAX != LONG_MAX +SWIGINTERN int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + const char* errmsg = val ? "int" : (char*)0; + long v; + if (SWIG_AsVal_long(obj, &v)) { + if (SWIG_CheckLongInRange(v, INT_MIN,INT_MAX, errmsg)) { + if (val) *val = static_cast<int >(v); + return 1; + } else { + return 0; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_type_error(errmsg, obj); + } + return 0; +} +#else +SWIGINTERNINLINE int + SWIG_AsVal_int(PyObject *obj, int *val) +{ + return SWIG_AsVal_long(obj,(long*)val); +} +#endif + + +SWIGINTERNINLINE int +SWIG_As_int(PyObject* obj) +{ + int v; + if (!SWIG_AsVal_int(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(int)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_int(PyObject* obj) +{ + return SWIG_AsVal_int(obj, (int*)0); +} + +static char const *OSRSpatialReferenceShadow_GetAttrValue(OSRSpatialReferenceShadow *self,char const *name,int child=0){ + return OSRGetAttrValue( self, name, child ); + } +static OGRErr OSRSpatialReferenceShadow_SetAttrValue(OSRSpatialReferenceShadow *self,char const *name,char const *value){ + return OSRSetAttrValue( self, name, value ); + } + +SWIGINTERN int + SWIG_AsVal_double(PyObject *obj, double *val) +{ + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return 1; + } + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return 1; + } + if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return 1; + } else { + if (!val) PyErr_Clear(); + return 0; + } + } + if (val) { + SWIG_type_error("double", obj); + } + return 0; +} + + +SWIGINTERNINLINE double +SWIG_As_double(PyObject* obj) +{ + double v; + if (!SWIG_AsVal_double(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(double)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_double(PyObject* obj) +{ + return SWIG_AsVal_double(obj, (double*)0); +} + +static OGRErr OSRSpatialReferenceShadow_SetAngularUnits(OSRSpatialReferenceShadow *self,char const *name,double to_radians){ + return OSRSetAngularUnits( self, name, to_radians ); + } +static double OSRSpatialReferenceShadow_GetAngularUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetLinearUnits(OSRSpatialReferenceShadow *self,char const *name,double to_meters){ + return OSRSetAngularUnits( self, name, to_meters ); + } +static double OSRSpatialReferenceShadow_GetLinearUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } +static char const *OSRSpatialReferenceShadow_GetLinearUnitsName(OSRSpatialReferenceShadow *self){ + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } +static char const *OSRSpatialReferenceShadow_GetAuthorityCode(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityCode( self, target_key ); + } +static char const *OSRSpatialReferenceShadow_GetAuthorityName(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityName( self, target_key ); + } +static OGRErr OSRSpatialReferenceShadow_SetUTM(OSRSpatialReferenceShadow *self,int zone,int north=1){ + return OSRSetUTM( self, zone, north ); + } +static OGRErr OSRSpatialReferenceShadow_SetStatePlane(OSRSpatialReferenceShadow *self,int zone,int is_nad83=1,char const *unitsname="",double units=0.0){ + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } +static OGRErr OSRSpatialReferenceShadow_AutoIdentifyEPSG(OSRSpatialReferenceShadow *self){ + return OSRAutoIdentifyEPSG( self ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjection(OSRSpatialReferenceShadow *self,char const *arg){ + return OSRSetProjection( self, arg ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetNormProjParm( self, name, val ); + } +static double OSRSpatialReferenceShadow_GetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } +static OGRErr OSRSpatialReferenceShadow_SetACEA(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetAE(OSRSpatialReferenceShadow *self,double clat,double clon,double fe,double fn){ + return OSRSetAE( self, clat, clon, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetCS(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetCS( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetBonne(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetBonne( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEC(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertIV(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertIV( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEckertVI(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertVI( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetEquirectangular(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetGS(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetGS( self, cm, fe, fn ); + } +static OGRErr OSRSpatialReferenceShadow_SetWellKnownGeogCS(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetWellKnownGeogCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_SetFromUserInput(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetFromUserInput( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_CopyGeogCSFrom(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRCopyGeogCSFrom( self, rhs ); + } +static OGRErr OSRSpatialReferenceShadow_SetTOWGS84(OSRSpatialReferenceShadow *self,double p1,double p2,double p3,double p4=0.0,double p5=0.0,double p6=0.0,double p7=0.0){ + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } + +static PyObject * +CreateTupleFromDoubleArray( double *first, unsigned int size ) { + PyObject *out = PyTuple_New( size ); + for( unsigned int i=0; i<size; i++ ) { + PyObject *val = PyFloat_FromDouble( *first ); + ++first; + PyTuple_SetItem( out, i, val ); + } + return out; +} + +static OGRErr OSRSpatialReferenceShadow_GetTOWGS84(OSRSpatialReferenceShadow *self,double argout[7]){ + return OSRGetTOWGS84( self, argout, 7 ); + } +static OGRErr OSRSpatialReferenceShadow_SetGeogCS(OSRSpatialReferenceShadow *self,char const *pszGeogName,char const *pszDatumName,char const *pszEllipsoidName,double dfSemiMajor,double dfInvFlattening,char const *pszPMName="Greenwich",double dfPMOffset=0.0,char const *pszUnits="degree",double dfConvertToRadians=0.0174532925199433){ + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } +static OGRErr OSRSpatialReferenceShadow_SetProjCS(OSRSpatialReferenceShadow *self,char const *name="unnamed"){ + return OSRSetProjCS( self, name ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromWkt(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromWkt( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromProj4(OSRSpatialReferenceShadow *self,char *ppszInput){ + return OSRImportFromProj4( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromESRI(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromESRI( self, ppszInput ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromEPSG(OSRSpatialReferenceShadow *self,int arg){ + return OSRImportFromEPSG(self, arg); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromPCI(OSRSpatialReferenceShadow *self,char const *proj,char const *units="METRE",double argin[17]=0){ + return OSRImportFromPCI( self, proj, units, argin ); + } + +SWIGINTERNINLINE long +SWIG_As_long(PyObject* obj) +{ + long v; + if (!SWIG_AsVal_long(obj, &v)) { + /* + this is needed to make valgrind/purify happier. + */ + memset((void*)&v, 0, sizeof(long)); + } + return v; +} + + +SWIGINTERNINLINE int +SWIG_Check_long(PyObject* obj) +{ + return SWIG_AsVal_long(obj, (long*)0); +} + +static OGRErr OSRSpatialReferenceShadow_ImportFromUSGS(OSRSpatialReferenceShadow *self,long proj_code,long zone=0,double argin[15]=0,long datum_code=0){ + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } +static OGRErr OSRSpatialReferenceShadow_ImportFromXML(OSRSpatialReferenceShadow *self,char const *xmlString){ + return OSRImportFromXML( self, xmlString ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToWkt(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToWkt( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPrettyWkt(OSRSpatialReferenceShadow *self,char **argout,int simplify=0){ + return OSRExportToPrettyWkt( self, argout, simplify ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToProj4(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToProj4( self, argout ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToPCI(OSRSpatialReferenceShadow *self,char **proj,char **units,double *parms[17]){ + return OSRExportToPCI( self, proj, units, parms ); + } + + /*@/usr/local/share/swig/1.3.27/python/pymacros.swg,72,SWIG_define@*/ +#define SWIG_From_long PyInt_FromLong +/*@@*/ + + +static OGRErr OSRSpatialReferenceShadow_ExportToUSGS(OSRSpatialReferenceShadow *self,long *code,long *zone,double *parms[15],long *datum){ + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +static OGRErr OSRSpatialReferenceShadow_ExportToXML(OSRSpatialReferenceShadow *self,char **argout,char const *dialect=""){ + return OSRExportToXML( self, argout, dialect ); + } +static OSRSpatialReferenceShadow *OSRSpatialReferenceShadow_CloneGeogCS(OSRSpatialReferenceShadow *self){ + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } +static OGRErr OSRSpatialReferenceShadow_Validate(OSRSpatialReferenceShadow *self){ + return OSRValidate(self); + } +static OGRErr OSRSpatialReferenceShadow_StripCTParms(OSRSpatialReferenceShadow *self){ + return OSRStripCTParms(self); + } +static OGRErr OSRSpatialReferenceShadow_FixupOrdering(OSRSpatialReferenceShadow *self){ + return OSRFixupOrdering(self); + } +static OGRErr OSRSpatialReferenceShadow_Fixup(OSRSpatialReferenceShadow *self){ + return OSRFixup(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphToESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphToESRI(self); + } +static OGRErr OSRSpatialReferenceShadow_MorphFromESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphFromESRI(self); + } +static OSRCoordinateTransformationShadow *new_OSRCoordinateTransformationShadow(OSRSpatialReferenceShadow *src,OSRSpatialReferenceShadow *dst){ + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } +static void delete_OSRCoordinateTransformationShadow(OSRCoordinateTransformationShadow *self){ + OCTDestroyCoordinateTransformation( self ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(OSRCoordinateTransformationShadow *self,double inout[3]){ + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +static void OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(OSRCoordinateTransformationShadow *self,double argout[3],double x,double y,double z=0.0){ + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } +#ifdef __cplusplus +extern "C" { +#endif +static PyObject *_wrap_GetWellKnownGeogCSAsWKT(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:GetWellKnownGeogCSAsWKT",&obj0)) goto fail; + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_new_SpatialReference(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + char *arg1 = (char *) "" ; + OSRSpatialReferenceShadow *result; + PyObject * obj0 = 0 ; + char *kwnames[] = { + (char *) "wkt", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:new_SpatialReference",kwnames,&obj0)) goto fail; + if (obj0) { + if (!SWIG_AsCharPtr(obj0, (char**)&arg1)) { + SWIG_arg_fail(1);SWIG_fail; + } + } + result = (OSRSpatialReferenceShadow *)new_OSRSpatialReferenceShadow((char const *)arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_SpatialReference(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_SpatialReference",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OSRSpatialReferenceShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference___str__(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference___str__",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OSRSpatialReferenceShadow___str__(arg1); + + resultobj = SWIG_FromCharPtr(result); + delete [] result; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_IsSame(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_IsSame",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (int)OSRSpatialReferenceShadow_IsSame(arg1,arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_IsSameGeogCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_IsSameGeogCS",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (int)OSRSpatialReferenceShadow_IsSameGeogCS(arg1,arg2); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_IsGeographic(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_IsGeographic",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OSRSpatialReferenceShadow_IsGeographic(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_IsProjected(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_IsProjected",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (int)OSRSpatialReferenceShadow_IsProjected(arg1); + + { + resultobj = SWIG_From_int(static_cast<int >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetAttrValue(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:SpatialReference_GetAttrValue",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (char *)OSRSpatialReferenceShadow_GetAttrValue(arg1,(char const *)arg2,arg3); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetAttrValue(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:SpatialReference_SetAttrValue",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAttrValue(arg1,(char const *)arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetAngularUnits(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:SpatialReference_SetAngularUnits",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAngularUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetAngularUnits(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_GetAngularUnits",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (double)OSRSpatialReferenceShadow_GetAngularUnits(arg1); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetLinearUnits(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:SpatialReference_SetLinearUnits",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetLinearUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetLinearUnits(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_GetLinearUnits",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (double)OSRSpatialReferenceShadow_GetLinearUnits(arg1); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetLinearUnitsName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_GetLinearUnitsName",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (char *)OSRSpatialReferenceShadow_GetLinearUnitsName(arg1); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetAuthorityCode(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_GetAuthorityCode",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityCode(arg1,(char const *)arg2); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetAuthorityName(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_GetAuthorityName",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (char *)OSRSpatialReferenceShadow_GetAuthorityName(arg1,(char const *)arg2); + + resultobj = SWIG_FromCharPtr(result); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetUTM(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:SpatialReference_SetUTM",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetUTM(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetStatePlane(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + char *arg4 = (char *) "" ; + double arg5 = (double) 0.0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|OOO:SpatialReference_SetStatePlane",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<int >(SWIG_As_int(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + if (obj3) { + if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) { + SWIG_arg_fail(4);SWIG_fail; + } + } + if (obj4) { + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetStatePlane(arg1,arg2,arg3,(char const *)arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_AutoIdentifyEPSG(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_AutoIdentifyEPSG",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_AutoIdentifyEPSG(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetProjection(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_SetProjection",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjection(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetProjParm(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:SpatialReference_SetProjParm",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetProjParm(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:SpatialReference_GetProjParm",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (double)OSRSpatialReferenceShadow_GetProjParm(arg1,(char const *)arg2,arg3); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetNormProjParm(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOO:SpatialReference_SetNormProjParm",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetNormProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetNormProjParm(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|O:SpatialReference_GetNormProjParm",&obj0,&obj1,&obj2)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (double)OSRSpatialReferenceShadow_GetNormProjParm(arg1,(char const *)arg2,arg3); + + { + resultobj = SWIG_From_double(static_cast<double >(result)); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetACEA(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOOOO:SpatialReference_SetACEA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + { + arg6 = static_cast<double >(SWIG_As_double(obj5)); + if (SWIG_arg_fail(6)) SWIG_fail; + } + { + arg7 = static_cast<double >(SWIG_As_double(obj6)); + if (SWIG_arg_fail(7)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetACEA(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetAE(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOO:SpatialReference_SetAE",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetAE(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOO:SpatialReference_SetCS",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetCS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetBonne(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOO:SpatialReference_SetBonne",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetBonne(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetEC(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOOOO:SpatialReference_SetEC",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + { + arg6 = static_cast<double >(SWIG_As_double(obj5)); + if (SWIG_arg_fail(6)) SWIG_fail; + } + { + arg7 = static_cast<double >(SWIG_As_double(obj6)); + if (SWIG_arg_fail(7)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEC(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetEckertIV(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOO:SpatialReference_SetEckertIV",&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertIV(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetEckertVI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOO:SpatialReference_SetEckertVI",&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertVI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetEquirectangular(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOO:SpatialReference_SetEquirectangular",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetEquirectangular(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetGS(PyObject *, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char *kwnames[] = { + (char *) "self",(char *) "cm",(char *) "fe",(char *) "fn", NULL + }; + + if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:SpatialReference_SetGS",kwnames,&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetGS(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetWellKnownGeogCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_SetWellKnownGeogCS",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetWellKnownGeogCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetFromUserInput(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_SetFromUserInput",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_SetFromUserInput(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_CopyGeogCSFrom(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_CopyGeogCSFrom",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_CopyGeogCSFrom(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetTOWGS84(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double arg6 = (double) 0.0 ; + double arg7 = (double) 0.0 ; + double arg8 = (double) 0.0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOO|OOOO:SpatialReference_SetTOWGS84",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + { + arg3 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + if (obj4) { + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + if (obj5) { + { + arg6 = static_cast<double >(SWIG_As_double(obj5)); + if (SWIG_arg_fail(6)) SWIG_fail; + } + } + if (obj6) { + { + arg7 = static_cast<double >(SWIG_As_double(obj6)); + if (SWIG_arg_fail(7)) SWIG_fail; + } + } + if (obj7) { + { + arg8 = static_cast<double >(SWIG_As_double(obj7)); + if (SWIG_arg_fail(8)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetTOWGS84(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_GetTOWGS84(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double *arg2 ; + OGRErr result; + double argout2[7] ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_GetTOWGS84",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_GetTOWGS84(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 7 ); + resultobj = t_output_helper(resultobj,out); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetGeogCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + double arg5 ; + double arg6 ; + char *arg7 = (char *) "Greenwich" ; + double arg8 = (double) 0.0 ; + char *arg9 = (char *) "degree" ; + double arg10 = (double) 0.0174532925199433 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + PyObject * obj8 = 0 ; + PyObject * obj9 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OOOOOO|OOOO:SpatialReference_SetGeogCS",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) { + SWIG_arg_fail(4);SWIG_fail; + } + { + arg5 = static_cast<double >(SWIG_As_double(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + { + arg6 = static_cast<double >(SWIG_As_double(obj5)); + if (SWIG_arg_fail(6)) SWIG_fail; + } + if (obj6) { + if (!SWIG_AsCharPtr(obj6, (char**)&arg7)) { + SWIG_arg_fail(7);SWIG_fail; + } + } + if (obj7) { + { + arg8 = static_cast<double >(SWIG_As_double(obj7)); + if (SWIG_arg_fail(8)) SWIG_fail; + } + } + if (obj8) { + if (!SWIG_AsCharPtr(obj8, (char**)&arg9)) { + SWIG_arg_fail(9);SWIG_fail; + } + } + if (obj9) { + { + arg10 = static_cast<double >(SWIG_As_double(obj9)); + if (SWIG_arg_fail(10)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetGeogCS(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,(char const *)arg7,arg8,(char const *)arg9,arg10); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_SetProjCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) "unnamed" ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O|O:SpatialReference_SetProjCS",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_SetProjCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromWkt(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_ImportFromWkt",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in) (char **ignorechange) */ + PyArg_Parse( obj1, "s", &val2 ); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromProj4(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_ImportFromProj4",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromESRI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *val2 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_ImportFromESRI",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in) (char **ignorechange) */ + PyArg_Parse( obj1, "s", &val2 ); + arg2 = &val2; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromESRI(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromEPSG(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_ImportFromEPSG",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromEPSG(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromPCI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "METRE" ; + double *arg4 = (double *) (double *)0 ; + OGRErr result; + double argin4[17] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|OO:SpatialReference_ImportFromPCI",&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + if (obj2) { + if (!SWIG_AsCharPtr(obj2, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + if (obj3) { + { + /* %typemap(in) (double argin4[ANY]) */ + arg4 = argin4; + if (! PySequence_Check(obj3) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + int seq_size = PySequence_Size(obj3); + if ( seq_size != 17 ) { + PyErr_SetString(PyExc_TypeError, "sequence must have length ##size"); + SWIG_fail; + } + for (unsigned int i=0; i<17; i++) { + PyObject *o = PySequence_GetItem(obj3,i); + double val; + PyArg_Parse(o, "d", &val ); + arg4[i] = val; + } + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromPCI(arg1,(char const *)arg2,(char const *)arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromUSGS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long arg2 ; + long arg3 = (long) 0 ; + double *arg4 = (double *) (double *)0 ; + long arg5 = (long) 0 ; + OGRErr result; + double argin4[15] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO|OOO:SpatialReference_ImportFromUSGS",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg2 = static_cast<long >(SWIG_As_long(obj1)); + if (SWIG_arg_fail(2)) SWIG_fail; + } + if (obj2) { + { + arg3 = static_cast<long >(SWIG_As_long(obj2)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + if (obj3) { + { + /* %typemap(in) (double argin4[ANY]) */ + arg4 = argin4; + if (! PySequence_Check(obj3) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + int seq_size = PySequence_Size(obj3); + if ( seq_size != 15 ) { + PyErr_SetString(PyExc_TypeError, "sequence must have length ##size"); + SWIG_fail; + } + for (unsigned int i=0; i<15; i++) { + PyObject *o = PySequence_GetItem(obj3,i); + double val; + PyArg_Parse(o, "d", &val ); + arg4[i] = val; + } + } + } + if (obj4) { + { + arg5 = static_cast<long >(SWIG_As_long(obj4)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ImportFromXML(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:SpatialReference_ImportFromXML",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (!SWIG_AsCharPtr(obj1, (char**)&arg2)) { + SWIG_arg_fail(2);SWIG_fail; + } + result = (OGRErr)OSRSpatialReferenceShadow_ImportFromXML(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToWkt(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_ExportToWkt",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_ExportToWkt(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToPrettyWkt(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + int arg3 = (int) 0 ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O|O:SpatialReference_ExportToPrettyWkt",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + { + arg3 = static_cast<int >(SWIG_As_int(obj1)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPrettyWkt(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToProj4(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_ExportToProj4",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_ExportToProj4(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToPCI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char **arg3 = (char **) 0 ; + double **arg4 ; + OGRErr result; + char *argout2 = 0 ; + char *argout3 = 0 ; + double *argout4 ; + PyObject * obj0 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + { + /* %typemap(in,numinputs=0) (char **argout3) */ + arg3 = &argout3; + } + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_ExportToPCI",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_ExportToPCI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg3 ) { + o = PyString_FromString( *arg3 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(argout) (double *argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( *arg4, 17 ); + resultobj = t_output_helper(resultobj,out); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg3 ) + CPLFree( *arg3 ); + } + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToUSGS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + double **arg4 ; + long *arg5 = (long *) 0 ; + OGRErr result; + long temp2 ; + int res2 = 0 ; + long temp3 ; + int res3 = 0 ; + double *argout4 ; + long temp5 ; + int res5 = 0 ; + PyObject * obj0 = 0 ; + + arg2 = &temp2; res2 = SWIG_NEWOBJ; + arg3 = &temp3; res3 = SWIG_NEWOBJ; + { + /* %typemap(in,numinputs=0) (double *argout4[ANY]) */ + arg4 = &argout4; + } + arg5 = &temp5; res5 = SWIG_NEWOBJ; + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_ExportToUSGS",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_ExportToUSGS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + resultobj = t_output_helper(resultobj, ((res2 == SWIG_NEWOBJ) ? + SWIG_From_long((*arg2)) : SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_long, 0))); + resultobj = t_output_helper(resultobj, ((res3 == SWIG_NEWOBJ) ? + SWIG_From_long((*arg3)) : SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_long, 0))); + { + /* %typemap(argout) (double *argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( *arg4, 15 ); + resultobj = t_output_helper(resultobj,out); + } + resultobj = t_output_helper(resultobj, ((res5 == SWIG_NEWOBJ) ? + SWIG_From_long((*arg5)) : SWIG_NewPointerObj((void*)(arg5), SWIGTYPE_p_long, 0))); + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (double *argout[ANY]) */ + CPLFree(*arg4); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_ExportToXML(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + OGRErr result; + char *argout2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + { + /* %typemap(in,numinputs=0) (char **argout2) */ + arg2 = &argout2; + } + if(!PyArg_ParseTuple(args,(char *)"O|O:SpatialReference_ExportToXML",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + if (obj1) { + if (!SWIG_AsCharPtr(obj1, (char**)&arg3)) { + SWIG_arg_fail(3);SWIG_fail; + } + } + result = (OGRErr)OSRSpatialReferenceShadow_ExportToXML(arg1,arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(argout) (char **argout) */ + PyObject *o; + if ( arg2 ) { + o = PyString_FromString( *arg2 ); + } + else { + o = Py_None; + Py_INCREF( o ); + } + resultobj = t_output_helper(resultobj, o); + } + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + { + /* %typemap(freearg) (char **argout) */ + if ( *arg2 ) + CPLFree( *arg2 ); + } + return NULL; +} + + +static PyObject *_wrap_SpatialReference_CloneGeogCS(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_CloneGeogCS",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OSRSpatialReferenceShadow *)OSRSpatialReferenceShadow_CloneGeogCS(arg1); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_Validate(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_Validate",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_Validate(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_StripCTParms(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_StripCTParms",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_StripCTParms(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_FixupOrdering(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_FixupOrdering",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_FixupOrdering(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_Fixup(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_Fixup",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_Fixup(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_MorphToESRI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_MorphToESRI",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_MorphToESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_SpatialReference_MorphFromESRI(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:SpatialReference_MorphFromESRI",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + result = (OGRErr)OSRSpatialReferenceShadow_MorphFromESRI(arg1); + + { + /* %typemap(out) OGRErr */ + if ( result != 0) { + PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) ); + SWIG_fail; + } + } + { + /* %typemap(ret) OGRErr */ + if (resultobj == Py_None ) { + Py_DECREF(resultobj); + resultobj = 0; + } + if (resultobj == 0) { + resultobj = PyInt_FromLong( 0 ); + } + } + return resultobj; + fail: + return NULL; +} + + +static PyObject * SpatialReference_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OSRSpatialReferenceShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyObject *_wrap_new_CoordinateTransformation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OSRCoordinateTransformationShadow *result; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:new_CoordinateTransformation",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + SWIG_Python_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_OSRSpatialReferenceShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(2)) SWIG_fail; + result = (OSRCoordinateTransformationShadow *)new_OSRCoordinateTransformationShadow(arg1,arg2); + + resultobj = SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_OSRCoordinateTransformationShadow, 1); + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_delete_CoordinateTransformation(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:delete_CoordinateTransformation",&obj0)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + delete_OSRCoordinateTransformationShadow(arg1); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_CoordinateTransformation_TransformPoint__SWIG_0(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double argin2[3] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OO:CoordinateTransformation_TransformPoint",&obj0,&obj1)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + /* %typemap(in) (double argin2[ANY]) */ + arg2 = argin2; + if (! PySequence_Check(obj1) ) { + PyErr_SetString(PyExc_TypeError, "not a sequence"); + SWIG_fail; + } + int seq_size = PySequence_Size(obj1); + if ( seq_size != 3 ) { + PyErr_SetString(PyExc_TypeError, "sequence must have length ##size"); + SWIG_fail; + } + for (unsigned int i=0; i<3; i++) { + PyObject *o = PySequence_GetItem(obj1,i); + double val; + PyArg_Parse(o, "d", &val ); + arg2[i] = val; + } + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(arg1,arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 3 ); + resultobj = t_output_helper(resultobj,out); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_CoordinateTransformation_TransformPoint__SWIG_1(PyObject *, PyObject *args) { + PyObject *resultobj = NULL; + OSRCoordinateTransformationShadow *arg1 = (OSRCoordinateTransformationShadow *) 0 ; + double *arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double argout2[3] ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if(!PyArg_ParseTuple(args,(char *)"OOO|O:CoordinateTransformation_TransformPoint",&obj0,&obj1,&obj2,&obj3)) goto fail; + SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_OSRCoordinateTransformationShadow, SWIG_POINTER_EXCEPTION | 0); + if (SWIG_arg_fail(1)) SWIG_fail; + { + arg3 = static_cast<double >(SWIG_As_double(obj1)); + if (SWIG_arg_fail(3)) SWIG_fail; + } + { + arg4 = static_cast<double >(SWIG_As_double(obj2)); + if (SWIG_arg_fail(4)) SWIG_fail; + } + if (obj3) { + { + arg5 = static_cast<double >(SWIG_As_double(obj3)); + if (SWIG_arg_fail(5)) SWIG_fail; + } + } + OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(arg1,arg2,arg3,arg4,arg5); + + Py_INCREF(Py_None); resultobj = Py_None; + { + /* %typemap(argout) (double argout[ANY]) */ + PyObject *out = CreateTupleFromDoubleArray( arg2, 3 ); + resultobj = t_output_helper(resultobj,out); + } + return resultobj; + fail: + return NULL; +} + + +static PyObject *_wrap_CoordinateTransformation_TransformPoint(PyObject *self, PyObject *args) { + int argc; + PyObject *argv[5]; + int ii; + + argc = PyObject_Length(args); + for (ii = 0; (ii < argc) && (ii < 4); ii++) { + argv[ii] = PyTuple_GetItem(args,ii); + } + if (argc == 2) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + { + void *ptr; + if (SWIG_ConvertPtr(argv[1], &ptr, SWIGTYPE_p_double, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_0(self,args); + } + } + } + if ((argc >= 3) && (argc <= 4)) { + int _v; + { + void *ptr; + if (SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_OSRCoordinateTransformationShadow, 0) == -1) { + _v = 0; + PyErr_Clear(); + } else { + _v = 1; + } + } + if (_v) { + _v = SWIG_Check_double(argv[1]); + if (_v) { + _v = SWIG_Check_double(argv[2]); + if (_v) { + if (argc <= 3) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_1(self,args); + } + _v = SWIG_Check_double(argv[3]); + if (_v) { + return _wrap_CoordinateTransformation_TransformPoint__SWIG_1(self,args); + } + } + } + } + } + + PyErr_SetString(PyExc_NotImplementedError,"No matching function for overloaded 'CoordinateTransformation_TransformPoint'"); + return NULL; +} + + +static PyObject * CoordinateTransformation_swigregister(PyObject *, PyObject *args) { + PyObject *obj; + if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; + SWIG_TypeClientData(SWIGTYPE_p_OSRCoordinateTransformationShadow, obj); + Py_INCREF(obj); + return Py_BuildValue((char *)""); +} +static PyMethodDef SwigMethods[] = { + { (char *)"GetProjectionMethods", py_OPTGetProjectionMethods, METH_VARARGS, NULL}, + { (char *)"GetWellKnownGeogCSAsWKT", _wrap_GetWellKnownGeogCSAsWKT, METH_VARARGS, NULL}, + { (char *)"new_SpatialReference", (PyCFunction) _wrap_new_SpatialReference, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"delete_SpatialReference", _wrap_delete_SpatialReference, METH_VARARGS, NULL}, + { (char *)"SpatialReference___str__", _wrap_SpatialReference___str__, METH_VARARGS, NULL}, + { (char *)"SpatialReference_IsSame", _wrap_SpatialReference_IsSame, METH_VARARGS, NULL}, + { (char *)"SpatialReference_IsSameGeogCS", _wrap_SpatialReference_IsSameGeogCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_IsGeographic", _wrap_SpatialReference_IsGeographic, METH_VARARGS, NULL}, + { (char *)"SpatialReference_IsProjected", _wrap_SpatialReference_IsProjected, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetAttrValue", _wrap_SpatialReference_GetAttrValue, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetAttrValue", _wrap_SpatialReference_SetAttrValue, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetAngularUnits", _wrap_SpatialReference_SetAngularUnits, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetAngularUnits", _wrap_SpatialReference_GetAngularUnits, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetLinearUnits", _wrap_SpatialReference_SetLinearUnits, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetLinearUnits", _wrap_SpatialReference_GetLinearUnits, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetLinearUnitsName", _wrap_SpatialReference_GetLinearUnitsName, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetAuthorityCode", _wrap_SpatialReference_GetAuthorityCode, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetAuthorityName", _wrap_SpatialReference_GetAuthorityName, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetUTM", _wrap_SpatialReference_SetUTM, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetStatePlane", _wrap_SpatialReference_SetStatePlane, METH_VARARGS, NULL}, + { (char *)"SpatialReference_AutoIdentifyEPSG", _wrap_SpatialReference_AutoIdentifyEPSG, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetProjection", _wrap_SpatialReference_SetProjection, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetProjParm", _wrap_SpatialReference_SetProjParm, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetProjParm", _wrap_SpatialReference_GetProjParm, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetNormProjParm", _wrap_SpatialReference_SetNormProjParm, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetNormProjParm", _wrap_SpatialReference_GetNormProjParm, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetACEA", _wrap_SpatialReference_SetACEA, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetAE", _wrap_SpatialReference_SetAE, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetCS", _wrap_SpatialReference_SetCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetBonne", _wrap_SpatialReference_SetBonne, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetEC", _wrap_SpatialReference_SetEC, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetEckertIV", _wrap_SpatialReference_SetEckertIV, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetEckertVI", _wrap_SpatialReference_SetEckertVI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetEquirectangular", _wrap_SpatialReference_SetEquirectangular, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetGS", (PyCFunction) _wrap_SpatialReference_SetGS, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"SpatialReference_SetWellKnownGeogCS", _wrap_SpatialReference_SetWellKnownGeogCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetFromUserInput", _wrap_SpatialReference_SetFromUserInput, METH_VARARGS, NULL}, + { (char *)"SpatialReference_CopyGeogCSFrom", _wrap_SpatialReference_CopyGeogCSFrom, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetTOWGS84", _wrap_SpatialReference_SetTOWGS84, METH_VARARGS, NULL}, + { (char *)"SpatialReference_GetTOWGS84", _wrap_SpatialReference_GetTOWGS84, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetGeogCS", _wrap_SpatialReference_SetGeogCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_SetProjCS", _wrap_SpatialReference_SetProjCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromWkt", _wrap_SpatialReference_ImportFromWkt, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromProj4", _wrap_SpatialReference_ImportFromProj4, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromESRI", _wrap_SpatialReference_ImportFromESRI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromEPSG", _wrap_SpatialReference_ImportFromEPSG, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromPCI", _wrap_SpatialReference_ImportFromPCI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromUSGS", _wrap_SpatialReference_ImportFromUSGS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ImportFromXML", _wrap_SpatialReference_ImportFromXML, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToWkt", _wrap_SpatialReference_ExportToWkt, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToPrettyWkt", _wrap_SpatialReference_ExportToPrettyWkt, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToProj4", _wrap_SpatialReference_ExportToProj4, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToPCI", _wrap_SpatialReference_ExportToPCI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToUSGS", _wrap_SpatialReference_ExportToUSGS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_ExportToXML", _wrap_SpatialReference_ExportToXML, METH_VARARGS, NULL}, + { (char *)"SpatialReference_CloneGeogCS", _wrap_SpatialReference_CloneGeogCS, METH_VARARGS, NULL}, + { (char *)"SpatialReference_Validate", _wrap_SpatialReference_Validate, METH_VARARGS, NULL}, + { (char *)"SpatialReference_StripCTParms", _wrap_SpatialReference_StripCTParms, METH_VARARGS, NULL}, + { (char *)"SpatialReference_FixupOrdering", _wrap_SpatialReference_FixupOrdering, METH_VARARGS, NULL}, + { (char *)"SpatialReference_Fixup", _wrap_SpatialReference_Fixup, METH_VARARGS, NULL}, + { (char *)"SpatialReference_MorphToESRI", _wrap_SpatialReference_MorphToESRI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_MorphFromESRI", _wrap_SpatialReference_MorphFromESRI, METH_VARARGS, NULL}, + { (char *)"SpatialReference_swigregister", SpatialReference_swigregister, METH_VARARGS, NULL}, + { (char *)"new_CoordinateTransformation", _wrap_new_CoordinateTransformation, METH_VARARGS, NULL}, + { (char *)"delete_CoordinateTransformation", _wrap_delete_CoordinateTransformation, METH_VARARGS, NULL}, + { (char *)"CoordinateTransformation_TransformPoint", _wrap_CoordinateTransformation_TransformPoint, METH_VARARGS, NULL}, + { (char *)"CoordinateTransformation_swigregister", CoordinateTransformation_swigregister, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|OGRErr *", 0, 0, 0}; +static swig_type_info _swigt__p_long = {"_p_long", "long *", 0, 0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, 0}; +static swig_type_info _swigt__p_p_double = {"_p_p_double", "double **", 0, 0, 0}; +static swig_type_info _swigt__ptrdiff_t = {"_ptrdiff_t", "ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__size_t = {"_size_t", "size_t", 0, 0, 0}; +static swig_type_info _swigt__std__ptrdiff_t = {"_std__ptrdiff_t", "std::ptrdiff_t", 0, 0, 0}; +static swig_type_info _swigt__std__size_t = {"_std__size_t", "std::size_t", 0, 0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_long, + &_swigt__p_p_char, + &_swigt__p_p_double, + &_swigt__ptrdiff_t, + &_swigt__size_t, + &_swigt__std__ptrdiff_t, + &_swigt__std__size_t, +}; + +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_double[] = { {&_swigt__p_p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__ptrdiff_t[] = { {&_swigt__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__size_t[] = { {&_swigt__size_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__ptrdiff_t[] = { {&_swigt__std__ptrdiff_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__std__size_t[] = { {&_swigt__std__size_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_long, + _swigc__p_p_char, + _swigc__p_p_double, + _swigc__ptrdiff_t, + _swigc__size_t, + _swigc__std__ptrdiff_t, + _swigc__std__size_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{ SWIG_PY_POINTER, (char*)"SRS_PT_ALBERS_CONIC_EQUAL_AREA", 0, 0, (void *)SRS_PT_ALBERS_CONIC_EQUAL_AREA, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_AZIMUTHAL_EQUIDISTANT", 0, 0, (void *)SRS_PT_AZIMUTHAL_EQUIDISTANT, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_CASSINI_SOLDNER", 0, 0, (void *)SRS_PT_CASSINI_SOLDNER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_CYLINDRICAL_EQUAL_AREA", 0, 0, (void *)SRS_PT_CYLINDRICAL_EQUAL_AREA, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_ECKERT_IV", 0, 0, (void *)SRS_PT_ECKERT_IV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_ECKERT_VI", 0, 0, (void *)SRS_PT_ECKERT_VI, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_EQUIDISTANT_CONIC", 0, 0, (void *)SRS_PT_EQUIDISTANT_CONIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_EQUIRECTANGULAR", 0, 0, (void *)SRS_PT_EQUIRECTANGULAR, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_GALL_STEREOGRAPHIC", 0, 0, (void *)SRS_PT_GALL_STEREOGRAPHIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_GNOMONIC", 0, 0, (void *)SRS_PT_GNOMONIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_GOODE_HOMOLOSINE", 0, 0, (void *)SRS_PT_GOODE_HOMOLOSINE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_HOTINE_OBLIQUE_MERCATOR", 0, 0, (void *)SRS_PT_HOTINE_OBLIQUE_MERCATOR, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN", 0, 0, (void *)SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_LABORDE_OBLIQUE_MERCATOR", 0, 0, (void *)SRS_PT_LABORDE_OBLIQUE_MERCATOR, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP", 0, 0, (void *)SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP", 0, 0, (void *)SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM", 0, 0, (void *)SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA", 0, 0, (void *)SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_MERCATOR_1SP", 0, 0, (void *)SRS_PT_MERCATOR_1SP, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_MERCATOR_2SP", 0, 0, (void *)SRS_PT_MERCATOR_2SP, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_MILLER_CYLINDRICAL", 0, 0, (void *)SRS_PT_MILLER_CYLINDRICAL, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_MOLLWEIDE", 0, 0, (void *)SRS_PT_MOLLWEIDE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_NEW_ZEALAND_MAP_GRID", 0, 0, (void *)SRS_PT_NEW_ZEALAND_MAP_GRID, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_OBLIQUE_STEREOGRAPHIC", 0, 0, (void *)SRS_PT_OBLIQUE_STEREOGRAPHIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_ORTHOGRAPHIC", 0, 0, (void *)SRS_PT_ORTHOGRAPHIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_POLAR_STEREOGRAPHIC", 0, 0, (void *)SRS_PT_POLAR_STEREOGRAPHIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_POLYCONIC", 0, 0, (void *)SRS_PT_POLYCONIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_ROBINSON", 0, 0, (void *)SRS_PT_ROBINSON, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_SINUSOIDAL", 0, 0, (void *)SRS_PT_SINUSOIDAL, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_STEREOGRAPHIC", 0, 0, (void *)SRS_PT_STEREOGRAPHIC, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_SWISS_OBLIQUE_CYLINDRICAL", 0, 0, (void *)SRS_PT_SWISS_OBLIQUE_CYLINDRICAL, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR_MI_22", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR_MI_22, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR_MI_23", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR_MI_23, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR_MI_24", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR_MI_24, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TRANSVERSE_MERCATOR_MI_25", 0, 0, (void *)SRS_PT_TRANSVERSE_MERCATOR_MI_25, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_TUNISIA_MINING_GRID", 0, 0, (void *)SRS_PT_TUNISIA_MINING_GRID, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_VANDERGRINTEN", 0, 0, (void *)SRS_PT_VANDERGRINTEN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PT_KROVAK", 0, 0, (void *)SRS_PT_KROVAK, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_CENTRAL_MERIDIAN", 0, 0, (void *)SRS_PP_CENTRAL_MERIDIAN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_SCALE_FACTOR", 0, 0, (void *)SRS_PP_SCALE_FACTOR, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_STANDARD_PARALLEL_1", 0, 0, (void *)SRS_PP_STANDARD_PARALLEL_1, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_STANDARD_PARALLEL_2", 0, 0, (void *)SRS_PP_STANDARD_PARALLEL_2, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_PSEUDO_STD_PARALLEL_1", 0, 0, (void *)SRS_PP_PSEUDO_STD_PARALLEL_1, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LONGITUDE_OF_CENTER", 0, 0, (void *)SRS_PP_LONGITUDE_OF_CENTER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LATITUDE_OF_CENTER", 0, 0, (void *)SRS_PP_LATITUDE_OF_CENTER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LONGITUDE_OF_ORIGIN", 0, 0, (void *)SRS_PP_LONGITUDE_OF_ORIGIN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LATITUDE_OF_ORIGIN", 0, 0, (void *)SRS_PP_LATITUDE_OF_ORIGIN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_FALSE_EASTING", 0, 0, (void *)SRS_PP_FALSE_EASTING, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_FALSE_NORTHING", 0, 0, (void *)SRS_PP_FALSE_NORTHING, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_AZIMUTH", 0, 0, (void *)SRS_PP_AZIMUTH, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LONGITUDE_OF_POINT_1", 0, 0, (void *)SRS_PP_LONGITUDE_OF_POINT_1, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LATITUDE_OF_POINT_1", 0, 0, (void *)SRS_PP_LATITUDE_OF_POINT_1, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LONGITUDE_OF_POINT_2", 0, 0, (void *)SRS_PP_LONGITUDE_OF_POINT_2, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LATITUDE_OF_POINT_2", 0, 0, (void *)SRS_PP_LATITUDE_OF_POINT_2, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LONGITUDE_OF_POINT_3", 0, 0, (void *)SRS_PP_LONGITUDE_OF_POINT_3, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LATITUDE_OF_POINT_3", 0, 0, (void *)SRS_PP_LATITUDE_OF_POINT_3, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_RECTIFIED_GRID_ANGLE", 0, 0, (void *)SRS_PP_RECTIFIED_GRID_ANGLE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_LANDSAT_NUMBER", 0, 0, (void *)SRS_PP_LANDSAT_NUMBER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_PATH_NUMBER", 0, 0, (void *)SRS_PP_PATH_NUMBER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_PERSPECTIVE_POINT_HEIGHT", 0, 0, (void *)SRS_PP_PERSPECTIVE_POINT_HEIGHT, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_FIPSZONE", 0, 0, (void *)SRS_PP_FIPSZONE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_PP_ZONE", 0, 0, (void *)SRS_PP_ZONE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_METER", 0, 0, (void *)SRS_UL_METER, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_FOOT", 0, 0, (void *)SRS_UL_FOOT, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_FOOT_CONV", 0, 0, (void *)SRS_UL_FOOT_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_US_FOOT", 0, 0, (void *)SRS_UL_US_FOOT, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_US_FOOT_CONV", 0, 0, (void *)SRS_UL_US_FOOT_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_NAUTICAL_MILE", 0, 0, (void *)SRS_UL_NAUTICAL_MILE, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_NAUTICAL_MILE_CONV", 0, 0, (void *)SRS_UL_NAUTICAL_MILE_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_LINK", 0, 0, (void *)SRS_UL_LINK, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_LINK_CONV", 0, 0, (void *)SRS_UL_LINK_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_CHAIN", 0, 0, (void *)SRS_UL_CHAIN, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_CHAIN_CONV", 0, 0, (void *)SRS_UL_CHAIN_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_ROD", 0, 0, (void *)SRS_UL_ROD, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_UL_ROD_CONV", 0, 0, (void *)SRS_UL_ROD_CONV, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_DN_NAD27", 0, 0, (void *)SRS_DN_NAD27, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_DN_NAD83", 0, 0, (void *)SRS_DN_NAD83, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_DN_WGS72", 0, 0, (void *)SRS_DN_WGS72, &SWIGTYPE_p_char}, +{ SWIG_PY_POINTER, (char*)"SRS_DN_WGS84", 0, 0, (void *)SRS_DN_WGS84, &SWIGTYPE_p_char}, +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + + SWIGRUNTIME void + SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + } + + /* This function will propagate the clientdata field of type to + * any new swig_type_info structures that have been added into the list + * of equivalent types. It is like calling + * SWIG_TypeClientData(type, clientdata) a second time. + */ + SWIGRUNTIME void + SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } + } + +#ifdef __cplusplus +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *v) { + v = v; + return PyString_FromString("<Swig global variables>"); + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { + swig_globalvar *var; + flags = flags; + fprintf(fp,"Swig global variables { "); + for (var = v->vars; var; var=var->next) { + fprintf(fp,"%s", var->name); + if (var->next) fprintf(fp,", "); + } + fprintf(fp," }\n"); + return 0; + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->get_attr)(); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return NULL; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + return (*var->set_attr)(p); + } + var = var->next; + } + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + return 1; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type +#if !defined(__cplusplus) + ; + static int type_init = 0; + if (!type_init) { + PyTypeObject tmp +#endif + = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + 0, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ +#if PY_VERSION_HEX >= 0x02000000 + 0, /* tp_traverse */ + 0, /* tp_clear */ +#endif +#if PY_VERSION_HEX >= 0x02010000 + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#endif +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; +#if !defined(__cplusplus) + varlink_type = tmp; + type_init = 1; + } +#endif + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_INT: + obj = PyInt_FromLong(constants[i].lvalue); + break; + case SWIG_PY_FLOAT: + obj = PyFloat_FromDouble(constants[i].dvalue); + break; + case SWIG_PY_STRING: + if (constants[i].pvalue) { + obj = PyString_FromString((char *) constants[i].pvalue); + } else { + Py_INCREF(Py_None); + obj = Py_None; + } + break; + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d,constants[i].name,obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* -----------------------------------------------------------------------------* + * Initialize type list + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + static PyObject *SWIG_globals = 0; + PyObject *m, *d; + if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + PyDict_SetItemString(d,"SRS_PT_ALBERS_CONIC_EQUAL_AREA", SWIG_FromCharPtr(SRS_PT_ALBERS_CONIC_EQUAL_AREA)); + PyDict_SetItemString(d,"SRS_PT_AZIMUTHAL_EQUIDISTANT", SWIG_FromCharPtr(SRS_PT_AZIMUTHAL_EQUIDISTANT)); + PyDict_SetItemString(d,"SRS_PT_CASSINI_SOLDNER", SWIG_FromCharPtr(SRS_PT_CASSINI_SOLDNER)); + PyDict_SetItemString(d,"SRS_PT_CYLINDRICAL_EQUAL_AREA", SWIG_FromCharPtr(SRS_PT_CYLINDRICAL_EQUAL_AREA)); + PyDict_SetItemString(d,"SRS_PT_ECKERT_IV", SWIG_FromCharPtr(SRS_PT_ECKERT_IV)); + PyDict_SetItemString(d,"SRS_PT_ECKERT_VI", SWIG_FromCharPtr(SRS_PT_ECKERT_VI)); + PyDict_SetItemString(d,"SRS_PT_EQUIDISTANT_CONIC", SWIG_FromCharPtr(SRS_PT_EQUIDISTANT_CONIC)); + PyDict_SetItemString(d,"SRS_PT_EQUIRECTANGULAR", SWIG_FromCharPtr(SRS_PT_EQUIRECTANGULAR)); + PyDict_SetItemString(d,"SRS_PT_GALL_STEREOGRAPHIC", SWIG_FromCharPtr(SRS_PT_GALL_STEREOGRAPHIC)); + PyDict_SetItemString(d,"SRS_PT_GNOMONIC", SWIG_FromCharPtr(SRS_PT_GNOMONIC)); + PyDict_SetItemString(d,"SRS_PT_GOODE_HOMOLOSINE", SWIG_FromCharPtr(SRS_PT_GOODE_HOMOLOSINE)); + PyDict_SetItemString(d,"SRS_PT_HOTINE_OBLIQUE_MERCATOR", SWIG_FromCharPtr(SRS_PT_HOTINE_OBLIQUE_MERCATOR)); + PyDict_SetItemString(d,"SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN", SWIG_FromCharPtr(SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN)); + PyDict_SetItemString(d,"SRS_PT_LABORDE_OBLIQUE_MERCATOR", SWIG_FromCharPtr(SRS_PT_LABORDE_OBLIQUE_MERCATOR)); + PyDict_SetItemString(d,"SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP", SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP)); + PyDict_SetItemString(d,"SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP", SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP)); + PyDict_SetItemString(d,"SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM", SWIG_FromCharPtr(SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM)); + PyDict_SetItemString(d,"SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA", SWIG_FromCharPtr(SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA)); + PyDict_SetItemString(d,"SRS_PT_MERCATOR_1SP", SWIG_FromCharPtr(SRS_PT_MERCATOR_1SP)); + PyDict_SetItemString(d,"SRS_PT_MERCATOR_2SP", SWIG_FromCharPtr(SRS_PT_MERCATOR_2SP)); + PyDict_SetItemString(d,"SRS_PT_MILLER_CYLINDRICAL", SWIG_FromCharPtr(SRS_PT_MILLER_CYLINDRICAL)); + PyDict_SetItemString(d,"SRS_PT_MOLLWEIDE", SWIG_FromCharPtr(SRS_PT_MOLLWEIDE)); + PyDict_SetItemString(d,"SRS_PT_NEW_ZEALAND_MAP_GRID", SWIG_FromCharPtr(SRS_PT_NEW_ZEALAND_MAP_GRID)); + PyDict_SetItemString(d,"SRS_PT_OBLIQUE_STEREOGRAPHIC", SWIG_FromCharPtr(SRS_PT_OBLIQUE_STEREOGRAPHIC)); + PyDict_SetItemString(d,"SRS_PT_ORTHOGRAPHIC", SWIG_FromCharPtr(SRS_PT_ORTHOGRAPHIC)); + PyDict_SetItemString(d,"SRS_PT_POLAR_STEREOGRAPHIC", SWIG_FromCharPtr(SRS_PT_POLAR_STEREOGRAPHIC)); + PyDict_SetItemString(d,"SRS_PT_POLYCONIC", SWIG_FromCharPtr(SRS_PT_POLYCONIC)); + PyDict_SetItemString(d,"SRS_PT_ROBINSON", SWIG_FromCharPtr(SRS_PT_ROBINSON)); + PyDict_SetItemString(d,"SRS_PT_SINUSOIDAL", SWIG_FromCharPtr(SRS_PT_SINUSOIDAL)); + PyDict_SetItemString(d,"SRS_PT_STEREOGRAPHIC", SWIG_FromCharPtr(SRS_PT_STEREOGRAPHIC)); + PyDict_SetItemString(d,"SRS_PT_SWISS_OBLIQUE_CYLINDRICAL", SWIG_FromCharPtr(SRS_PT_SWISS_OBLIQUE_CYLINDRICAL)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_SOUTH_ORIENTED)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR_MI_22", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_22)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR_MI_23", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_23)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR_MI_24", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_24)); + PyDict_SetItemString(d,"SRS_PT_TRANSVERSE_MERCATOR_MI_25", SWIG_FromCharPtr(SRS_PT_TRANSVERSE_MERCATOR_MI_25)); + PyDict_SetItemString(d,"SRS_PT_TUNISIA_MINING_GRID", SWIG_FromCharPtr(SRS_PT_TUNISIA_MINING_GRID)); + PyDict_SetItemString(d,"SRS_PT_VANDERGRINTEN", SWIG_FromCharPtr(SRS_PT_VANDERGRINTEN)); + PyDict_SetItemString(d,"SRS_PT_KROVAK", SWIG_FromCharPtr(SRS_PT_KROVAK)); + PyDict_SetItemString(d,"SRS_PP_CENTRAL_MERIDIAN", SWIG_FromCharPtr(SRS_PP_CENTRAL_MERIDIAN)); + PyDict_SetItemString(d,"SRS_PP_SCALE_FACTOR", SWIG_FromCharPtr(SRS_PP_SCALE_FACTOR)); + PyDict_SetItemString(d,"SRS_PP_STANDARD_PARALLEL_1", SWIG_FromCharPtr(SRS_PP_STANDARD_PARALLEL_1)); + PyDict_SetItemString(d,"SRS_PP_STANDARD_PARALLEL_2", SWIG_FromCharPtr(SRS_PP_STANDARD_PARALLEL_2)); + PyDict_SetItemString(d,"SRS_PP_PSEUDO_STD_PARALLEL_1", SWIG_FromCharPtr(SRS_PP_PSEUDO_STD_PARALLEL_1)); + PyDict_SetItemString(d,"SRS_PP_LONGITUDE_OF_CENTER", SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_CENTER)); + PyDict_SetItemString(d,"SRS_PP_LATITUDE_OF_CENTER", SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_CENTER)); + PyDict_SetItemString(d,"SRS_PP_LONGITUDE_OF_ORIGIN", SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_ORIGIN)); + PyDict_SetItemString(d,"SRS_PP_LATITUDE_OF_ORIGIN", SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_ORIGIN)); + PyDict_SetItemString(d,"SRS_PP_FALSE_EASTING", SWIG_FromCharPtr(SRS_PP_FALSE_EASTING)); + PyDict_SetItemString(d,"SRS_PP_FALSE_NORTHING", SWIG_FromCharPtr(SRS_PP_FALSE_NORTHING)); + PyDict_SetItemString(d,"SRS_PP_AZIMUTH", SWIG_FromCharPtr(SRS_PP_AZIMUTH)); + PyDict_SetItemString(d,"SRS_PP_LONGITUDE_OF_POINT_1", SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_1)); + PyDict_SetItemString(d,"SRS_PP_LATITUDE_OF_POINT_1", SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_1)); + PyDict_SetItemString(d,"SRS_PP_LONGITUDE_OF_POINT_2", SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_2)); + PyDict_SetItemString(d,"SRS_PP_LATITUDE_OF_POINT_2", SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_2)); + PyDict_SetItemString(d,"SRS_PP_LONGITUDE_OF_POINT_3", SWIG_FromCharPtr(SRS_PP_LONGITUDE_OF_POINT_3)); + PyDict_SetItemString(d,"SRS_PP_LATITUDE_OF_POINT_3", SWIG_FromCharPtr(SRS_PP_LATITUDE_OF_POINT_3)); + PyDict_SetItemString(d,"SRS_PP_RECTIFIED_GRID_ANGLE", SWIG_FromCharPtr(SRS_PP_RECTIFIED_GRID_ANGLE)); + PyDict_SetItemString(d,"SRS_PP_LANDSAT_NUMBER", SWIG_FromCharPtr(SRS_PP_LANDSAT_NUMBER)); + PyDict_SetItemString(d,"SRS_PP_PATH_NUMBER", SWIG_FromCharPtr(SRS_PP_PATH_NUMBER)); + PyDict_SetItemString(d,"SRS_PP_PERSPECTIVE_POINT_HEIGHT", SWIG_FromCharPtr(SRS_PP_PERSPECTIVE_POINT_HEIGHT)); + PyDict_SetItemString(d,"SRS_PP_FIPSZONE", SWIG_FromCharPtr(SRS_PP_FIPSZONE)); + PyDict_SetItemString(d,"SRS_PP_ZONE", SWIG_FromCharPtr(SRS_PP_ZONE)); + PyDict_SetItemString(d,"SRS_UL_METER", SWIG_FromCharPtr(SRS_UL_METER)); + PyDict_SetItemString(d,"SRS_UL_FOOT", SWIG_FromCharPtr(SRS_UL_FOOT)); + PyDict_SetItemString(d,"SRS_UL_FOOT_CONV", SWIG_FromCharPtr(SRS_UL_FOOT_CONV)); + PyDict_SetItemString(d,"SRS_UL_US_FOOT", SWIG_FromCharPtr(SRS_UL_US_FOOT)); + PyDict_SetItemString(d,"SRS_UL_US_FOOT_CONV", SWIG_FromCharPtr(SRS_UL_US_FOOT_CONV)); + PyDict_SetItemString(d,"SRS_UL_NAUTICAL_MILE", SWIG_FromCharPtr(SRS_UL_NAUTICAL_MILE)); + PyDict_SetItemString(d,"SRS_UL_NAUTICAL_MILE_CONV", SWIG_FromCharPtr(SRS_UL_NAUTICAL_MILE_CONV)); + PyDict_SetItemString(d,"SRS_UL_LINK", SWIG_FromCharPtr(SRS_UL_LINK)); + PyDict_SetItemString(d,"SRS_UL_LINK_CONV", SWIG_FromCharPtr(SRS_UL_LINK_CONV)); + PyDict_SetItemString(d,"SRS_UL_CHAIN", SWIG_FromCharPtr(SRS_UL_CHAIN)); + PyDict_SetItemString(d,"SRS_UL_CHAIN_CONV", SWIG_FromCharPtr(SRS_UL_CHAIN_CONV)); + PyDict_SetItemString(d,"SRS_UL_ROD", SWIG_FromCharPtr(SRS_UL_ROD)); + PyDict_SetItemString(d,"SRS_UL_ROD_CONV", SWIG_FromCharPtr(SRS_UL_ROD_CONV)); + PyDict_SetItemString(d,"SRS_DN_NAD27", SWIG_FromCharPtr(SRS_DN_NAD27)); + PyDict_SetItemString(d,"SRS_DN_NAD83", SWIG_FromCharPtr(SRS_DN_NAD83)); + PyDict_SetItemString(d,"SRS_DN_WGS72", SWIG_FromCharPtr(SRS_DN_WGS72)); + PyDict_SetItemString(d,"SRS_DN_WGS84", SWIG_FromCharPtr(SRS_DN_WGS84)); + { + PyDict_SetItemString(d,"SRS_WGS84_SEMIMAJOR", SWIG_From_double(static_cast<double >(SRS_WGS84_SEMIMAJOR))); + } + { + PyDict_SetItemString(d,"SRS_WGS84_INVFLATTENING", SWIG_From_double(static_cast<double >(SRS_WGS84_INVFLATTENING))); + } +} + diff --git a/Utilities/GDAL/swig/python/setup.py b/Utilities/GDAL/swig/python/setup.py new file mode 100644 index 0000000000..ce64400ef1 --- /dev/null +++ b/Utilities/GDAL/swig/python/setup.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python + +import sys +import os +import string + +from os import path +from glob import glob +from distutils.core import setup, Extension +from distutils.sysconfig import parse_makefile,expand_makefile_vars + +from distutils.core import setup, Extension + +# Function needed to make unique lists. +def unique(list): + """Stolen from MapScript setup script""" + dict = {} + for item in list: + dict[item] = '' + return dict.keys() + + +include_dirs = ['../../port', + '../../gcore', + '../../alg', + '../../ogr'] + + +# Put your build libraries and lib link directories here +# These *must* match what is in nmake.opt. We could get +# fancier here and parse the nmake.opt for lib files in the future. +if sys.platform == 'win32': + # Created by the GDAL build process. + # This was swiped from MapServer + setupvars = "../setup.ini" + + # Open and read lines from setup.ini. + try: + fp = open(setupvars, "r") + except IOError, e: + raise IOError, '%s. %s' % (e, "Has GDAL been made?") + gdal_basedir = fp.readline() + gdal_version = fp.readline() + gdal_libs = fp.readline() + gdal_includes = fp.readline() + lib_opts = gdal_libs.split() + library_dirs = [x[2:] for x in lib_opts if x[:2] == "-L"] + library_dirs = unique(library_dirs) + library_dirs = library_dirs + gdal_basedir.split() + libraries = [] + extras = [] + + for x in lib_opts: + if x[:2] == '-l': + libraries.append( x[2:] ) + if x[-4:] == '.lib' or x[-4:] == '.LIB': + dir, lib = os.path.split(x) + libraries.append( lib[:-4] ) + if len(dir) > 0: + library_dirs.append( dir ) + if x[-2:] == '.a': + extras.append(x) + + # don't forget to add gdal to the list :) + libraries.append('gdal_i') + extra_link_args = []#['/NODEFAULTLIB:MSVCRT'] + +elif sys.platform == 'cygwin': + TOP_DIR = "../.." + + DICT = parse_makefile(os.path.join(TOP_DIR,"GDALMake.opt")) + + library_dirs = [TOP_DIR+"/","./"] + prefix = string.split(DICT[expand_makefile_vars("prefix",DICT)])[0] + prefix_lib = prefix + "/lib" + library_dirs.append(prefix_lib) + + extra_link_args = [] + + print "\nLIBRARY_DIRS:\n\t",library_dirs + + libraries = ["gdal"] + gdal_libs = ["LIBS","PG_LIB","MYSQL_LIB"] + for gdal_lib in gdal_libs: + for lib in string.split(DICT[expand_makefile_vars(gdal_lib,DICT)]): + if lib[0:2] == "-l": + libraries.append(lib[2:]) + libraries.append("stdc++") + + print "\nLIBRARIES:\n\t",libraries + + include_dirs=[path.join(TOP_DIR,"gcore"), path.join(TOP_DIR,"port"), + path.join(TOP_DIR,"ogr"), path.join(TOP_DIR,"pymod"), ] # only necessary + + include_files = [ + glob(path.join(TOP_DIR,"gcore", "*.h")), + glob(path.join(TOP_DIR,"port", "*.h")), + glob(path.join(TOP_DIR,"alg", "*.h")), + glob(path.join(TOP_DIR,"ogr", "*.h")), + glob(path.join(TOP_DIR,"ogr", "ogrsf_frmts", "*.h")) + ] + + IF=[] + for i in include_files: + IF.extend(i) + include_files=IF + del IF + + print "\nINCLUDE_FILES:",include_files +else: + libraries = ['gdal'] + library_dirs = ['../../', '../../.libs'] + extra_link_args = [] + + +gdal_module = Extension('_gdal', + sources=['gdal_wrap.cpp'], + include_dirs = include_dirs, + libraries = libraries, + library_dirs = library_dirs, + extra_link_args = extra_link_args) + +gdalconst_module = Extension('_gdalconst', + sources=['gdalconst_wrap.c'], + include_dirs = include_dirs, + libraries = libraries, + library_dirs = library_dirs, + extra_link_args = extra_link_args) + +osr_module = Extension('_osr', + sources=['osr_wrap.cpp'], + include_dirs = include_dirs, + libraries = libraries, + library_dirs = library_dirs, + extra_link_args = extra_link_args) + +ogr_module = Extension('_ogr', + sources=['ogr_wrap.cpp'], + include_dirs = include_dirs, + libraries = libraries, + library_dirs = library_dirs, + extra_link_args = extra_link_args) + + +setup( name = 'Gdal Wrapper', + version = 'ng using swig 1.3', + description = 'Swig 1.3 wrapper over gdal', + py_modules = ['gdal', 'osr', 'ogr','gdalconst'], + url="http://www.gdal.org", + ext_modules = [gdal_module, + gdalconst_module, + osr_module, + ogr_module],debug=1 ) diff --git a/Utilities/GDAL/swig/ruby/.cvsignore b/Utilities/GDAL/swig/ruby/.cvsignore new file mode 100644 index 0000000000..4beb3af18f --- /dev/null +++ b/Utilities/GDAL/swig/ruby/.cvsignore @@ -0,0 +1,9 @@ +*.lo +*.so +*.obj +*.o +*.pdb +*.ilk +*.lib +*.exp +*.libs diff --git a/Utilities/GDAL/swig/ruby/GNUmakefile b/Utilities/GDAL/swig/ruby/GNUmakefile new file mode 100644 index 0000000000..4d3f60bbd4 --- /dev/null +++ b/Utilities/GDAL/swig/ruby/GNUmakefile @@ -0,0 +1,26 @@ + + +include ../../GDALmake.opt + +all: build + +BINDING = ruby +include ../SWIGmake.base + +# Add -prefix "Gdal::" to SWIGARGS +SWIGARGS += -autorename -prefix "gdal::" + +clean: + $(MAKE) -f RubyMakefile.mk clean + +veryclean: clean + rm -f $(WRAPPERS) + $(MAKE) -f RubyMakefile.mk veryclean + +generate: ${WRAPPERS} + +build: ${WRAPPERS} + $(MAKE) -f RubyMakefile.mk build + +install: + $(MAKE) -f RubyMakefile.mk install diff --git a/Utilities/GDAL/swig/ruby/RubyMakefile.mk b/Utilities/GDAL/swig/ruby/RubyMakefile.mk new file mode 100644 index 0000000000..1f1e8fb72e --- /dev/null +++ b/Utilities/GDAL/swig/ruby/RubyMakefile.mk @@ -0,0 +1,57 @@ +# This makefile generates 4 Ruby extensions - one each for +# gdal, ogr, osr, and gdalconstants. There are two important +# things to note: +# +# * It makes multiple calls to Ruby to discover the Ruby version, +# location of header files, libraries, etc. Thus Ruby must +# be on your path. +# +# * By convention Ruby method names are lower case with underscores, +# thus methods such as "GetFieldName" need to be mapped to +# "get_field_name." This is done by running the separate +# RenamesMakefile.mk script. + +BINDING = ruby +GDAL_ROOT = ../.. +RUBY = ruby + +include $(GDAL_ROOT)/GDALmake.opt + +RUBY_MODULES = gdal.so ogr.so gdalconst.so osr.so +RUBY_INCLUDE_DIR := $(shell ruby -rrbconfig -e "puts Config::CONFIG['archdir']") +RUBY_LIB_DIR := $(shell ruby -rrbconfig -e "puts Config::CONFIG['libdir']") +RUBY_SO_NAME := $(shell ruby -rrbconfig -e "puts Config::CONFIG['RUBY_SO_NAME']") +RUBY_EXTENSIONS_DIR := $(shell ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']") +INSTALL_DIR := $(RUBY_EXTENSIONS_DIR)/gdal + +RUBY_INCLUDE = -I$(RUBY_INCLUDE_DIR) +LDFLAGS += -shared -L$(RUBY_LIB_DIR) +RUBY_LIB := -l$(RUBY_SO_NAME) + +build: $(RUBY_MODULES) + +clean: + rm -f *.so + rm -f *.o + rm -f *.lo + +veryclean: clean + rm -frd $(INSTALL_DIR) + +$(INSTALL_DIR): + mkdir -v $(INSTALL_DIR) + +install: $(INSTALL_DIR) + $(INSTALL) $(RUBY_MODULES) $(INSTALL_DIR) + +$(RUBY_MODULES): %.so: %_wrap.o + $(LD) $(LDFLAGS) $(LIBS) $(GDAL_SLIB_LINK) $(RUBY_LIB) $< -o $@ + +%.o: %.cpp + $(CXX) $(CFLAGS) $(GDAL_INCLUDE) $(RUBY_INCLUDE) -c $< + +%.o: %.cxx + $(CXX) $(CFLAGS) $(GDAL_INCLUDE) $(RUBY_INCLUDE) -c $< + +%.o: %.c + $(CC) $(CFLAGS) $(GDAL_INCLUDE) $(RUBY_INCLUDE) -c $< diff --git a/Utilities/GDAL/swig/ruby/gdal_wrap.cpp b/Utilities/GDAL/swig/ruby/gdal_wrap.cpp new file mode 100644 index 0000000000..3d4e8de9a8 --- /dev/null +++ b/Utilities/GDAL/swig/ruby/gdal_wrap.cpp @@ -0,0 +1,8731 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.28 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGRUBY + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#define SWIG_ObjectPreviouslyDeletedError -100 + + +#include <ruby.h> + +/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ +#ifndef NUM2LL +#define NUM2LL(x) NUM2LONG((x)) +#endif +#ifndef LL2NUM +#define LL2NUM(x) INT2NUM((long) (x)) +#endif +#ifndef ULL2NUM +#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) +#endif + +/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ +#ifndef NUM2ULL +#ifdef HAVE_LONG_LONG +#define NUM2ULL(x) rb_num2ull((x)) +#else +#define NUM2ULL(x) NUM2ULONG(x) +#endif +#endif + +/* + * Need to be very careful about how these macros are defined, especially + * when compiling C++ code or C code with an ANSI C compiler. + * + * VALUEFUNC(f) is a macro used to typecast a C function that implements + * a Ruby method so that it can be passed as an argument to API functions + * like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is a macro used to typecast a C function that implements + * either the "mark" or "free" stuff for a Ruby Data object, so that it + * can be passed as an argument to API functions like Data_Wrap_Struct() + * and Data_Make_Struct(). + */ + +#ifdef __cplusplus +# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((void (*)()) f) +# else +# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# endif +# endif +#else +# define VALUEFUNC(f) (f) +# define VOIDFUNC(f) (f) +#endif + +/* Don't use for expressions have side effect */ +#ifndef RB_STRING_VALUE +#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) +#endif +#ifndef StringValue +#define StringValue(s) RB_STRING_VALUE(s) +#endif +#ifndef StringValuePtr +#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr +#endif +#ifndef StringValueLen +#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len +#endif +#ifndef SafeStringValue +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_str(v);\ +} while (0) +#endif + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubytracking.swg + * + * This file contains support for tracking mappings from + * Ruby objects to C++ objects. This functionality is needed + * to implement mark functions for Ruby's mark and sweep + * garbage collector. + ************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Global Ruby hash table to store Trackings from C/C++ + structs to Ruby Objects. */ +static VALUE swig_ruby_trackings; + +/* Global variable that stores a reference to the ruby + hash table delete function. */ +static ID swig_ruby_hash_delete = 0; + +/* Setup a Ruby hash table to store Trackings */ +SWIGRUNTIME void SWIG_RubyInitializeTrackings() { + /* Create a ruby hash table to store Trackings from C++ + objects to Ruby objects. Also make sure to tell + the garabage collector about the hash table. */ + swig_ruby_trackings = rb_hash_new(); + rb_gc_register_address(&swig_ruby_trackings); + + /* Now store a reference to the hash table delete function + so that we only have to look it up once.*/ + swig_ruby_hash_delete = rb_intern("delete"); +} + +/* Get a Ruby number to reference a pointer */ +SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { + /* We cast the pointer to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the pointer to a Ruby number */ + unsigned long value = (unsigned long) ptr; + return LONG2NUM(value); +} + +/* Get a Ruby number to reference an object */ +SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { + /* We cast the object to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the Object to a Ruby number */ + unsigned long value = (unsigned long) object; + return LONG2NUM(value); +} + +/* Get a Ruby object from a previously stored reference */ +SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { + /* The provided Ruby number object is a reference + to the Ruby object we want.*/ + + /* First convert the Ruby number to a C number */ + unsigned long value = NUM2LONG(reference); + return (VALUE) value; +} + +/* Add a Tracking from a C/C++ struct to a Ruby object */ +SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { + /* In a Ruby hash table we store the pointer and + the associated Ruby object. The trick here is + that we cannot store the Ruby object directly - if + we do then it cannot be garbage collected. So + instead we typecast it as a unsigned long and + convert it to a Ruby number object.*/ + + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Get a reference to the Ruby object as a Ruby number */ + VALUE value = SWIG_RubyObjectToReference(object); + + /* Store the mapping to the global hash table. */ + rb_hash_aset(swig_ruby_trackings, key, value); +} + +/* Get the Ruby object that owns the specified C/C++ struct */ +SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Now lookup the value stored in the global hash table */ + VALUE value = rb_hash_aref(swig_ruby_trackings, key); + + if (value == Qnil) { + /* No object exists - return nil. */ + return Qnil; + } + else { + /* Convert this value to Ruby object */ + return SWIG_RubyReferenceToObject(value); + } +} + +/* Remove a Tracking from a C/C++ struct to a Ruby object. It + is very important to remove objects once they are destroyed + since the same memory address may be reused later to create + a new object. */ +SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Delete the object from the hash table by calling Ruby's + do this we need to call the Hash.delete method.*/ + rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); +} + +/* This is a helper method that unlinks a Ruby object from its + underlying C++ object. This is needed if the lifetime of the + Ruby object is longer than the C++ object */ +SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { + DATA_PTR(object) = 0; + } +} + + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubyrun.swg + * + * This file contains the runtime support for Ruby modules + * and includes code for managing global variables and pointer + * type checking. + * + ************************************************************************/ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) +#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) +#define swig_owntype ruby_owntype + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Ruby-specific SWIG API */ + +#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() +#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) +#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) +#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) +#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +typedef struct { + VALUE klass; + VALUE mImpl; + void (*mark)(void *); + void (*destroy)(void *); + int trackObjects; +} swig_class; + + +static VALUE _mSWIG = Qnil; +static VALUE _cSWIG_Pointer = Qnil; +static VALUE swig_runtime_data_type_pointer = Qnil; + +/* Initialize Ruby runtime support */ +SWIGRUNTIME void +SWIG_Ruby_InitRuntime(void) +{ + if (_mSWIG == Qnil) { + _mSWIG = rb_define_module("SWIG"); + } +} + +/* Define Ruby class for C type */ +SWIGRUNTIME void +SWIG_Ruby_define_class(swig_type_info *type) +{ + VALUE klass; + char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + if (NIL_P(_cSWIG_Pointer)) { + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } + klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + free((void *) klass_name); +} + +/* Create a new pointer object */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) +{ + int own = flags & SWIG_POINTER_OWN; + + char *klass_name; + swig_class *sklass; + VALUE klass; + VALUE obj; + + if (!ptr) + return Qnil; + + if (type->clientdata) { + sklass = (swig_class *) type->clientdata; + + /* Are we tracking this class and have we already returned this Ruby object? */ + if (sklass->trackObjects) { + obj = SWIG_RubyInstanceFor(ptr); + if (obj != Qnil) { + return obj; + } + } + + /* Create a new Ruby object */ + obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), (own ? VOIDFUNC(sklass->destroy) : 0), ptr); + + /* If tracking is on for this class then track this object. */ + if (sklass->trackObjects) { + SWIG_RubyAddTracking(ptr, obj); + } + } else { + klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + klass = rb_const_get(_mSWIG, rb_intern(klass_name)); + free((void *) klass_name); + obj = Data_Wrap_Struct(klass, 0, 0, ptr); + } + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + + return obj; +} + +/* Create a new class instance (always owned) */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) +{ + VALUE obj; + swig_class *sklass = (swig_class *) type->clientdata; + obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + return obj; +} + +/* Get type mangle from class name */ +SWIGRUNTIMEINLINE char * +SWIG_Ruby_MangleStr(VALUE obj) +{ + VALUE stype = rb_iv_get(obj, "__swigtype__"); + return StringValuePtr(stype); +} + +/* Acquire a pointer value */ +typedef void (*ruby_owntype)(void*); + +SWIGRUNTIME ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { + if (obj) { + ruby_owntype oldown = RDATA(obj)->dfree; + RDATA(obj)->dfree = own; + return oldown; + } else { + return 0; + } +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +{ + char *c; + swig_cast_info *tc; + void *vptr = 0; + + /* Grab the pointer */ + if (NIL_P(obj)) { + *ptr = 0; + return SWIG_OK; + } else { + if (TYPE(obj) != T_DATA) { + return SWIG_ERROR; + } + Data_Get_Struct(obj, void, vptr); + } + + if (own) *own = RDATA(obj)->dfree; + + /* Check to see if the input object is giving up ownership + of the underlying C struct or C++ object. If so then we + need to reset the destructor since the Ruby object no + longer owns the underlying C++ object.*/ + if (flags & SWIG_POINTER_DISOWN) { + /* Is tracking on for this class? */ + int track = 0; + if (ty && ty->clientdata) { + swig_class *sklass = (swig_class *) ty->clientdata; + track = sklass->trackObjects; + } + + if (track) { + /* We are tracking objects for this class. Thus we change the destructor + * to SWIG_RubyRemoveTracking. This allows us to + * remove the mapping from the C++ to Ruby object + * when the Ruby object is garbage collected. If we don't + * do this, then it is possible we will return a reference + * to a Ruby object that no longer exists thereby crashing Ruby. */ + RDATA(obj)->dfree = SWIG_RubyRemoveTracking; + } else { + RDATA(obj)->dfree = 0; + } + } + + /* Do type-checking if type info was provided */ + if (ty) { + if (ty->clientdata) { + if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + *ptr = vptr; + return SWIG_OK; + } + } + if ((c = SWIG_MangleStr(obj)) == NULL) { + return SWIG_ERROR; + } + tc = SWIG_TypeCheck(c, ty); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc, vptr); + } + return SWIG_OK; +} + +/* Check convert */ +SWIGRUNTIMEINLINE int +SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) +{ + char *c = SWIG_MangleStr(obj); + if (!c) return 0; + return SWIG_TypeCheck(c,ty) != 0; +} + +SWIGRUNTIME VALUE +SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r, ptr, sz); + strcpy(r, type->name); + return rb_str_new2(result); +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (TYPE(obj) != T_STRING) goto type_error; + c = StringValuePtr(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c, ptr, sz); + if (ty) { + tc = SWIG_TypeCheck(c, ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + return SWIG_ERROR; +} + +SWIGRUNTIME swig_module_info * +SWIG_Ruby_GetModule() +{ + VALUE pointer; + swig_module_info *ret = 0; + VALUE verbose = rb_gv_get("VERBOSE"); + + /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ + rb_gv_set("VERBOSE", Qfalse); + + /* first check if pointer already created */ + pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + if (pointer != Qnil) { + Data_Get_Struct(pointer, swig_module_info, ret); + } + + /* reinstate warnings */ + rb_gv_set("VERBOSE", verbose); + return ret; +} + +SWIGRUNTIME void +SWIG_Ruby_SetModule(swig_module_info *pointer) +{ + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); +} + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + +/* ----------------------------------------------------------------------------- + * Ruby API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN VALUE +SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { + if (NIL_P(target)) { + target = o; + } else { + if (TYPE(target) != T_ARRAY) { + VALUE o2 = target; + target = rb_ary_new(); + rb_ary_push(target, o2); + } + rb_ary_push(target, o); + } + return target; +} + +#ifdef __cplusplus +} +#endif + + + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + + + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + + +#define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0) + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_CPLErrorHandler swig_types[0] +#define SWIGTYPE_p_CPLXMLNode swig_types[1] +#define SWIGTYPE_p_GByte swig_types[2] +#define SWIGTYPE_p_GDALColorEntry swig_types[3] +#define SWIGTYPE_p_GDALColorTable swig_types[4] +#define SWIGTYPE_p_GDALDatasetShadow swig_types[5] +#define SWIGTYPE_p_GDALDriverShadow swig_types[6] +#define SWIGTYPE_p_GDALMajorObjectShadow swig_types[7] +#define SWIGTYPE_p_GDALRasterBandShadow swig_types[8] +#define SWIGTYPE_p_GDAL_GCP swig_types[9] +#define SWIGTYPE_p_char swig_types[10] +#define SWIGTYPE_p_double swig_types[11] +#define SWIGTYPE_p_int swig_types[12] +#define SWIGTYPE_p_p_GDAL_GCP swig_types[13] +#define SWIGTYPE_p_p_char swig_types[14] +static swig_type_info *swig_types[16]; +static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init Init_gdal +#define SWIG_name "Gdal::Gdal" + +static VALUE mGdal; + + +#define SWIGVERSION 0x010328 + + + + +#define SWIG_as_voidptr(a) const_cast<void * >(static_cast<const void * >(a)) + + +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast<void** >(a)) + + + + +/* Define custom exceptions for errors that do not map to existing Ruby + exceptions. Note this only works for C++ since a global cannot be + initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + +VALUE getNullReferenceError() { + static int init = 0; + static VALUE rb_eNullReferenceError ; + if (!init) { + init = 1; + rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); + } + return rb_eNullReferenceError; +} + +VALUE getObjectPreviouslyDeletedError() { + static int init = 0; + static VALUE rb_eObjectPreviouslyDeleted ; + if (!init) { + init = 1; + rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); + } + return rb_eObjectPreviouslyDeleted; +} + +VALUE getExceptionClass() { + static int init = 0; + static VALUE rubyExceptionClass ; + if (!init) { + init = 1; + rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); + } + return rubyExceptionClass; +} + +SWIGINTERN VALUE +SWIG_Ruby_ErrorType(int SWIG_code) { + VALUE type; + switch (SWIG_code) { + case SWIG_MemoryError: + type = rb_eNoMemError; + break; + case SWIG_IOError: + type = rb_eIOError; + break; + case SWIG_RuntimeError: + type = rb_eRuntimeError; + break; + case SWIG_IndexError: + type = rb_eIndexError; + break; + case SWIG_TypeError: + type = rb_eTypeError; + break; + case SWIG_DivisionByZero: + type = rb_eZeroDivError; + break; + case SWIG_OverflowError: + type = rb_eRangeError; + break; + case SWIG_SyntaxError: + type = rb_eSyntaxError; + break; + case SWIG_ValueError: + type = rb_eArgError; + break; + case SWIG_SystemError: + type = rb_eFatal; + break; + case SWIG_AttributeError: + type = rb_eRuntimeError; + break; + case SWIG_NullReferenceError: + type = getNullReferenceError(); + break; + case SWIG_ObjectPreviouslyDeletedError: + type = getObjectPreviouslyDeletedError(); + break; + case SWIG_UnknownError: + type = rb_eRuntimeError; + break; + default: + type = rb_eRuntimeError; + } + return type; +} + + +/* This code checks to see if the Ruby object being raised as part + of an exception inherits from the Ruby class Exception. If so, + the object is simply returned. If not, then a new Ruby exception + object is created and that will be returned to Ruby.*/ +SWIGINTERN VALUE +SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { + VALUE exceptionClass = getExceptionClass(); + if (rb_obj_is_kind_of(obj, exceptionClass)) { + return obj; + } else { + return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); + } +} + + + +#include <stdexcept> + + +#include <iostream> +using namespace std; + +#include "cpl_port.h" +#include "cpl_string.h" + +#include "gdal.h" +#include "gdal_priv.h" +#include "gdal_alg.h" +#include "gdalwarper.h" + +typedef void GDALMajorObjectShadow; +typedef void GDALDriverShadow; +typedef void GDALDatasetShadow; +typedef void GDALRasterBandShadow; + +typedef int FALSE_IS_ERR; + + + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} + + +void UseExceptions() { + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} + + + +static CPLXMLNode *RubyArrayToXMLTree(VALUE rubyArray) +{ + int nChildCount = 0, iChild, nType; + CPLXMLNode *psThisNode; + CPLXMLNode *psChild; + char *pszText = NULL; + + nChildCount = RARRAY(rubyArray)->len - 2; + if( nChildCount < 0 ) + { + rb_raise(rb_eRuntimeError, "Error in input XMLTree, child count is less than zero."); + } + + VALUE item1 = rb_ary_entry(rubyArray, 0); + nType = NUM2INT(item1); + + VALUE item2 = rb_ary_entry(rubyArray, 1); + pszText = StringValuePtr(item2); + + psThisNode = CPLCreateXMLNode( NULL, (CPLXMLNodeType) nType, pszText ); + + for( iChild = 0; iChild < nChildCount; iChild++ ) + { + psChild = RubyArrayToXMLTree( rb_ary_entry(rubyArray,iChild+2) ); + CPLAddXMLChild( psThisNode, psChild ); + } + + return psThisNode; +} + +static VALUE XMLTreeToRubyArray( CPLXMLNode *psTree ) +{ + int nChildCount = 0, iChild; + CPLXMLNode *psChild; + + for( psChild = psTree->psChild; + psChild != NULL; + psChild = psChild->psNext ) + nChildCount++; + + VALUE rubyArray = rb_ary_new2(nChildCount+2); + + rb_ary_store(rubyArray, 0, INT2NUM((int) psTree->eType)); + rb_ary_store(rubyArray, 1, rb_str_new2(psTree->pszValue)); + + for( psChild = psTree->psChild, iChild = 2; + psChild != NULL; + psChild = psChild->psNext, iChild++ ) + { + rb_ary_store(rubyArray, iChild, XMLTreeToRubyArray(psChild)); + } + + return rubyArray; +} + + + void Debug( const char *msg_class, const char *message ) { + CPLDebug( msg_class, message ); + } + void Error( CPLErr msg_class = CE_Failure, int err_code = 0, const char* msg = "error" ) { + CPLError( msg_class, err_code, msg ); + } + + CPLErr PushErrorHandler( char const * pszCallbackName = "CPLQuietErrorHandler" ) { + CPLErrorHandler pfnHandler = NULL; + if( EQUAL(pszCallbackName,"CPLQuietErrorHandler") ) + pfnHandler = CPLQuietErrorHandler; + else if( EQUAL(pszCallbackName,"CPLDefaultErrorHandler") ) + pfnHandler = CPLDefaultErrorHandler; + else if( EQUAL(pszCallbackName,"CPLLoggingErrorHandler") ) + pfnHandler = CPLLoggingErrorHandler; + + if ( pfnHandler == NULL ) + return CE_Fatal; + + CPLPushErrorHandler( pfnHandler ); + + return CE_None; + } + + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) +{ + if (TYPE(obj) == T_STRING) { + char *cstr = rb_string_value_ptr(&(obj)); + size_t size = RSTRING(obj)->len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast<char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + + + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + +SWIGINTERN VALUE +SWIG_ruby_failed() +{ + return Qnil; +} + + + +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + long *res = (long *)(args[1]); + *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_long (VALUE obj, long* val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + long v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (VALUE obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast<int >(v); + } + } + return res; +} + + + +#define SWIG_From_long LONG2NUM + + + +SWIGINTERNINLINE VALUE +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > LONG_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj(const_cast<char * >(carray), pchar_descriptor, 0) : Qnil; + } else { + return rb_str_new(carray, static_cast<long >(size)); + } + } else { + return Qnil; + } +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + +SWIGINTERN char const *GDALMajorObjectShadow_GetDescription(GDALMajorObjectShadow *self){ + return GDALGetDescription( self ); + } +SWIGINTERN void GDALMajorObjectShadow_SetDescription(GDALMajorObjectShadow *self,char const *pszNewDesc){ + GDALSetDescription( self, pszNewDesc ); + } +SWIGINTERN char **GDALMajorObjectShadow_GetMetadata_Dict(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +SWIGINTERN char **GDALMajorObjectShadow_GetMetadata_List(GDALMajorObjectShadow *self,char const *pszDomain=""){ + return GDALGetMetadata( self, pszDomain ); + } +SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_0(GDALMajorObjectShadow *self,char **papszMetadata,char const *pszDomain=""){ + return GDALSetMetadata( self, papszMetadata, pszDomain ); + } +SWIGINTERN CPLErr GDALMajorObjectShadow_SetMetadata__SWIG_1(GDALMajorObjectShadow *self,char *pszMetadataString,char const *pszDomain=""){ + char *tmpList[2]; + tmpList[0] = pszMetadataString; + tmpList[1] = 0; + return GDALSetMetadata( self, tmpList, pszDomain ); + } +SWIGINTERN GDALDatasetShadow *GDALDriverShadow_Create(GDALDriverShadow *self,char const *name,int xsize,int ysize,int bands=1,GDALDataType eType=GDT_Byte,char **options=0){ + GDALDatasetShadow* ds = (GDALDatasetShadow*) GDALCreate( self, name, xsize, ysize, bands, eType, options ); + return ds; + } +SWIGINTERN GDALDatasetShadow *GDALDriverShadow_CreateCopy(GDALDriverShadow *self,char const *name,GDALDatasetShadow *src,int strict=1,char **options=0){ + GDALDatasetShadow *ds = (GDALDatasetShadow*) GDALCreateCopy(self, name, src, strict, 0, 0, 0 ); + return ds; + } +SWIGINTERN int GDALDriverShadow_Delete(GDALDriverShadow *self,char const *name){ + return GDALDeleteDataset( self, name ); + } + +char const *GDALDriverShadow_ShortName_get( GDALDriverShadow *h ) { + return GDALGetDriverShortName( h ); +} +char const *GDALDriverShadow_LongName_get( GDALDriverShadow *h ) { + return GDALGetDriverLongName( h ); +} +char const *GDALDriverShadow_HelpTopic_get( GDALDriverShadow *h ) { + return GDALGetDriverHelpTopic( h ); +} + + + +SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + double *res = (double *)(args[1]); + *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj))); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_double (VALUE obj, double *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { + double v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + + + +#define SWIG_From_double rb_float_new + + +SWIGINTERN GDAL_GCP *new_GDAL_GCP(double x=0.0,double y=0.0,double z=0.0,double pixel=0.0,double line=0.0,char const *info="",char const *id=""){ + GDAL_GCP *self = (GDAL_GCP*) CPLMalloc( sizeof( GDAL_GCP ) ); + self->dfGCPX = x; + self->dfGCPY = y; + self->dfGCPZ = z; + self->dfGCPPixel = pixel; + self->dfGCPLine = line; + self->pszInfo = CPLStrdup( (info == 0) ? "" : info ); + self->pszId = CPLStrdup( (id==0)? "" : id ); + return self; + } + + +double GDAL_GCP_GCPX_get( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_GCPX_set( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_GCPY_get( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_GCPY_set( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_GCPZ_get( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_GCPZ_set( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_GCPPixel_get( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_GCPPixel_set( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_GCPLine_get( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_GCPLine_set( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_Info_get( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_Info_set( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_Id_get( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_Id_set( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + + +/* Duplicate, but transposed names for C# because +* the C# module outputs backwards names +*/ +double GDAL_GCP_get_GCPX( GDAL_GCP *h ) { + return h->dfGCPX; +} +void GDAL_GCP_set_GCPX( GDAL_GCP *h, double val ) { + h->dfGCPX = val; +} +double GDAL_GCP_get_GCPY( GDAL_GCP *h ) { + return h->dfGCPY; +} +void GDAL_GCP_set_GCPY( GDAL_GCP *h, double val ) { + h->dfGCPY = val; +} +double GDAL_GCP_get_GCPZ( GDAL_GCP *h ) { + return h->dfGCPZ; +} +void GDAL_GCP_set_GCPZ( GDAL_GCP *h, double val ) { + h->dfGCPZ = val; +} +double GDAL_GCP_get_GCPPixel( GDAL_GCP *h ) { + return h->dfGCPPixel; +} +void GDAL_GCP_set_GCPPixel( GDAL_GCP *h, double val ) { + h->dfGCPPixel = val; +} +double GDAL_GCP_get_GCPLine( GDAL_GCP *h ) { + return h->dfGCPLine; +} +void GDAL_GCP_set_GCPLine( GDAL_GCP *h, double val ) { + h->dfGCPLine = val; +} +const char * GDAL_GCP_get_Info( GDAL_GCP *h ) { + return h->pszInfo; +} +void GDAL_GCP_set_Info( GDAL_GCP *h, const char * val ) { + if ( h->pszInfo ) + CPLFree( h->pszInfo ); + h->pszInfo = CPLStrdup(val); +} +const char * GDAL_GCP_get_Id( GDAL_GCP *h ) { + return h->pszId; +} +void GDAL_GCP_set_Id( GDAL_GCP *h, const char * val ) { + if ( h->pszId ) + CPLFree( h->pszId ); + h->pszId = CPLStrdup(val); +} + + +SWIGINTERN GDALDriverShadow *GDALDatasetShadow_GetDriver(GDALDatasetShadow *self){ + return (GDALDriverShadow*) GDALGetDatasetDriver( self ); + } +SWIGINTERN GDALRasterBandShadow *GDALDatasetShadow_GetRasterBand(GDALDatasetShadow *self,int nBand){ + return (GDALRasterBandShadow*) GDALGetRasterBand( self, nBand ); + } +SWIGINTERN char const *GDALDatasetShadow_GetProjection(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +SWIGINTERN char const *GDALDatasetShadow_GetProjectionRef(GDALDatasetShadow *self){ + return GDALGetProjectionRef( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_SetProjection(GDALDatasetShadow *self,char const *prj){ + return GDALSetProjection( self, prj ); + } +SWIGINTERN void GDALDatasetShadow_GetGeoTransform(GDALDatasetShadow *self,double argout[6]){ + if ( GDALGetGeoTransform( self, argout ) != 0 ) { + argout[0] = 0.0; + argout[1] = 1.0; + argout[2] = 0.0; + argout[3] = 0.0; + argout[4] = 0.0; + argout[5] = 1.0; + } + } +SWIGINTERN CPLErr GDALDatasetShadow_SetGeoTransform(GDALDatasetShadow *self,double argin[6]){ + return GDALSetGeoTransform( self, argin ); + } +SWIGINTERN int GDALDatasetShadow_BuildOverviews(GDALDatasetShadow *self,char const *resampling="NEAREST",int overviewlist=0,int *pOverviews=0){ + return GDALBuildOverviews( self, resampling, overviewlist, pOverviews, 0, 0, 0, 0); + } +SWIGINTERN int GDALDatasetShadow_GetGCPCount(GDALDatasetShadow *self){ + return GDALGetGCPCount( self ); + } +SWIGINTERN char const *GDALDatasetShadow_GetGCPProjection(GDALDatasetShadow *self){ + return GDALGetGCPProjection( self ); + } +SWIGINTERN void GDALDatasetShadow_GetGCPs(GDALDatasetShadow *self,int *nGCPs,GDAL_GCP const **pGCPs){ + *nGCPs = GDALGetGCPCount( self ); + *pGCPs = GDALGetGCPs( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_SetGCPs(GDALDatasetShadow *self,int nGCPs,GDAL_GCP const *pGCPs,char const *pszGCPProjection){ + return GDALSetGCPs( self, nGCPs, pGCPs, pszGCPProjection ); + } +SWIGINTERN void GDALDatasetShadow_FlushCache(GDALDatasetShadow *self){ + GDALFlushCache( self ); + } +SWIGINTERN CPLErr GDALDatasetShadow_AddBand(GDALDatasetShadow *self,GDALDataType datatype=GDT_Byte,char **options=0){ + return GDALAddBand( self, datatype, options ); + } +SWIGINTERN CPLErr GDALDatasetShadow_WriteRaster(GDALDatasetShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,GDALDataType *buf_type=0,int band_list=0,int *pband_list=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype; + if ( buf_type != 0 ) { + ntype = (GDALDataType) *buf_type; + } else { + int lastband = GDALGetRasterCount( self ) - 1; + ntype = GDALGetRasterDataType( GDALGetRasterBand( self, lastband ) ); + } + bool myBandList = false; + int nBandCount; + int *pBandList; + if ( band_list != 0 ) { + myBandList = false; + nBandCount = band_list; + pBandList = pband_list; + } + else { + myBandList = true; + nBandCount = GDALGetRasterCount( self ); + pBandList = (int*) CPLMalloc( sizeof(int) * nBandCount ); + for( int i = 0; i< nBandCount; ++i ) { + pBandList[i] = i; + } + } + return GDALDatasetRasterIO( self, GF_Write, xoff, yoff, xsize, ysize, + (void*) buf_string, nxsize, nysize, ntype, + band_list, pband_list, 0, 0, 0 ); + if ( myBandList ) { + CPLFree( pBandList ); + } + } + +int GDALDatasetShadow_RasterXSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterXSize( h ); +} +int GDALDatasetShadow_RasterYSize_get( GDALDatasetShadow *h ) { + return GDALGetRasterYSize( h ); +} +int GDALDatasetShadow_RasterCount_get( GDALDatasetShadow *h ) { + return GDALGetRasterCount( h ); +} + + +static +CPLErr ReadRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int *buf_size, char **buf ) +{ + + *buf_size = buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type ) / 8; + *buf = (char*) malloc( *buf_size ); + CPLErr result = GDALRasterIO( obj, GF_Read, xoff, yoff, xsize, ysize, + (void *) *buf, buf_xsize, buf_ysize, + buf_type, 0, 0 ); + if ( result != CE_None ) { + free( *buf ); + *buf = 0; + *buf_size = 0; + } + return result; +} + +static +CPLErr WriteRaster_internal( GDALRasterBandShadow *obj, + int xoff, int yoff, int xsize, int ysize, + int buf_xsize, int buf_ysize, + GDALDataType buf_type, + int buf_size, char *buffer ) +{ + if ( buf_size < buf_xsize * buf_ysize * GDALGetDataTypeSize( buf_type) /8 ) { + return CE_Failure; + } + + return GDALRasterIO( obj, GF_Write, xoff, yoff, xsize, ysize, + (void *) buffer, buf_xsize, buf_ysize, buf_type, 0, 0 ); +} + +SWIGINTERN GDALColorInterp GDALRasterBandShadow_GetRasterColorInterpretation(GDALRasterBandShadow *self){ + return GDALGetRasterColorInterpretation( self ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_SetRasterColorInterpretation(GDALRasterBandShadow *self,GDALColorInterp val){ + return GDALSetRasterColorInterpretation( self, val ); + } +SWIGINTERN void GDALRasterBandShadow_GetNoDataValue(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterNoDataValue( self, hasval ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_SetNoDataValue(GDALRasterBandShadow *self,double d){ + return GDALSetRasterNoDataValue( self, d ); + } +SWIGINTERN void GDALRasterBandShadow_GetMinimum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMinimum( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetMaximum(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterMaximum( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetOffset(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterOffset( self, hasval ); + } +SWIGINTERN void GDALRasterBandShadow_GetScale(GDALRasterBandShadow *self,double *val,int *hasval){ + *val = GDALGetRasterScale( self, hasval ); + } +SWIGINTERN int GDALRasterBandShadow_GetOverviewCount(GDALRasterBandShadow *self){ + return GDALGetOverviewCount( self ); + } +SWIGINTERN GDALRasterBandShadow *GDALRasterBandShadow_GetOverview(GDALRasterBandShadow *self,int i){ + return (GDALRasterBandShadow*) GDALGetOverview( self, i ); + } +SWIGINTERN int GDALRasterBandShadow_Checksum(GDALRasterBandShadow *self,int xoff=0,int yoff=0,int *xsize=0,int *ysize=0){ + int nxsize = (xsize!=0) ? *xsize : GDALGetRasterBandXSize( self ); + int nysize = (ysize!=0) ? *ysize : GDALGetRasterBandYSize( self ); + return GDALChecksumImage( self, xoff, yoff, nxsize, nysize ); + } +SWIGINTERN void GDALRasterBandShadow_ComputeRasterMinMax(GDALRasterBandShadow *self,double argout[2],int approx_ok=0){ + GDALComputeRasterMinMax( self, approx_ok, argout ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_Fill(GDALRasterBandShadow *self,double real_fill,double imag_fill=0.0){ + return GDALFillRaster( self, real_fill, imag_fill ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_ReadRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int *buf_len,char **buf,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return ReadRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf ); + } +SWIGINTERN CPLErr GDALRasterBandShadow_WriteRaster(GDALRasterBandShadow *self,int xoff,int yoff,int xsize,int ysize,int buf_len,char *buf_string,int *buf_xsize=0,int *buf_ysize=0,int *buf_type=0){ + int nxsize = (buf_xsize==0) ? xsize : *buf_xsize; + int nysize = (buf_ysize==0) ? ysize : *buf_ysize; + GDALDataType ntype = (buf_type==0) ? GDALGetRasterDataType(self) + : (GDALDataType)*buf_type; + return WriteRaster_internal( self, xoff, yoff, xsize, ysize, + nxsize, nysize, ntype, buf_len, buf_string ); + } +SWIGINTERN void GDALRasterBandShadow_FlushCache(GDALRasterBandShadow *self){ + GDALFlushRasterCache( self ); + } +SWIGINTERN GDALColorTable *GDALRasterBandShadow_GetRasterColorTable(GDALRasterBandShadow *self){ + return (GDALColorTable*) GDALGetRasterColorTable( self ); + } +SWIGINTERN int GDALRasterBandShadow_SetRasterColorTable(GDALRasterBandShadow *self,GDALColorTable *arg){ + return GDALSetRasterColorTable( self, arg ); + } + +GDALDataType GDALRasterBandShadow_DataType_get( GDALRasterBandShadow *h ) { + return GDALGetRasterDataType( h ); +} +int GDALRasterBandShadow_XSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandXSize( h ); +} +int GDALRasterBandShadow_YSize_get( GDALRasterBandShadow *h ) { + return GDALGetRasterBandYSize( h ); +} + + +int GetDriverCount() { + return GDALGetDriverCount(); +} + + +GDALDriverShadow* GetDriverByName( char const *name ) { + return (GDALDriverShadow*) GDALGetDriverByName( name ); +} + + +GDALDriverShadow* GetDriver( int i ) { + return (GDALDriverShadow*) GDALGetDriver( i ); +} + + +GDALDatasetShadow* Open( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpen( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow* OpenShared( char const* name, GDALAccess eAccess = GA_ReadOnly ) { + GDALDatasetShadow *ds = GDALOpenShared( name, eAccess ); + return (GDALDatasetShadow*) ds; +} + + +GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, + const char *src_wkt = 0, + const char *dst_wkt = 0, + GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, + double maxerror = 0.0 ) { + GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt, + dst_wkt, + eResampleAlg, + maxerror, + 0 ); + if (ds == 0) { + throw CPLGetLastErrorMsg(); + } + return ds; + +} + +SWIGINTERN VALUE +_wrap_use_exceptions(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + UseExceptions(); + + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_dont_use_exceptions(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + DontUseExceptions(); + + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_debug(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Debug" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Debug" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + Debug((char const *)arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_error(int argc, VALUE *argv, VALUE self) { + CPLErr arg1 = (CPLErr) CE_Failure ; + int arg2 = (int) 0 ; + char *arg3 = (char *) "error" ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + + if ((argc < 0) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + { + /* %typemap(in) CPLErr */ + arg1 = (CPLErr) NUM2INT(argv[0]); + } + } + if (argc > 1) { + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "Error" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + if (argc > 2) { + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "Error" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + Error(arg1,arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +fail: + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_push_error_handler__SWIG_0(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) "CPLQuietErrorHandler" ; + CPLErr result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "PushErrorHandler" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + { + CPLErrorReset(); + result = (CPLErr)PushErrorHandler((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_push_error_handler__SWIG_1(int argc, VALUE *argv, VALUE self) { + CPLErrorHandler arg1 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + void *argp; + CPLErrorHandler * temp; + int res = SWIG_ConvertPtr(argv[0], &argp, SWIGTYPE_p_CPLErrorHandler, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(((res != SWIG_ERROR) ? res : SWIG_TypeError), "in method '" "CPLPushErrorHandler" "', argument " "1"" of type '" "CPLErrorHandler""'"); + } + if (!argp) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CPLPushErrorHandler" "', argument " "1"" of type '" "CPLErrorHandler""'"); + } else { + arg1 = *(reinterpret_cast<CPLErrorHandler * >(argp)); + } + } + { + CPLErrorReset(); + CPLPushErrorHandler(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE _wrap_push_error_handler(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[1]; + int ii; + + argc = nargs; + for (ii = 0; (ii < argc) && (ii < 1); ii++) { + argv[ii] = args[ii]; + } + if ((argc >= 0) && (argc <= 1)) { + int _v; + if (argc <= 0) { + return _wrap_push_error_handler__SWIG_0(nargs, args, self); + } + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_push_error_handler__SWIG_0(nargs, args, self); + } + } + if (argc == 1) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CPLErrorHandler, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_push_error_handler__SWIG_1(nargs, args, self); + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'push_error_handler'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_pop_error_handler(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + CPLPopErrorHandler(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_error_reset(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + CPLErrorReset(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_last_error_no(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)CPLGetLastErrorNo(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_last_error_type(int argc, VALUE *argv, VALUE self) { + CPLErr result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (CPLErr)CPLGetLastErrorType(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_last_error_msg(int argc, VALUE *argv, VALUE self) { + char *result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (char *)CPLGetLastErrorMsg(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_push_finder_location(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLPushFinderLocation" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + CPLPushFinderLocation((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_pop_finder_location(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + CPLPopFinderLocation(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_finder_clean(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + CPLFinderClean(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_find_file(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLFindFile" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CPLFindFile" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)CPLFindFile((char const *)arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_set_config_option(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLSetConfigOption" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CPLSetConfigOption" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + CPLSetConfigOption((char const *)arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_config_option(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLGetConfigOption" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CPLGetConfigOption" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)CPLGetConfigOption((char const *)arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_binary_to_hex(int argc, VALUE *argv, VALUE self) { + int arg1 ; + GByte *arg2 = (GByte *) 0 ; + char *result = 0 ; + int res1 ; + GByte *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /*%typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (int nBytes, const GByte *pabyData) */ + + res1 = SWIG_AsCharPtrAndSize(argv[0], (char**)&buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLBinaryToHex" "', argument " "1"" of type '" "(GByte*, int)""'"); + } + arg1 = (int) size1 - 1; + arg2 = (GByte *) buf1; + } + { + CPLErrorReset(); + result = (char *)CPLBinaryToHex(arg1,(GByte const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + { + /* %typemap(freearg) (int nBytes, const GByte *pabyData) */ + CPLFree(result); + } + return vresult; +fail: + { + /* %typemap(freearg) (int nBytes, const GByte *pabyData) */ + CPLFree(result); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_hex_to_binary(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int *arg2 = (int *) 0 ; + GByte *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int size1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /*% typemap(in,numinputs=1,fragment="SWIG_AsCharPtrAndSize") (const char *pszHex, int *pnBytes) */ + arg2 = &size1; + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLHexToBinary" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + { + CPLErrorReset(); + result = (GByte *)CPLHexToBinary((char const *)arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) GByte* */ + + /* Stops insertion of default type map. */ + } + { + /* %typemap(argout) (const char *pszHex, int *pnBytes) */ + vresult = SWIG_FromCharPtrAndSize((char*)result, (size_t)*arg2); + CPLFree(result); + } + return vresult; +fail: + return Qnil; +} + + +swig_class cMajorObject; + +SWIGINTERN VALUE +_wrap_MajorObject_get_description(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDescription" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALMajorObjectShadow_GetDescription(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_MajorObject_set_description(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetDescription" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetDescription" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDALMajorObjectShadow_SetDescription(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_MajorObject_get_metadata_dict(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetMetadata_Dict" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + if (argc > 0) { + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetMetadata_Dict" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + { + CPLErrorReset(); + result = (char **)GDALMajorObjectShadow_GetMetadata_Dict(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) char **dict */ + + /* Get a pointer to the c array */ + char **stringarray = result; + + /* Create a new hash table, this will be returned to Ruby. */ + vresult = rb_hash_new(); + if ( stringarray != NULL ) { + while (*stringarray != NULL ) { + /* Get the key and value */ + char const *valptr; + char *keyptr; + valptr = CPLParseNameValue( *stringarray, &keyptr ); + + if ( valptr != 0 ) { + /* Convert the key and value to Ruby strings */ + VALUE nm = rb_str_new2( keyptr ); + VALUE val = rb_str_new2( valptr ); + /* Save the key, value pair to the hash table. */ + rb_hash_aset(vresult, nm, val); + CPLFree( keyptr ); + } + stringarray++; + } + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_MajorObject_get_metadata_list(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) "" ; + char **result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetMetadata_List" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + if (argc > 0) { + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetMetadata_List" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + { + CPLErrorReset(); + result = (char **)GDALMajorObjectShadow_GetMetadata_List(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) char **options */ + + char **stringarray = result; + if ( stringarray == NULL ) { + vresult = Qnil; + } + else { + int len = CSLCount( stringarray ); + vresult = rb_ary_new2( len ); + for ( int i = 0; i < len; ++i, ++stringarray ) { + VALUE nm = rb_str_new2( *stringarray ); + rb_ary_push(vresult, nm); + } + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_MajorObject_set_metadata__SWIG_0(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char **arg2 = (char **) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetMetadata" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + { + /* %typemap(in) char **dict */ + + arg2 = NULL; + + /* is the provided object an array or a hash? */ + if ( TYPE(argv[0]) == T_ARRAY) { + /* get the size of the array */ + int size = RARRAY(argv[0])->len; + + for (int i = 0; i < size; i++) { + /* get the ruby object */ + VALUE value = rb_ary_entry(argv[0], i); + + /* Convert the value to a string via ruby duck typing + * (i.e., the object might not actually be a string) + */ + char *pszItem = StringValuePtr(value); + arg2 = CSLAddString( arg2, pszItem ); + } + } + + else if ( TYPE(argv[0]) == T_HASH) { + /* This is a hash - get the size by calling via the ruby method */ + int size = NUM2INT(rb_funcall(argv[0], rb_intern("size"), 0, NULL)); + + if ( size > 0 ) { + /* Get the keys by caling via ruby */ + VALUE keys_arr = rb_funcall(argv[0], rb_intern("keys"), 0, NULL); + + for( int i=0; i<size; i++ ) { + /* Get the key and value as ruby objects */ + VALUE key = rb_ary_entry(keys_arr, i); + VALUE value = rb_hash_aref(argv[0], key); + + /* Convert the key and value to strings via ruby duck typing + * (i.e., the objects might not actually be strings) + */ + char *nm = StringValuePtr(key); + char *val = StringValuePtr(value); + + /* Add the value */ + arg2 = CSLAddNameValue( arg2, nm, val ); + } + } + } + else { + rb_raise(rb_eTypeError, "Argument must be dictionary or sequence of strings"); + } + } + if (argc > 1) { + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetMetadata" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_0(arg1,arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return vresult; +fail: + { + /* %typemap(freearg) char **dict */ + CSLDestroy( arg2 ); + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_MajorObject_set_metadata__SWIG_1(int argc, VALUE *argv, VALUE self) { + GDALMajorObjectShadow *arg1 = (GDALMajorObjectShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) "" ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALMajorObjectShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetMetadata" "', argument " "1"" of type '" "GDALMajorObjectShadow *""'"); + } + arg1 = reinterpret_cast<GDALMajorObjectShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetMetadata" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + if (argc > 1) { + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetMetadata" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + { + CPLErrorReset(); + result = (CPLErr)GDALMajorObjectShadow_SetMetadata__SWIG_1(arg1,arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_MajorObject_set_metadata(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[4]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 3); ii++) { + argv[ii] = args[ii-1]; + } + if ((argc >= 2) && (argc <= 3)) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_GDALMajorObjectShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + /* %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) (char **dict) */ + _v = ((TYPE(argv[1]) == T_HASH) || (TYPE(argv[1]) == T_ARRAY)) ? 1 : 0; + } + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_set_metadata__SWIG_0(nargs, args, self); + } + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_MajorObject_set_metadata__SWIG_0(nargs, args, self); + } + } + } + } + if ((argc >= 2) && (argc <= 3)) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_GDALMajorObjectShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + if (argc <= 2) { + return _wrap_MajorObject_set_metadata__SWIG_1(nargs, args, self); + } + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_MajorObject_set_metadata__SWIG_1(nargs, args, self); + } + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'MajorObject_set_metadata'"); + return Qnil; +} + + +swig_class cDriver; + +SWIGINTERN VALUE +_wrap_Driver_short_name_get(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ShortName" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_ShortName_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_long_name_get(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "LongName" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_LongName_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_help_topic_get(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "HelpTopic" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDriverShadow_HelpTopic_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_create(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + int arg4 ; + int arg5 = (int) 1 ; + GDALDataType arg6 = (GDALDataType) GDT_Byte ; + char **arg7 = (char **) 0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + char *kwnames[] = { + "self","name","xsize","ysize","bands","eType","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 3) || (argc > 6)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Create" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Create" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "Create" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + ecode4 = SWIG_AsVal_int(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "Create" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + if (argc > 3) { + ecode5 = SWIG_AsVal_int(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "Create" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast<int >(val5); + } + if (argc > 4) { + { + /* %typemap(in) CPLErr */ + arg6 = (GDALDataType) NUM2INT(argv[4]); + } + } + if (argc > 5) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[5], T_ARRAY); + + int size = RARRAY(argv[5])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[5], i); + char *pszItem = StringValuePtr(item); + arg7 = CSLAddString( arg7, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_Create(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg7 ); + } + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg7 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_create_copy(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + GDALDatasetShadow *arg3 = (GDALDatasetShadow *) 0 ; + int arg4 = (int) 1 ; + char **arg5 = (char **) 0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 ; + int val4 ; + int ecode4 = 0 ; + char *kwnames[] = { + "self","name","src","strict","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateCopy" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateCopy" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "CreateCopy" "', argument " "3"" of type '" "GDALDatasetShadow *""'"); + } + arg3 = reinterpret_cast<GDALDatasetShadow * >(argp3); + if (argc > 2) { + ecode4 = SWIG_AsVal_int(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "CreateCopy" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + } + if (argc > 3) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[3], T_ARRAY); + + int size = RARRAY(argv[3])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[3], i); + char *pszItem = StringValuePtr(item); + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)GDALDriverShadow_CreateCopy(arg1,(char const *)arg2,arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg5 ); + } + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg5 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_delete(int argc, VALUE *argv, VALUE self) { + GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Delete" "', argument " "1"" of type '" "GDALDriverShadow *""'"); + } + arg1 = reinterpret_cast<GDALDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Delete" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)GDALDriverShadow_Delete(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +swig_class cGCP; + +SWIGINTERN VALUE +_wrap_GCP_gcpx_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GCPX" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpx_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpy_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GCPY" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpy_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpz_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GCPZ" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpz_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcppixel_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GCPPixel" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcppixel_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpline_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GCPLine" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_gcpline_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_info_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Info" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_info_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_id_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Id" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GCP_id_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_GCP_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_GCP_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_GDAL_GCP); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_GCP(int argc, VALUE *argv, VALUE self) { + double arg1 = (double) 0.0 ; + double arg2 = (double) 0.0 ; + double arg3 = (double) 0.0 ; + double arg4 = (double) 0.0 ; + double arg5 = (double) 0.0 ; + char *arg6 = (char *) "" ; + char *arg7 = (char *) "" ; + GDAL_GCP *result = 0 ; + double val1 ; + int ecode1 = 0 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + + if ((argc < 0) || (argc > 7)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + ecode1 = SWIG_AsVal_double(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast<double >(val1); + } + if (argc > 1) { + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + } + if (argc > 2) { + ecode3 = SWIG_AsVal_double(argv[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + } + if (argc > 3) { + ecode4 = SWIG_AsVal_double(argv[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + } + if (argc > 4) { + ecode5 = SWIG_AsVal_double(argv[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + } + if (argc > 5) { + res6 = SWIG_AsCharPtrAndSize(argv[5], &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(((res6 != SWIG_ERROR) ? res6 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "6"" of type '" "char const *""'"); + } + arg6 = buf6; + } + if (argc > 6) { + res7 = SWIG_AsCharPtrAndSize(argv[6], &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(((res7 != SWIG_ERROR) ? res7 : SWIG_TypeError), "in method '" "GDAL_GCP" "', argument " "7"" of type '" "char const *""'"); + } + arg7 = buf7; + } + { + CPLErrorReset(); + result = (GDAL_GCP *)new_GDAL_GCP(arg1,arg2,arg3,arg4,arg5,(char const *)arg6,(char const *)arg7); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return self; +fail: + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return Qnil; +} + + +SWIGINTERN void delete_GDAL_GCP(GDAL_GCP *self){ + if ( self->pszInfo ) + CPLFree( self->pszInfo ); + if ( self->pszId ) + CPLFree( self->pszId ); + CPLFree( self ); + } +SWIGINTERN void +free_GDAL_GCP(GDAL_GCP *arg1) { + delete_GDAL_GCP(arg1); +} + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpx_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPX_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPX_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpx_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPX_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPX_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPX_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpy_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPY_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPY_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpy_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPY_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPY_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPY_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpz_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPZ_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPZ_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpz_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPZ_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPZ_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPZ_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcppixel_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPPixel_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPPixel_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcppixel_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPPixel_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPPixel_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPPixel_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpline_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPLine_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_GCPLine_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_gcpline_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPLine_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_GCPLine_set" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_GCPLine_set(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_info_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_Info_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Info_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_info_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_Info_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GDAL_GCP_Info_set" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Info_set(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_id_get(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_Id_get" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_Id_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_id_set(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_Id_set" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GDAL_GCP_Id_set" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_Id_set(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_gcpx(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPX(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_gcpx(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPX" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPX" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPX(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_gcpy(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPY(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_gcpy(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPY" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPY" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPY(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_gcpz(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPZ(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_gcpz(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPZ" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPZ" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPZ(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_gcppixel(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPPixel(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_gcppixel(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPPixel" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPPixel" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPPixel(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_gcpline(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (double)GDAL_GCP_get_GCPLine(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_gcpline(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + double arg2 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPLine" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + ecode2 = SWIG_AsVal_double(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_GCPLine" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + GDAL_GCP_set_GCPLine(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_info(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Info(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_info(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_Info" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_Info" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_set_Info(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_get_id(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_get_Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + { + CPLErrorReset(); + result = (char *)GDAL_GCP_get_Id(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gdal_gcp_set_id(int argc, VALUE *argv, VALUE self) { + GDAL_GCP *arg1 = (GDAL_GCP *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDAL_GCP, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDAL_GCP_set_Id" "', argument " "1"" of type '" "GDAL_GCP *""'"); + } + arg1 = reinterpret_cast<GDAL_GCP * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GDAL_GCP_set_Id" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + GDAL_GCP_set_Id(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_gcps_to_geo_transform(int argc, VALUE *argv, VALUE self) { + int arg1 ; + GDAL_GCP *arg2 = (GDAL_GCP *) 0 ; + double *arg3 ; + int arg4 = (int) 1 ; + FALSE_IS_ERR result; + GDAL_GCP *tmpGCPList1 ; + double argout3[6] ; + int val4 ; + int ecode4 = 0 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout3[ANY]) */ + arg3 = argout3; + } + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap( in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + + /* Check if is a list */ + Check_Type(argv[0], T_ARRAY); + + arg1 = RARRAY(argv[0])->len; + tmpGCPList1 = (GDAL_GCP*) malloc(arg1*sizeof(GDAL_GCP)); + arg2 = tmpGCPList1; + + for( int i = 0; i<arg1; i++ ) { + VALUE rubyItem = rb_ary_entry(argv[0],i); + GDAL_GCP *item = 0; + + SWIG_ConvertPtr( rubyItem, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + + if (!item) { + rb_raise(rb_eRuntimeError, "GDAL_GCP item cannot be nil"); + } + + memcpy( (void*) item, (void*) tmpGCPList1, sizeof( GDAL_GCP ) ); + ++tmpGCPList1; + } + } + if (argc > 1) { + ecode4 = SWIG_AsVal_int(argv[1], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "GDALGCPsToGeoTransform" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + } + { + CPLErrorReset(); + result = GDALGCPsToGeoTransform(arg1,(GDAL_GCP const *)arg2,arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) IF_FALSE_RETURN_NONE */ + if (result == 0 ) { + vresult = Qnil; + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<6; i++) + { + VALUE value = rb_float_new((arg3)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + { + /* %typemap( freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + return vresult; +fail: + { + /* %typemap( freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg2) { + free( (void*) arg2 ); + } + } + return Qnil; +} + + +swig_class cDataset; + +SWIGINTERN VALUE +_wrap_Dataset_raster_xsize_get(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "RasterXSize" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterXSize_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_raster_ysize_get(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "RasterYSize" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterYSize_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_raster_count_get(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "RasterCount" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_RasterCount_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN void delete_GDALDatasetShadow(GDALDatasetShadow *self){ + if ( GDALDereferenceDataset( self ) <= 0 ) { + GDALClose(self); + } + } +SWIGINTERN void +free_GDALDatasetShadow(GDALDatasetShadow *arg1) { + delete_GDALDatasetShadow(arg1); +} + +SWIGINTERN VALUE +_wrap_Dataset_get_driver(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDriverShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDriver" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALDriverShadow *)GDALDatasetShadow_GetDriver(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_raster_band(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetRasterBand" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetRasterBand" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALDatasetShadow_GetRasterBand(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_projection(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjection(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_projection_ref(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetProjectionRef" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetProjectionRef(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_set_projection(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetProjection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetProjection(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_geo_transform(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + void *argp1 = 0 ; + int res1 ; + double argout2[6] ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeoTransform" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_GetGeoTransform(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<6; i++) + { + VALUE value = rb_float_new((arg2)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_set_geo_transform(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + double *arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + double temp2[6] ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGeoTransform" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + /* %typemap(in) (double argin[ANY]) (double temp2[6]) */ + /* Make sure this is an array. */ + Check_Type(argv[0], T_ARRAY); + + /* Get the length */ + int seq_size = RARRAY(argv[0])->len; + + if ( seq_size != 6 ) { + rb_raise(rb_eRangeError, "sequence must have length %i.", seq_size); + } + + for( int i = 0; i<6; i++ ) { + /* Get the Ruby Object */ + VALUE item = rb_ary_entry(argv[0],i); + + /* Convert to double and store in array*/ + temp2[i] = NUM2DBL(item); + } + + /* Set argument arg2 equal to the temp2 array */ + arg2 = temp2; + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGeoTransform(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_build_overviews(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) "NEAREST" ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + char *kwnames[] = { + "self","resampling","overviewlist", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "BuildOverviews" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + if (argc > 0) { + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "BuildOverviews" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + if (argc > 1) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + + /* Make sure this is an array. */ + Check_Type(argv[1], T_ARRAY); + + /* Get the length */ + arg3 = RARRAY(argv[1])->len; + + /* Allocate space for the C array. */ + arg4 = (int*) malloc(arg3*sizeof(int)); + + for( int i = 0; i<arg3; i++ ) { + /* Get the Ruby Object */ + VALUE item = rb_ary_entry(argv[1],i); + /* Conver to an integer */ + arg4[i] = NUM2INT(item); + } + } + } + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_BuildOverviews(arg1,(char const *)arg2,arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg4) { + free((void*) arg4); + } + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_gcpcount(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGCPCount" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALDatasetShadow_GetGCPCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_gcpprojection(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGCPProjection" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)GDALDatasetShadow_GetGCPProjection(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_get_gcps(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int *arg2 = (int *) 0 ; + GDAL_GCP **arg3 = (GDAL_GCP **) 0 ; + void *argp1 = 0 ; + int res1 ; + int nGCPs2 = 0 ; + GDAL_GCP *pGCPs2 = 0 ; + VALUE vresult = Qnil; + + { + /* %typemap( in,numinputs=0) (int *nGCPs2, GDAL_GCP const **pGCPs2 ) */ + arg2 = &nGCPs2; + arg3 = &pGCPs2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGCPs" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_GetGCPs(arg1,arg2,(GDAL_GCP const **)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap( argout) (int *nGCPs, GDAL_GCP const **pGCPs ) */ + + /* vresult = rb_ary_new2(*arg2); + + for( int i = 0; i < *arg2; i++ ) { + GDAL_GCP *o = new_GDAL_GCP( (*arg3)[i].dfGCPX, + (*arg3)[i].dfGCPY, + (*arg3)[i].dfGCPZ, + (*arg3)[i].dfGCPPixel, + (*arg3)[i].dfGCPLine, + (*arg3)[i].pszInfo, + (*arg3)[i].pszId ); + + rb_ary_store(vresult, i, + SWIG_NewPointerObj((void*)o, SWIGTYPE_p_GDAL_GCP,1)); + }*/ + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_set_gcps(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + GDAL_GCP *arg3 = (GDAL_GCP *) 0 ; + char *arg4 = (char *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + GDAL_GCP *tmpGCPList2 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGCPs" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + /* %typemap( in,numinputs=1) (int nGCPs, GDAL_GCP const *pGCPs ) */ + + /* Check if is a list */ + Check_Type(argv[0], T_ARRAY); + + arg2 = RARRAY(argv[0])->len; + tmpGCPList2 = (GDAL_GCP*) malloc(arg2*sizeof(GDAL_GCP)); + arg3 = tmpGCPList2; + + for( int i = 0; i<arg2; i++ ) { + VALUE rubyItem = rb_ary_entry(argv[0],i); + GDAL_GCP *item = 0; + + SWIG_ConvertPtr( rubyItem, (void**)&item, SWIGTYPE_p_GDAL_GCP, SWIG_POINTER_EXCEPTION | 0 ); + + if (!item) { + rb_raise(rb_eRuntimeError, "GDAL_GCP item cannot be nil"); + } + + memcpy( (void*) item, (void*) tmpGCPList2, sizeof( GDAL_GCP ) ); + ++tmpGCPList2; + } + } + res4 = SWIG_AsCharPtrAndSize(argv[1], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "SetGCPs" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_SetGCPs(arg1,arg2,(GDAL_GCP const *)arg3,(char const *)arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + { + /* %typemap( freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return vresult; +fail: + { + /* %typemap( freearg) (int nGCPs, GDAL_GCP const *pGCPs ) */ + if (arg3) { + free( (void*) arg3 ); + } + } + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_flush_cache(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "FlushCache" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + { + CPLErrorReset(); + GDALDatasetShadow_FlushCache(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_add_band(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + GDALDataType arg2 = (GDALDataType) GDT_Byte ; + char **arg3 = (char **) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + char *kwnames[] = { + "self","datatype","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AddBand" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + if (argc > 0) { + { + /* %typemap(in) CPLErr */ + arg2 = (GDALDataType) NUM2INT(argv[0]); + } + } + if (argc > 1) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[1], T_ARRAY); + + int size = RARRAY(argv[1])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[1], i); + char *pszItem = StringValuePtr(item); + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_AddBand(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg3 ); + } + return vresult; +fail: + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg3 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Dataset_write_raster(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + GDALDataType *arg10 = (GDALDataType *) 0 ; + int arg11 = (int) 0 ; + int *arg12 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int res6 ; + char *buf6 = 0 ; + size_t size6 = 0 ; + int alloc6 = 0 ; + void *argp8 = 0 ; + int res8 ; + void *argp9 = 0 ; + int res9 ; + void *argp10 = 0 ; + int res10 ; + char *kwnames[] = { + "self","xoff","yoff","xsize","ysize","buf_len","buf_xsize","buf_ysize","buf_type","band_list", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 5) || (argc > 9)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 5)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + ecode4 = SWIG_AsVal_int(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + ecode5 = SWIG_AsVal_int(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast<int >(val5); + res6 = SWIG_AsCharPtrAndSize(argv[4], &buf6, &size6, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(((res6 != SWIG_ERROR) ? res6 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "6"" of type '" "int""'"); + } + arg7 = static_cast<char * >(buf6) ; + arg6 = static_cast<int >(size6 - 1) ; + if (argc > 5) { + res8 = SWIG_ConvertPtr(argv[5], &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(((res8 != SWIG_ERROR) ? res8 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "8"" of type '" "int *""'"); + } + arg8 = reinterpret_cast<int * >(argp8); + } + if (argc > 6) { + res9 = SWIG_ConvertPtr(argv[6], &argp9,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(((res9 != SWIG_ERROR) ? res9 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "9"" of type '" "int *""'"); + } + arg9 = reinterpret_cast<int * >(argp9); + } + if (argc > 7) { + res10 = SWIG_ConvertPtr(argv[7], &argp10,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(((res10 != SWIG_ERROR) ? res10 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "10"" of type '" "GDALDataType *""'"); + } + arg10 = reinterpret_cast<GDALDataType * >(argp10); + } + if (argc > 8) { + { + /* %typemap(in,numinputs=1) (int nList, int* pList) */ + + /* Make sure this is an array. */ + Check_Type(argv[8], T_ARRAY); + + /* Get the length */ + arg11 = RARRAY(argv[8])->len; + + /* Allocate space for the C array. */ + arg12 = (int*) malloc(arg11*sizeof(int)); + + for( int i = 0; i<arg11; i++ ) { + /* Get the Ruby Object */ + VALUE item = rb_ary_entry(argv[8],i); + /* Conver to an integer */ + arg12[i] = NUM2INT(item); + } + } + } + { + CPLErrorReset(); + result = (CPLErr)GDALDatasetShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + return vresult; +fail: + { + /* %typemap(freearg) (int nList, int* pList) */ + if (arg12) { + free((void*) arg12); + } + } + return Qnil; +} + + +swig_class cBand; + +SWIGINTERN VALUE +_wrap_Band_xsize_get(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "XSize" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_XSize_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_ysize_get(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "YSize" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_YSize_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_data_type_get(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALDataType result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "DataType" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALDataType)GDALRasterBandShadow_DataType_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_raster_color_interpretation(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetRasterColorInterpretation" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALColorInterp)GDALRasterBandShadow_GetRasterColorInterpretation(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_set_raster_color_interpretation(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorInterp arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetRasterColorInterpretation" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + /* %typemap(in) CPLErr */ + arg2 = (GDALColorInterp) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetRasterColorInterpretation(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_no_data_value(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 ; + double tmpval2 ; + int tmphasval2 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetNoDataValue" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetNoDataValue(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*arg3 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*arg2); + } + + vresult = SWIG_Ruby_AppendOutput(vresult, argOut); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_set_no_data_value(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetNoDataValue" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetNoDataValue" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_SetNoDataValue(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_minimum(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 ; + double tmpval2 ; + int tmphasval2 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetMinimum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetMinimum(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*arg3 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*arg2); + } + + vresult = SWIG_Ruby_AppendOutput(vresult, argOut); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_maximum(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 ; + double tmpval2 ; + int tmphasval2 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetMaximum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetMaximum(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*arg3 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*arg2); + } + + vresult = SWIG_Ruby_AppendOutput(vresult, argOut); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_offset(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 ; + double tmpval2 ; + int tmphasval2 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetOffset" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetOffset(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*arg3 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*arg2); + } + + vresult = SWIG_Ruby_AppendOutput(vresult, argOut); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_scale(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 = (double *) 0 ; + int *arg3 = (int *) 0 ; + void *argp1 = 0 ; + int res1 ; + double tmpval2 ; + int tmphasval2 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double *val, int*hasval) */ + arg2 = &tmpval2; + arg3 = &tmphasval2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetScale" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_GetScale(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double *val, int *hasval) */ + VALUE argOut; + + if ( !*arg3 ) { + argOut = Qnil; + } + else { + argOut = rb_float_new(*arg2); + } + + vresult = SWIG_Ruby_AppendOutput(vresult, argOut); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_overview_count(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetOverviewCount" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_GetOverviewCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_overview(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + GDALRasterBandShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetOverview" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetOverview" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (GDALRasterBandShadow *)GDALRasterBandShadow_GetOverview(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_checksum(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 = (int) 0 ; + int arg3 = (int) 0 ; + int *arg4 = (int *) 0 ; + int *arg5 = (int *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 ; + void *argp5 = 0 ; + int res5 ; + char *kwnames[] = { + "self","xoff","yoff","xsize","ysize", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Checksum" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + if (argc > 0) { + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "Checksum" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "Checksum" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + if (argc > 2) { + res4 = SWIG_ConvertPtr(argv[2], &argp4,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "Checksum" "', argument " "4"" of type '" "int *""'"); + } + arg4 = reinterpret_cast<int * >(argp4); + } + if (argc > 3) { + res5 = SWIG_ConvertPtr(argv[3], &argp5,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(((res5 != SWIG_ERROR) ? res5 : SWIG_TypeError), "in method '" "Checksum" "', argument " "5"" of type '" "int *""'"); + } + arg5 = reinterpret_cast<int * >(argp5); + } + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_Checksum(arg1,arg2,arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_compute_raster_min_max(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 0 ; + void *argp1 = 0 ; + int res1 ; + double argout2[2] ; + int val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ComputeRasterMinMax" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + if (argc > 0) { + ecode3 = SWIG_AsVal_int(argv[0], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "ComputeRasterMinMax" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + GDALRasterBandShadow_ComputeRasterMinMax(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<2; i++) + { + VALUE value = rb_float_new((arg2)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_fill(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + double arg2 ; + double arg3 = (double) 0.0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Fill" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "Fill" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + if (argc > 1) { + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "Fill" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_Fill(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_read_raster(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int *arg6 = (int *) 0 ; + char **arg7 = (char **) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int nLen6 = 0 ; + char *pBuf6 = 0 ; + void *argp8 = 0 ; + int res8 ; + void *argp9 = 0 ; + int res9 ; + void *argp10 = 0 ; + int res10 ; + char *kwnames[] = { + "self","xoff","yoff","xsize","ysize","buf_xsize","buf_ysize","buf_type", NULL + }; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (int *nLen6, char **pBuf6 ) ( int nLen6 = 0, char *pBuf6 = 0 ) */ + arg6 = &nLen6; + arg7 = &pBuf6; + } + if ((argc < 4) || (argc > 7)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + ecode4 = SWIG_AsVal_int(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + ecode5 = SWIG_AsVal_int(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast<int >(val5); + if (argc > 4) { + res8 = SWIG_ConvertPtr(argv[4], &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(((res8 != SWIG_ERROR) ? res8 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "8"" of type '" "int *""'"); + } + arg8 = reinterpret_cast<int * >(argp8); + } + if (argc > 5) { + res9 = SWIG_ConvertPtr(argv[5], &argp9,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(((res9 != SWIG_ERROR) ? res9 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "9"" of type '" "int *""'"); + } + arg9 = reinterpret_cast<int * >(argp9); + } + if (argc > 6) { + res10 = SWIG_ConvertPtr(argv[6], &argp10,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(((res10 != SWIG_ERROR) ? res10 : SWIG_TypeError), "in method '" "ReadRaster" "', argument " "10"" of type '" "int *""'"); + } + arg10 = reinterpret_cast<int * >(argp10); + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_ReadRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + vresult = rb_str_new(*arg7, *arg6); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg7 ) { + free( *arg7 ); + } + } + return vresult; +fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg7 ) { + free( *arg7 ); + } + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_write_raster(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + int arg2 ; + int arg3 ; + int arg4 ; + int arg5 ; + int arg6 ; + char *arg7 = (char *) 0 ; + int *arg8 = (int *) 0 ; + int *arg9 = (int *) 0 ; + int *arg10 = (int *) 0 ; + CPLErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int res6 ; + char *buf6 = 0 ; + size_t size6 = 0 ; + int alloc6 = 0 ; + void *argp8 = 0 ; + int res8 ; + void *argp9 = 0 ; + int res9 ; + void *argp10 = 0 ; + int res10 ; + char *kwnames[] = { + "self","xoff","yoff","xsize","ysize","buf_len","buf_xsize","buf_ysize","buf_type", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 5) || (argc > 8)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 5)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + ecode4 = SWIG_AsVal_int(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "4"" of type '" "int""'"); + } + arg4 = static_cast<int >(val4); + ecode5 = SWIG_AsVal_int(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "5"" of type '" "int""'"); + } + arg5 = static_cast<int >(val5); + res6 = SWIG_AsCharPtrAndSize(argv[4], &buf6, &size6, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(((res6 != SWIG_ERROR) ? res6 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "6"" of type '" "int""'"); + } + arg7 = static_cast<char * >(buf6) ; + arg6 = static_cast<int >(size6 - 1) ; + if (argc > 5) { + res8 = SWIG_ConvertPtr(argv[5], &argp8,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(((res8 != SWIG_ERROR) ? res8 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "8"" of type '" "int *""'"); + } + arg8 = reinterpret_cast<int * >(argp8); + } + if (argc > 6) { + res9 = SWIG_ConvertPtr(argv[6], &argp9,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(((res9 != SWIG_ERROR) ? res9 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "9"" of type '" "int *""'"); + } + arg9 = reinterpret_cast<int * >(argp9); + } + if (argc > 7) { + res10 = SWIG_ConvertPtr(argv[7], &argp10,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res10)) { + SWIG_exception_fail(((res10 != SWIG_ERROR) ? res10 : SWIG_TypeError), "in method '" "WriteRaster" "', argument " "10"" of type '" "int *""'"); + } + arg10 = reinterpret_cast<int * >(argp10); + } + { + CPLErrorReset(); + result = (CPLErr)GDALRasterBandShadow_WriteRaster(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) CPLErr */ + vresult = (CPLErr)LONG2NUM(result); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_flush_cache(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "FlushCache" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + GDALRasterBandShadow_FlushCache(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_get_raster_color_table(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetRasterColorTable" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + { + CPLErrorReset(); + result = (GDALColorTable *)GDALRasterBandShadow_GetRasterColorTable(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorTable, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Band_set_raster_color_table(int argc, VALUE *argv, VALUE self) { + GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; + GDALColorTable *arg2 = (GDALColorTable *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetRasterColorTable" "', argument " "1"" of type '" "GDALRasterBandShadow *""'"); + } + arg1 = reinterpret_cast<GDALRasterBandShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetRasterColorTable" "', argument " "2"" of type '" "GDALColorTable *""'"); + } + arg2 = reinterpret_cast<GDALColorTable * >(argp2); + { + CPLErrorReset(); + result = (int)GDALRasterBandShadow_SetRasterColorTable(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +swig_class cColorTable; + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_ColorTable_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_ColorTable_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_GDALColorTable); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_ColorTable(int argc, VALUE *argv, VALUE self) { + GDALPaletteInterp arg1 = (GDALPaletteInterp) GPI_RGB ; + GDALColorTable *result = 0 ; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + { + /* %typemap(in) CPLErr */ + arg1 = (GDALPaletteInterp) NUM2INT(argv[0]); + } + } + { + CPLErrorReset(); + result = (GDALColorTable *)new GDALColorTable(arg1); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return self; +fail: + return Qnil; +} + + +SWIGINTERN void +free_GDALColorTable(GDALColorTable *arg1) { + delete arg1; +} + +SWIGINTERN VALUE +_wrap_ColorTable_clone(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALColorTable *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Clone" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (GDALColorTable *)((GDALColorTable const *)arg1)->Clone(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorTable, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ColorTable_get_palette_interpretation(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + GDALPaletteInterp result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetPaletteInterpretation" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (GDALPaletteInterp)((GDALColorTable const *)arg1)->GetPaletteInterpretation(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ColorTable_get_count(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetColorEntryCount" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryCount(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ColorTable_get_color_entry(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetColorEntry" "', argument " "1"" of type '" "GDALColorTable *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetColorEntry" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (GDALColorEntry *)(arg1)->GetColorEntry(arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALColorEntry, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ColorTable_get_color_entry_as_rgb(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetColorEntryAsRGB" "', argument " "1"" of type '" "GDALColorTable const *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetColorEntryAsRGB" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_GDALColorEntry, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "GetColorEntryAsRGB" "', argument " "3"" of type '" "GDALColorEntry *""'"); + } + arg3 = reinterpret_cast<GDALColorEntry * >(argp3); + { + CPLErrorReset(); + result = (int)((GDALColorTable const *)arg1)->GetColorEntryAsRGB(arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_ColorTable_set_color_entry(int argc, VALUE *argv, VALUE self) { + GDALColorTable *arg1 = (GDALColorTable *) 0 ; + int arg2 ; + GDALColorEntry *arg3 = (GDALColorEntry *) 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_GDALColorTable, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetColorEntry" "', argument " "1"" of type '" "GDALColorTable *""'"); + } + arg1 = reinterpret_cast<GDALColorTable * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetColorEntry" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_GDALColorEntry, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetColorEntry" "', argument " "3"" of type '" "GDALColorEntry const *""'"); + } + arg3 = reinterpret_cast<GDALColorEntry * >(argp3); + { + CPLErrorReset(); + (arg1)->SetColorEntry(arg2,(GDALColorEntry const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_all_register(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + GDALAllRegister(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_cache_max(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GDALGetCacheMax(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_set_cache_max(int argc, VALUE *argv, VALUE self) { + int arg1 ; + int val1 ; + int ecode1 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_int(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GDALSetCacheMax" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast<int >(val1); + { + CPLErrorReset(); + GDALSetCacheMax(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_set_cache_used(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GDALGetCacheUsed(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_data_type_size(int argc, VALUE *argv, VALUE self) { + GDALDataType arg1 ; + int result; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) CPLErr */ + arg1 = (GDALDataType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (int)GDALGetDataTypeSize(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_data_type_is_complex(int argc, VALUE *argv, VALUE self) { + GDALDataType arg1 ; + int result; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) CPLErr */ + arg1 = (GDALDataType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (int)GDALDataTypeIsComplex(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_data_type_name(int argc, VALUE *argv, VALUE self) { + GDALDataType arg1 ; + char *result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) CPLErr */ + arg1 = (GDALDataType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (char *)GDALGetDataTypeName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_data_type_by_name(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + GDALDataType result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GDALGetDataTypeByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (GDALDataType)GDALGetDataTypeByName((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_color_interpretation_name(int argc, VALUE *argv, VALUE self) { + GDALColorInterp arg1 ; + char *result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) CPLErr */ + arg1 = (GDALColorInterp) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (char *)GDALGetColorInterpretationName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_palette_interpretation_name(int argc, VALUE *argv, VALUE self) { + GDALPaletteInterp arg1 ; + char *result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) CPLErr */ + arg1 = (GDALPaletteInterp) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (char *)GDALGetPaletteInterpretationName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_dec_to_dms(int argc, VALUE *argv, VALUE self) { + double arg1 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 2 ; + char *result = 0 ; + double val1 ; + int ecode1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_double(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GDALDecToDMS" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast<double >(val1); + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GDALDecToDMS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 2) { + ecode3 = SWIG_AsVal_int(argv[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GDALDecToDMS" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (char *)GDALDecToDMS(arg1,(char const *)arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_packed_dms_to_dec(int argc, VALUE *argv, VALUE self) { + double arg1 ; + double result; + double val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_double(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GDALPackedDMSToDec" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast<double >(val1); + { + CPLErrorReset(); + result = (double)GDALPackedDMSToDec(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_dec_to_packed_dms(int argc, VALUE *argv, VALUE self) { + double arg1 ; + double result; + double val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_double(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GDALDecToPackedDMS" "', argument " "1"" of type '" "double""'"); + } + arg1 = static_cast<double >(val1); + { + CPLErrorReset(); + result = (double)GDALDecToPackedDMS(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_parse_xml_string(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + CPLXMLNode *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CPLParseXMLString" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (CPLXMLNode *)CPLParseXMLString(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) (CPLXMLNode*) */ + + vresult = XMLTreeToRubyArray(result); + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(ret) (CPLXMLNode*) */ + if ( result ) { + CPLDestroyXMLNode( result ); + } + } return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_serialize_xml_tree(int argc, VALUE *argv, VALUE self) { + CPLXMLNode *arg1 = (CPLXMLNode *) 0 ; + char *result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) (CPLXMLNode* xmlnode ) */ + arg1 = RubyArrayToXMLTree(argv[0]); + + if ( !arg1 ) { + rb_raise(rb_eRuntimeError, "Could not convert Ruby Array to XML tree."); + } + } + { + CPLErrorReset(); + result = (char *)CPLSerializeXMLTree(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + { + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + + if ( arg1 ) { + CPLDestroyXMLNode( arg1 ); + } + } + return vresult; +fail: + { + /* %typemap(freearg) (CPLXMLNode *xmlnode) */ + + if ( arg1 ) { + CPLDestroyXMLNode( arg1 ); + } + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver_count(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)GetDriverCount(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver_by_name(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + GDALDriverShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDriverByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriverByName((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver(int argc, VALUE *argv, VALUE self) { + int arg1 ; + GDALDriverShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_int(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GetDriver" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast<int >(val1); + { + CPLErrorReset(); + result = (GDALDriverShadow *)GetDriver(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDriverShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_open(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Open" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (argc > 1) { + { + /* %typemap(in) CPLErr */ + arg2 = (GDALAccess) NUM2INT(argv[1]); + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)Open((char const *)arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_open_shared(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + GDALAccess arg2 = (GDALAccess) GA_ReadOnly ; + GDALDatasetShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OpenShared" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (argc > 1) { + { + /* %typemap(in) CPLErr */ + arg2 = (GDALAccess) NUM2INT(argv[1]); + } + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)OpenShared((char const *)arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_auto_create_warped_vrt(int argc, VALUE *argv, VALUE self) { + GDALDatasetShadow *arg1 = (GDALDatasetShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + GDALResampleAlg arg4 = (GDALResampleAlg) GRA_NearestNeighbour ; + double arg5 = (double) 0.0 ; + GDALDatasetShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 5)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_GDALDatasetShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AutoCreateWarpedVRT" "', argument " "1"" of type '" "GDALDatasetShadow *""'"); + } + arg1 = reinterpret_cast<GDALDatasetShadow * >(argp1); + if (argc > 1) { + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "AutoCreateWarpedVRT" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + } + if (argc > 2) { + res3 = SWIG_AsCharPtrAndSize(argv[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "AutoCreateWarpedVRT" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + } + if (argc > 3) { + { + /* %typemap(in) CPLErr */ + arg4 = (GDALResampleAlg) NUM2INT(argv[3]); + } + } + if (argc > 4) { + ecode5 = SWIG_AsVal_double(argv[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "AutoCreateWarpedVRT" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + } + { + CPLErrorReset(); + result = (GDALDatasetShadow *)AutoCreateWarpedVRT(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_GDALDatasetShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static void *_p_GDALDriverShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDriverShadow *) x)); +} +static void *_p_GDALDatasetShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALDatasetShadow *) x)); +} +static void *_p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow(void *x) { + return (void *)((GDALMajorObjectShadow *) ((GDALRasterBandShadow *) x)); +} +static swig_type_info _swigt__p_CPLErrorHandler = {"_p_CPLErrorHandler", "CPLErrorHandler *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_CPLXMLNode = {"_p_CPLXMLNode", "CPLXMLNode *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GByte = {"_p_GByte", "GByte *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALColorEntry = {"_p_GDALColorEntry", "GDALColorEntry *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALColorTable = {"_p_GDALColorTable", "GDALColorTable *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALDatasetShadow = {"_p_GDALDatasetShadow", "GDALDatasetShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALDriverShadow = {"_p_GDALDriverShadow", "GDALDriverShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALMajorObjectShadow = {"_p_GDALMajorObjectShadow", "GDALMajorObjectShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDALRasterBandShadow = {"_p_GDALRasterBandShadow", "GDALRasterBandShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_GDAL_GCP = {"_p_GDAL_GCP", "GDAL_GCP *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *|GDALPaletteInterp *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_GDAL_GCP = {"_p_p_GDAL_GCP", "GDAL_GCP **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_CPLErrorHandler, + &_swigt__p_CPLXMLNode, + &_swigt__p_GByte, + &_swigt__p_GDALColorEntry, + &_swigt__p_GDALColorTable, + &_swigt__p_GDALDatasetShadow, + &_swigt__p_GDALDriverShadow, + &_swigt__p_GDALMajorObjectShadow, + &_swigt__p_GDALRasterBandShadow, + &_swigt__p_GDAL_GCP, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_GDAL_GCP, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__p_CPLErrorHandler[] = { {&_swigt__p_CPLErrorHandler, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_CPLXMLNode[] = { {&_swigt__p_CPLXMLNode, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GByte[] = { {&_swigt__p_GByte, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorEntry[] = { {&_swigt__p_GDALColorEntry, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALColorTable[] = { {&_swigt__p_GDALColorTable, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDatasetShadow[] = { {&_swigt__p_GDALDatasetShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALDriverShadow[] = { {&_swigt__p_GDALDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALMajorObjectShadow[] = { {&_swigt__p_GDALMajorObjectShadow, 0, 0, 0}, {&_swigt__p_GDALDriverShadow, _p_GDALDriverShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALDatasetShadow, _p_GDALDatasetShadowTo_p_GDALMajorObjectShadow, 0, 0}, {&_swigt__p_GDALRasterBandShadow, _p_GDALRasterBandShadowTo_p_GDALMajorObjectShadow, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDALRasterBandShadow[] = { {&_swigt__p_GDALRasterBandShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_GDAL_GCP[] = { {&_swigt__p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_GDAL_GCP[] = { {&_swigt__p_p_GDAL_GCP, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_CPLErrorHandler, + _swigc__p_CPLXMLNode, + _swigc__p_GByte, + _swigc__p_GDALColorEntry, + _swigc__p_GDALColorTable, + _swigc__p_GDALDatasetShadow, + _swigc__p_GDALDriverShadow, + _swigc__p_GDALMajorObjectShadow, + _swigc__p_GDALRasterBandShadow, + _swigc__p_GDAL_GCP, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_GDAL_GCP, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void Init_gdal(void) { + size_t i; + + SWIG_InitRuntime(); + mGdal = rb_define_module("Gdal"); + mGdal = rb_define_module_under(mGdal, "Gdal"); + + SWIG_InitializeModule(0); + for (i = 0; i < swig_module.size; i++) { + SWIG_define_class(swig_module.types[i]); + } + + SWIG_RubyInitializeTrackings(); + + /* gdal_ruby.i %init code */ + if ( GDALGetDriverCount() == 0 ) { + GDALAllRegister(); + } + + rb_define_module_function(mGdal, "use_exceptions", VALUEFUNC(_wrap_use_exceptions), -1); + rb_define_module_function(mGdal, "dont_use_exceptions", VALUEFUNC(_wrap_dont_use_exceptions), -1); + rb_define_module_function(mGdal, "debug", VALUEFUNC(_wrap_debug), -1); + rb_define_module_function(mGdal, "error", VALUEFUNC(_wrap_error), -1); + rb_define_module_function(mGdal, "push_error_handler", VALUEFUNC(_wrap_push_error_handler), -1); + rb_define_module_function(mGdal, "pop_error_handler", VALUEFUNC(_wrap_pop_error_handler), -1); + rb_define_module_function(mGdal, "error_reset", VALUEFUNC(_wrap_error_reset), -1); + rb_define_module_function(mGdal, "get_last_error_no", VALUEFUNC(_wrap_get_last_error_no), -1); + rb_define_module_function(mGdal, "get_last_error_type", VALUEFUNC(_wrap_get_last_error_type), -1); + rb_define_module_function(mGdal, "get_last_error_msg", VALUEFUNC(_wrap_get_last_error_msg), -1); + rb_define_module_function(mGdal, "push_finder_location", VALUEFUNC(_wrap_push_finder_location), -1); + rb_define_module_function(mGdal, "pop_finder_location", VALUEFUNC(_wrap_pop_finder_location), -1); + rb_define_module_function(mGdal, "finder_clean", VALUEFUNC(_wrap_finder_clean), -1); + rb_define_module_function(mGdal, "find_file", VALUEFUNC(_wrap_find_file), -1); + rb_define_module_function(mGdal, "set_config_option", VALUEFUNC(_wrap_set_config_option), -1); + rb_define_module_function(mGdal, "get_config_option", VALUEFUNC(_wrap_get_config_option), -1); + rb_define_module_function(mGdal, "binary_to_hex", VALUEFUNC(_wrap_binary_to_hex), -1); + rb_define_module_function(mGdal, "hex_to_binary", VALUEFUNC(_wrap_hex_to_binary), -1); + + cMajorObject.klass = rb_define_class_under(mGdal, "MajorObject", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_GDALMajorObjectShadow, (void *) &cMajorObject); + rb_undef_alloc_func(cMajorObject.klass); + rb_define_method(cMajorObject.klass, "get_description", VALUEFUNC(_wrap_MajorObject_get_description), -1); + rb_define_method(cMajorObject.klass, "set_description", VALUEFUNC(_wrap_MajorObject_set_description), -1); + rb_define_method(cMajorObject.klass, "get_metadata_dict", VALUEFUNC(_wrap_MajorObject_get_metadata_dict), -1); + rb_define_method(cMajorObject.klass, "get_metadata_list", VALUEFUNC(_wrap_MajorObject_get_metadata_list), -1); + rb_define_method(cMajorObject.klass, "set_metadata", VALUEFUNC(_wrap_MajorObject_set_metadata), -1); + cMajorObject.mark = 0; + cMajorObject.trackObjects = 0; + + cDriver.klass = rb_define_class_under(mGdal, "Driver", ((swig_class *) SWIGTYPE_p_GDALMajorObjectShadow->clientdata)->klass); + SWIG_TypeClientData(SWIGTYPE_p_GDALDriverShadow, (void *) &cDriver); + rb_undef_alloc_func(cDriver.klass); + rb_define_method(cDriver.klass, "short_name", VALUEFUNC(_wrap_Driver_short_name_get), -1); + rb_define_method(cDriver.klass, "long_name", VALUEFUNC(_wrap_Driver_long_name_get), -1); + rb_define_method(cDriver.klass, "help_topic", VALUEFUNC(_wrap_Driver_help_topic_get), -1); + rb_define_method(cDriver.klass, "create", VALUEFUNC(_wrap_Driver_create), -1); + rb_define_method(cDriver.klass, "create_copy", VALUEFUNC(_wrap_Driver_create_copy), -1); + rb_define_method(cDriver.klass, "delete", VALUEFUNC(_wrap_Driver_delete), -1); + cDriver.mark = 0; + cDriver.trackObjects = 0; + + cGCP.klass = rb_define_class_under(mGdal, "GCP", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_GDAL_GCP, (void *) &cGCP); + rb_define_alloc_func(cGCP.klass, _wrap_GCP_allocate); + rb_define_method(cGCP.klass, "initialize", VALUEFUNC(_wrap_new_GCP), -1); + rb_define_method(cGCP.klass, "gcpx=", VALUEFUNC(_wrap_GCP_gcpx_set), -1); + rb_define_method(cGCP.klass, "gcpx", VALUEFUNC(_wrap_GCP_gcpx_get), -1); + rb_define_method(cGCP.klass, "gcpy=", VALUEFUNC(_wrap_GCP_gcpy_set), -1); + rb_define_method(cGCP.klass, "gcpy", VALUEFUNC(_wrap_GCP_gcpy_get), -1); + rb_define_method(cGCP.klass, "gcpz=", VALUEFUNC(_wrap_GCP_gcpz_set), -1); + rb_define_method(cGCP.klass, "gcpz", VALUEFUNC(_wrap_GCP_gcpz_get), -1); + rb_define_method(cGCP.klass, "gcppixel=", VALUEFUNC(_wrap_GCP_gcppixel_set), -1); + rb_define_method(cGCP.klass, "gcppixel", VALUEFUNC(_wrap_GCP_gcppixel_get), -1); + rb_define_method(cGCP.klass, "gcpline=", VALUEFUNC(_wrap_GCP_gcpline_set), -1); + rb_define_method(cGCP.klass, "gcpline", VALUEFUNC(_wrap_GCP_gcpline_get), -1); + rb_define_method(cGCP.klass, "info=", VALUEFUNC(_wrap_GCP_info_set), -1); + rb_define_method(cGCP.klass, "info", VALUEFUNC(_wrap_GCP_info_get), -1); + rb_define_method(cGCP.klass, "id=", VALUEFUNC(_wrap_GCP_id_set), -1); + rb_define_method(cGCP.klass, "id", VALUEFUNC(_wrap_GCP_id_get), -1); + cGCP.mark = 0; + cGCP.destroy = (void (*)(void *)) free_GDAL_GCP; + cGCP.trackObjects = 0; + rb_define_module_function(mGdal, "gdal_gcp_gcpx_get", VALUEFUNC(_wrap_gdal_gcp_gcpx_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpx_set", VALUEFUNC(_wrap_gdal_gcp_gcpx_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpy_get", VALUEFUNC(_wrap_gdal_gcp_gcpy_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpy_set", VALUEFUNC(_wrap_gdal_gcp_gcpy_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpz_get", VALUEFUNC(_wrap_gdal_gcp_gcpz_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpz_set", VALUEFUNC(_wrap_gdal_gcp_gcpz_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcppixel_get", VALUEFUNC(_wrap_gdal_gcp_gcppixel_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcppixel_set", VALUEFUNC(_wrap_gdal_gcp_gcppixel_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpline_get", VALUEFUNC(_wrap_gdal_gcp_gcpline_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_gcpline_set", VALUEFUNC(_wrap_gdal_gcp_gcpline_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_info_get", VALUEFUNC(_wrap_gdal_gcp_info_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_info_set", VALUEFUNC(_wrap_gdal_gcp_info_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_id_get", VALUEFUNC(_wrap_gdal_gcp_id_get), -1); + rb_define_module_function(mGdal, "gdal_gcp_id_set", VALUEFUNC(_wrap_gdal_gcp_id_set), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_gcpx", VALUEFUNC(_wrap_gdal_gcp_get_gcpx), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_gcpx", VALUEFUNC(_wrap_gdal_gcp_set_gcpx), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_gcpy", VALUEFUNC(_wrap_gdal_gcp_get_gcpy), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_gcpy", VALUEFUNC(_wrap_gdal_gcp_set_gcpy), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_gcpz", VALUEFUNC(_wrap_gdal_gcp_get_gcpz), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_gcpz", VALUEFUNC(_wrap_gdal_gcp_set_gcpz), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_gcppixel", VALUEFUNC(_wrap_gdal_gcp_get_gcppixel), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_gcppixel", VALUEFUNC(_wrap_gdal_gcp_set_gcppixel), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_gcpline", VALUEFUNC(_wrap_gdal_gcp_get_gcpline), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_gcpline", VALUEFUNC(_wrap_gdal_gcp_set_gcpline), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_info", VALUEFUNC(_wrap_gdal_gcp_get_info), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_info", VALUEFUNC(_wrap_gdal_gcp_set_info), -1); + rb_define_module_function(mGdal, "gdal_gcp_get_id", VALUEFUNC(_wrap_gdal_gcp_get_id), -1); + rb_define_module_function(mGdal, "gdal_gcp_set_id", VALUEFUNC(_wrap_gdal_gcp_set_id), -1); + rb_define_module_function(mGdal, "gcps_to_geo_transform", VALUEFUNC(_wrap_gcps_to_geo_transform), -1); + + cDataset.klass = rb_define_class_under(mGdal, "Dataset", ((swig_class *) SWIGTYPE_p_GDALMajorObjectShadow->clientdata)->klass); + SWIG_TypeClientData(SWIGTYPE_p_GDALDatasetShadow, (void *) &cDataset); + rb_undef_alloc_func(cDataset.klass); + rb_define_method(cDataset.klass, "raster_xsize", VALUEFUNC(_wrap_Dataset_raster_xsize_get), -1); + rb_define_method(cDataset.klass, "raster_ysize", VALUEFUNC(_wrap_Dataset_raster_ysize_get), -1); + rb_define_method(cDataset.klass, "raster_count", VALUEFUNC(_wrap_Dataset_raster_count_get), -1); + rb_define_method(cDataset.klass, "get_driver", VALUEFUNC(_wrap_Dataset_get_driver), -1); + rb_define_method(cDataset.klass, "get_raster_band", VALUEFUNC(_wrap_Dataset_get_raster_band), -1); + rb_define_method(cDataset.klass, "get_projection", VALUEFUNC(_wrap_Dataset_get_projection), -1); + rb_define_method(cDataset.klass, "get_projection_ref", VALUEFUNC(_wrap_Dataset_get_projection_ref), -1); + rb_define_method(cDataset.klass, "set_projection", VALUEFUNC(_wrap_Dataset_set_projection), -1); + rb_define_method(cDataset.klass, "get_geo_transform", VALUEFUNC(_wrap_Dataset_get_geo_transform), -1); + rb_define_method(cDataset.klass, "set_geo_transform", VALUEFUNC(_wrap_Dataset_set_geo_transform), -1); + rb_define_method(cDataset.klass, "build_overviews", VALUEFUNC(_wrap_Dataset_build_overviews), -1); + rb_define_method(cDataset.klass, "get_gcpcount", VALUEFUNC(_wrap_Dataset_get_gcpcount), -1); + rb_define_method(cDataset.klass, "get_gcpprojection", VALUEFUNC(_wrap_Dataset_get_gcpprojection), -1); + rb_define_method(cDataset.klass, "get_gcps", VALUEFUNC(_wrap_Dataset_get_gcps), -1); + rb_define_method(cDataset.klass, "set_gcps", VALUEFUNC(_wrap_Dataset_set_gcps), -1); + rb_define_method(cDataset.klass, "flush_cache", VALUEFUNC(_wrap_Dataset_flush_cache), -1); + rb_define_method(cDataset.klass, "add_band", VALUEFUNC(_wrap_Dataset_add_band), -1); + rb_define_method(cDataset.klass, "write_raster", VALUEFUNC(_wrap_Dataset_write_raster), -1); + cDataset.mark = 0; + cDataset.destroy = (void (*)(void *)) free_GDALDatasetShadow; + cDataset.trackObjects = 0; + + cBand.klass = rb_define_class_under(mGdal, "Band", ((swig_class *) SWIGTYPE_p_GDALMajorObjectShadow->clientdata)->klass); + SWIG_TypeClientData(SWIGTYPE_p_GDALRasterBandShadow, (void *) &cBand); + rb_undef_alloc_func(cBand.klass); + rb_define_method(cBand.klass, "xsize", VALUEFUNC(_wrap_Band_xsize_get), -1); + rb_define_method(cBand.klass, "ysize", VALUEFUNC(_wrap_Band_ysize_get), -1); + rb_define_method(cBand.klass, "data_type", VALUEFUNC(_wrap_Band_data_type_get), -1); + rb_define_method(cBand.klass, "get_raster_color_interpretation", VALUEFUNC(_wrap_Band_get_raster_color_interpretation), -1); + rb_define_method(cBand.klass, "set_raster_color_interpretation", VALUEFUNC(_wrap_Band_set_raster_color_interpretation), -1); + rb_define_method(cBand.klass, "get_no_data_value", VALUEFUNC(_wrap_Band_get_no_data_value), -1); + rb_define_method(cBand.klass, "set_no_data_value", VALUEFUNC(_wrap_Band_set_no_data_value), -1); + rb_define_method(cBand.klass, "get_minimum", VALUEFUNC(_wrap_Band_get_minimum), -1); + rb_define_method(cBand.klass, "get_maximum", VALUEFUNC(_wrap_Band_get_maximum), -1); + rb_define_method(cBand.klass, "get_offset", VALUEFUNC(_wrap_Band_get_offset), -1); + rb_define_method(cBand.klass, "get_scale", VALUEFUNC(_wrap_Band_get_scale), -1); + rb_define_method(cBand.klass, "get_overview_count", VALUEFUNC(_wrap_Band_get_overview_count), -1); + rb_define_method(cBand.klass, "get_overview", VALUEFUNC(_wrap_Band_get_overview), -1); + rb_define_method(cBand.klass, "checksum", VALUEFUNC(_wrap_Band_checksum), -1); + rb_define_method(cBand.klass, "compute_raster_min_max", VALUEFUNC(_wrap_Band_compute_raster_min_max), -1); + rb_define_method(cBand.klass, "fill", VALUEFUNC(_wrap_Band_fill), -1); + rb_define_method(cBand.klass, "read_raster", VALUEFUNC(_wrap_Band_read_raster), -1); + rb_define_method(cBand.klass, "write_raster", VALUEFUNC(_wrap_Band_write_raster), -1); + rb_define_method(cBand.klass, "flush_cache", VALUEFUNC(_wrap_Band_flush_cache), -1); + rb_define_method(cBand.klass, "get_raster_color_table", VALUEFUNC(_wrap_Band_get_raster_color_table), -1); + rb_define_method(cBand.klass, "set_raster_color_table", VALUEFUNC(_wrap_Band_set_raster_color_table), -1); + cBand.mark = 0; + cBand.trackObjects = 0; + + cColorTable.klass = rb_define_class_under(mGdal, "ColorTable", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_GDALColorTable, (void *) &cColorTable); + rb_define_alloc_func(cColorTable.klass, _wrap_ColorTable_allocate); + rb_define_method(cColorTable.klass, "initialize", VALUEFUNC(_wrap_new_ColorTable), -1); + rb_define_method(cColorTable.klass, "clone", VALUEFUNC(_wrap_ColorTable_clone), -1); + rb_define_method(cColorTable.klass, "get_palette_interpretation", VALUEFUNC(_wrap_ColorTable_get_palette_interpretation), -1); + rb_define_method(cColorTable.klass, "get_count", VALUEFUNC(_wrap_ColorTable_get_count), -1); + rb_define_method(cColorTable.klass, "get_color_entry", VALUEFUNC(_wrap_ColorTable_get_color_entry), -1); + rb_define_method(cColorTable.klass, "get_color_entry_as_rgb", VALUEFUNC(_wrap_ColorTable_get_color_entry_as_rgb), -1); + rb_define_method(cColorTable.klass, "set_color_entry", VALUEFUNC(_wrap_ColorTable_set_color_entry), -1); + cColorTable.mark = 0; + cColorTable.destroy = (void (*)(void *)) free_GDALColorTable; + cColorTable.trackObjects = 0; + rb_define_module_function(mGdal, "all_register", VALUEFUNC(_wrap_all_register), -1); + rb_define_module_function(mGdal, "get_cache_max", VALUEFUNC(_wrap_get_cache_max), -1); + rb_define_module_function(mGdal, "set_cache_max", VALUEFUNC(_wrap_set_cache_max), -1); + rb_define_module_function(mGdal, "set_cache_used", VALUEFUNC(_wrap_set_cache_used), -1); + rb_define_module_function(mGdal, "get_data_type_size", VALUEFUNC(_wrap_get_data_type_size), -1); + rb_define_module_function(mGdal, "data_type_is_complex", VALUEFUNC(_wrap_data_type_is_complex), -1); + rb_define_module_function(mGdal, "get_data_type_name", VALUEFUNC(_wrap_get_data_type_name), -1); + rb_define_module_function(mGdal, "get_data_type_by_name", VALUEFUNC(_wrap_get_data_type_by_name), -1); + rb_define_module_function(mGdal, "get_color_interpretation_name", VALUEFUNC(_wrap_get_color_interpretation_name), -1); + rb_define_module_function(mGdal, "get_palette_interpretation_name", VALUEFUNC(_wrap_get_palette_interpretation_name), -1); + rb_define_module_function(mGdal, "dec_to_dms", VALUEFUNC(_wrap_dec_to_dms), -1); + rb_define_module_function(mGdal, "packed_dms_to_dec", VALUEFUNC(_wrap_packed_dms_to_dec), -1); + rb_define_module_function(mGdal, "dec_to_packed_dms", VALUEFUNC(_wrap_dec_to_packed_dms), -1); + rb_define_module_function(mGdal, "parse_xml_string", VALUEFUNC(_wrap_parse_xml_string), -1); + rb_define_module_function(mGdal, "serialize_xml_tree", VALUEFUNC(_wrap_serialize_xml_tree), -1); + rb_define_module_function(mGdal, "get_driver_count", VALUEFUNC(_wrap_get_driver_count), -1); + rb_define_module_function(mGdal, "get_driver_by_name", VALUEFUNC(_wrap_get_driver_by_name), -1); + rb_define_module_function(mGdal, "get_driver", VALUEFUNC(_wrap_get_driver), -1); + rb_define_module_function(mGdal, "open", VALUEFUNC(_wrap_open), -1); + rb_define_module_function(mGdal, "open_shared", VALUEFUNC(_wrap_open_shared), -1); + rb_define_module_function(mGdal, "auto_create_warped_vrt", VALUEFUNC(_wrap_auto_create_warped_vrt), -1); +} + diff --git a/Utilities/GDAL/swig/ruby/gdalconst_wrap.c b/Utilities/GDAL/swig/ruby/gdalconst_wrap.c new file mode 100644 index 0000000000..e1c6e5efdb --- /dev/null +++ b/Utilities/GDAL/swig/ruby/gdalconst_wrap.c @@ -0,0 +1,1734 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.28 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGRUBY +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#define SWIG_ObjectPreviouslyDeletedError -100 + + +#include <ruby.h> + +/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ +#ifndef NUM2LL +#define NUM2LL(x) NUM2LONG((x)) +#endif +#ifndef LL2NUM +#define LL2NUM(x) INT2NUM((long) (x)) +#endif +#ifndef ULL2NUM +#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) +#endif + +/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ +#ifndef NUM2ULL +#ifdef HAVE_LONG_LONG +#define NUM2ULL(x) rb_num2ull((x)) +#else +#define NUM2ULL(x) NUM2ULONG(x) +#endif +#endif + +/* + * Need to be very careful about how these macros are defined, especially + * when compiling C++ code or C code with an ANSI C compiler. + * + * VALUEFUNC(f) is a macro used to typecast a C function that implements + * a Ruby method so that it can be passed as an argument to API functions + * like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is a macro used to typecast a C function that implements + * either the "mark" or "free" stuff for a Ruby Data object, so that it + * can be passed as an argument to API functions like Data_Wrap_Struct() + * and Data_Make_Struct(). + */ + +#ifdef __cplusplus +# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((void (*)()) f) +# else +# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# endif +# endif +#else +# define VALUEFUNC(f) (f) +# define VOIDFUNC(f) (f) +#endif + +/* Don't use for expressions have side effect */ +#ifndef RB_STRING_VALUE +#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) +#endif +#ifndef StringValue +#define StringValue(s) RB_STRING_VALUE(s) +#endif +#ifndef StringValuePtr +#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr +#endif +#ifndef StringValueLen +#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len +#endif +#ifndef SafeStringValue +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_str(v);\ +} while (0) +#endif + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubytracking.swg + * + * This file contains support for tracking mappings from + * Ruby objects to C++ objects. This functionality is needed + * to implement mark functions for Ruby's mark and sweep + * garbage collector. + ************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Global Ruby hash table to store Trackings from C/C++ + structs to Ruby Objects. */ +static VALUE swig_ruby_trackings; + +/* Global variable that stores a reference to the ruby + hash table delete function. */ +static ID swig_ruby_hash_delete = 0; + +/* Setup a Ruby hash table to store Trackings */ +SWIGRUNTIME void SWIG_RubyInitializeTrackings() { + /* Create a ruby hash table to store Trackings from C++ + objects to Ruby objects. Also make sure to tell + the garabage collector about the hash table. */ + swig_ruby_trackings = rb_hash_new(); + rb_gc_register_address(&swig_ruby_trackings); + + /* Now store a reference to the hash table delete function + so that we only have to look it up once.*/ + swig_ruby_hash_delete = rb_intern("delete"); +} + +/* Get a Ruby number to reference a pointer */ +SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { + /* We cast the pointer to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the pointer to a Ruby number */ + unsigned long value = (unsigned long) ptr; + return LONG2NUM(value); +} + +/* Get a Ruby number to reference an object */ +SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { + /* We cast the object to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the Object to a Ruby number */ + unsigned long value = (unsigned long) object; + return LONG2NUM(value); +} + +/* Get a Ruby object from a previously stored reference */ +SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { + /* The provided Ruby number object is a reference + to the Ruby object we want.*/ + + /* First convert the Ruby number to a C number */ + unsigned long value = NUM2LONG(reference); + return (VALUE) value; +} + +/* Add a Tracking from a C/C++ struct to a Ruby object */ +SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { + /* In a Ruby hash table we store the pointer and + the associated Ruby object. The trick here is + that we cannot store the Ruby object directly - if + we do then it cannot be garbage collected. So + instead we typecast it as a unsigned long and + convert it to a Ruby number object.*/ + + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Get a reference to the Ruby object as a Ruby number */ + VALUE value = SWIG_RubyObjectToReference(object); + + /* Store the mapping to the global hash table. */ + rb_hash_aset(swig_ruby_trackings, key, value); +} + +/* Get the Ruby object that owns the specified C/C++ struct */ +SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Now lookup the value stored in the global hash table */ + VALUE value = rb_hash_aref(swig_ruby_trackings, key); + + if (value == Qnil) { + /* No object exists - return nil. */ + return Qnil; + } + else { + /* Convert this value to Ruby object */ + return SWIG_RubyReferenceToObject(value); + } +} + +/* Remove a Tracking from a C/C++ struct to a Ruby object. It + is very important to remove objects once they are destroyed + since the same memory address may be reused later to create + a new object. */ +SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Delete the object from the hash table by calling Ruby's + do this we need to call the Hash.delete method.*/ + rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); +} + +/* This is a helper method that unlinks a Ruby object from its + underlying C++ object. This is needed if the lifetime of the + Ruby object is longer than the C++ object */ +SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { + DATA_PTR(object) = 0; + } +} + + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubyrun.swg + * + * This file contains the runtime support for Ruby modules + * and includes code for managing global variables and pointer + * type checking. + * + ************************************************************************/ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) +#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) +#define swig_owntype ruby_owntype + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Ruby-specific SWIG API */ + +#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() +#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) +#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) +#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) +#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +typedef struct { + VALUE klass; + VALUE mImpl; + void (*mark)(void *); + void (*destroy)(void *); + int trackObjects; +} swig_class; + + +static VALUE _mSWIG = Qnil; +static VALUE _cSWIG_Pointer = Qnil; +static VALUE swig_runtime_data_type_pointer = Qnil; + +/* Initialize Ruby runtime support */ +SWIGRUNTIME void +SWIG_Ruby_InitRuntime(void) +{ + if (_mSWIG == Qnil) { + _mSWIG = rb_define_module("SWIG"); + } +} + +/* Define Ruby class for C type */ +SWIGRUNTIME void +SWIG_Ruby_define_class(swig_type_info *type) +{ + VALUE klass; + char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + if (NIL_P(_cSWIG_Pointer)) { + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } + klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + free((void *) klass_name); +} + +/* Create a new pointer object */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) +{ + int own = flags & SWIG_POINTER_OWN; + + char *klass_name; + swig_class *sklass; + VALUE klass; + VALUE obj; + + if (!ptr) + return Qnil; + + if (type->clientdata) { + sklass = (swig_class *) type->clientdata; + + /* Are we tracking this class and have we already returned this Ruby object? */ + if (sklass->trackObjects) { + obj = SWIG_RubyInstanceFor(ptr); + if (obj != Qnil) { + return obj; + } + } + + /* Create a new Ruby object */ + obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), (own ? VOIDFUNC(sklass->destroy) : 0), ptr); + + /* If tracking is on for this class then track this object. */ + if (sklass->trackObjects) { + SWIG_RubyAddTracking(ptr, obj); + } + } else { + klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + klass = rb_const_get(_mSWIG, rb_intern(klass_name)); + free((void *) klass_name); + obj = Data_Wrap_Struct(klass, 0, 0, ptr); + } + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + + return obj; +} + +/* Create a new class instance (always owned) */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) +{ + VALUE obj; + swig_class *sklass = (swig_class *) type->clientdata; + obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + return obj; +} + +/* Get type mangle from class name */ +SWIGRUNTIMEINLINE char * +SWIG_Ruby_MangleStr(VALUE obj) +{ + VALUE stype = rb_iv_get(obj, "__swigtype__"); + return StringValuePtr(stype); +} + +/* Acquire a pointer value */ +typedef void (*ruby_owntype)(void*); + +SWIGRUNTIME ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { + if (obj) { + ruby_owntype oldown = RDATA(obj)->dfree; + RDATA(obj)->dfree = own; + return oldown; + } else { + return 0; + } +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +{ + char *c; + swig_cast_info *tc; + void *vptr = 0; + + /* Grab the pointer */ + if (NIL_P(obj)) { + *ptr = 0; + return SWIG_OK; + } else { + if (TYPE(obj) != T_DATA) { + return SWIG_ERROR; + } + Data_Get_Struct(obj, void, vptr); + } + + if (own) *own = RDATA(obj)->dfree; + + /* Check to see if the input object is giving up ownership + of the underlying C struct or C++ object. If so then we + need to reset the destructor since the Ruby object no + longer owns the underlying C++ object.*/ + if (flags & SWIG_POINTER_DISOWN) { + /* Is tracking on for this class? */ + int track = 0; + if (ty && ty->clientdata) { + swig_class *sklass = (swig_class *) ty->clientdata; + track = sklass->trackObjects; + } + + if (track) { + /* We are tracking objects for this class. Thus we change the destructor + * to SWIG_RubyRemoveTracking. This allows us to + * remove the mapping from the C++ to Ruby object + * when the Ruby object is garbage collected. If we don't + * do this, then it is possible we will return a reference + * to a Ruby object that no longer exists thereby crashing Ruby. */ + RDATA(obj)->dfree = SWIG_RubyRemoveTracking; + } else { + RDATA(obj)->dfree = 0; + } + } + + /* Do type-checking if type info was provided */ + if (ty) { + if (ty->clientdata) { + if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + *ptr = vptr; + return SWIG_OK; + } + } + if ((c = SWIG_MangleStr(obj)) == NULL) { + return SWIG_ERROR; + } + tc = SWIG_TypeCheck(c, ty); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc, vptr); + } + return SWIG_OK; +} + +/* Check convert */ +SWIGRUNTIMEINLINE int +SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) +{ + char *c = SWIG_MangleStr(obj); + if (!c) return 0; + return SWIG_TypeCheck(c,ty) != 0; +} + +SWIGRUNTIME VALUE +SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r, ptr, sz); + strcpy(r, type->name); + return rb_str_new2(result); +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (TYPE(obj) != T_STRING) goto type_error; + c = StringValuePtr(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c, ptr, sz); + if (ty) { + tc = SWIG_TypeCheck(c, ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + return SWIG_ERROR; +} + +SWIGRUNTIME swig_module_info * +SWIG_Ruby_GetModule() +{ + VALUE pointer; + swig_module_info *ret = 0; + VALUE verbose = rb_gv_get("VERBOSE"); + + /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ + rb_gv_set("VERBOSE", Qfalse); + + /* first check if pointer already created */ + pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + if (pointer != Qnil) { + Data_Get_Struct(pointer, swig_module_info, ret); + } + + /* reinstate warnings */ + rb_gv_set("VERBOSE", verbose); + return ret; +} + +SWIGRUNTIME void +SWIG_Ruby_SetModule(swig_module_info *pointer) +{ + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); +} + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + +/* ----------------------------------------------------------------------------- + * Ruby API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN VALUE +SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { + if (NIL_P(target)) { + target = o; + } else { + if (TYPE(target) != T_ARRAY) { + VALUE o2 = target; + target = rb_ary_new(); + rb_ary_push(target, o2); + } + rb_ary_push(target, o); + } + return target; +} + +#ifdef __cplusplus +} +#endif + + + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + + + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +static swig_type_info *swig_types[2]; +static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init Init_gdalconst +#define SWIG_name "Gdal::Gdalconst" + +static VALUE mGdalconst; + + +#define SWIGVERSION 0x010328 + + + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) + + +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + + + +/* Define custom exceptions for errors that do not map to existing Ruby + exceptions. Note this only works for C++ since a global cannot be + initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + +VALUE getNullReferenceError() { + static int init = 0; + static VALUE rb_eNullReferenceError ; + if (!init) { + init = 1; + rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); + } + return rb_eNullReferenceError; +} + +VALUE getObjectPreviouslyDeletedError() { + static int init = 0; + static VALUE rb_eObjectPreviouslyDeleted ; + if (!init) { + init = 1; + rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); + } + return rb_eObjectPreviouslyDeleted; +} + +VALUE getExceptionClass() { + static int init = 0; + static VALUE rubyExceptionClass ; + if (!init) { + init = 1; + rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); + } + return rubyExceptionClass; +} + +SWIGINTERN VALUE +SWIG_Ruby_ErrorType(int SWIG_code) { + VALUE type; + switch (SWIG_code) { + case SWIG_MemoryError: + type = rb_eNoMemError; + break; + case SWIG_IOError: + type = rb_eIOError; + break; + case SWIG_RuntimeError: + type = rb_eRuntimeError; + break; + case SWIG_IndexError: + type = rb_eIndexError; + break; + case SWIG_TypeError: + type = rb_eTypeError; + break; + case SWIG_DivisionByZero: + type = rb_eZeroDivError; + break; + case SWIG_OverflowError: + type = rb_eRangeError; + break; + case SWIG_SyntaxError: + type = rb_eSyntaxError; + break; + case SWIG_ValueError: + type = rb_eArgError; + break; + case SWIG_SystemError: + type = rb_eFatal; + break; + case SWIG_AttributeError: + type = rb_eRuntimeError; + break; + case SWIG_NullReferenceError: + type = getNullReferenceError(); + break; + case SWIG_ObjectPreviouslyDeletedError: + type = getObjectPreviouslyDeletedError(); + break; + case SWIG_UnknownError: + type = rb_eRuntimeError; + break; + default: + type = rb_eRuntimeError; + } + return type; +} + + +/* This code checks to see if the Ruby object being raised as part + of an exception inherits from the Ruby class Exception. If so, + the object is simply returned. If not, then a new Ruby exception + object is created and that will be returned to Ruby.*/ +SWIGINTERN VALUE +SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { + VALUE exceptionClass = getExceptionClass(); + if (rb_obj_is_kind_of(obj, exceptionClass)) { + return obj; + } else { + return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); + } +} + + + +#include "gdal.h" +#include "gdalwarper.h" +#include "cpl_string.h" +#include "cpl_minixml.h" + + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + + +#define SWIG_From_long LONG2NUM + + + +SWIGINTERNINLINE VALUE +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > LONG_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : Qnil; + } else { + return rb_str_new(carray, (long)(size)); + } + } else { + return Qnil; + } +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void Init_gdalconst(void) { + size_t i; + + SWIG_InitRuntime(); + mGdalconst = rb_define_module("Gdal"); + mGdalconst = rb_define_module_under(mGdalconst, "Gdalconst"); + + SWIG_InitializeModule(0); + for (i = 0; i < swig_module.size; i++) { + SWIG_define_class(swig_module.types[i]); + } + + SWIG_RubyInitializeTrackings(); + rb_define_const(mGdalconst, "GDT_UNKNOWN", SWIG_From_int((int)(GDT_Unknown))); + rb_define_const(mGdalconst, "GDT_BYTE", SWIG_From_int((int)(GDT_Byte))); + rb_define_const(mGdalconst, "GDT_UINT16", SWIG_From_int((int)(GDT_UInt16))); + rb_define_const(mGdalconst, "GDT_INT16", SWIG_From_int((int)(GDT_Int16))); + rb_define_const(mGdalconst, "GDT_UINT32", SWIG_From_int((int)(GDT_UInt32))); + rb_define_const(mGdalconst, "GDT_INT32", SWIG_From_int((int)(GDT_Int32))); + rb_define_const(mGdalconst, "GDT_FLOAT32", SWIG_From_int((int)(GDT_Float32))); + rb_define_const(mGdalconst, "GDT_FLOAT64", SWIG_From_int((int)(GDT_Float64))); + rb_define_const(mGdalconst, "GDT_CINT16", SWIG_From_int((int)(GDT_CInt16))); + rb_define_const(mGdalconst, "GDT_CINT32", SWIG_From_int((int)(GDT_CInt32))); + rb_define_const(mGdalconst, "GDT_CFLOAT32", SWIG_From_int((int)(GDT_CFloat32))); + rb_define_const(mGdalconst, "GDT_CFLOAT64", SWIG_From_int((int)(GDT_CFloat64))); + rb_define_const(mGdalconst, "GDT_TYPECOUNT", SWIG_From_int((int)(GDT_TypeCount))); + rb_define_const(mGdalconst, "GA_READONLY", SWIG_From_int((int)(GA_ReadOnly))); + rb_define_const(mGdalconst, "GA_UPDATE", SWIG_From_int((int)(GA_Update))); + rb_define_const(mGdalconst, "GF_READ", SWIG_From_int((int)(GF_Read))); + rb_define_const(mGdalconst, "GF_WRITE", SWIG_From_int((int)(GF_Write))); + rb_define_const(mGdalconst, "GCI_UNDEFINED", SWIG_From_int((int)(GCI_Undefined))); + rb_define_const(mGdalconst, "GCI_GRAYINDEX", SWIG_From_int((int)(GCI_GrayIndex))); + rb_define_const(mGdalconst, "GCI_PALETTEINDEX", SWIG_From_int((int)(GCI_PaletteIndex))); + rb_define_const(mGdalconst, "GCI_REDBAND", SWIG_From_int((int)(GCI_RedBand))); + rb_define_const(mGdalconst, "GCI_GREENBAND", SWIG_From_int((int)(GCI_GreenBand))); + rb_define_const(mGdalconst, "GCI_BLUEBAND", SWIG_From_int((int)(GCI_BlueBand))); + rb_define_const(mGdalconst, "GCI_ALPHABAND", SWIG_From_int((int)(GCI_AlphaBand))); + rb_define_const(mGdalconst, "GCI_HUEBAND", SWIG_From_int((int)(GCI_HueBand))); + rb_define_const(mGdalconst, "GCI_SATURATIONBAND", SWIG_From_int((int)(GCI_SaturationBand))); + rb_define_const(mGdalconst, "GCI_LIGHTNESSBAND", SWIG_From_int((int)(GCI_LightnessBand))); + rb_define_const(mGdalconst, "GCI_CYANBAND", SWIG_From_int((int)(GCI_CyanBand))); + rb_define_const(mGdalconst, "GCI_MAGENTABAND", SWIG_From_int((int)(GCI_MagentaBand))); + rb_define_const(mGdalconst, "GCI_YELLOWBAND", SWIG_From_int((int)(GCI_YellowBand))); + rb_define_const(mGdalconst, "GCI_BLACKBAND", SWIG_From_int((int)(GCI_BlackBand))); + rb_define_const(mGdalconst, "GRA_NEARESTNEIGHBOUR", SWIG_From_int((int)(GRA_NearestNeighbour))); + rb_define_const(mGdalconst, "GRA_BILINEAR", SWIG_From_int((int)(GRA_Bilinear))); + rb_define_const(mGdalconst, "GRA_CUBIC", SWIG_From_int((int)(GRA_Cubic))); + rb_define_const(mGdalconst, "GRA_CUBICSPLINE", SWIG_From_int((int)(GRA_CubicSpline))); + rb_define_const(mGdalconst, "GPI_GRAY", SWIG_From_int((int)(GPI_Gray))); + rb_define_const(mGdalconst, "GPI_RGB", SWIG_From_int((int)(GPI_RGB))); + rb_define_const(mGdalconst, "GPI_CMYK", SWIG_From_int((int)(GPI_CMYK))); + rb_define_const(mGdalconst, "GPI_HLS", SWIG_From_int((int)(GPI_HLS))); + rb_define_const(mGdalconst, "CXT_ELEMENT", SWIG_From_int((int)(CXT_Element))); + rb_define_const(mGdalconst, "CXT_TEXT", SWIG_From_int((int)(CXT_Text))); + rb_define_const(mGdalconst, "CXT_ATTRIBUTE", SWIG_From_int((int)(CXT_Attribute))); + rb_define_const(mGdalconst, "CXT_COMMENT", SWIG_From_int((int)(CXT_Comment))); + rb_define_const(mGdalconst, "CXT_LITERAL", SWIG_From_int((int)(CXT_Literal))); + rb_define_const(mGdalconst, "CE_NONE", SWIG_From_int((int)(CE_None))); + rb_define_const(mGdalconst, "CE_DEBUG", SWIG_From_int((int)(CE_Debug))); + rb_define_const(mGdalconst, "CE_WARNING", SWIG_From_int((int)(CE_Warning))); + rb_define_const(mGdalconst, "CE_FAILURE", SWIG_From_int((int)(CE_Failure))); + rb_define_const(mGdalconst, "CE_FATAL", SWIG_From_int((int)(CE_Fatal))); + rb_define_const(mGdalconst, "CPLE_NONE", SWIG_From_int((int)(CPLE_None))); + rb_define_const(mGdalconst, "CPLE_APPDEFINED", SWIG_From_int((int)(CPLE_AppDefined))); + rb_define_const(mGdalconst, "CPLE_OUTOFMEMORY", SWIG_From_int((int)(CPLE_OutOfMemory))); + rb_define_const(mGdalconst, "CPLE_FILEIO", SWIG_From_int((int)(CPLE_FileIO))); + rb_define_const(mGdalconst, "CPLE_OPENFAILED", SWIG_From_int((int)(CPLE_OpenFailed))); + rb_define_const(mGdalconst, "CPLE_ILLEGALARG", SWIG_From_int((int)(CPLE_IllegalArg))); + rb_define_const(mGdalconst, "CPLE_NOTSUPPORTED", SWIG_From_int((int)(CPLE_NotSupported))); + rb_define_const(mGdalconst, "CPLE_ASSERTIONFAILED", SWIG_From_int((int)(CPLE_AssertionFailed))); + rb_define_const(mGdalconst, "CPLE_NOWRITEACCESS", SWIG_From_int((int)(CPLE_NoWriteAccess))); + rb_define_const(mGdalconst, "CPLE_USERINTERRUPT", SWIG_From_int((int)(CPLE_UserInterrupt))); + rb_define_const(mGdalconst, "DMD_LONGNAME", SWIG_FromCharPtr(GDAL_DMD_LONGNAME)); + rb_define_const(mGdalconst, "DMD_HELPTOPIC", SWIG_FromCharPtr(GDAL_DMD_HELPTOPIC)); + rb_define_const(mGdalconst, "DMD_MIMETYPE", SWIG_FromCharPtr(GDAL_DMD_MIMETYPE)); + rb_define_const(mGdalconst, "DMD_EXTENSION", SWIG_FromCharPtr(GDAL_DMD_EXTENSION)); + rb_define_const(mGdalconst, "DMD_CREATIONOPTIONLIST", SWIG_FromCharPtr(GDAL_DMD_CREATIONOPTIONLIST)); + rb_define_const(mGdalconst, "DMD_CREATIONDATATYPES", SWIG_FromCharPtr(GDAL_DMD_CREATIONDATATYPES)); + rb_define_const(mGdalconst, "DCAP_CREATE", SWIG_FromCharPtr(GDAL_DCAP_CREATE)); + rb_define_const(mGdalconst, "DCAP_CREATECOPY", SWIG_FromCharPtr(GDAL_DCAP_CREATECOPY)); + rb_define_const(mGdalconst, "CPLES_BACKSLASHQUOTABLE", SWIG_From_int((int)(CPLES_BackslashQuotable))); + rb_define_const(mGdalconst, "CPLES_XML", SWIG_From_int((int)(CPLES_XML))); + rb_define_const(mGdalconst, "CPLES_URL", SWIG_From_int((int)(CPLES_URL))); + rb_define_const(mGdalconst, "CPLES_SQL", SWIG_From_int((int)(CPLES_SQL))); + rb_define_const(mGdalconst, "CPLES_CSV", SWIG_From_int((int)(CPLES_CSV))); +} + diff --git a/Utilities/GDAL/swig/ruby/makefile.vc b/Utilities/GDAL/swig/ruby/makefile.vc new file mode 100755 index 0000000000..58ceb54794 --- /dev/null +++ b/Utilities/GDAL/swig/ruby/makefile.vc @@ -0,0 +1,67 @@ +# Use this makefile to build Ruby GDAL bindings on Windows. +# +# nmake -f makefile.vc build - Will build the bindings +# nmake -f makefile.vc install - Will install the bindings +# to the local Ruby installation +# +# Note you must manually set the variable RUBY_DIR, and possibly +# RUBY_VERSION. + +GDAL_ROOT = ../.. +!INCLUDE $(GDAL_ROOT)/nmake.opt + +RUBY_VERSION = 1.8 +RUBY_ARCH = i386-mswin32 +RUBY_SO_NAME = msvcrt-ruby18.lib + +RUBY_DIR = C:\Development\ruby +RUBY_ARCH_DIR = $(RUBY_DIR)\lib\ruby\$(RUBY_VERSION)\$(RUBY_ARCH) +INSTALLATION_DIR = $(RUBY_DIR)\lib\ruby\site_ruby\$(RUBY_VERSION)\i386-msvcrt\gdal + +$(INSTALLATION_DIR): + mkdir $(INSTALLATION_DIR) + +install: $(INSTALLATION_DIR) + cp *.so $(INSTALLATION_DIR) + +build: $(INSTALLATION_DIR) gdal.so gdalconst.so ogr.so osr.so + +gdal.so: gdal_wrap.obj + link /dll /debug $(LINKER_FLAGS) $(EXTERNAL_LIBS) \ + /LIBPATH:$(RUBY_DIR)/lib $(RUBY_SO_NAME) $(GDALLIB) \ + /out:$*.so $*_wrap.obj + +gdalconst.so: gdalconst_wrap.obj + link /dll /debug $(LINKER_FLAGS) $(EXTERNAL_LIBS) \ + /LIBPATH:$(RUBY_DIR)/lib $(RUBY_SO_NAME) $(GDALLIB) \ + /out:$*.so $*_wrap.obj + +ogr.so: ogr_wrap.obj + link /dll /debug $(LINKER_FLAGS) $(EXTERNAL_LIBS) \ + /LIBPATH:$(RUBY_DIR)/lib $(RUBY_SO_NAME) $(GDALLIB) \ + /out:$*.so $*_wrap.obj + +osr.so: osr_wrap.obj + link /dll /debug $(LINKER_FLAGS) $(EXTERNAL_LIBS) \ + /LIBPATH:$(RUBY_DIR)/lib $(RUBY_SO_NAME) $(GDALLIB) \ + /out:$*.so $*_wrap.obj + + +.c.obj: + $(CC) $(CFLAGS) /I $(RUBY_ARCH_DIR) /c $*.c + +.cpp.obj: + $(CC) $(CFLAGS) /I $(RUBY_ARCH_DIR) /c $*.cpp + +clean: + -del *.c + -del *.cpp + -del *.so + -del *.dll + -del *.obj + -del *.exp + -del *.ilk + -del *.pdb + -del *.lib + rmdir /S /Q $(RUBY_ARCH_DIR)\gdal + diff --git a/Utilities/GDAL/swig/ruby/ogr_wrap.cpp b/Utilities/GDAL/swig/ruby/ogr_wrap.cpp new file mode 100644 index 0000000000..d77e4c20da --- /dev/null +++ b/Utilities/GDAL/swig/ruby/ogr_wrap.cpp @@ -0,0 +1,9865 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.28 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGRUBY + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#define SWIG_ObjectPreviouslyDeletedError -100 + + +#include <ruby.h> + +/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ +#ifndef NUM2LL +#define NUM2LL(x) NUM2LONG((x)) +#endif +#ifndef LL2NUM +#define LL2NUM(x) INT2NUM((long) (x)) +#endif +#ifndef ULL2NUM +#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) +#endif + +/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ +#ifndef NUM2ULL +#ifdef HAVE_LONG_LONG +#define NUM2ULL(x) rb_num2ull((x)) +#else +#define NUM2ULL(x) NUM2ULONG(x) +#endif +#endif + +/* + * Need to be very careful about how these macros are defined, especially + * when compiling C++ code or C code with an ANSI C compiler. + * + * VALUEFUNC(f) is a macro used to typecast a C function that implements + * a Ruby method so that it can be passed as an argument to API functions + * like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is a macro used to typecast a C function that implements + * either the "mark" or "free" stuff for a Ruby Data object, so that it + * can be passed as an argument to API functions like Data_Wrap_Struct() + * and Data_Make_Struct(). + */ + +#ifdef __cplusplus +# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((void (*)()) f) +# else +# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# endif +# endif +#else +# define VALUEFUNC(f) (f) +# define VOIDFUNC(f) (f) +#endif + +/* Don't use for expressions have side effect */ +#ifndef RB_STRING_VALUE +#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) +#endif +#ifndef StringValue +#define StringValue(s) RB_STRING_VALUE(s) +#endif +#ifndef StringValuePtr +#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr +#endif +#ifndef StringValueLen +#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len +#endif +#ifndef SafeStringValue +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_str(v);\ +} while (0) +#endif + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubytracking.swg + * + * This file contains support for tracking mappings from + * Ruby objects to C++ objects. This functionality is needed + * to implement mark functions for Ruby's mark and sweep + * garbage collector. + ************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Global Ruby hash table to store Trackings from C/C++ + structs to Ruby Objects. */ +static VALUE swig_ruby_trackings; + +/* Global variable that stores a reference to the ruby + hash table delete function. */ +static ID swig_ruby_hash_delete = 0; + +/* Setup a Ruby hash table to store Trackings */ +SWIGRUNTIME void SWIG_RubyInitializeTrackings() { + /* Create a ruby hash table to store Trackings from C++ + objects to Ruby objects. Also make sure to tell + the garabage collector about the hash table. */ + swig_ruby_trackings = rb_hash_new(); + rb_gc_register_address(&swig_ruby_trackings); + + /* Now store a reference to the hash table delete function + so that we only have to look it up once.*/ + swig_ruby_hash_delete = rb_intern("delete"); +} + +/* Get a Ruby number to reference a pointer */ +SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { + /* We cast the pointer to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the pointer to a Ruby number */ + unsigned long value = (unsigned long) ptr; + return LONG2NUM(value); +} + +/* Get a Ruby number to reference an object */ +SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { + /* We cast the object to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the Object to a Ruby number */ + unsigned long value = (unsigned long) object; + return LONG2NUM(value); +} + +/* Get a Ruby object from a previously stored reference */ +SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { + /* The provided Ruby number object is a reference + to the Ruby object we want.*/ + + /* First convert the Ruby number to a C number */ + unsigned long value = NUM2LONG(reference); + return (VALUE) value; +} + +/* Add a Tracking from a C/C++ struct to a Ruby object */ +SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { + /* In a Ruby hash table we store the pointer and + the associated Ruby object. The trick here is + that we cannot store the Ruby object directly - if + we do then it cannot be garbage collected. So + instead we typecast it as a unsigned long and + convert it to a Ruby number object.*/ + + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Get a reference to the Ruby object as a Ruby number */ + VALUE value = SWIG_RubyObjectToReference(object); + + /* Store the mapping to the global hash table. */ + rb_hash_aset(swig_ruby_trackings, key, value); +} + +/* Get the Ruby object that owns the specified C/C++ struct */ +SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Now lookup the value stored in the global hash table */ + VALUE value = rb_hash_aref(swig_ruby_trackings, key); + + if (value == Qnil) { + /* No object exists - return nil. */ + return Qnil; + } + else { + /* Convert this value to Ruby object */ + return SWIG_RubyReferenceToObject(value); + } +} + +/* Remove a Tracking from a C/C++ struct to a Ruby object. It + is very important to remove objects once they are destroyed + since the same memory address may be reused later to create + a new object. */ +SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Delete the object from the hash table by calling Ruby's + do this we need to call the Hash.delete method.*/ + rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); +} + +/* This is a helper method that unlinks a Ruby object from its + underlying C++ object. This is needed if the lifetime of the + Ruby object is longer than the C++ object */ +SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { + DATA_PTR(object) = 0; + } +} + + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubyrun.swg + * + * This file contains the runtime support for Ruby modules + * and includes code for managing global variables and pointer + * type checking. + * + ************************************************************************/ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) +#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) +#define swig_owntype ruby_owntype + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Ruby-specific SWIG API */ + +#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() +#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) +#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) +#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) +#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +typedef struct { + VALUE klass; + VALUE mImpl; + void (*mark)(void *); + void (*destroy)(void *); + int trackObjects; +} swig_class; + + +static VALUE _mSWIG = Qnil; +static VALUE _cSWIG_Pointer = Qnil; +static VALUE swig_runtime_data_type_pointer = Qnil; + +/* Initialize Ruby runtime support */ +SWIGRUNTIME void +SWIG_Ruby_InitRuntime(void) +{ + if (_mSWIG == Qnil) { + _mSWIG = rb_define_module("SWIG"); + } +} + +/* Define Ruby class for C type */ +SWIGRUNTIME void +SWIG_Ruby_define_class(swig_type_info *type) +{ + VALUE klass; + char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + if (NIL_P(_cSWIG_Pointer)) { + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } + klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + free((void *) klass_name); +} + +/* Create a new pointer object */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) +{ + int own = flags & SWIG_POINTER_OWN; + + char *klass_name; + swig_class *sklass; + VALUE klass; + VALUE obj; + + if (!ptr) + return Qnil; + + if (type->clientdata) { + sklass = (swig_class *) type->clientdata; + + /* Are we tracking this class and have we already returned this Ruby object? */ + if (sklass->trackObjects) { + obj = SWIG_RubyInstanceFor(ptr); + if (obj != Qnil) { + return obj; + } + } + + /* Create a new Ruby object */ + obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), (own ? VOIDFUNC(sklass->destroy) : 0), ptr); + + /* If tracking is on for this class then track this object. */ + if (sklass->trackObjects) { + SWIG_RubyAddTracking(ptr, obj); + } + } else { + klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + klass = rb_const_get(_mSWIG, rb_intern(klass_name)); + free((void *) klass_name); + obj = Data_Wrap_Struct(klass, 0, 0, ptr); + } + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + + return obj; +} + +/* Create a new class instance (always owned) */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) +{ + VALUE obj; + swig_class *sklass = (swig_class *) type->clientdata; + obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + return obj; +} + +/* Get type mangle from class name */ +SWIGRUNTIMEINLINE char * +SWIG_Ruby_MangleStr(VALUE obj) +{ + VALUE stype = rb_iv_get(obj, "__swigtype__"); + return StringValuePtr(stype); +} + +/* Acquire a pointer value */ +typedef void (*ruby_owntype)(void*); + +SWIGRUNTIME ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { + if (obj) { + ruby_owntype oldown = RDATA(obj)->dfree; + RDATA(obj)->dfree = own; + return oldown; + } else { + return 0; + } +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +{ + char *c; + swig_cast_info *tc; + void *vptr = 0; + + /* Grab the pointer */ + if (NIL_P(obj)) { + *ptr = 0; + return SWIG_OK; + } else { + if (TYPE(obj) != T_DATA) { + return SWIG_ERROR; + } + Data_Get_Struct(obj, void, vptr); + } + + if (own) *own = RDATA(obj)->dfree; + + /* Check to see if the input object is giving up ownership + of the underlying C struct or C++ object. If so then we + need to reset the destructor since the Ruby object no + longer owns the underlying C++ object.*/ + if (flags & SWIG_POINTER_DISOWN) { + /* Is tracking on for this class? */ + int track = 0; + if (ty && ty->clientdata) { + swig_class *sklass = (swig_class *) ty->clientdata; + track = sklass->trackObjects; + } + + if (track) { + /* We are tracking objects for this class. Thus we change the destructor + * to SWIG_RubyRemoveTracking. This allows us to + * remove the mapping from the C++ to Ruby object + * when the Ruby object is garbage collected. If we don't + * do this, then it is possible we will return a reference + * to a Ruby object that no longer exists thereby crashing Ruby. */ + RDATA(obj)->dfree = SWIG_RubyRemoveTracking; + } else { + RDATA(obj)->dfree = 0; + } + } + + /* Do type-checking if type info was provided */ + if (ty) { + if (ty->clientdata) { + if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + *ptr = vptr; + return SWIG_OK; + } + } + if ((c = SWIG_MangleStr(obj)) == NULL) { + return SWIG_ERROR; + } + tc = SWIG_TypeCheck(c, ty); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc, vptr); + } + return SWIG_OK; +} + +/* Check convert */ +SWIGRUNTIMEINLINE int +SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) +{ + char *c = SWIG_MangleStr(obj); + if (!c) return 0; + return SWIG_TypeCheck(c,ty) != 0; +} + +SWIGRUNTIME VALUE +SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r, ptr, sz); + strcpy(r, type->name); + return rb_str_new2(result); +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (TYPE(obj) != T_STRING) goto type_error; + c = StringValuePtr(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c, ptr, sz); + if (ty) { + tc = SWIG_TypeCheck(c, ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + return SWIG_ERROR; +} + +SWIGRUNTIME swig_module_info * +SWIG_Ruby_GetModule() +{ + VALUE pointer; + swig_module_info *ret = 0; + VALUE verbose = rb_gv_get("VERBOSE"); + + /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ + rb_gv_set("VERBOSE", Qfalse); + + /* first check if pointer already created */ + pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + if (pointer != Qnil) { + Data_Get_Struct(pointer, swig_module_info, ret); + } + + /* reinstate warnings */ + rb_gv_set("VERBOSE", verbose); + return ret; +} + +SWIGRUNTIME void +SWIG_Ruby_SetModule(swig_module_info *pointer) +{ + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); +} + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + +/* ----------------------------------------------------------------------------- + * Ruby API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN VALUE +SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { + if (NIL_P(target)) { + target = o; + } else { + if (TYPE(target) != T_ARRAY) { + VALUE o2 = target; + target = rb_ary_new(); + rb_ary_push(target, o2); + } + rb_ary_push(target, o); + } + return target; +} + +#ifdef __cplusplus +} +#endif + + + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + + + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + + +#define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0) + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_GIntBig swig_types[0] +#define SWIGTYPE_p_OGRDataSourceShadow swig_types[1] +#define SWIGTYPE_p_OGRDriverShadow swig_types[2] +#define SWIGTYPE_p_OGRFeatureDefnShadow swig_types[3] +#define SWIGTYPE_p_OGRFeatureShadow swig_types[4] +#define SWIGTYPE_p_OGRFieldDefnShadow swig_types[5] +#define SWIGTYPE_p_OGRGeometryShadow swig_types[6] +#define SWIGTYPE_p_OGRLayerShadow swig_types[7] +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[8] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[9] +#define SWIGTYPE_p_char swig_types[10] +#define SWIGTYPE_p_double swig_types[11] +#define SWIGTYPE_p_int swig_types[12] +#define SWIGTYPE_p_p_char swig_types[13] +static swig_type_info *swig_types[15]; +static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init Init_ogr +#define SWIG_name "Gdal::Ogr" + +static VALUE mOgr; + + +#define SWIGVERSION 0x010328 + + + + +#define SWIG_as_voidptr(a) const_cast<void * >(static_cast<const void * >(a)) + + +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast<void** >(a)) + + + + +/* Define custom exceptions for errors that do not map to existing Ruby + exceptions. Note this only works for C++ since a global cannot be + initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + +VALUE getNullReferenceError() { + static int init = 0; + static VALUE rb_eNullReferenceError ; + if (!init) { + init = 1; + rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); + } + return rb_eNullReferenceError; +} + +VALUE getObjectPreviouslyDeletedError() { + static int init = 0; + static VALUE rb_eObjectPreviouslyDeleted ; + if (!init) { + init = 1; + rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); + } + return rb_eObjectPreviouslyDeleted; +} + +VALUE getExceptionClass() { + static int init = 0; + static VALUE rubyExceptionClass ; + if (!init) { + init = 1; + rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); + } + return rubyExceptionClass; +} + +SWIGINTERN VALUE +SWIG_Ruby_ErrorType(int SWIG_code) { + VALUE type; + switch (SWIG_code) { + case SWIG_MemoryError: + type = rb_eNoMemError; + break; + case SWIG_IOError: + type = rb_eIOError; + break; + case SWIG_RuntimeError: + type = rb_eRuntimeError; + break; + case SWIG_IndexError: + type = rb_eIndexError; + break; + case SWIG_TypeError: + type = rb_eTypeError; + break; + case SWIG_DivisionByZero: + type = rb_eZeroDivError; + break; + case SWIG_OverflowError: + type = rb_eRangeError; + break; + case SWIG_SyntaxError: + type = rb_eSyntaxError; + break; + case SWIG_ValueError: + type = rb_eArgError; + break; + case SWIG_SystemError: + type = rb_eFatal; + break; + case SWIG_AttributeError: + type = rb_eRuntimeError; + break; + case SWIG_NullReferenceError: + type = getNullReferenceError(); + break; + case SWIG_ObjectPreviouslyDeletedError: + type = getObjectPreviouslyDeletedError(); + break; + case SWIG_UnknownError: + type = rb_eRuntimeError; + break; + default: + type = rb_eRuntimeError; + } + return type; +} + + +/* This code checks to see if the Ruby object being raised as part + of an exception inherits from the Ruby class Exception. If so, + the object is simply returned. If not, then a new Ruby exception + object is created and that will be returned to Ruby.*/ +SWIGINTERN VALUE +SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { + VALUE exceptionClass = getExceptionClass(); + if (rb_obj_is_kind_of(obj, exceptionClass)) { + return obj; + } else { + return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); + } +} + + + +#include <stdexcept> + + +#include <iostream> +using namespace std; + +#include "ogr_api.h" +#include "ogr_core.h" +#include "cpl_port.h" +#include "cpl_string.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OGRDriverShadow; +typedef void OGRDataSourceShadow; +typedef void OGRLayerShadow; +typedef void OGRFeatureShadow; +typedef void OGRFeatureDefnShadow; +typedef void OGRGeometryShadow; +typedef void OSRCoordinateTransformationShadow; +typedef void OGRFieldDefnShadow; + + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + + +#define SWIG_From_long LONG2NUM + + + +SWIGINTERNINLINE VALUE +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > LONG_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj(const_cast<char * >(carray), pchar_descriptor, 0) : Qnil; + } else { + return rb_str_new(carray, static_cast<long >(size)); + } + } else { + return Qnil; + } +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +#ifdef __cplusplus +extern "C" { +#endif +#include "rubyio.h" +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +struct timeval rb_time_timeval(VALUE); +#endif +#ifdef __cplusplus +} +#endif + + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + + +void VeryQuiteErrorHandler(CPLErr eclass, int code, const char *msg ) { + /* If the error class is CE_Fatal, we want to have a message issued + because the CPL support code does an abort() before any exception + can be generated */ + if (eclass == CE_Fatal ) { + CPLDefaultErrorHandler(eclass, code, msg ); + } +} + + +void UseExceptions() { + CPLSetErrorHandler( (CPLErrorHandler) VeryQuiteErrorHandler ); +} + +void DontUseExceptions() { + CPLSetErrorHandler( CPLDefaultErrorHandler ); +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) +{ + if (TYPE(obj) == T_STRING) { + char *cstr = rb_string_value_ptr(&(obj)); + size_t size = RSTRING(obj)->len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast<char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + + +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_CreateDataSource(OGRDriverShadow *self,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CreateDataSource( self, name, options); + return ds; + } +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_CopyDataSource(OGRDriverShadow *self,OGRDataSourceShadow *copy_ds,char const *name,char **options=0){ + OGRDataSourceShadow *ds = (OGRDataSourceShadow*) OGR_Dr_CopyDataSource(self, copy_ds, name, options); + return ds; + } + +SWIGINTERN VALUE +SWIG_ruby_failed() +{ + return Qnil; +} + + + +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + long *res = (long *)(args[1]); + *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_long (VALUE obj, long* val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + long v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (VALUE obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast<int >(v); + } + } + return res; +} + +SWIGINTERN OGRDataSourceShadow *OGRDriverShadow_Open(OGRDriverShadow *self,char const *name,int update=0){ + OGRDataSourceShadow* ds = (OGRDataSourceShadow*) OGR_Dr_Open(self, name, update); + return ds; + } +SWIGINTERN int OGRDriverShadow_DeleteDataSource(OGRDriverShadow *self,char const *name){ + return OGR_Dr_DeleteDataSource( self, name ); + } +SWIGINTERN bool OGRDriverShadow_TestCapability(OGRDriverShadow *self,char const *cap){ + return OGR_Dr_TestCapability(self, cap); + } + +SWIGINTERNINLINE VALUE +SWIG_From_bool (bool value) +{ + return value ? Qtrue : Qfalse; +} + +SWIGINTERN char const *OGRDriverShadow_GetName(OGRDriverShadow *self){ + return OGR_Dr_GetName( self ); + } +SWIGINTERN int OGRDataSourceShadow_GetRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetRefCount(self); + } +SWIGINTERN int OGRDataSourceShadow_GetSummaryRefCount(OGRDataSourceShadow *self){ + return OGR_DS_GetSummaryRefCount(self); + } +SWIGINTERN int OGRDataSourceShadow_GetLayerCount(OGRDataSourceShadow *self){ + return OGR_DS_GetLayerCount(self); + } +SWIGINTERN OGRDriverShadow *OGRDataSourceShadow_GetDriver(OGRDataSourceShadow *self){ + OGRDriverShadow* driver; + OGRDataSourceShadow* ds; + ds = (OGRDataSourceShadow*)OGROpen((const char *) OGR_DS_GetName(self),0,&driver); + OGRReleaseDataSource(ds); + return driver; + } +SWIGINTERN char const *OGRDataSourceShadow_GetName(OGRDataSourceShadow *self){ + return OGR_DS_GetName(self); + } +SWIGINTERN OGRErr OGRDataSourceShadow_DeleteLayer(OGRDataSourceShadow *self,int index){ + return OGR_DS_DeleteLayer(self, index); + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_CreateLayer(OGRDataSourceShadow *self,char const *name,OSRSpatialReferenceShadow *reference=NULL,OGRwkbGeometryType geom_type=wkbUnknown,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CreateLayer( self, + name, + reference, + geom_type, + options); + return layer; + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_CopyLayer(OGRDataSourceShadow *self,OGRLayerShadow *src_layer,char const *new_name,char **options=0){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_CopyLayer( self, + src_layer, + new_name, + options); + return layer; + } +SWIGINTERN bool OGRDataSourceShadow_TestCapability(OGRDataSourceShadow *self,char const *cap){ + return OGR_DS_TestCapability(self, cap); + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_ExecuteSQL(OGRDataSourceShadow *self,char const *statement,OGRGeometryShadow *geom=NULL,char const *dialect=""){ + OGRLayerShadow* layer = (OGRLayerShadow*) OGR_DS_ExecuteSQL((OGRDataSourceShadow*)self, + statement, + geom, + dialect); + return layer; + } +SWIGINTERN void OGRDataSourceShadow_ReleaseResultSet(OGRDataSourceShadow *self,OGRLayerShadow *layer){ + OGR_DS_ReleaseResultSet(self, layer); + } +SWIGINTERN OGRLayerShadow *OGRDataSourceShadow_GetLayer(OGRDataSourceShadow *self,VALUE whichLayer){ + // get field index + switch (TYPE(whichLayer)) { + case T_STRING: { + char* name = StringValuePtr(whichLayer); + return OGR_DS_GetLayerByName(self, name); + break; + } + case T_FIXNUM: { + int index = NUM2INT(whichLayer); + return OGR_DS_GetLayer(self, index); + break; + } + default: + SWIG_exception(SWIG_TypeError, "Value must be a string or integer."); + } + } +SWIGINTERN int OGRLayerShadow_GetRefCount(OGRLayerShadow *self){ + return OGR_L_GetRefCount(self); + } +SWIGINTERN void OGRLayerShadow_SetSpatialFilter(OGRLayerShadow *self,OGRGeometryShadow *filter){ + OGR_L_SetSpatialFilter (self, filter); + } + + +SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + double *res = (double *)(args[1]); + *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj))); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_double (VALUE obj, double *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { + double v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + +SWIGINTERN void OGRLayerShadow_SetSpatialFilterRect(OGRLayerShadow *self,double minx,double miny,double maxx,double maxy){ + OGR_L_SetSpatialFilterRect(self, minx, miny, maxx, maxy); + } +SWIGINTERN OGRGeometryShadow *OGRLayerShadow_GetSpatialFilter(OGRLayerShadow *self){ + return (OGRGeometryShadow *) OGR_L_GetSpatialFilter(self); + } +SWIGINTERN OGRErr OGRLayerShadow_SetAttributeFilter(OGRLayerShadow *self,char *filter_string){ + return OGR_L_SetAttributeFilter((OGRLayerShadow*)self, filter_string); + } +SWIGINTERN void OGRLayerShadow_ResetReading(OGRLayerShadow *self){ + OGR_L_ResetReading(self); + } +SWIGINTERN char const *OGRLayerShadow_GetName(OGRLayerShadow *self){ + return OGR_FD_GetName(OGR_L_GetLayerDefn(self)); + } +SWIGINTERN OGRFeatureShadow *OGRLayerShadow_GetFeature(OGRLayerShadow *self,long fid){ + return (OGRFeatureShadow*) OGR_L_GetFeature(self, fid); + } +SWIGINTERN OGRFeatureShadow *OGRLayerShadow_GetNextFeature(OGRLayerShadow *self){ + return (OGRFeatureShadow*) OGR_L_GetNextFeature(self); + } +SWIGINTERN OGRErr OGRLayerShadow_SetNextByIndex(OGRLayerShadow *self,long new_index){ + return OGR_L_SetNextByIndex(self, new_index); + } +SWIGINTERN OGRErr OGRLayerShadow_SetFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_SetFeature(self, feature); + } +SWIGINTERN OGRErr OGRLayerShadow_CreateFeature(OGRLayerShadow *self,OGRFeatureShadow *feature){ + return OGR_L_CreateFeature(self, feature); + } +SWIGINTERN OGRErr OGRLayerShadow_DeleteFeature(OGRLayerShadow *self,long fid){ + return OGR_L_DeleteFeature(self, fid); + } +SWIGINTERN OGRErr OGRLayerShadow_SyncToDisk(OGRLayerShadow *self){ + return OGR_L_SyncToDisk(self); + } +SWIGINTERN OGRFeatureDefnShadow *OGRLayerShadow_GetLayerDefn(OGRLayerShadow *self){ + return (OGRFeatureDefnShadow*) OGR_L_GetLayerDefn(self); + } +SWIGINTERN int OGRLayerShadow_GetFeatureCount(OGRLayerShadow *self,int force=1){ + return OGR_L_GetFeatureCount(self, force); + } +SWIGINTERN OGRErr OGRLayerShadow_GetExtent(OGRLayerShadow *self,double argout[4],int force=1){ + return OGR_L_GetExtent(self, (OGREnvelope*)argout, force); + } +SWIGINTERN bool OGRLayerShadow_TestCapability(OGRLayerShadow *self,char const *cap){ + return OGR_L_TestCapability(self, cap); + } +SWIGINTERN OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){ + return OGR_L_CreateField(self, field_def, approx_ok); + } +SWIGINTERN OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){ + return OGR_L_StartTransaction(self); + } +SWIGINTERN OGRErr OGRLayerShadow_CommitTransaction(OGRLayerShadow *self){ + return OGR_L_CommitTransaction(self); + } +SWIGINTERN OGRErr OGRLayerShadow_RollbackTransaction(OGRLayerShadow *self){ + return OGR_L_RollbackTransaction(self); + } +SWIGINTERN OSRSpatialReferenceShadow *OGRLayerShadow_GetSpatialRef(OGRLayerShadow *self){ + return (OSRSpatialReferenceShadow*) OGR_L_GetSpatialRef(self); + } +SWIGINTERN GIntBig OGRLayerShadow_GetFeatureRead(OGRLayerShadow *self){ + return OGR_L_GetFeaturesRead(self); + } +SWIGINTERN void OGRLayerShadow_each(OGRLayerShadow *self){ + OGRFeatureShadow* feature = NULL; + + while (feature = (OGRFeatureShadow*) OGR_L_GetNextFeature(self)) + { + /* Convert the pointer to a Ruby object. Note we set the flag + to one manually to show this is a new object */ + VALUE object = SWIG_NewPointerObj((void *) feature, SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_OWN); + + /* Now invoke the block specified for this method. */ + rb_yield(object); + } + } +SWIGINTERN OGRFeatureShadow *new_OGRFeatureShadow(OGRFeatureDefnShadow *feature_def=0){ + return (OGRFeatureShadow*) OGR_F_Create( feature_def ); + } +SWIGINTERN OGRFeatureDefnShadow *OGRFeatureShadow_GetDefnRef(OGRFeatureShadow *self){ + return (OGRFeatureDefnShadow*) OGR_F_GetDefnRef(self); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetGeometry(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometry(self, geom); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetGeometryDirectly(OGRFeatureShadow *self,OGRGeometryShadow *geom){ + return OGR_F_SetGeometryDirectly(self, geom); + } +SWIGINTERN OGRGeometryShadow *OGRFeatureShadow_GetGeometryRef(OGRFeatureShadow *self){ + return (OGRGeometryShadow*) OGR_F_GetGeometryRef(self); + } +SWIGINTERN OGRFeatureShadow *OGRFeatureShadow_Clone(OGRFeatureShadow *self){ + return (OGRFeatureShadow*) OGR_F_Clone(self); + } +SWIGINTERN bool OGRFeatureShadow_Equal(OGRFeatureShadow *self,OGRFeatureShadow *feature){ + return OGR_F_Equal(self, feature); + } +SWIGINTERN int OGRFeatureShadow_GetFieldCount(OGRFeatureShadow *self){ + return OGR_F_GetFieldCount(self); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, id); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureShadow_GetFieldDefnRef__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (OGRFieldDefnShadow *) OGR_F_GetFieldDefnRef(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN char const *OGRFeatureShadow_GetFieldAsString__SWIG_0(OGRFeatureShadow *self,int id){ + return (const char *) OGR_F_GetFieldAsString(self, id); + } +SWIGINTERN char const *OGRFeatureShadow_GetFieldAsString__SWIG_1(OGRFeatureShadow *self,char const *name){ + return (const char *) OGR_F_GetFieldAsString(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN int OGRFeatureShadow_GetFieldAsInteger__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsInteger(self, id); + } +SWIGINTERN int OGRFeatureShadow_GetFieldAsInteger__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsInteger(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN double OGRFeatureShadow_GetFieldAsDouble__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_GetFieldAsDouble(self, id); + } + + +#define SWIG_From_double rb_float_new + + +SWIGINTERN double OGRFeatureShadow_GetFieldAsDouble__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldAsDouble(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN bool OGRFeatureShadow_IsFieldSet__SWIG_0(OGRFeatureShadow *self,int id){ + return OGR_F_IsFieldSet(self, id); + } +SWIGINTERN bool OGRFeatureShadow_IsFieldSet__SWIG_1(OGRFeatureShadow *self,char const *name){ + return OGR_F_IsFieldSet(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN int OGRFeatureShadow_GetFieldIndex(OGRFeatureShadow *self,char const *name){ + return OGR_F_GetFieldIndex(self, name); + } +SWIGINTERN int OGRFeatureShadow_GetFID(OGRFeatureShadow *self){ + return OGR_F_GetFID(self); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetFID(OGRFeatureShadow *self,int fid){ + return OGR_F_SetFID(self, fid); + } +SWIGINTERN void OGRFeatureShadow_DumpReadable(OGRFeatureShadow *self){ + OGR_F_DumpReadable(self, NULL); + } +SWIGINTERN void OGRFeatureShadow_UnsetField__SWIG_0(OGRFeatureShadow *self,int id){ + OGR_F_UnsetField(self, id); + } +SWIGINTERN void OGRFeatureShadow_UnsetField__SWIG_1(OGRFeatureShadow *self,char const *name){ + OGR_F_UnsetField(self, OGR_F_GetFieldIndex(self, name)); + } +SWIGINTERN void OGRFeatureShadow_SetField__SWIG_0(OGRFeatureShadow *self,int id,char const *value){ + OGR_F_SetFieldString(self, id, value); + } +SWIGINTERN void OGRFeatureShadow_SetField__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + OGR_F_SetFieldString(self, OGR_F_GetFieldIndex(self, name), value); + } +SWIGINTERN OGRErr OGRFeatureShadow_SetFrom(OGRFeatureShadow *self,OGRFeatureShadow *other,int forgiving=1){ + return OGR_F_SetFrom(self, other, forgiving); + } +SWIGINTERN char const *OGRFeatureShadow_GetStyleString(OGRFeatureShadow *self){ + return (const char*) OGR_F_GetStyleString(self); + } +SWIGINTERN void OGRFeatureShadow_SetStyleString(OGRFeatureShadow *self,char const *the_string){ + OGR_F_SetStyleString(self, the_string); + } +SWIGINTERN OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_0(OGRFeatureShadow *self,int id){ + return (OGRFieldType) OGR_Fld_GetType( OGR_F_GetFieldDefnRef( self, id)); + } +SWIGINTERN OGRFieldType OGRFeatureShadow_GetFieldType__SWIG_1(OGRFeatureShadow *self,char const *name,char const *value){ + return (OGRFieldType) OGR_Fld_GetType( + OGR_F_GetFieldDefnRef( self, + OGR_F_GetFieldIndex(self, + name) + ) + ); + + } +SWIGINTERN VALUE OGRFeatureShadow_GetField(OGRFeatureShadow *self,VALUE object){ + VALUE result; + + int index; + + // get field index + switch (TYPE(object)) { + case T_STRING: + index = OGR_F_GetFieldIndex(self, StringValuePtr(object)); + break; + case T_FIXNUM: + index = NUM2INT(object); + break; + default: + SWIG_exception(SWIG_TypeError, "Value must be a string or integer."); + } + + int count = OGR_F_GetFieldCount(self); + + if (index < 0 || index > count) { + SWIG_exception(SWIG_IndexError, "Illegal field requested."); + } + + // is the field unset? + if (!OGR_F_IsFieldSet(self, index)) { + result = Qnil; + return result; + } + + // get field type + OGRFieldType field_type = (OGRFieldType) OGR_Fld_GetType(OGR_F_GetFieldDefnRef( self, index)); + + switch (field_type) { + case OFTInteger: { + const int value = OGR_F_GetFieldAsInteger(self, index); + result = INT2NUM(value); + break; + } + + case OFTIntegerList: { + int len = 0; + const int* list = OGR_F_GetFieldAsIntegerList(self, index, &len); + + result = rb_ary_new2(len); + + for ( int i = 0; i < len; ++i, ++list ) { + VALUE item = INT2NUM(*list); + rb_ary_store(result, item, i); + } + break; + } + + case OFTReal: { + const double value = OGR_F_GetFieldAsDouble(self, index); + return rb_float_new(value); + break; + } + + case OFTRealList: { + int len = 0; + const double* list = OGR_F_GetFieldAsDoubleList(self, index, &len); + + result = rb_ary_new2(len); + + for ( int i = 0; i < len; ++i, ++list ) { + VALUE item = rb_float_new(*list); + rb_ary_store(result, item, i); + } + break; + } + + case OFTString: { + const char* value = (const char *) OGR_F_GetFieldAsString(self, index); + return rb_str_new2(value); + break; + } + + case OFTStringList: +/* int len3 = 0; + const char** string_list = OGR_F_GetFieldAsStringList(self, index, &len); + + result = rb_ary_new2(len3); + + for ( int i = 0; i < len; ++i, ++string_list ) { + VALUE item = rb_str_new2(*string_list); + rb_ary_store(result, item, i); + }*/ + result = Qnil; + break; + default: + SWIG_exception(SWIG_TypeError, "Unsupported field type."); + } + + return result; + } +SWIGINTERN OGRFeatureDefnShadow *new_OGRFeatureDefnShadow(char const *name=NULL){ + return (OGRFeatureDefnShadow* )OGR_FD_Create(name); + } +SWIGINTERN char const *OGRFeatureDefnShadow_GetName(OGRFeatureDefnShadow *self){ + return OGR_FD_GetName(self); + } +SWIGINTERN int OGRFeatureDefnShadow_GetFieldCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetFieldCount(self); + } +SWIGINTERN OGRFieldDefnShadow *OGRFeatureDefnShadow_GetFieldDefn(OGRFeatureDefnShadow *self,int i){ + return (OGRFieldDefnShadow*) OGR_FD_GetFieldDefn(self, i); + } +SWIGINTERN int OGRFeatureDefnShadow_GetFieldIndex(OGRFeatureDefnShadow *self,char const *name){ + return OGR_FD_GetFieldIndex(self, name); + } +SWIGINTERN void OGRFeatureDefnShadow_AddFieldDefn(OGRFeatureDefnShadow *self,OGRFieldDefnShadow *defn){ + OGR_FD_AddFieldDefn(self, defn); + } +SWIGINTERN OGRwkbGeometryType OGRFeatureDefnShadow_GetGeomType(OGRFeatureDefnShadow *self){ + return (OGRwkbGeometryType) OGR_FD_GetGeomType(self); + } +SWIGINTERN void OGRFeatureDefnShadow_SetGeomType(OGRFeatureDefnShadow *self,OGRwkbGeometryType geom_type){ + OGR_FD_SetGeomType(self, geom_type); + } +SWIGINTERN int OGRFeatureDefnShadow_GetReferenceCount(OGRFeatureDefnShadow *self){ + return OGR_FD_GetReferenceCount(self); + } +SWIGINTERN OGRFieldDefnShadow *new_OGRFieldDefnShadow(char const *name="unnamed",OGRFieldType field_type=OFTString){ + return (OGRFieldDefnShadow*) OGR_Fld_Create(name, field_type); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetName(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetNameRef(OGRFieldDefnShadow *self){ + return (const char *) OGR_Fld_GetNameRef(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetName(OGRFieldDefnShadow *self,char const *name){ + OGR_Fld_SetName(self, name); + } +SWIGINTERN OGRFieldType OGRFieldDefnShadow_GetType(OGRFieldDefnShadow *self){ + return OGR_Fld_GetType(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetType(OGRFieldDefnShadow *self,OGRFieldType type){ + OGR_Fld_SetType(self, type); + } +SWIGINTERN OGRJustification OGRFieldDefnShadow_GetJustify(OGRFieldDefnShadow *self){ + return OGR_Fld_GetJustify(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetJustify(OGRFieldDefnShadow *self,OGRJustification justify){ + OGR_Fld_SetJustify(self, justify); + } +SWIGINTERN int OGRFieldDefnShadow_GetWidth(OGRFieldDefnShadow *self){ + return OGR_Fld_GetWidth(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetWidth(OGRFieldDefnShadow *self,int width){ + OGR_Fld_SetWidth(self, width); + } +SWIGINTERN int OGRFieldDefnShadow_GetPrecision(OGRFieldDefnShadow *self){ + return OGR_Fld_GetPrecision(self); + } +SWIGINTERN void OGRFieldDefnShadow_SetPrecision(OGRFieldDefnShadow *self,int precision){ + OGR_Fld_SetPrecision(self, precision); + } +SWIGINTERN char const *OGRFieldDefnShadow_GetFieldTypeName(OGRFieldDefnShadow *self,OGRFieldType type){ + return OGR_GetFieldTypeName(type); + } + + OGRGeometryShadow* CreateGeometryFromWkb( int len, char *bin_string, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkb( (unsigned char *) bin_string, + reference, + &geom, + len ); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow* CreateGeometryFromWkt( char **val, + OSRSpatialReferenceShadow *reference=NULL ) { + void *geom; + OGRErr err = OGR_G_CreateFromWkt(val, + reference, + &geom); + if (err != 0 ) + return NULL; + return (OGRGeometryShadow*) geom; + } + + + + OGRGeometryShadow *CreateGeometryFromGML( const char * input_string ) { + OGRGeometryShadow* geom = (OGRGeometryShadow*)OGR_G_CreateFromGML(input_string); + return geom; + } + + +SWIGINTERN OGRGeometryShadow *new_OGRGeometryShadow(OGRwkbGeometryType type=wkbUnknown,char *wkt=0,int wkb=0,char *wkb_buf=0,char *gml=0){ + if (type != wkbUnknown ) { + return (OGRGeometryShadow*) OGR_G_CreateGeometry( type ); + } + else if ( wkt != 0 ) { + return CreateGeometryFromWkt( &wkt ); + } + else if ( wkb != 0 ) { + return CreateGeometryFromWkb( wkb, wkb_buf ); + } + else if ( gml != 0 ) { + return CreateGeometryFromGML( gml ); + } + // throw? + else return 0; + } + +#define output_helper SWIG_Ruby_AppendOutput + +SWIGINTERN OGRErr OGRGeometryShadow_ExportToWkt(OGRGeometryShadow *self,char **argout){ + return OGR_G_ExportToWkt(self, argout); + } +SWIGINTERN OGRErr OGRGeometryShadow_ExportToWkb(OGRGeometryShadow *self,int *nLen,char **pBuf,OGRwkbByteOrder byte_order=wkbXDR){ + *nLen = OGR_G_WkbSize( self ); + *pBuf = (char *) malloc( *nLen * sizeof(unsigned char) ); + return OGR_G_ExportToWkb(self, byte_order, (unsigned char*) *pBuf ); + } +SWIGINTERN char const *OGRGeometryShadow_ExportToGML(OGRGeometryShadow *self){ + return (const char *) OGR_G_ExportToGML(self); + } +SWIGINTERN void OGRGeometryShadow_AddPoint(OGRGeometryShadow *self,double x,double y,double z=0){ + OGR_G_AddPoint( self, x, y, z ); + } +SWIGINTERN OGRErr OGRGeometryShadow_AddGeometryDirectly(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometryDirectly( self, other ); + } +SWIGINTERN OGRErr OGRGeometryShadow_AddGeometry(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_AddGeometry( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Clone(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_Clone(self); + } +SWIGINTERN OGRwkbGeometryType OGRGeometryShadow_GetGeometryType(OGRGeometryShadow *self){ + return (OGRwkbGeometryType) OGR_G_GetGeometryType(self); + } +SWIGINTERN char const *OGRGeometryShadow_GetGeometryName(OGRGeometryShadow *self){ + return (const char *) OGR_G_GetGeometryName(self); + } +SWIGINTERN double OGRGeometryShadow_GetArea(OGRGeometryShadow *self){ + return OGR_G_GetArea(self); + } +SWIGINTERN int OGRGeometryShadow_GetPointCount(OGRGeometryShadow *self){ + return OGR_G_GetPointCount(self); + } +SWIGINTERN double OGRGeometryShadow_GetX(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetX(self, point); + } +SWIGINTERN double OGRGeometryShadow_GetY(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetY(self, point); + } +SWIGINTERN double OGRGeometryShadow_GetZ(OGRGeometryShadow *self,int point=0){ + return OGR_G_GetZ(self, point); + } +SWIGINTERN int OGRGeometryShadow_GetGeometryCount(OGRGeometryShadow *self){ + return OGR_G_GetGeometryCount(self); + } +SWIGINTERN void OGRGeometryShadow_SetPoint(OGRGeometryShadow *self,int point,double x,double y,double z=0){ + OGR_G_SetPoint(self, point, x, y, z); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_GetGeometryRef(OGRGeometryShadow *self,int geom){ + return (OGRGeometryShadow*) OGR_G_GetGeometryRef(self, geom); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_GetBoundary(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_GetBoundary(self); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_ConvexHull(OGRGeometryShadow *self){ + return (OGRGeometryShadow*) OGR_G_ConvexHull(self); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Buffer(OGRGeometryShadow *self,double distance,int quadsecs=30){ + return (OGRGeometryShadow*) OGR_G_Buffer( self, distance, quadsecs ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Intersection(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Intersection( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Union(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Union( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Difference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_Difference( self, other ); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_SymmetricDifference(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return (OGRGeometryShadow*) OGR_G_SymmetricDifference( self, other ); + } +SWIGINTERN double OGRGeometryShadow_Distance(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Distance(self, other); + } +SWIGINTERN void OGRGeometryShadow_Empty(OGRGeometryShadow *self){ + OGR_G_Empty(self); + } +SWIGINTERN bool OGRGeometryShadow_Intersect(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Intersect(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Equal(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Equal(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Disjoint(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Disjoint(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Touches(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Touches(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Crosses(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Crosses(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Within(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Within(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Contains(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Contains(self, other); + } +SWIGINTERN bool OGRGeometryShadow_Overlaps(OGRGeometryShadow *self,OGRGeometryShadow *other){ + return OGR_G_Overlaps(self, other); + } +SWIGINTERN OGRErr OGRGeometryShadow_TransformTo(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + return OGR_G_TransformTo(self, reference); + } +SWIGINTERN OGRErr OGRGeometryShadow_Transform(OGRGeometryShadow *self,OSRCoordinateTransformationShadow *trans){ + return OGR_G_Transform(self, trans); + } +SWIGINTERN OSRSpatialReferenceShadow *OGRGeometryShadow_GetSpatialReference(OGRGeometryShadow *self){ + return (OSRSpatialReferenceShadow*)OGR_G_GetSpatialReference(self); + } +SWIGINTERN void OGRGeometryShadow_AssignSpatialReference(OGRGeometryShadow *self,OSRSpatialReferenceShadow *reference){ + OGR_G_AssignSpatialReference(self, reference); + } +SWIGINTERN void OGRGeometryShadow_CloseRings(OGRGeometryShadow *self){ + OGR_G_CloseRings(self); + } +SWIGINTERN void OGRGeometryShadow_FlattenTo2D(OGRGeometryShadow *self){ + OGR_G_FlattenTo2D(self); + } +SWIGINTERN void OGRGeometryShadow_GetEnvelope(OGRGeometryShadow *self,double argout[4]){ + OGR_G_GetEnvelope(self, (OGREnvelope*)argout); + } +SWIGINTERN OGRGeometryShadow *OGRGeometryShadow_Centroid(OGRGeometryShadow *self){ + OGRGeometryShadow *pt = new_OGRGeometryShadow( wkbPoint ); + OGRErr rcode = OGR_G_Centroid( self, pt ); + return pt; + } +SWIGINTERN int OGRGeometryShadow_WkbSize(OGRGeometryShadow *self){ + return OGR_G_WkbSize(self); + } +SWIGINTERN int OGRGeometryShadow_GetCoordinateDimension(OGRGeometryShadow *self){ + return OGR_G_GetCoordinateDimension(self); + } +SWIGINTERN int OGRGeometryShadow_GetDimension(OGRGeometryShadow *self){ + return OGR_G_GetDimension(self); + } + +char const *OGRDriverShadow_get_name( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_get_name( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + +char const *OGRDriverShadow_name_get( OGRDriverShadow *h ) { + return OGR_Dr_GetName( h ); +} + +char const *OGRDataSourceShadow_name_get( OGRDataSourceShadow *h ) { + return OGR_DS_GetName( h ); +} + + + OGRDataSourceShadow* GetOpenDS(int ds_number) { + OGRDataSourceShadow* layer = (OGRDataSourceShadow*) OGRGetOpenDS(ds_number); + return layer; + } + + + OGRDataSourceShadow* Open( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpen(filename,update,NULL); + return ds; + } + + + OGRDataSourceShadow* OpenShared( const char *filename, int update =0 ) { + OGRDataSourceShadow* ds = (OGRDataSourceShadow*)OGROpenShared(filename,update,NULL); + return ds; + } + + +OGRDriverShadow* GetDriverByName( char const *name ) { + return (OGRDriverShadow*) OGRGetDriverByName( name ); +} + +OGRDriverShadow* GetDriver(int driver_number) { + return (OGRDriverShadow*) OGRGetDriver(driver_number); +} + +SWIGINTERN VALUE +_wrap_use_exceptions(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + UseExceptions(); + + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_dont_use_exceptions(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + DontUseExceptions(); + + return Qnil; +fail: + return Qnil; +} + + +swig_class cDriver; + +SWIGINTERN VALUE +_wrap_Driver_name_get(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "name" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDriverShadow_name_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_create_data_source(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + char *kwnames[] = { + "self","name","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateDataSource" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[1], T_ARRAY); + + int size = RARRAY(argv[1])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[1], i); + char *pszItem = StringValuePtr(item); + arg3 = CSLAddString( arg3, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_CreateDataSource(arg1,(char const *)arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg3 ); + } + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg3 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_copy_data_source(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + OGRDataSourceShadow *arg2 = (OGRDataSourceShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + char *kwnames[] = { + "self","copy_ds","name","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CopyDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CopyDataSource" "', argument " "2"" of type '" "OGRDataSourceShadow *""'"); + } + arg2 = reinterpret_cast<OGRDataSourceShadow * >(argp2); + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "CopyDataSource" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + if (argc > 2) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[2], T_ARRAY); + + int size = RARRAY(argv[2])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[2], i); + char *pszItem = StringValuePtr(item); + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_CopyDataSource(arg1,arg2,(char const *)arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_OWN | 0 ); + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg4 ); + } + return vresult; +fail: + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg4 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_open(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + char *kwnames[] = { + "self","name","update", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Open" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Open" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "Open" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OGRDriverShadow_Open(arg1,(char const *)arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_delete_data_source(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "DeleteDataSource" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "DeleteDataSource" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRDriverShadow_DeleteDataSource(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_test_capability(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRDriverShadow_TestCapability(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Driver_get_name(int argc, VALUE *argv, VALUE self) { + OGRDriverShadow *arg1 = (OGRDriverShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetName" "', argument " "1"" of type '" "OGRDriverShadow *""'"); + } + arg1 = reinterpret_cast<OGRDriverShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDriverShadow_GetName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +swig_class cDataSource; + +SWIGINTERN VALUE +_wrap_DataSource_name_get(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "name" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDataSourceShadow_name_get(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN void delete_OGRDataSourceShadow(OGRDataSourceShadow *self){ + OGRReleaseDataSource(self); + } +SWIGINTERN void +free_OGRDataSourceShadow(OGRDataSourceShadow *arg1) { + delete_OGRDataSourceShadow(arg1); +} + +SWIGINTERN VALUE +_wrap_DataSource_get_ref_count(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetRefCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetRefCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_get_summary_ref_count(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetSummaryRefCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetSummaryRefCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_get_layer_count(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetLayerCount" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRDataSourceShadow_GetLayerCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_get_driver(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRDriverShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDriver" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRDriverShadow *)OGRDataSourceShadow_GetDriver(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_get_name(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetName" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRDataSourceShadow_GetName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_delete_layer(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + int arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "DeleteLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "DeleteLayer" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRDataSourceShadow_DeleteLayer(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_create_layer(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRwkbGeometryType arg4 = (OGRwkbGeometryType) wkbUnknown ; + char **arg5 = (char **) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 ; + char *kwnames[] = { + "self","name","reference","geom_type","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateLayer" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "CreateLayer" "', argument " "3"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg3 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp3); + } + if (argc > 2) { + { + /* %typemap(in) CPLErr */ + arg4 = (OGRwkbGeometryType) NUM2INT(argv[2]); + } + } + if (argc > 3) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[3], T_ARRAY); + + int size = RARRAY(argv[3])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[3], i); + char *pszItem = StringValuePtr(item); + arg5 = CSLAddString( arg5, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_CreateLayer(arg1,(char const *)arg2,arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg5 ); + } + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg5 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_copy_layer(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + char *arg3 = (char *) 0 ; + char **arg4 = (char **) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + char *kwnames[] = { + "self","src_layer","new_name","options", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CopyLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CopyLayer" "', argument " "2"" of type '" "OGRLayerShadow *""'"); + } + arg2 = reinterpret_cast<OGRLayerShadow * >(argp2); + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "CopyLayer" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + if (argc > 2) { + { + /* %typemap(in) char **options */ + + /* Check if is a list */ + Check_Type(argv[2], T_ARRAY); + + int size = RARRAY(argv[2])->len; + for (int i = 0; i < size; i++) { + VALUE item = rb_ary_entry(argv[2], i); + char *pszItem = StringValuePtr(item); + arg4 = CSLAddString( arg4, pszItem ); + } + } + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_CopyLayer(arg1,arg2,(char const *)arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg4 ); + } + return vresult; +fail: + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(freearg) char **options */ + + CSLDestroy( arg4 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_test_capability(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRDataSourceShadow_TestCapability(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_execute_sql(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRGeometryShadow *arg3 = (OGRGeometryShadow *) NULL ; + char *arg4 = (char *) "" ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + char *kwnames[] = { + "self","statement","geom","dialect", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ExecuteSQL" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "ExecuteSQL" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "ExecuteSQL" "', argument " "3"" of type '" "OGRGeometryShadow *""'"); + } + arg3 = reinterpret_cast<OGRGeometryShadow * >(argp3); + } + if (argc > 2) { + res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "ExecuteSQL" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + } + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_ExecuteSQL(arg1,(char const *)arg2,arg3,(char const *)arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_OWN | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_release_result_set(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + OGRLayerShadow *arg2 = (OGRLayerShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ReleaseResultSet" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRLayerShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "ReleaseResultSet" "', argument " "2"" of type '" "OGRLayerShadow *""'"); + } + { + CPLErrorReset(); + OGRDataSourceShadow_ReleaseResultSet(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_DataSource_get_layer(int argc, VALUE *argv, VALUE self) { + OGRDataSourceShadow *arg1 = (OGRDataSourceShadow *) 0 ; + VALUE arg2 = (VALUE) 0 ; + OGRLayerShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetLayer" "', argument " "1"" of type '" "OGRDataSourceShadow *""'"); + } + arg1 = reinterpret_cast<OGRDataSourceShadow * >(argp1); + arg2 = argv[0]; + { + CPLErrorReset(); + result = (OGRLayerShadow *)OGRDataSourceShadow_GetLayer(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +swig_class cLayer; + +SWIGINTERN VALUE +_wrap_Layer_get_ref_count(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetRefCount" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRLayerShadow_GetRefCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_set_spatial_filter(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetSpatialFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetSpatialFilter" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + OGRLayerShadow_SetSpatialFilter(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_set_spatial_filter_rect(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetSpatialFilterRect" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetSpatialFilterRect" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetSpatialFilterRect" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetSpatialFilterRect" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetSpatialFilterRect" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + { + CPLErrorReset(); + OGRLayerShadow_SetSpatialFilterRect(arg1,arg2,arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_spatial_filter(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetSpatialFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRLayerShadow_GetSpatialFilter(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_set_attribute_filter(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetAttributeFilter" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetAttributeFilter" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetAttributeFilter(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_reset_reading(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ResetReading" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + OGRLayerShadow_ResetReading(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_name(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetName" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRLayerShadow_GetName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_feature(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + long val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFeature" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast<long >(val2); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRLayerShadow_GetFeature(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_next_feature(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetNextFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRLayerShadow_GetNextFeature(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_set_next_by_index(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + long val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetNextByIndex" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetNextByIndex" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast<long >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetNextByIndex(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_set_feature(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetFeature" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast<OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SetFeature(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_create_feature(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateFeature" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast<OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CreateFeature(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_delete_feature(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + long arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + long val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "DeleteFeature" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + ecode2 = SWIG_AsVal_long(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "DeleteFeature" "', argument " "2"" of type '" "long""'"); + } + arg2 = static_cast<long >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_DeleteFeature(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_sync_to_disk(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SyncToDisk" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_SyncToDisk(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_layer_defn(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFeatureDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetLayerDefn" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)OGRLayerShadow_GetLayerDefn(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_feature_count(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + int arg2 = (int) 1 ; + int result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "self","force", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFeatureCount" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + if (argc > 0) { + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFeatureCount" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (int)OGRLayerShadow_GetFeatureCount(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_extent(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + double *arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double argout2[4] ; + int val3 ; + int ecode3 = 0 ; + char *kwnames[] = { + "self","force", NULL + }; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetExtent" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + if (argc > 0) { + ecode3 = SWIG_AsVal_int(argv[0], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GetExtent" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_GetExtent(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<4; i++) + { + VALUE value = rb_float_new((arg2)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_test_capability(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "TestCapability" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRLayerShadow_TestCapability(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_create_field(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + char *kwnames[] = { + "self","field_def","approx_ok", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateField" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateField" "', argument " "2"" of type '" "OGRFieldDefnShadow *""'"); + } + arg2 = reinterpret_cast<OGRFieldDefnShadow * >(argp2); + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "CreateField" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CreateField(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_start_transaction(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "StartTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_StartTransaction(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_commit_transaction(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CommitTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_CommitTransaction(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_rollback_transaction(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "RollbackTransaction" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRLayerShadow_RollbackTransaction(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_spatial_ref(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + OSRSpatialReferenceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetSpatialRef" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = (OSRSpatialReferenceShadow *)OGRLayerShadow_GetSpatialRef(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_get_feature_read(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + GIntBig result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFeatureRead" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + result = OGRLayerShadow_GetFeatureRead(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj((new GIntBig(static_cast<const GIntBig& >(result))), SWIGTYPE_p_GIntBig, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Layer_each(int argc, VALUE *argv, VALUE self) { + OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "each" "', argument " "1"" of type '" "OGRLayerShadow *""'"); + } + arg1 = reinterpret_cast<OGRLayerShadow * >(argp1); + { + CPLErrorReset(); + OGRLayerShadow_each(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +swig_class cFeature; + +SWIGINTERN void delete_OGRFeatureShadow(OGRFeatureShadow *self){ + OGR_F_Destroy(self); + } +SWIGINTERN void +free_OGRFeatureShadow(OGRFeatureShadow *arg1) { + delete_OGRFeatureShadow(arg1); +} + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_Feature_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_Feature_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_OGRFeatureShadow); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_Feature(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + char *kwnames[] = { + "feature_def", NULL + }; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OGRFeatureShadow" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + } + { + CPLErrorReset(); + result = (OGRFeatureShadow *)new_OGRFeatureShadow(arg1); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return self; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_defn_ref(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)OGRFeatureShadow_GetDefnRef(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_geometry(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGeometry" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetGeometry" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetGeometry(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_geometry_directly(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGeometryDirectly" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetGeometryDirectly" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetGeometryDirectly(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_geometry_ref(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeometryRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRFeatureShadow_GetGeometryRef(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_clone(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Clone" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFeatureShadow *)OGRFeatureShadow_Clone(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFeatureShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_equal(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Equal" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Equal" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast<OGRFeatureShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_Equal(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_count(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldCount" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_defn_ref__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldDefnRef" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_defn_ref__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldDefnRef" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldDefnRef" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureShadow_GetFieldDefnRef__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_get_field_defn_ref(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_get_field_defn_ref__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_get_field_defn_ref__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_get_field_defn_ref'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_string__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldAsString" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_string__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldAsString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetFieldAsString__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_get_field_as_string(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_get_field_as_string__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_get_field_as_string__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_get_field_as_string'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_integer__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + int result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsInteger" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldAsInteger" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_integer__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsInteger" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldAsInteger" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldAsInteger__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_get_field_as_integer(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_get_field_as_integer__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_get_field_as_integer__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_get_field_as_integer'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_double__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + double result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsDouble" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldAsDouble" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_as_double__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldAsDouble" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldAsDouble" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (double)OGRFeatureShadow_GetFieldAsDouble__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_get_field_as_double(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_get_field_as_double__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_get_field_as_double__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_get_field_as_double'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_is_field_set__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + bool result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsFieldSet" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "IsFieldSet" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_is_field_set__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsFieldSet" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "IsFieldSet" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (bool)OGRFeatureShadow_IsFieldSet__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_is_field_set(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_is_field_set__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_is_field_set__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_is_field_set'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_index(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldIndex" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldIndex" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFieldIndex(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_fid(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFID" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureShadow_GetFID(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_fid(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetFID" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetFID" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetFID(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_dump_readable(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "DumpReadable" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + OGRFeatureShadow_DumpReadable(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_unset_field__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "UnsetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "UnsetField" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + OGRFeatureShadow_UnsetField__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_unset_field__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "UnsetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "UnsetField" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFeatureShadow_UnsetField__SWIG_1(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_unset_field(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[3]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 2); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_unset_field__SWIG_0(nargs, args, self); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_unset_field__SWIG_1(nargs, args, self); + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_unset_field'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_field__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetField" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetField" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + { + CPLErrorReset(); + OGRFeatureShadow_SetField__SWIG_0(arg1,arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +fail: + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_field__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetField" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetField" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + { + CPLErrorReset(); + OGRFeatureShadow_SetField__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_set_field(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[4]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 3); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_set_field__SWIG_0(nargs, args, self); + } + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_set_field__SWIG_1(nargs, args, self); + } + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_set_field'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_from(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + OGRFeatureShadow *arg2 = (OGRFeatureShadow *) 0 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + char *kwnames[] = { + "self","other","forgiving", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetFrom" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetFrom" "', argument " "2"" of type '" "OGRFeatureShadow *""'"); + } + arg2 = reinterpret_cast<OGRFeatureShadow * >(argp2); + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetFrom" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (OGRErr)OGRFeatureShadow_SetFrom(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_style_string(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetStyleString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFeatureShadow_GetStyleString(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_set_style_string(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetStyleString" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetStyleString" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFeatureShadow_SetStyleString(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_type__SWIG_0(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + int arg2 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldType" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldType" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_0(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field_type__SWIG_1(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldType" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldType" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "GetFieldType" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + { + CPLErrorReset(); + result = (OGRFieldType)OGRFeatureShadow_GetFieldType__SWIG_1(arg1,(char const *)arg2,(char const *)arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE _wrap_Feature_get_field_type(int nargs, VALUE *args, VALUE self) { + int argc; + VALUE argv[4]; + int ii; + + argc = nargs + 1; + argv[0] = self; + for (ii = 1; (ii < argc) && (ii < 3); ii++) { + argv[ii] = args[ii-1]; + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_int(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_Feature_get_field_type__SWIG_0(nargs, args, self); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_OGRFeatureShadow, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_AsCharPtrAndSize(argv[2], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Feature_get_field_type__SWIG_1(nargs, args, self); + } + } + } + } + +fail: + rb_raise(rb_eArgError, "No matching function for overloaded 'Feature_get_field_type'"); + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Feature_get_field(int argc, VALUE *argv, VALUE self) { + OGRFeatureShadow *arg1 = (OGRFeatureShadow *) 0 ; + VALUE arg2 = (VALUE) 0 ; + VALUE result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetField" "', argument " "1"" of type '" "OGRFeatureShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureShadow * >(argp1); + arg2 = argv[0]; + { + CPLErrorReset(); + result = (VALUE)OGRFeatureShadow_GetField(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = result; + return vresult; +fail: + return Qnil; +} + + +swig_class cFeatureDefn; + +SWIGINTERN void delete_OGRFeatureDefnShadow(OGRFeatureDefnShadow *self){ + OGR_FD_Destroy(self); + } +SWIGINTERN void +free_OGRFeatureDefnShadow(OGRFeatureDefnShadow *arg1) { + delete_OGRFeatureDefnShadow(arg1); +} + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_FeatureDefn_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_FeatureDefn_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_OGRFeatureDefnShadow); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_FeatureDefn(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) NULL ; + OGRFeatureDefnShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *kwnames[] = { + "name", NULL + }; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OGRFeatureDefnShadow" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + { + CPLErrorReset(); + result = (OGRFeatureDefnShadow *)new_OGRFeatureDefnShadow((char const *)arg1); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_name(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetName" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFeatureDefnShadow_GetName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_field_count(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldCount" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetFieldCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_field_defn(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int arg2 ; + OGRFieldDefnShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldDefn" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetFieldDefn" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)OGRFeatureDefnShadow_GetFieldDefn(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_field_index(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldIndex" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetFieldIndex" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetFieldIndex(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_add_field_defn(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRFieldDefnShadow *arg2 = (OGRFieldDefnShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AddFieldDefn" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "AddFieldDefn" "', argument " "2"" of type '" "OGRFieldDefnShadow *""'"); + } + arg2 = reinterpret_cast<OGRFieldDefnShadow * >(argp2); + { + CPLErrorReset(); + OGRFeatureDefnShadow_AddFieldDefn(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_geom_type(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeomType" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRwkbGeometryType)OGRFeatureDefnShadow_GetGeomType(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_set_geom_type(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + OGRwkbGeometryType arg2 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGeomType" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + { + /* %typemap(in) CPLErr */ + arg2 = (OGRwkbGeometryType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + OGRFeatureDefnShadow_SetGeomType(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FeatureDefn_get_reference_count(int argc, VALUE *argv, VALUE self) { + OGRFeatureDefnShadow *arg1 = (OGRFeatureDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFeatureDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetReferenceCount" "', argument " "1"" of type '" "OGRFeatureDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFeatureDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFeatureDefnShadow_GetReferenceCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +swig_class cFieldDefn; + +SWIGINTERN void delete_OGRFieldDefnShadow(OGRFieldDefnShadow *self){ + OGR_Fld_Destroy(self); + } +SWIGINTERN void +free_OGRFieldDefnShadow(OGRFieldDefnShadow *arg1) { + delete_OGRFieldDefnShadow(arg1); +} + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_FieldDefn_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_FieldDefn_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_OGRFieldDefnShadow); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_FieldDefn(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) "unnamed" ; + OGRFieldType arg2 = (OGRFieldType) OFTString ; + OGRFieldDefnShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *kwnames[] = { + "name","field_type", NULL + }; + + if ((argc < 0) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OGRFieldDefnShadow" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + if (argc > 1) { + { + /* %typemap(in) CPLErr */ + arg2 = (OGRFieldType) NUM2INT(argv[1]); + } + } + { + CPLErrorReset(); + result = (OGRFieldDefnShadow *)new_OGRFieldDefnShadow((char const *)arg1,arg2); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_name(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_name_ref(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetNameRef" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetNameRef(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_set_name(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetName" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + { + CPLErrorReset(); + OGRFieldDefnShadow_SetName(arg1,(char const *)arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_type(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetType" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRFieldType)OGRFieldDefnShadow_GetType(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_set_type(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetType" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + /* %typemap(in) CPLErr */ + arg2 = (OGRFieldType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + OGRFieldDefnShadow_SetType(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_justify(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetJustify" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRJustification)OGRFieldDefnShadow_GetJustify(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_set_justify(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRJustification arg2 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetJustify" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + /* %typemap(in) CPLErr */ + arg2 = (OGRJustification) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + OGRFieldDefnShadow_SetJustify(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_width(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetWidth" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFieldDefnShadow_GetWidth(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_set_width(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetWidth" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetWidth" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetWidth(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_precision(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetPrecision" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRFieldDefnShadow_GetPrecision(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_set_precision(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetPrecision" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetPrecision" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + OGRFieldDefnShadow_SetPrecision(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_FieldDefn_get_field_type_name(int argc, VALUE *argv, VALUE self) { + OGRFieldDefnShadow *arg1 = (OGRFieldDefnShadow *) 0 ; + OGRFieldType arg2 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRFieldDefnShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetFieldTypeName" "', argument " "1"" of type '" "OGRFieldDefnShadow *""'"); + } + arg1 = reinterpret_cast<OGRFieldDefnShadow * >(argp1); + { + /* %typemap(in) CPLErr */ + arg2 = (OGRFieldType) NUM2INT(argv[0]); + } + { + CPLErrorReset(); + result = (char *)OGRFieldDefnShadow_GetFieldTypeName(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_create_geometry_from_wkb(int argc, VALUE *argv, VALUE self) { + int arg1 ; + char *arg2 = (char *) 0 ; + OSRSpatialReferenceShadow *arg3 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + void *argp3 = 0 ; + int res3 ; + char *kwnames[] = { + "len","reference", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateGeometryFromWkb" "', argument " "1"" of type '" "int""'"); + } + arg2 = static_cast<char * >(buf1) ; + arg1 = static_cast<int >(size1 - 1) ; + if (argc > 1) { + res3 = SWIG_ConvertPtr(argv[1], &argp3,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "CreateGeometryFromWkb" "', argument " "3"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg3 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp3); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromWkb(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_create_geometry_from_wkt(int argc, VALUE *argv, VALUE self) { + char **arg1 = (char **) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) NULL ; + OGRGeometryShadow *result = 0 ; + char *val1 = 0 ; + void *argp2 = 0 ; + int res2 ; + char *kwnames[] = { + "val","reference", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + { + /* %typemap(in) char ** ( char *val1=0 ) */ + + val1 = StringValuePtr(argv[0]); + arg1 = &val1; + } + if (argc > 1) { + res2 = SWIG_ConvertPtr(argv[1], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CreateGeometryFromWkt" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromWkt(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_create_geometry_from_gml(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + OGRGeometryShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CreateGeometryFromGML" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (OGRGeometryShadow *)CreateGeometryFromGML((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +swig_class cGeometry; + +SWIGINTERN void delete_OGRGeometryShadow(OGRGeometryShadow *self){ + OGR_G_DestroyGeometry( self ); + } +SWIGINTERN void +free_OGRGeometryShadow(OGRGeometryShadow *arg1) { + delete_OGRGeometryShadow(arg1); +} + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_Geometry_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_Geometry_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_OGRGeometryShadow); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_Geometry(int argc, VALUE *argv, VALUE self) { + OGRwkbGeometryType arg1 = (OGRwkbGeometryType) wkbUnknown ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + OGRGeometryShadow *result = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + char *kwnames[] = { + "type","wkt","wkb","wkb_buf","gml", NULL + }; + + if ((argc < 0) || (argc > 5)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + { + /* %typemap(in) CPLErr */ + arg1 = (OGRwkbGeometryType) NUM2INT(argv[0]); + } + } + if (argc > 1) { + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "OGRGeometryShadow" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + } + if (argc > 2) { + ecode3 = SWIG_AsVal_int(argv[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "OGRGeometryShadow" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + if (argc > 3) { + res4 = SWIG_AsCharPtrAndSize(argv[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "OGRGeometryShadow" "', argument " "4"" of type '" "char *""'"); + } + arg4 = buf4; + } + if (argc > 4) { + res5 = SWIG_AsCharPtrAndSize(argv[4], &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(((res5 != SWIG_ERROR) ? res5 : SWIG_TypeError), "in method '" "OGRGeometryShadow" "', argument " "5"" of type '" "char *""'"); + } + arg5 = buf5; + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)new_OGRGeometryShadow(arg1,arg2,arg3,arg4,arg5); + DATA_PTR(self) = result; + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + return self; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_export_to_wkt(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + char *argout2 = 0 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (char **argout2) ( char *argout2=0 ) */ + arg2 = &argout2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ExportToWkt" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_ExportToWkt(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + VALUE outArg; + if ( arg2 ) { + outArg = rb_str_new2( *arg2 ); + } + else { + outArg = Qnil; + } + + vresult = SWIG_Ruby_AppendOutput(vresult, outArg); + } + { + /* %typemap(freearg) (char **argout) */ + + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + { + /* %typemap(freearg) (char **argout) */ + + if ( *arg2 ) + CPLFree( *arg2 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_export_to_wkb(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int *arg2 = (int *) 0 ; + char **arg3 = (char **) 0 ; + OGRwkbByteOrder arg4 = (OGRwkbByteOrder) wkbXDR ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int nLen2 = 0 ; + char *pBuf2 = 0 ; + char *kwnames[] = { + "self","byte_order", NULL + }; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (int *nLen2, char **pBuf2 ) ( int nLen2 = 0, char *pBuf2 = 0 ) */ + arg2 = &nLen2; + arg3 = &pBuf2; + } + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ExportToWkb" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + if (argc > 0) { + { + /* %typemap(in) CPLErr */ + arg4 = (OGRwkbByteOrder) NUM2INT(argv[0]); + } + } + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_ExportToWkb(arg1,arg2,arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (int *nLen, char **pBuf ) */ + vresult = rb_str_new(*arg3, *arg2); + } + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg3 ) { + free( *arg3 ); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + { + /* %typemap(freearg) (int *nLen, char **pBuf ) */ + if( *arg3 ) { + free( *arg3 ); + } + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_export_to_gml(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ExportToGML" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRGeometryShadow_ExportToGML(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_add_point(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 = (double) 0 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + char *kwnames[] = { + "self","x","y","z", NULL + }; + + if ((argc < 2) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AddPoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "AddPoint" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "AddPoint" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + if (argc > 2) { + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "AddPoint" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + } + { + CPLErrorReset(); + OGRGeometryShadow_AddPoint(arg1,arg2,arg3,arg4); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_add_geometry_directly(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AddGeometryDirectly" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], SWIG_as_voidptrptr(&arg2), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "AddGeometryDirectly" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_AddGeometryDirectly(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_add_geometry(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AddGeometry" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "AddGeometry" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_AddGeometry(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_clone(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Clone" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Clone(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_geometry_type(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRwkbGeometryType result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeometryType" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRwkbGeometryType)OGRGeometryShadow_GetGeometryType(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_geometry_name(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeometryName" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (char *)OGRGeometryShadow_GetGeometryName(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_area(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetArea" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetArea(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_point_count(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetPointCount" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetPointCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_x(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "self","point", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetX" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + if (argc > 0) { + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetX" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetX(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_y(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "self","point", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetY" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + if (argc > 0) { + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetY" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetY(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_z(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 = (int) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "self","point", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetZ" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + if (argc > 0) { + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetZ" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_GetZ(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_geometry_count(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeometryCount" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetGeometryCount(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_set_point(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + char *kwnames[] = { + "self","point","x","y","z", NULL + }; + + if ((argc < 3) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetPoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetPoint" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetPoint" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetPoint" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + if (argc > 3) { + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetPoint" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + } + { + CPLErrorReset(); + OGRGeometryShadow_SetPoint(arg1,arg2,arg3,arg4,arg5); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_geometry_ref(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int arg2 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetGeometryRef" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "GetGeometryRef" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_GetGeometryRef(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_boundary(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetBoundary" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_GetBoundary(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_convex_hull(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "ConvexHull" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_ConvexHull(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_buffer(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double arg2 ; + int arg3 = (int) 30 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + char *kwnames[] = { + "self","distance","quadsecs", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Buffer" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "Buffer" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "Buffer" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Buffer(arg1,arg2,arg3); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_intersection(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Intersection" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Intersection" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Intersection(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_union(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Union" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Union" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Union(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_difference(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Difference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Difference" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Difference(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_symmetric_difference(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SymmetricDifference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SymmetricDifference" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_SymmetricDifference(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_distance(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Distance" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Distance" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (double)OGRGeometryShadow_Distance(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_empty(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Empty" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_Empty(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_intersect(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Intersect" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Intersect" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Intersect(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_equal(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Equal" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Equal" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Equal(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_disjoint(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Disjoint" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Disjoint" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Disjoint(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_touches(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Touches" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Touches" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Touches(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_crosses(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Crosses" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Crosses" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Crosses(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_within(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Within" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Within" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Within(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_contains(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Contains" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Contains" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Contains(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_overlaps(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *arg2 = (OGRGeometryShadow *) 0 ; + bool result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Overlaps" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Overlaps" "', argument " "2"" of type '" "OGRGeometryShadow *""'"); + } + arg2 = reinterpret_cast<OGRGeometryShadow * >(argp2); + { + CPLErrorReset(); + result = (bool)OGRGeometryShadow_Overlaps(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_bool(static_cast<bool >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_transform_to(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "TransformTo" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "TransformTo" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_TransformTo(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_transform(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRCoordinateTransformationShadow *arg2 = (OSRCoordinateTransformationShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Transform" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRCoordinateTransformationShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "Transform" "', argument " "2"" of type '" "OSRCoordinateTransformationShadow *""'"); + } + arg2 = reinterpret_cast<OSRCoordinateTransformationShadow * >(argp2); + { + CPLErrorReset(); + result = (OGRErr)OGRGeometryShadow_Transform(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_spatial_reference(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetSpatialReference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OSRSpatialReferenceShadow *)OGRGeometryShadow_GetSpatialReference(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_assign_spatial_reference(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AssignSpatialReference" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "AssignSpatialReference" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + { + CPLErrorReset(); + OGRGeometryShadow_AssignSpatialReference(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_close_rings(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CloseRings" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_CloseRings(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_flatten_to2_d(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + void *argp1 = 0 ; + int res1 ; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "FlattenTo2D" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_FlattenTo2D(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_envelope(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + double *arg2 ; + void *argp1 = 0 ; + int res1 ; + double argout2[4] ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetEnvelope" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + OGRGeometryShadow_GetEnvelope(arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<4; i++) + { + VALUE value = rb_float_new((arg2)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_centroid(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + OGRGeometryShadow *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Centroid" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (OGRGeometryShadow *)OGRGeometryShadow_Centroid(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRGeometryShadow, SWIG_POINTER_OWN | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_wkb_size(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "WkbSize" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_WkbSize(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_coordinate_dimension(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetCoordinateDimension" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetCoordinateDimension(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_Geometry_get_dimension(int argc, VALUE *argv, VALUE self) { + OGRGeometryShadow *arg1 = (OGRGeometryShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OGRGeometryShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDimension" "', argument " "1"" of type '" "OGRGeometryShadow *""'"); + } + arg1 = reinterpret_cast<OGRGeometryShadow * >(argp1); + { + CPLErrorReset(); + result = (int)OGRGeometryShadow_GetDimension(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver_count(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)OGRGetDriverCount(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_open_dscount(int argc, VALUE *argv, VALUE self) { + int result; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + result = (int)OGRGetOpenDSCount(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_set_generate_db2_v72_byte_order(int argc, VALUE *argv, VALUE self) { + int arg1 ; + OGRErr result; + int val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_int(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "OGRSetGenerate_DB2_V72_BYTE_ORDER" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast<int >(val1); + { + CPLErrorReset(); + result = (OGRErr)OGRSetGenerate_DB2_V72_BYTE_ORDER(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_register_all(int argc, VALUE *argv, VALUE self) { + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + { + CPLErrorReset(); + OGRRegisterAll(); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + return Qnil; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_open_ds(int argc, VALUE *argv, VALUE self) { + int arg1 ; + OGRDataSourceShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_int(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GetOpenDS" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast<int >(val1); + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)GetOpenDS(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_open(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "filename","update", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "Open" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (argc > 1) { + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "Open" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)Open((char const *)arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_open_shared(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + int arg2 = (int) 0 ; + OGRDataSourceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + char *kwnames[] = { + "filename","update", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OpenShared" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + if (argc > 1) { + ecode2 = SWIG_AsVal_int(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "OpenShared" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + } + { + CPLErrorReset(); + result = (OGRDataSourceShadow *)OpenShared((char const *)arg1,arg2); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDataSourceShadow, SWIG_POINTER_OWN | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver_by_name(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + OGRDriverShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetDriverByName" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + { + CPLErrorReset(); + result = (OGRDriverShadow *)GetDriverByName((char const *)arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_get_driver(int argc, VALUE *argv, VALUE self) { + int arg1 ; + OGRDriverShadow *result = 0 ; + int val1 ; + int ecode1 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + ecode1 = SWIG_AsVal_int(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(((ecode1 != SWIG_ERROR) ? ecode1 : SWIG_TypeError), "in method '" "GetDriver" "', argument " "1"" of type '" "int""'"); + } + arg1 = static_cast<int >(val1); + { + CPLErrorReset(); + result = (OGRDriverShadow *)GetDriver(arg1); + + CPLErr eclass = CPLGetLastErrorType(); + if ( eclass == CE_Failure || eclass == CE_Fatal ) { + SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); + } + } + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OGRDriverShadow, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_GIntBig = {"_p_GIntBig", "GIntBig *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRDataSourceShadow = {"_p_OGRDataSourceShadow", "OGRDataSourceShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRDriverShadow = {"_p_OGRDriverShadow", "OGRDriverShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRFeatureDefnShadow = {"_p_OGRFeatureDefnShadow", "OGRFeatureDefnShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRFeatureShadow = {"_p_OGRFeatureShadow", "OGRFeatureShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRFieldDefnShadow = {"_p_OGRFieldDefnShadow", "OGRFieldDefnShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRGeometryShadow = {"_p_OGRGeometryShadow", "OGRGeometryShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OGRLayerShadow = {"_p_OGRLayerShadow", "OGRLayerShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OSRCoordinateTransformationShadow = {"_p_OSRCoordinateTransformationShadow", "OSRCoordinateTransformationShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_OSRSpatialReferenceShadow = {"_p_OSRSpatialReferenceShadow", "OSRSpatialReferenceShadow *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_GIntBig, + &_swigt__p_OGRDataSourceShadow, + &_swigt__p_OGRDriverShadow, + &_swigt__p_OGRFeatureDefnShadow, + &_swigt__p_OGRFeatureShadow, + &_swigt__p_OGRFieldDefnShadow, + &_swigt__p_OGRGeometryShadow, + &_swigt__p_OGRLayerShadow, + &_swigt__p_OSRCoordinateTransformationShadow, + &_swigt__p_OSRSpatialReferenceShadow, + &_swigt__p_char, + &_swigt__p_double, + &_swigt__p_int, + &_swigt__p_p_char, +}; + +static swig_cast_info _swigc__p_GIntBig[] = { {&_swigt__p_GIntBig, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDataSourceShadow[] = { {&_swigt__p_OGRDataSourceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRDriverShadow[] = { {&_swigt__p_OGRDriverShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureDefnShadow[] = { {&_swigt__p_OGRFeatureDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFeatureShadow[] = { {&_swigt__p_OGRFeatureShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRFieldDefnShadow[] = { {&_swigt__p_OGRFieldDefnShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRGeometryShadow[] = { {&_swigt__p_OGRGeometryShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OGRLayerShadow[] = { {&_swigt__p_OGRLayerShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRCoordinateTransformationShadow[] = { {&_swigt__p_OSRCoordinateTransformationShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_OSRSpatialReferenceShadow[] = { {&_swigt__p_OSRSpatialReferenceShadow, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_GIntBig, + _swigc__p_OGRDataSourceShadow, + _swigc__p_OGRDriverShadow, + _swigc__p_OGRFeatureDefnShadow, + _swigc__p_OGRFeatureShadow, + _swigc__p_OGRFieldDefnShadow, + _swigc__p_OGRGeometryShadow, + _swigc__p_OGRLayerShadow, + _swigc__p_OSRCoordinateTransformationShadow, + _swigc__p_OSRSpatialReferenceShadow, + _swigc__p_char, + _swigc__p_double, + _swigc__p_int, + _swigc__p_p_char, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +/************************************************************************* + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop though that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. +**/ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + swig_type_info *type, *ret; + swig_cast_info *cast; + size_t i; + swig_module_info *module_head; + static int init_run = 0; + + clientdata = clientdata; + + if (init_run) return; + init_run = 1; + + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (module_head) { + swig_module.next = module_head->next; + module_head->next = &swig_module; + } else { + /* This is the first module loaded */ + swig_module.next = &swig_module; + SWIG_SetModule(clientdata, &swig_module); + } + + /* Now work on filling in swig_module.types */ + for (i = 0; i < swig_module.size; ++i) { + type = 0; + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ + if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); + } + if (ret && type == swig_module.type_initial[i]) { + cast->type = ret; + ret = 0; + } + + if (!ret) { + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + + cast++; + } + + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void Init_ogr(void) { + size_t i; + + SWIG_InitRuntime(); + mOgr = rb_define_module("Gdal"); + mOgr = rb_define_module_under(mOgr, "Ogr"); + + SWIG_InitializeModule(0); + for (i = 0; i < swig_module.size; i++) { + SWIG_define_class(swig_module.types[i]); + } + + SWIG_RubyInitializeTrackings(); + rb_define_const(mOgr, "WKB25BIT", SWIG_From_int(static_cast<int >(wkb25DBit))); + rb_define_const(mOgr, "WKBUNKNOWN", SWIG_From_int(static_cast<int >(0))); + rb_define_const(mOgr, "WKBPOINT", SWIG_From_int(static_cast<int >(1))); + rb_define_const(mOgr, "WKBLINESTRING", SWIG_From_int(static_cast<int >(2))); + rb_define_const(mOgr, "WKBPOLYGON", SWIG_From_int(static_cast<int >(3))); + rb_define_const(mOgr, "WKBMULTIPOINT", SWIG_From_int(static_cast<int >(4))); + rb_define_const(mOgr, "WKBMULTILINESTRING", SWIG_From_int(static_cast<int >(5))); + rb_define_const(mOgr, "WKBMULTIPOLYGON", SWIG_From_int(static_cast<int >(6))); + rb_define_const(mOgr, "WKBGEOMETRYCOLLECTION", SWIG_From_int(static_cast<int >(7))); + rb_define_const(mOgr, "WKBNONE", SWIG_From_int(static_cast<int >(100))); + rb_define_const(mOgr, "WKBLINEARRING", SWIG_From_int(static_cast<int >(101))); + rb_define_const(mOgr, "WKBPOINT25D", SWIG_From_int(static_cast<int >(wkbPoint+wkb25DBit))); + rb_define_const(mOgr, "WKBLINESTRING25D", SWIG_From_int(static_cast<int >(wkbLineString+wkb25DBit))); + rb_define_const(mOgr, "WKBPOLYGON25D", SWIG_From_int(static_cast<int >(wkbPolygon+wkb25DBit))); + rb_define_const(mOgr, "WKBMULTIPOINT25D", SWIG_From_int(static_cast<int >(wkbMultiPoint+wkb25DBit))); + rb_define_const(mOgr, "WKBMULTILINESTRING25D", SWIG_From_int(static_cast<int >(wkbMultiLineString+wkb25DBit))); + rb_define_const(mOgr, "WKBMULTIPOLYGON25D", SWIG_From_int(static_cast<int >(wkbMultiPolygon+wkb25DBit))); + rb_define_const(mOgr, "WKBGEOMETRYCOLLECTION25D", SWIG_From_int(static_cast<int >(wkbGeometryCollection+wkb25DBit))); + rb_define_const(mOgr, "OFTINTEGER", SWIG_From_int(static_cast<int >(0))); + rb_define_const(mOgr, "OFTINTEGERLIST", SWIG_From_int(static_cast<int >(1))); + rb_define_const(mOgr, "OFTREAL", SWIG_From_int(static_cast<int >(2))); + rb_define_const(mOgr, "OFTREALLIST", SWIG_From_int(static_cast<int >(3))); + rb_define_const(mOgr, "OFTSTRING", SWIG_From_int(static_cast<int >(4))); + rb_define_const(mOgr, "OFTSTRINGLIST", SWIG_From_int(static_cast<int >(5))); + rb_define_const(mOgr, "OFTWIDESTRING", SWIG_From_int(static_cast<int >(6))); + rb_define_const(mOgr, "OFTWIDESTRINGLIST", SWIG_From_int(static_cast<int >(7))); + rb_define_const(mOgr, "OFTBINARY", SWIG_From_int(static_cast<int >(8))); + rb_define_const(mOgr, "OJUNDEFINED", SWIG_From_int(static_cast<int >(0))); + rb_define_const(mOgr, "OJLEFT", SWIG_From_int(static_cast<int >(1))); + rb_define_const(mOgr, "OJRIGHT", SWIG_From_int(static_cast<int >(2))); + rb_define_const(mOgr, "WKBXDR", SWIG_From_int(static_cast<int >(0))); + rb_define_const(mOgr, "WKBNDR", SWIG_From_int(static_cast<int >(1))); + rb_define_const(mOgr, "OLCRANDOMREAD", SWIG_FromCharPtr("RandomRead")); + rb_define_const(mOgr, "OLCSEQUENTIALWRITE", SWIG_FromCharPtr("SequentialWrite")); + rb_define_const(mOgr, "OLCRANDOMWRITE", SWIG_FromCharPtr("RandomWrite")); + rb_define_const(mOgr, "OLCFASTSPATIALFILTER", SWIG_FromCharPtr("FastSpatialFilter")); + rb_define_const(mOgr, "OLCFASTFEATURECOUNT", SWIG_FromCharPtr("FastFeatureCount")); + rb_define_const(mOgr, "OLCFASTGETEXTENT", SWIG_FromCharPtr("FastGetExtent")); + rb_define_const(mOgr, "OLCCREATEFIELD", SWIG_FromCharPtr("CreateField")); + rb_define_const(mOgr, "OLCTRANSACTIONS", SWIG_FromCharPtr("Transactions")); + rb_define_const(mOgr, "OLCDELETEFEATURE", SWIG_FromCharPtr("DeleteFeature")); + rb_define_const(mOgr, "OLCFASTSETNEXTBYINDEX", SWIG_FromCharPtr("FastSetNextByIndex")); + rb_define_const(mOgr, "ODSCCREATELAYER", SWIG_FromCharPtr("CreateLayer")); + rb_define_const(mOgr, "ODSCDELETELAYER", SWIG_FromCharPtr("DeleteLayer")); + rb_define_const(mOgr, "ODRCCREATEDATASOURCE", SWIG_FromCharPtr("CreateDataSource")); + rb_define_const(mOgr, "ODRCDELETEDATASOURCE", SWIG_FromCharPtr("DeleteDataSource")); + rb_define_module_function(mOgr, "use_exceptions", VALUEFUNC(_wrap_use_exceptions), -1); + rb_define_module_function(mOgr, "dont_use_exceptions", VALUEFUNC(_wrap_dont_use_exceptions), -1); + + + if ( OGRGetDriverCount() == 0 ) { + OGRRegisterAll(); + } + + /* Setup exception handling */ + UseExceptions(); + + rb_require("gdal/osr"); + + cDriver.klass = rb_define_class_under(mOgr, "Driver", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRDriverShadow, (void *) &cDriver); + rb_undef_alloc_func(cDriver.klass); + rb_define_method(cDriver.klass, "name", VALUEFUNC(_wrap_Driver_name_get), -1); + rb_define_method(cDriver.klass, "create_data_source", VALUEFUNC(_wrap_Driver_create_data_source), -1); + rb_define_method(cDriver.klass, "copy_data_source", VALUEFUNC(_wrap_Driver_copy_data_source), -1); + rb_define_method(cDriver.klass, "open", VALUEFUNC(_wrap_Driver_open), -1); + rb_define_method(cDriver.klass, "delete_data_source", VALUEFUNC(_wrap_Driver_delete_data_source), -1); + rb_define_method(cDriver.klass, "test_capability", VALUEFUNC(_wrap_Driver_test_capability), -1); + rb_define_method(cDriver.klass, "get_name", VALUEFUNC(_wrap_Driver_get_name), -1); + cDriver.mark = 0; + cDriver.trackObjects = 0; + + cDataSource.klass = rb_define_class_under(mOgr, "DataSource", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRDataSourceShadow, (void *) &cDataSource); + rb_undef_alloc_func(cDataSource.klass); + rb_define_method(cDataSource.klass, "name", VALUEFUNC(_wrap_DataSource_name_get), -1); + rb_define_method(cDataSource.klass, "get_ref_count", VALUEFUNC(_wrap_DataSource_get_ref_count), -1); + rb_define_method(cDataSource.klass, "get_summary_ref_count", VALUEFUNC(_wrap_DataSource_get_summary_ref_count), -1); + rb_define_method(cDataSource.klass, "get_layer_count", VALUEFUNC(_wrap_DataSource_get_layer_count), -1); + rb_define_method(cDataSource.klass, "get_driver", VALUEFUNC(_wrap_DataSource_get_driver), -1); + rb_define_method(cDataSource.klass, "get_name", VALUEFUNC(_wrap_DataSource_get_name), -1); + rb_define_method(cDataSource.klass, "delete_layer", VALUEFUNC(_wrap_DataSource_delete_layer), -1); + rb_define_method(cDataSource.klass, "create_layer", VALUEFUNC(_wrap_DataSource_create_layer), -1); + rb_define_method(cDataSource.klass, "copy_layer", VALUEFUNC(_wrap_DataSource_copy_layer), -1); + rb_define_method(cDataSource.klass, "test_capability", VALUEFUNC(_wrap_DataSource_test_capability), -1); + rb_define_method(cDataSource.klass, "execute_sql", VALUEFUNC(_wrap_DataSource_execute_sql), -1); + rb_define_method(cDataSource.klass, "release_result_set", VALUEFUNC(_wrap_DataSource_release_result_set), -1); + rb_define_method(cDataSource.klass, "get_layer", VALUEFUNC(_wrap_DataSource_get_layer), -1); + cDataSource.mark = 0; + cDataSource.destroy = (void (*)(void *)) free_OGRDataSourceShadow; + cDataSource.trackObjects = 0; + + cLayer.klass = rb_define_class_under(mOgr, "Layer", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRLayerShadow, (void *) &cLayer); + rb_include_module(cLayer.klass, rb_eval_string("Enumerable")); + rb_undef_alloc_func(cLayer.klass); + rb_define_method(cLayer.klass, "get_ref_count", VALUEFUNC(_wrap_Layer_get_ref_count), -1); + rb_define_method(cLayer.klass, "set_spatial_filter", VALUEFUNC(_wrap_Layer_set_spatial_filter), -1); + rb_define_method(cLayer.klass, "set_spatial_filter_rect", VALUEFUNC(_wrap_Layer_set_spatial_filter_rect), -1); + rb_define_method(cLayer.klass, "get_spatial_filter", VALUEFUNC(_wrap_Layer_get_spatial_filter), -1); + rb_define_method(cLayer.klass, "set_attribute_filter", VALUEFUNC(_wrap_Layer_set_attribute_filter), -1); + rb_define_method(cLayer.klass, "reset_reading", VALUEFUNC(_wrap_Layer_reset_reading), -1); + rb_define_method(cLayer.klass, "get_name", VALUEFUNC(_wrap_Layer_get_name), -1); + rb_define_method(cLayer.klass, "get_feature", VALUEFUNC(_wrap_Layer_get_feature), -1); + rb_define_method(cLayer.klass, "get_next_feature", VALUEFUNC(_wrap_Layer_get_next_feature), -1); + rb_define_method(cLayer.klass, "set_next_by_index", VALUEFUNC(_wrap_Layer_set_next_by_index), -1); + rb_define_method(cLayer.klass, "set_feature", VALUEFUNC(_wrap_Layer_set_feature), -1); + rb_define_method(cLayer.klass, "create_feature", VALUEFUNC(_wrap_Layer_create_feature), -1); + rb_define_method(cLayer.klass, "delete_feature", VALUEFUNC(_wrap_Layer_delete_feature), -1); + rb_define_method(cLayer.klass, "sync_to_disk", VALUEFUNC(_wrap_Layer_sync_to_disk), -1); + rb_define_method(cLayer.klass, "get_layer_defn", VALUEFUNC(_wrap_Layer_get_layer_defn), -1); + rb_define_method(cLayer.klass, "get_feature_count", VALUEFUNC(_wrap_Layer_get_feature_count), -1); + rb_define_method(cLayer.klass, "get_extent", VALUEFUNC(_wrap_Layer_get_extent), -1); + rb_define_method(cLayer.klass, "test_capability", VALUEFUNC(_wrap_Layer_test_capability), -1); + rb_define_method(cLayer.klass, "create_field", VALUEFUNC(_wrap_Layer_create_field), -1); + rb_define_method(cLayer.klass, "start_transaction", VALUEFUNC(_wrap_Layer_start_transaction), -1); + rb_define_method(cLayer.klass, "commit_transaction", VALUEFUNC(_wrap_Layer_commit_transaction), -1); + rb_define_method(cLayer.klass, "rollback_transaction", VALUEFUNC(_wrap_Layer_rollback_transaction), -1); + rb_define_method(cLayer.klass, "get_spatial_ref", VALUEFUNC(_wrap_Layer_get_spatial_ref), -1); + rb_define_method(cLayer.klass, "get_feature_read", VALUEFUNC(_wrap_Layer_get_feature_read), -1); + rb_define_method(cLayer.klass, "each", VALUEFUNC(_wrap_Layer_each), -1); + cLayer.mark = 0; + cLayer.trackObjects = 0; + + cFeature.klass = rb_define_class_under(mOgr, "Feature", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureShadow, (void *) &cFeature); + rb_define_alloc_func(cFeature.klass, _wrap_Feature_allocate); + rb_define_method(cFeature.klass, "initialize", VALUEFUNC(_wrap_new_Feature), -1); + rb_define_method(cFeature.klass, "get_defn_ref", VALUEFUNC(_wrap_Feature_get_defn_ref), -1); + rb_define_method(cFeature.klass, "set_geometry", VALUEFUNC(_wrap_Feature_set_geometry), -1); + rb_define_method(cFeature.klass, "set_geometry_directly", VALUEFUNC(_wrap_Feature_set_geometry_directly), -1); + rb_define_method(cFeature.klass, "get_geometry_ref", VALUEFUNC(_wrap_Feature_get_geometry_ref), -1); + rb_define_method(cFeature.klass, "clone", VALUEFUNC(_wrap_Feature_clone), -1); + rb_define_method(cFeature.klass, "equal", VALUEFUNC(_wrap_Feature_equal), -1); + rb_define_method(cFeature.klass, "get_field_count", VALUEFUNC(_wrap_Feature_get_field_count), -1); + rb_define_method(cFeature.klass, "get_field_defn_ref", VALUEFUNC(_wrap_Feature_get_field_defn_ref), -1); + rb_define_method(cFeature.klass, "get_field_as_string", VALUEFUNC(_wrap_Feature_get_field_as_string), -1); + rb_define_method(cFeature.klass, "get_field_as_integer", VALUEFUNC(_wrap_Feature_get_field_as_integer), -1); + rb_define_method(cFeature.klass, "get_field_as_double", VALUEFUNC(_wrap_Feature_get_field_as_double), -1); + rb_define_method(cFeature.klass, "is_field_set", VALUEFUNC(_wrap_Feature_is_field_set), -1); + rb_define_method(cFeature.klass, "get_field_index", VALUEFUNC(_wrap_Feature_get_field_index), -1); + rb_define_method(cFeature.klass, "get_fid", VALUEFUNC(_wrap_Feature_get_fid), -1); + rb_define_method(cFeature.klass, "set_fid", VALUEFUNC(_wrap_Feature_set_fid), -1); + rb_define_method(cFeature.klass, "dump_readable", VALUEFUNC(_wrap_Feature_dump_readable), -1); + rb_define_method(cFeature.klass, "unset_field", VALUEFUNC(_wrap_Feature_unset_field), -1); + rb_define_method(cFeature.klass, "set_field", VALUEFUNC(_wrap_Feature_set_field), -1); + rb_define_method(cFeature.klass, "set_from", VALUEFUNC(_wrap_Feature_set_from), -1); + rb_define_method(cFeature.klass, "get_style_string", VALUEFUNC(_wrap_Feature_get_style_string), -1); + rb_define_method(cFeature.klass, "set_style_string", VALUEFUNC(_wrap_Feature_set_style_string), -1); + rb_define_method(cFeature.klass, "get_field_type", VALUEFUNC(_wrap_Feature_get_field_type), -1); + rb_define_method(cFeature.klass, "get_field", VALUEFUNC(_wrap_Feature_get_field), -1); + cFeature.mark = 0; + cFeature.destroy = (void (*)(void *)) free_OGRFeatureShadow; + cFeature.trackObjects = 0; + + cFeatureDefn.klass = rb_define_class_under(mOgr, "FeatureDefn", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRFeatureDefnShadow, (void *) &cFeatureDefn); + rb_define_alloc_func(cFeatureDefn.klass, _wrap_FeatureDefn_allocate); + rb_define_method(cFeatureDefn.klass, "initialize", VALUEFUNC(_wrap_new_FeatureDefn), -1); + rb_define_method(cFeatureDefn.klass, "get_name", VALUEFUNC(_wrap_FeatureDefn_get_name), -1); + rb_define_method(cFeatureDefn.klass, "get_field_count", VALUEFUNC(_wrap_FeatureDefn_get_field_count), -1); + rb_define_method(cFeatureDefn.klass, "get_field_defn", VALUEFUNC(_wrap_FeatureDefn_get_field_defn), -1); + rb_define_method(cFeatureDefn.klass, "get_field_index", VALUEFUNC(_wrap_FeatureDefn_get_field_index), -1); + rb_define_method(cFeatureDefn.klass, "add_field_defn", VALUEFUNC(_wrap_FeatureDefn_add_field_defn), -1); + rb_define_method(cFeatureDefn.klass, "get_geom_type", VALUEFUNC(_wrap_FeatureDefn_get_geom_type), -1); + rb_define_method(cFeatureDefn.klass, "set_geom_type", VALUEFUNC(_wrap_FeatureDefn_set_geom_type), -1); + rb_define_method(cFeatureDefn.klass, "get_reference_count", VALUEFUNC(_wrap_FeatureDefn_get_reference_count), -1); + cFeatureDefn.mark = 0; + cFeatureDefn.destroy = (void (*)(void *)) free_OGRFeatureDefnShadow; + cFeatureDefn.trackObjects = 0; + + cFieldDefn.klass = rb_define_class_under(mOgr, "FieldDefn", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRFieldDefnShadow, (void *) &cFieldDefn); + rb_define_alloc_func(cFieldDefn.klass, _wrap_FieldDefn_allocate); + rb_define_method(cFieldDefn.klass, "initialize", VALUEFUNC(_wrap_new_FieldDefn), -1); + rb_define_method(cFieldDefn.klass, "get_name", VALUEFUNC(_wrap_FieldDefn_get_name), -1); + rb_define_method(cFieldDefn.klass, "get_name_ref", VALUEFUNC(_wrap_FieldDefn_get_name_ref), -1); + rb_define_method(cFieldDefn.klass, "set_name", VALUEFUNC(_wrap_FieldDefn_set_name), -1); + rb_define_method(cFieldDefn.klass, "get_type", VALUEFUNC(_wrap_FieldDefn_get_type), -1); + rb_define_method(cFieldDefn.klass, "set_type", VALUEFUNC(_wrap_FieldDefn_set_type), -1); + rb_define_method(cFieldDefn.klass, "get_justify", VALUEFUNC(_wrap_FieldDefn_get_justify), -1); + rb_define_method(cFieldDefn.klass, "set_justify", VALUEFUNC(_wrap_FieldDefn_set_justify), -1); + rb_define_method(cFieldDefn.klass, "get_width", VALUEFUNC(_wrap_FieldDefn_get_width), -1); + rb_define_method(cFieldDefn.klass, "set_width", VALUEFUNC(_wrap_FieldDefn_set_width), -1); + rb_define_method(cFieldDefn.klass, "get_precision", VALUEFUNC(_wrap_FieldDefn_get_precision), -1); + rb_define_method(cFieldDefn.klass, "set_precision", VALUEFUNC(_wrap_FieldDefn_set_precision), -1); + rb_define_method(cFieldDefn.klass, "get_field_type_name", VALUEFUNC(_wrap_FieldDefn_get_field_type_name), -1); + cFieldDefn.mark = 0; + cFieldDefn.destroy = (void (*)(void *)) free_OGRFieldDefnShadow; + cFieldDefn.trackObjects = 0; + rb_define_module_function(mOgr, "create_geometry_from_wkb", VALUEFUNC(_wrap_create_geometry_from_wkb), -1); + rb_define_module_function(mOgr, "create_geometry_from_wkt", VALUEFUNC(_wrap_create_geometry_from_wkt), -1); + rb_define_module_function(mOgr, "create_geometry_from_gml", VALUEFUNC(_wrap_create_geometry_from_gml), -1); + + cGeometry.klass = rb_define_class_under(mOgr, "Geometry", rb_cObject); + SWIG_TypeClientData(SWIGTYPE_p_OGRGeometryShadow, (void *) &cGeometry); + rb_define_alloc_func(cGeometry.klass, _wrap_Geometry_allocate); + rb_define_method(cGeometry.klass, "initialize", VALUEFUNC(_wrap_new_Geometry), -1); + rb_define_method(cGeometry.klass, "export_to_wkt", VALUEFUNC(_wrap_Geometry_export_to_wkt), -1); + rb_define_method(cGeometry.klass, "export_to_wkb", VALUEFUNC(_wrap_Geometry_export_to_wkb), -1); + rb_define_method(cGeometry.klass, "export_to_gml", VALUEFUNC(_wrap_Geometry_export_to_gml), -1); + rb_define_method(cGeometry.klass, "add_point", VALUEFUNC(_wrap_Geometry_add_point), -1); + rb_define_method(cGeometry.klass, "add_geometry_directly", VALUEFUNC(_wrap_Geometry_add_geometry_directly), -1); + rb_define_method(cGeometry.klass, "add_geometry", VALUEFUNC(_wrap_Geometry_add_geometry), -1); + rb_define_method(cGeometry.klass, "clone", VALUEFUNC(_wrap_Geometry_clone), -1); + rb_define_method(cGeometry.klass, "get_geometry_type", VALUEFUNC(_wrap_Geometry_get_geometry_type), -1); + rb_define_method(cGeometry.klass, "get_geometry_name", VALUEFUNC(_wrap_Geometry_get_geometry_name), -1); + rb_define_method(cGeometry.klass, "get_area", VALUEFUNC(_wrap_Geometry_get_area), -1); + rb_define_method(cGeometry.klass, "get_point_count", VALUEFUNC(_wrap_Geometry_get_point_count), -1); + rb_define_method(cGeometry.klass, "get_x", VALUEFUNC(_wrap_Geometry_get_x), -1); + rb_define_method(cGeometry.klass, "get_y", VALUEFUNC(_wrap_Geometry_get_y), -1); + rb_define_method(cGeometry.klass, "get_z", VALUEFUNC(_wrap_Geometry_get_z), -1); + rb_define_method(cGeometry.klass, "get_geometry_count", VALUEFUNC(_wrap_Geometry_get_geometry_count), -1); + rb_define_method(cGeometry.klass, "set_point", VALUEFUNC(_wrap_Geometry_set_point), -1); + rb_define_method(cGeometry.klass, "get_geometry_ref", VALUEFUNC(_wrap_Geometry_get_geometry_ref), -1); + rb_define_method(cGeometry.klass, "get_boundary", VALUEFUNC(_wrap_Geometry_get_boundary), -1); + rb_define_method(cGeometry.klass, "convex_hull", VALUEFUNC(_wrap_Geometry_convex_hull), -1); + rb_define_method(cGeometry.klass, "buffer", VALUEFUNC(_wrap_Geometry_buffer), -1); + rb_define_method(cGeometry.klass, "intersection", VALUEFUNC(_wrap_Geometry_intersection), -1); + rb_define_method(cGeometry.klass, "union", VALUEFUNC(_wrap_Geometry_union), -1); + rb_define_method(cGeometry.klass, "difference", VALUEFUNC(_wrap_Geometry_difference), -1); + rb_define_method(cGeometry.klass, "symmetric_difference", VALUEFUNC(_wrap_Geometry_symmetric_difference), -1); + rb_define_method(cGeometry.klass, "distance", VALUEFUNC(_wrap_Geometry_distance), -1); + rb_define_method(cGeometry.klass, "empty", VALUEFUNC(_wrap_Geometry_empty), -1); + rb_define_method(cGeometry.klass, "intersect", VALUEFUNC(_wrap_Geometry_intersect), -1); + rb_define_method(cGeometry.klass, "equal", VALUEFUNC(_wrap_Geometry_equal), -1); + rb_define_method(cGeometry.klass, "disjoint", VALUEFUNC(_wrap_Geometry_disjoint), -1); + rb_define_method(cGeometry.klass, "touches", VALUEFUNC(_wrap_Geometry_touches), -1); + rb_define_method(cGeometry.klass, "crosses", VALUEFUNC(_wrap_Geometry_crosses), -1); + rb_define_method(cGeometry.klass, "within", VALUEFUNC(_wrap_Geometry_within), -1); + rb_define_method(cGeometry.klass, "contains", VALUEFUNC(_wrap_Geometry_contains), -1); + rb_define_method(cGeometry.klass, "overlaps", VALUEFUNC(_wrap_Geometry_overlaps), -1); + rb_define_method(cGeometry.klass, "transform_to", VALUEFUNC(_wrap_Geometry_transform_to), -1); + rb_define_method(cGeometry.klass, "transform", VALUEFUNC(_wrap_Geometry_transform), -1); + rb_define_method(cGeometry.klass, "get_spatial_reference", VALUEFUNC(_wrap_Geometry_get_spatial_reference), -1); + rb_define_method(cGeometry.klass, "assign_spatial_reference", VALUEFUNC(_wrap_Geometry_assign_spatial_reference), -1); + rb_define_method(cGeometry.klass, "close_rings", VALUEFUNC(_wrap_Geometry_close_rings), -1); + rb_define_method(cGeometry.klass, "flatten_to2_d", VALUEFUNC(_wrap_Geometry_flatten_to2_d), -1); + rb_define_method(cGeometry.klass, "get_envelope", VALUEFUNC(_wrap_Geometry_get_envelope), -1); + rb_define_method(cGeometry.klass, "centroid", VALUEFUNC(_wrap_Geometry_centroid), -1); + rb_define_method(cGeometry.klass, "wkb_size", VALUEFUNC(_wrap_Geometry_wkb_size), -1); + rb_define_method(cGeometry.klass, "get_coordinate_dimension", VALUEFUNC(_wrap_Geometry_get_coordinate_dimension), -1); + rb_define_method(cGeometry.klass, "get_dimension", VALUEFUNC(_wrap_Geometry_get_dimension), -1); + cGeometry.mark = 0; + cGeometry.destroy = (void (*)(void *)) free_OGRGeometryShadow; + cGeometry.trackObjects = 0; + rb_define_module_function(mOgr, "get_driver_count", VALUEFUNC(_wrap_get_driver_count), -1); + rb_define_module_function(mOgr, "get_open_dscount", VALUEFUNC(_wrap_get_open_dscount), -1); + rb_define_module_function(mOgr, "set_generate_db2_v72_byte_order", VALUEFUNC(_wrap_set_generate_db2_v72_byte_order), -1); + rb_define_module_function(mOgr, "register_all", VALUEFUNC(_wrap_register_all), -1); + rb_define_module_function(mOgr, "get_open_ds", VALUEFUNC(_wrap_get_open_ds), -1); + rb_define_module_function(mOgr, "open", VALUEFUNC(_wrap_open), -1); + rb_define_module_function(mOgr, "open_shared", VALUEFUNC(_wrap_open_shared), -1); + rb_define_module_function(mOgr, "get_driver_by_name", VALUEFUNC(_wrap_get_driver_by_name), -1); + rb_define_module_function(mOgr, "get_driver", VALUEFUNC(_wrap_get_driver), -1); +} + diff --git a/Utilities/GDAL/swig/ruby/osr_wrap.cpp b/Utilities/GDAL/swig/ruby/osr_wrap.cpp new file mode 100644 index 0000000000..955485141b --- /dev/null +++ b/Utilities/GDAL/swig/ruby/osr_wrap.cpp @@ -0,0 +1,5898 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.28 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGRUBY + +#ifdef __cplusplus +template<class T> class SwigValueWrapper { + T *tt; +public: + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs); +}; +#endif + +/*********************************************************************** + * + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * + ************************************************************************/ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) +# if (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods for Windows DLLs */ +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# define SWIGEXPORT +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#define SWIG_ObjectPreviouslyDeletedError -100 + + +#include <ruby.h> + +/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ +#ifndef NUM2LL +#define NUM2LL(x) NUM2LONG((x)) +#endif +#ifndef LL2NUM +#define LL2NUM(x) INT2NUM((long) (x)) +#endif +#ifndef ULL2NUM +#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) +#endif + +/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ +#ifndef NUM2ULL +#ifdef HAVE_LONG_LONG +#define NUM2ULL(x) rb_num2ull((x)) +#else +#define NUM2ULL(x) NUM2ULONG(x) +#endif +#endif + +/* + * Need to be very careful about how these macros are defined, especially + * when compiling C++ code or C code with an ANSI C compiler. + * + * VALUEFUNC(f) is a macro used to typecast a C function that implements + * a Ruby method so that it can be passed as an argument to API functions + * like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is a macro used to typecast a C function that implements + * either the "mark" or "free" stuff for a Ruby Data object, so that it + * can be passed as an argument to API functions like Data_Wrap_Struct() + * and Data_Make_Struct(). + */ + +#ifdef __cplusplus +# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((void (*)()) f) +# else +# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) +# define VALUEFUNC(f) ((VALUE (*)()) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# endif +# endif +#else +# define VALUEFUNC(f) (f) +# define VOIDFUNC(f) (f) +#endif + +/* Don't use for expressions have side effect */ +#ifndef RB_STRING_VALUE +#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) +#endif +#ifndef StringValue +#define StringValue(s) RB_STRING_VALUE(s) +#endif +#ifndef StringValuePtr +#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr +#endif +#ifndef StringValueLen +#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len +#endif +#ifndef SafeStringValue +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_str(v);\ +} while (0) +#endif + +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC +#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) +#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") +#endif + + +/*********************************************************************** + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * + ************************************************************************/ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "2" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store inforomation on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (int)(*f1 - *f2); + } + return (l1 - f1) - (l2 - f2); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubytracking.swg + * + * This file contains support for tracking mappings from + * Ruby objects to C++ objects. This functionality is needed + * to implement mark functions for Ruby's mark and sweep + * garbage collector. + ************************************************************************/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Global Ruby hash table to store Trackings from C/C++ + structs to Ruby Objects. */ +static VALUE swig_ruby_trackings; + +/* Global variable that stores a reference to the ruby + hash table delete function. */ +static ID swig_ruby_hash_delete = 0; + +/* Setup a Ruby hash table to store Trackings */ +SWIGRUNTIME void SWIG_RubyInitializeTrackings() { + /* Create a ruby hash table to store Trackings from C++ + objects to Ruby objects. Also make sure to tell + the garabage collector about the hash table. */ + swig_ruby_trackings = rb_hash_new(); + rb_gc_register_address(&swig_ruby_trackings); + + /* Now store a reference to the hash table delete function + so that we only have to look it up once.*/ + swig_ruby_hash_delete = rb_intern("delete"); +} + +/* Get a Ruby number to reference a pointer */ +SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { + /* We cast the pointer to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the pointer to a Ruby number */ + unsigned long value = (unsigned long) ptr; + return LONG2NUM(value); +} + +/* Get a Ruby number to reference an object */ +SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { + /* We cast the object to an unsigned long + and then store a reference to it using + a Ruby number object. */ + + /* Convert the Object to a Ruby number */ + unsigned long value = (unsigned long) object; + return LONG2NUM(value); +} + +/* Get a Ruby object from a previously stored reference */ +SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { + /* The provided Ruby number object is a reference + to the Ruby object we want.*/ + + /* First convert the Ruby number to a C number */ + unsigned long value = NUM2LONG(reference); + return (VALUE) value; +} + +/* Add a Tracking from a C/C++ struct to a Ruby object */ +SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { + /* In a Ruby hash table we store the pointer and + the associated Ruby object. The trick here is + that we cannot store the Ruby object directly - if + we do then it cannot be garbage collected. So + instead we typecast it as a unsigned long and + convert it to a Ruby number object.*/ + + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Get a reference to the Ruby object as a Ruby number */ + VALUE value = SWIG_RubyObjectToReference(object); + + /* Store the mapping to the global hash table. */ + rb_hash_aset(swig_ruby_trackings, key, value); +} + +/* Get the Ruby object that owns the specified C/C++ struct */ +SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Now lookup the value stored in the global hash table */ + VALUE value = rb_hash_aref(swig_ruby_trackings, key); + + if (value == Qnil) { + /* No object exists - return nil. */ + return Qnil; + } + else { + /* Convert this value to Ruby object */ + return SWIG_RubyReferenceToObject(value); + } +} + +/* Remove a Tracking from a C/C++ struct to a Ruby object. It + is very important to remove objects once they are destroyed + since the same memory address may be reused later to create + a new object. */ +SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { + /* Get a reference to the pointer as a Ruby number */ + VALUE key = SWIG_RubyPtrToReference(ptr); + + /* Delete the object from the hash table by calling Ruby's + do this we need to call the Hash.delete method.*/ + rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); +} + +/* This is a helper method that unlinks a Ruby object from its + underlying C++ object. This is needed if the lifetime of the + Ruby object is longer than the C++ object */ +SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { + DATA_PTR(object) = 0; + } +} + + +#ifdef __cplusplus +} +#endif + +/*********************************************************************** + * rubyrun.swg + * + * This file contains the runtime support for Ruby modules + * and includes code for managing global variables and pointer + * type checking. + * + ************************************************************************/ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) +#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) +#define swig_owntype ruby_owntype + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Ruby-specific SWIG API */ + +#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() +#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) +#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) +#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) +#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) + + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +typedef struct { + VALUE klass; + VALUE mImpl; + void (*mark)(void *); + void (*destroy)(void *); + int trackObjects; +} swig_class; + + +static VALUE _mSWIG = Qnil; +static VALUE _cSWIG_Pointer = Qnil; +static VALUE swig_runtime_data_type_pointer = Qnil; + +/* Initialize Ruby runtime support */ +SWIGRUNTIME void +SWIG_Ruby_InitRuntime(void) +{ + if (_mSWIG == Qnil) { + _mSWIG = rb_define_module("SWIG"); + } +} + +/* Define Ruby class for C type */ +SWIGRUNTIME void +SWIG_Ruby_define_class(swig_type_info *type) +{ + VALUE klass; + char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + if (NIL_P(_cSWIG_Pointer)) { + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } + klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + free((void *) klass_name); +} + +/* Create a new pointer object */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) +{ + int own = flags & SWIG_POINTER_OWN; + + char *klass_name; + swig_class *sklass; + VALUE klass; + VALUE obj; + + if (!ptr) + return Qnil; + + if (type->clientdata) { + sklass = (swig_class *) type->clientdata; + + /* Are we tracking this class and have we already returned this Ruby object? */ + if (sklass->trackObjects) { + obj = SWIG_RubyInstanceFor(ptr); + if (obj != Qnil) { + return obj; + } + } + + /* Create a new Ruby object */ + obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), (own ? VOIDFUNC(sklass->destroy) : 0), ptr); + + /* If tracking is on for this class then track this object. */ + if (sklass->trackObjects) { + SWIG_RubyAddTracking(ptr, obj); + } + } else { + klass_name = (char *) malloc(4 + strlen(type->name) + 1); + sprintf(klass_name, "TYPE%s", type->name); + klass = rb_const_get(_mSWIG, rb_intern(klass_name)); + free((void *) klass_name); + obj = Data_Wrap_Struct(klass, 0, 0, ptr); + } + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + + return obj; +} + +/* Create a new class instance (always owned) */ +SWIGRUNTIME VALUE +SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) +{ + VALUE obj; + swig_class *sklass = (swig_class *) type->clientdata; + obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); + rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name)); + return obj; +} + +/* Get type mangle from class name */ +SWIGRUNTIMEINLINE char * +SWIG_Ruby_MangleStr(VALUE obj) +{ + VALUE stype = rb_iv_get(obj, "__swigtype__"); + return StringValuePtr(stype); +} + +/* Acquire a pointer value */ +typedef void (*ruby_owntype)(void*); + +SWIGRUNTIME ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { + if (obj) { + ruby_owntype oldown = RDATA(obj)->dfree; + RDATA(obj)->dfree = own; + return oldown; + } else { + return 0; + } +} + +/* Convert a pointer value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +{ + char *c; + swig_cast_info *tc; + void *vptr = 0; + + /* Grab the pointer */ + if (NIL_P(obj)) { + *ptr = 0; + return SWIG_OK; + } else { + if (TYPE(obj) != T_DATA) { + return SWIG_ERROR; + } + Data_Get_Struct(obj, void, vptr); + } + + if (own) *own = RDATA(obj)->dfree; + + /* Check to see if the input object is giving up ownership + of the underlying C struct or C++ object. If so then we + need to reset the destructor since the Ruby object no + longer owns the underlying C++ object.*/ + if (flags & SWIG_POINTER_DISOWN) { + /* Is tracking on for this class? */ + int track = 0; + if (ty && ty->clientdata) { + swig_class *sklass = (swig_class *) ty->clientdata; + track = sklass->trackObjects; + } + + if (track) { + /* We are tracking objects for this class. Thus we change the destructor + * to SWIG_RubyRemoveTracking. This allows us to + * remove the mapping from the C++ to Ruby object + * when the Ruby object is garbage collected. If we don't + * do this, then it is possible we will return a reference + * to a Ruby object that no longer exists thereby crashing Ruby. */ + RDATA(obj)->dfree = SWIG_RubyRemoveTracking; + } else { + RDATA(obj)->dfree = 0; + } + } + + /* Do type-checking if type info was provided */ + if (ty) { + if (ty->clientdata) { + if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + *ptr = vptr; + return SWIG_OK; + } + } + if ((c = SWIG_MangleStr(obj)) == NULL) { + return SWIG_ERROR; + } + tc = SWIG_TypeCheck(c, ty); + if (!tc) { + return SWIG_ERROR; + } + *ptr = SWIG_TypeCast(tc, vptr); + } + return SWIG_OK; +} + +/* Check convert */ +SWIGRUNTIMEINLINE int +SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) +{ + char *c = SWIG_MangleStr(obj); + if (!c) return 0; + return SWIG_TypeCheck(c,ty) != 0; +} + +SWIGRUNTIME VALUE +SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; + *(r++) = '_'; + r = SWIG_PackData(r, ptr, sz); + strcpy(r, type->name); + return rb_str_new2(result); +} + +/* Convert a packed value value */ +SWIGRUNTIME int +SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c; + + if (TYPE(obj) != T_STRING) goto type_error; + c = StringValuePtr(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') goto type_error; + c++; + c = SWIG_UnpackData(c, ptr, sz); + if (ty) { + tc = SWIG_TypeCheck(c, ty); + if (!tc) goto type_error; + } + return SWIG_OK; + + type_error: + return SWIG_ERROR; +} + +SWIGRUNTIME swig_module_info * +SWIG_Ruby_GetModule() +{ + VALUE pointer; + swig_module_info *ret = 0; + VALUE verbose = rb_gv_get("VERBOSE"); + + /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ + rb_gv_set("VERBOSE", Qfalse); + + /* first check if pointer already created */ + pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); + if (pointer != Qnil) { + Data_Get_Struct(pointer, swig_module_info, ret); + } + + /* reinstate warnings */ + rb_gv_set("VERBOSE", verbose); + return ret; +} + +SWIGRUNTIME void +SWIG_Ruby_SetModule(swig_module_info *pointer) +{ + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); +} + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + +/* ----------------------------------------------------------------------------- + * Ruby API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN VALUE +SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { + if (NIL_P(target)) { + target = o; + } else { + if (TYPE(target) != T_ARRAY) { + VALUE o2 = target; + target = rb_ary_new(); + rb_ary_push(target, o2); + } + rb_ary_push(target, o); + } + return target; +} + +#ifdef __cplusplus +} +#endif + + + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + + + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_OSRCoordinateTransformationShadow swig_types[0] +#define SWIGTYPE_p_OSRSpatialReferenceShadow swig_types[1] +#define SWIGTYPE_p_char swig_types[2] +#define SWIGTYPE_p_double swig_types[3] +#define SWIGTYPE_p_int swig_types[4] +#define SWIGTYPE_p_long swig_types[5] +#define SWIGTYPE_p_p_char swig_types[6] +#define SWIGTYPE_p_p_double swig_types[7] +static swig_type_info *swig_types[9]; +static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#define SWIG_init Init_osr +#define SWIG_name "Gdal::Osr" + +static VALUE mOsr; + + +#define SWIGVERSION 0x010328 + + + + +#define SWIG_as_voidptr(a) const_cast<void * >(static_cast<const void * >(a)) + + +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast<void** >(a)) + + + + +/* Define custom exceptions for errors that do not map to existing Ruby + exceptions. Note this only works for C++ since a global cannot be + initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ + +VALUE getNullReferenceError() { + static int init = 0; + static VALUE rb_eNullReferenceError ; + if (!init) { + init = 1; + rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); + } + return rb_eNullReferenceError; +} + +VALUE getObjectPreviouslyDeletedError() { + static int init = 0; + static VALUE rb_eObjectPreviouslyDeleted ; + if (!init) { + init = 1; + rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); + } + return rb_eObjectPreviouslyDeleted; +} + +VALUE getExceptionClass() { + static int init = 0; + static VALUE rubyExceptionClass ; + if (!init) { + init = 1; + rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); + } + return rubyExceptionClass; +} + +SWIGINTERN VALUE +SWIG_Ruby_ErrorType(int SWIG_code) { + VALUE type; + switch (SWIG_code) { + case SWIG_MemoryError: + type = rb_eNoMemError; + break; + case SWIG_IOError: + type = rb_eIOError; + break; + case SWIG_RuntimeError: + type = rb_eRuntimeError; + break; + case SWIG_IndexError: + type = rb_eIndexError; + break; + case SWIG_TypeError: + type = rb_eTypeError; + break; + case SWIG_DivisionByZero: + type = rb_eZeroDivError; + break; + case SWIG_OverflowError: + type = rb_eRangeError; + break; + case SWIG_SyntaxError: + type = rb_eSyntaxError; + break; + case SWIG_ValueError: + type = rb_eArgError; + break; + case SWIG_SystemError: + type = rb_eFatal; + break; + case SWIG_AttributeError: + type = rb_eRuntimeError; + break; + case SWIG_NullReferenceError: + type = getNullReferenceError(); + break; + case SWIG_ObjectPreviouslyDeletedError: + type = getObjectPreviouslyDeletedError(); + break; + case SWIG_UnknownError: + type = rb_eRuntimeError; + break; + default: + type = rb_eRuntimeError; + } + return type; +} + + +/* This code checks to see if the Ruby object being raised as part + of an exception inherits from the Ruby class Exception. If so, + the object is simply returned. If not, then a new Ruby exception + object is created and that will be returned to Ruby.*/ +SWIGINTERN VALUE +SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { + VALUE exceptionClass = getExceptionClass(); + if (rb_obj_is_kind_of(obj, exceptionClass)) { + return obj; + } else { + return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); + } +} + + + +#include <stdexcept> + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor() +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > LONG_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_NewPointerObj(const_cast<char * >(carray), pchar_descriptor, 0) : Qnil; + } else { + return rb_str_new(carray, static_cast<long >(size)); + } + } else { + return Qnil; + } +} + + +SWIGINTERNINLINE VALUE +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + + +#define SWIG_From_double rb_float_new + + + +#include <iostream> +using namespace std; + +#include "cpl_string.h" +#include "cpl_conv.h" + +#include "ogr_srs_api.h" + +typedef void OSRSpatialReferenceShadow; +typedef void OSRCoordinateTransformationShadow; + + + +#ifdef __cplusplus +extern "C" { +#endif +#include "rubyio.h" +#ifdef __cplusplus +} +#endif + + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +struct timeval rb_time_timeval(VALUE); +#endif +#ifdef __cplusplus +} +#endif + + + +static char const * +OGRErrMessages( int rc ) { + switch( rc ) { + case 0: + return "OGR Error: None"; + case 1: + return "OGR Error: Not enough data"; + case 2: + return "OGR Error: Not enough memory"; + case 3: + return "OGR Error: Unsupported geometry type"; + case 4: + return "OGR Error: Unsupported operation"; + case 5: + return "OGR Error: Corrupt data"; + case 6: + return "OGR Error: General Error"; + case 7: + return "OGR Error: Unsupported SRS"; + default: + return "OGR Error: Unknown"; + } +} + + +OGRErr GetWellKnownGeogCSAsWKT( const char *name, char **argout ) { + OGRSpatialReferenceH srs = OSRNewSpatialReference(""); + OSRSetWellKnownGeogCS( srs, name ); + OGRErr rcode = OSRExportToWkt ( srs, argout ); + OSRDestroySpatialReference( srs ); + return rcode; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) +{ + if (TYPE(obj) == T_STRING) { + char *cstr = rb_string_value_ptr(&(obj)); + size_t size = RSTRING(obj)->len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = reinterpret_cast<char* >(memcpy((new char[size]), cstr, sizeof(char)*(size))); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + + + +#define output_helper SWIG_Ruby_AppendOutput + +SWIGINTERN OSRSpatialReferenceShadow *new_OSRSpatialReferenceShadow(char const *wkt=""){ + OSRSpatialReferenceShadow *sr = (OSRSpatialReferenceShadow*) OSRNewSpatialReference(wkt); + if (sr) { + OSRReference( sr ); + } + return sr; + } +SWIGINTERN char *OSRSpatialReferenceShadow___str__(OSRSpatialReferenceShadow *self){ + char *buf = 0; + OSRExportToPrettyWkt( self, &buf, 0 ); + return buf; + } +SWIGINTERN int OSRSpatialReferenceShadow_IsSame(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSame( self, rhs ); + } + +#include <limits.h> +#ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +#endif +#ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +#endif + + + +#define SWIG_From_long LONG2NUM + + + +SWIGINTERNINLINE VALUE +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + +SWIGINTERN int OSRSpatialReferenceShadow_IsSameGeogCS(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRIsSameGeogCS( self, rhs ); + } +SWIGINTERN int OSRSpatialReferenceShadow_IsGeographic(OSRSpatialReferenceShadow *self){ + return OSRIsGeographic(self); + } +SWIGINTERN int OSRSpatialReferenceShadow_IsProjected(OSRSpatialReferenceShadow *self){ + return OSRIsProjected(self); + } + +SWIGINTERN VALUE +SWIG_ruby_failed() +{ + return Qnil; +} + + + +SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + long *res = (long *)(args[1]); + *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_long (VALUE obj, long* val) +{ + VALUE type = TYPE(obj); + if ((type == T_FIXNUM) || (type == T_BIGNUM)) { + long v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (VALUE obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = static_cast<int >(v); + } + } + return res; +} + +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAttrValue(OSRSpatialReferenceShadow *self,char const *name,int child=0){ + return OSRGetAttrValue( self, name, child ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAttrValue(OSRSpatialReferenceShadow *self,char const *name,char const *value){ + return OSRSetAttrValue( self, name, value ); + } + + +SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) +{ + VALUE obj = args[0]; + VALUE type = TYPE(obj); + double *res = (double *)(args[1]); + *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj))); + return obj; +} + + + +SWIGINTERN int +SWIG_AsVal_double (VALUE obj, double *val) +{ + VALUE type = TYPE(obj); + if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { + double v; + VALUE a[2] = { obj, (VALUE)(&v) }; + if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (val) *val = v; + return SWIG_OK; + } + } + return SWIG_TypeError; +} + +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAngularUnits(OSRSpatialReferenceShadow *self,char const *name,double to_radians){ + return OSRSetAngularUnits( self, name, to_radians ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetAngularUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetAngularUnits( self, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetLinearUnits(OSRSpatialReferenceShadow *self,char const *name,double to_meters){ + return OSRSetAngularUnits( self, name, to_meters ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetLinearUnits(OSRSpatialReferenceShadow *self){ + // Return code ignored. + return OSRGetLinearUnits( self, 0 ); + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetLinearUnitsName(OSRSpatialReferenceShadow *self){ + const char *name = 0; + if ( OSRIsProjected( self ) ) { + name = OSRGetAttrValue( self, "PROJCS|UNIT", 0 ); + } + else if ( OSRIsLocal( self ) ) { + name = OSRGetAttrValue( self, "LOCAL_CS|UNIT", 0 ); + } + + if (name != 0) + return name; + + return "Meter"; + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAuthorityCode(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityCode( self, target_key ); + } +SWIGINTERN char const *OSRSpatialReferenceShadow_GetAuthorityName(OSRSpatialReferenceShadow *self,char const *target_key){ + return OSRGetAuthorityName( self, target_key ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetUTM(OSRSpatialReferenceShadow *self,int zone,int north=1){ + return OSRSetUTM( self, zone, north ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetStatePlane(OSRSpatialReferenceShadow *self,int zone,int is_nad83=1,char const *unitsname="",double units=0.0){ + return OSRSetStatePlaneWithUnits( self, zone, is_nad83, unitsname, units ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_AutoIdentifyEPSG(OSRSpatialReferenceShadow *self){ + return OSRAutoIdentifyEPSG( self ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjection(OSRSpatialReferenceShadow *self,char const *arg){ + return OSRSetProjection( self, arg ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetProjParm( self, name, val ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetProjParm( self, name, default_val, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double val){ + return OSRSetNormProjParm( self, name, val ); + } +SWIGINTERN double OSRSpatialReferenceShadow_GetNormProjParm(OSRSpatialReferenceShadow *self,char const *name,double default_val=0.0){ + // Return code ignored. + return OSRGetNormProjParm( self, name, default_val, 0 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetACEA(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetACEA( self, stdp1, stdp2, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetAE(OSRSpatialReferenceShadow *self,double clat,double clon,double fe,double fn){ + return OSRSetAE( self, clat, clon, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetCS(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetCS( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetBonne(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetBonne( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEC(OSRSpatialReferenceShadow *self,double stdp1,double stdp2,double clat,double clong,double fe,double fn){ + return OSRSetEC( self, stdp1, stdp2, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEckertIV(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertIV( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEckertVI(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetEckertVI( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetEquirectangular(OSRSpatialReferenceShadow *self,double clat,double clong,double fe,double fn){ + return OSRSetEquirectangular( self, clat, clong, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetGS(OSRSpatialReferenceShadow *self,double cm,double fe,double fn){ + return OSRSetGS( self, cm, fe, fn ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetWellKnownGeogCS(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetWellKnownGeogCS( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetFromUserInput(OSRSpatialReferenceShadow *self,char const *name){ + return OSRSetFromUserInput( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_CopyGeogCSFrom(OSRSpatialReferenceShadow *self,OSRSpatialReferenceShadow *rhs){ + return OSRCopyGeogCSFrom( self, rhs ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetTOWGS84(OSRSpatialReferenceShadow *self,double p1,double p2,double p3,double p4=0.0,double p5=0.0,double p6=0.0,double p7=0.0){ + return OSRSetTOWGS84( self, p1, p2, p3, p4, p5, p6, p7 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_GetTOWGS84(OSRSpatialReferenceShadow *self,double argout[7]){ + return OSRGetTOWGS84( self, argout, 7 ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetGeogCS(OSRSpatialReferenceShadow *self,char const *pszGeogName,char const *pszDatumName,char const *pszEllipsoidName,double dfSemiMajor,double dfInvFlattening,char const *pszPMName="Greenwich",double dfPMOffset=0.0,char const *pszUnits="degree",double dfConvertToRadians=0.0174532925199433){ + return OSRSetGeogCS( self, pszGeogName, pszDatumName, pszEllipsoidName, + dfSemiMajor, dfInvFlattening, + pszPMName, dfPMOffset, pszUnits, dfConvertToRadians ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_SetProjCS(OSRSpatialReferenceShadow *self,char const *name="unnamed"){ + return OSRSetProjCS( self, name ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromWkt(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromWkt( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromProj4(OSRSpatialReferenceShadow *self,char *ppszInput){ + return OSRImportFromProj4( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromESRI(OSRSpatialReferenceShadow *self,char **ppszInput){ + return OSRImportFromESRI( self, ppszInput ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromEPSG(OSRSpatialReferenceShadow *self,int arg){ + return OSRImportFromEPSG(self, arg); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromPCI(OSRSpatialReferenceShadow *self,char const *proj,char const *units="METRE",double argin[17]=0){ + return OSRImportFromPCI( self, proj, units, argin ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromUSGS(OSRSpatialReferenceShadow *self,long proj_code,long zone=0,double argin[15]=0,long datum_code=0){ + return OSRImportFromUSGS( self, proj_code, zone, argin, datum_code ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ImportFromXML(OSRSpatialReferenceShadow *self,char const *xmlString){ + return OSRImportFromXML( self, xmlString ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToWkt(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToWkt( self, argout ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToPrettyWkt(OSRSpatialReferenceShadow *self,char **argout,int simplify=0){ + return OSRExportToPrettyWkt( self, argout, simplify ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToProj4(OSRSpatialReferenceShadow *self,char **argout){ + return OSRExportToProj4( self, argout ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToPCI(OSRSpatialReferenceShadow *self,char **proj,char **units,double *parms[17]){ + return OSRExportToPCI( self, proj, units, parms ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToUSGS(OSRSpatialReferenceShadow *self,long *code,long *zone,double *parms[15],long *datum){ + return OSRExportToUSGS( self, code, zone, parms, datum ); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_ExportToXML(OSRSpatialReferenceShadow *self,char **argout,char const *dialect=""){ + return OSRExportToXML( self, argout, dialect ); + } +SWIGINTERN OSRSpatialReferenceShadow *OSRSpatialReferenceShadow_CloneGeogCS(OSRSpatialReferenceShadow *self){ + return (OSRSpatialReferenceShadow*) OSRCloneGeogCS(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_Validate(OSRSpatialReferenceShadow *self){ + return OSRValidate(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_StripCTParms(OSRSpatialReferenceShadow *self){ + return OSRStripCTParms(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_FixupOrdering(OSRSpatialReferenceShadow *self){ + return OSRFixupOrdering(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_Fixup(OSRSpatialReferenceShadow *self){ + return OSRFixup(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_MorphToESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphToESRI(self); + } +SWIGINTERN OGRErr OSRSpatialReferenceShadow_MorphFromESRI(OSRSpatialReferenceShadow *self){ + return OSRMorphFromESRI(self); + } +SWIGINTERN OSRCoordinateTransformationShadow *new_OSRCoordinateTransformationShadow(OSRSpatialReferenceShadow *src,OSRSpatialReferenceShadow *dst){ + OSRCoordinateTransformationShadow *obj = (OSRCoordinateTransformationShadow*) OCTNewCoordinateTransformation( src, dst ); + if (obj == 0 ) { + throw "Failed to create coordinate transformation"; + } + return obj; + } +SWIGINTERN void OSRCoordinateTransformationShadow_TransformPoint__SWIG_0(OSRCoordinateTransformationShadow *self,double inout[3]){ + OCTTransform( self, 1, &inout[0], &inout[1], &inout[2] ); + } +SWIGINTERN void OSRCoordinateTransformationShadow_TransformPoint__SWIG_1(OSRCoordinateTransformationShadow *self,double argout[3],double x,double y,double z=0.0){ + argout[0] = x; + argout[1] = y; + argout[2] = z; + OCTTransform( self, 1, &argout[0], &argout[1], &argout[2] ); + } +SWIGINTERN VALUE +_wrap_get_well_known_geog_csas_wkt(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + OGRErr result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *argout2 = 0 ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (char **argout2) ( char *argout2=0 ) */ + arg2 = &argout2; + } + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetWellKnownGeogCSAsWKT" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + result = (OGRErr)GetWellKnownGeogCSAsWKT((char const *)arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (char **argout) */ + VALUE outArg; + if ( arg2 ) { + outArg = rb_str_new2( *arg2 ); + } + else { + outArg = Qnil; + } + + vresult = SWIG_Ruby_AppendOutput(vresult, outArg); + } + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(freearg) (char **argout) */ + + if ( *arg2 ) + CPLFree( *arg2 ); + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + { + /* %typemap(freearg) (char **argout) */ + + if ( *arg2 ) + CPLFree( *arg2 ); + } + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GetProjectionMethods(int argc, VALUE *argv, VALUE self) { + char **result = 0 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + result = (char **)OPTGetProjectionMethods(); + + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0 ); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GetProjectionMethodParameterList(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + char **result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *val2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OPTGetParameterList" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + { + /* %typemap(in) char ** ( char *val2=0 ) */ + + val2 = StringValuePtr(argv[1]); + arg2 = &val2; + } + result = (char **)OPTGetParameterList(arg1,arg2); + + vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return vresult; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_GetProjectionMethodParamInfo(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char **arg3 = (char **) 0 ; + char **arg4 = (char **) 0 ; + double *arg5 = (double *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + char *val3 = 0 ; + char *val4 = 0 ; + void *argp5 = 0 ; + int res5 ; + + if ((argc < 5) || (argc > 5)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 5)",argc); SWIG_fail; + } + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OPTGetParameterInfo" "', argument " "1"" of type '" "char *""'"); + } + arg1 = buf1; + res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "OPTGetParameterInfo" "', argument " "2"" of type '" "char *""'"); + } + arg2 = buf2; + { + /* %typemap(in) char ** ( char *val3=0 ) */ + + val3 = StringValuePtr(argv[2]); + arg3 = &val3; + } + { + /* %typemap(in) char ** ( char *val4=0 ) */ + + val4 = StringValuePtr(argv[3]); + arg4 = &val4; + } + res5 = SWIG_ConvertPtr(argv[4], &argp5,SWIGTYPE_p_double, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(((res5 != SWIG_ERROR) ? res5 : SWIG_TypeError), "in method '" "OPTGetParameterInfo" "', argument " "5"" of type '" "double *""'"); + } + arg5 = reinterpret_cast<double * >(argp5); + OPTGetParameterInfo(arg1,arg2,arg3,arg4,arg5); + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +swig_class cSpatialReference; + +#ifdef HAVE_RB_DEFINE_ALLOC_FUNC +SWIGINTERN VALUE +_wrap_SpatialReference_allocate(VALUE self) { +#else + SWIGINTERN VALUE + _wrap_SpatialReference_allocate(int argc, VALUE *argv, VALUE self) { +#endif + + + VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_OSRSpatialReferenceShadow); +#ifndef HAVE_RB_DEFINE_ALLOC_FUNC + rb_obj_call_init(vresult, argc, argv); +#endif + return vresult; + } + + +SWIGINTERN VALUE +_wrap_new_SpatialReference(int argc, VALUE *argv, VALUE self) { + char *arg1 = (char *) "" ; + OSRSpatialReferenceShadow *result = 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + char *kwnames[] = { + "wkt", NULL + }; + + if ((argc < 0) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + if (argc > 0) { + res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "OSRSpatialReferenceShadow" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = buf1; + } + result = (OSRSpatialReferenceShadow *)new_OSRSpatialReferenceShadow((char const *)arg1); + DATA_PTR(self) = result; + + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return self; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return Qnil; +} + + +SWIGINTERN void delete_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *self){ + if (OSRDereference( self ) == 0 ) { + OSRDestroySpatialReference( self ); + } + } +SWIGINTERN void +free_OSRSpatialReferenceShadow(OSRSpatialReferenceShadow *arg1) { + delete_OSRSpatialReferenceShadow(arg1); +} + +SWIGINTERN VALUE +_wrap_SpatialReference___str__(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "__str__" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (char *)OSRSpatialReferenceShadow___str__(arg1); + + vresult = SWIG_FromCharPtr(result); + delete [] result; + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_is_same(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsSame" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "IsSame" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + result = (int)OSRSpatialReferenceShadow_IsSame(arg1,arg2); + + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_is_same_geog_cs(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsSameGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "IsSameGeogCS" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + result = (int)OSRSpatialReferenceShadow_IsSameGeogCS(arg1,arg2); + + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_is_geographic(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsGeographic" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (int)OSRSpatialReferenceShadow_IsGeographic(arg1); + + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_is_projected(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "IsProjected" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (int)OSRSpatialReferenceShadow_IsProjected(arg1); + + vresult = SWIG_From_int(static_cast<int >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_attr_value(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 = (int) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetAttrValue" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetAttrValue" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GetAttrValue" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + result = (char *)OSRSpatialReferenceShadow_GetAttrValue(arg1,(char const *)arg2,arg3); + + vresult = SWIG_FromCharPtr(result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_attr_value(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetAttrValue" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetAttrValue" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetAttrValue" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + result = (OGRErr)OSRSpatialReferenceShadow_SetAttrValue(arg1,(char const *)arg2,(char const *)arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_angular_units(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetAngularUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetAngularUnits" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetAngularUnits" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetAngularUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_angular_units(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetAngularUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (double)OSRSpatialReferenceShadow_GetAngularUnits(arg1); + + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_linear_units(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetLinearUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetLinearUnits" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetLinearUnits" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetLinearUnits(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_linear_units(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetLinearUnits" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (double)OSRSpatialReferenceShadow_GetLinearUnits(arg1); + + vresult = SWIG_From_double(static_cast<double >(result)); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_linear_units_name(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetLinearUnitsName" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (char *)OSRSpatialReferenceShadow_GetLinearUnitsName(arg1); + + vresult = SWIG_FromCharPtr(result); + return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_authority_code(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetAuthorityCode" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetAuthorityCode" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (char *)OSRSpatialReferenceShadow_GetAuthorityCode(arg1,(char const *)arg2); + + vresult = SWIG_FromCharPtr(result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_authority_name(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *result = 0 ; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetAuthorityName" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetAuthorityName" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (char *)OSRSpatialReferenceShadow_GetAuthorityName(arg1,(char const *)arg2); + + vresult = SWIG_FromCharPtr(result); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_utm(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetUTM" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetUTM" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetUTM" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetUTM(arg1,arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_state_plane(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + int arg2 ; + int arg3 = (int) 1 ; + char *arg4 = (char *) "" ; + double arg5 = (double) 0.0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetStatePlane" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_int(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetStatePlane" "', argument " "2"" of type '" "int""'"); + } + arg2 = static_cast<int >(val2); + if (argc > 1) { + ecode3 = SWIG_AsVal_int(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetStatePlane" "', argument " "3"" of type '" "int""'"); + } + arg3 = static_cast<int >(val3); + } + if (argc > 2) { + res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "SetStatePlane" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + } + if (argc > 3) { + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetStatePlane" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetStatePlane(arg1,arg2,arg3,(char const *)arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_auto_identify_epsg(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + VALUE vresult = Qnil; + + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "AutoIdentifyEPSG" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_AutoIdentifyEPSG(arg1); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_projection(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetProjection" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetProjection" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetProjection(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_proj_parm(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_proj_parm(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GetProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + } + result = (double)OSRSpatialReferenceShadow_GetProjParm(arg1,(char const *)arg2,arg3); + + vresult = SWIG_From_double(static_cast<double >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_norm_proj_parm(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 2) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetNormProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetNormProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetNormProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + result = (OGRErr)OSRSpatialReferenceShadow_SetNormProjParm(arg1,(char const *)arg2,arg3); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_norm_proj_parm(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + double arg3 = (double) 0.0 ; + double result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + double val3 ; + int ecode3 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 2)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetNormProjParm" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "GetNormProjParm" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + if (argc > 1) { + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "GetNormProjParm" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + } + result = (double)OSRSpatialReferenceShadow_GetNormProjParm(arg1,(char const *)arg2,arg3); + + vresult = SWIG_From_double(static_cast<double >(result)); + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_acea(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 6) || (argc > 6)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 6)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + ecode6 = SWIG_AsVal_double(argv[4], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(((ecode6 != SWIG_ERROR) ? ecode6 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast<double >(val6); + ecode7 = SWIG_AsVal_double(argv[5], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(((ecode7 != SWIG_ERROR) ? ecode7 : SWIG_TypeError), "in method '" "SetACEA" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast<double >(val7); + result = (OGRErr)OSRSpatialReferenceShadow_SetACEA(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_ae(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetAE" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetAE" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetAE" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetAE" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetAE" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetAE(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_cs(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetCS" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetCS" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetCS" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetCS" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetCS(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_bonne(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetBonne" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetBonne" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetBonne" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetBonne" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetBonne" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetBonne(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_ec(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + double arg6 ; + double arg7 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 6) || (argc > 6)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 6)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetEC" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetEC" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetEC" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetEC" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetEC" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + ecode6 = SWIG_AsVal_double(argv[4], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(((ecode6 != SWIG_ERROR) ? ecode6 : SWIG_TypeError), "in method '" "SetEC" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast<double >(val6); + ecode7 = SWIG_AsVal_double(argv[5], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(((ecode7 != SWIG_ERROR) ? ecode7 : SWIG_TypeError), "in method '" "SetEC" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast<double >(val7); + result = (OGRErr)OSRSpatialReferenceShadow_SetEC(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_eckert_iv(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 3) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetEckertIV" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetEckertIV" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetEckertIV" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetEckertIV" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertIV(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_eckert_vi(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 3) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetEckertVI" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetEckertVI" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetEckertVI" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetEckertVI" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetEckertVI(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_equirectangular(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 4) || (argc > 4)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetEquirectangular" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetEquirectangular" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetEquirectangular" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetEquirectangular" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetEquirectangular" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + result = (OGRErr)OSRSpatialReferenceShadow_SetEquirectangular(arg1,arg2,arg3,arg4,arg5); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_gs(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + char *kwnames[] = { + "self","cm","fe","fn", NULL + }; + VALUE vresult = Qnil; + + if ((argc < 3) || (argc > 3)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetGS" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetGS" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetGS" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + result = (OGRErr)OSRSpatialReferenceShadow_SetGS(arg1,arg2,arg3,arg4); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_well_known_geog_cs(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetWellKnownGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetWellKnownGeogCS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetWellKnownGeogCS(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_from_user_input(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetFromUserInput" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetFromUserInput" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + result = (OGRErr)OSRSpatialReferenceShadow_SetFromUserInput(arg1,(char const *)arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_copy_geog_csfrom(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + OSRSpatialReferenceShadow *arg2 = (OSRSpatialReferenceShadow *) 0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 ; + VALUE vresult = Qnil; + + if ((argc < 1) || (argc > 1)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "CopyGeogCSFrom" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_ConvertPtr(argv[0], &argp2,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "CopyGeogCSFrom" "', argument " "2"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg2 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp2); + result = (OGRErr)OSRSpatialReferenceShadow_CopyGeogCSFrom(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_towgs84(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double arg2 ; + double arg3 ; + double arg4 ; + double arg5 = (double) 0.0 ; + double arg6 = (double) 0.0 ; + double arg7 = (double) 0.0 ; + double arg8 = (double) 0.0 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + double val4 ; + int ecode4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + double val7 ; + int ecode7 = 0 ; + double val8 ; + int ecode8 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 3) || (argc > 7)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + ecode2 = SWIG_AsVal_double(argv[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(((ecode2 != SWIG_ERROR) ? ecode2 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "2"" of type '" "double""'"); + } + arg2 = static_cast<double >(val2); + ecode3 = SWIG_AsVal_double(argv[1], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(((ecode3 != SWIG_ERROR) ? ecode3 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "3"" of type '" "double""'"); + } + arg3 = static_cast<double >(val3); + ecode4 = SWIG_AsVal_double(argv[2], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(((ecode4 != SWIG_ERROR) ? ecode4 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "4"" of type '" "double""'"); + } + arg4 = static_cast<double >(val4); + if (argc > 3) { + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + } + if (argc > 4) { + ecode6 = SWIG_AsVal_double(argv[4], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(((ecode6 != SWIG_ERROR) ? ecode6 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast<double >(val6); + } + if (argc > 5) { + ecode7 = SWIG_AsVal_double(argv[5], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(((ecode7 != SWIG_ERROR) ? ecode7 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "7"" of type '" "double""'"); + } + arg7 = static_cast<double >(val7); + } + if (argc > 6) { + ecode8 = SWIG_AsVal_double(argv[6], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(((ecode8 != SWIG_ERROR) ? ecode8 : SWIG_TypeError), "in method '" "SetTOWGS84" "', argument " "8"" of type '" "double""'"); + } + arg8 = static_cast<double >(val8); + } + result = (OGRErr)OSRSpatialReferenceShadow_SetTOWGS84(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_get_towgs84(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + double *arg2 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + double argout2[7] ; + VALUE vresult = Qnil; + + { + /* %typemap(in,numinputs=0) (double argout2[ANY]) */ + arg2 = argout2; + } + if ((argc < 0) || (argc > 0)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "GetTOWGS84" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + result = (OGRErr)OSRSpatialReferenceShadow_GetTOWGS84(arg1,arg2); + + { + /* %typemap(out) OGRErr */ + if (result != 0) { + rb_raise(rb_eRuntimeError, OGRErrMessages(result)); + } + } + { + /* %typemap(argout) (double argout[ANY]) */ + VALUE outArr = rb_ary_new(); + + for(int i=0; i<7; i++) + { + VALUE value = rb_float_new((arg2)[i]); + rb_ary_push(outArr, value); + } + + /* Add the output to the result */ + vresult = SWIG_Ruby_AppendOutput(vresult, outArr); + } + { + /* %typemap(ret) OGRErr */ + if (vresult == Qnil) { + vresult = INT2NUM(0); + } + } return vresult; +fail: + return Qnil; +} + + +SWIGINTERN VALUE +_wrap_SpatialReference_set_geog_cs(int argc, VALUE *argv, VALUE self) { + OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + double arg5 ; + double arg6 ; + char *arg7 = (char *) "Greenwich" ; + double arg8 = (double) 0.0 ; + char *arg9 = (char *) "degree" ; + double arg10 = (double) 0.0174532925199433 ; + OGRErr result; + void *argp1 = 0 ; + int res1 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + double val5 ; + int ecode5 = 0 ; + double val6 ; + int ecode6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + double val8 ; + int ecode8 = 0 ; + int res9 ; + char *buf9 = 0 ; + int alloc9 = 0 ; + double val10 ; + int ecode10 = 0 ; + VALUE vresult = Qnil; + + if ((argc < 5) || (argc > 9)) { + rb_raise(rb_eArgError, "wrong # of arguments(%d for 5)",argc); SWIG_fail; + } + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_OSRSpatialReferenceShadow, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(((res1 != SWIG_ERROR) ? res1 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "1"" of type '" "OSRSpatialReferenceShadow *""'"); + } + arg1 = reinterpret_cast<OSRSpatialReferenceShadow * >(argp1); + res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(((res2 != SWIG_ERROR) ? res2 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = buf2; + res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(((res3 != SWIG_ERROR) ? res3 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = buf3; + res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(((res4 != SWIG_ERROR) ? res4 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = buf4; + ecode5 = SWIG_AsVal_double(argv[3], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(((ecode5 != SWIG_ERROR) ? ecode5 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "5"" of type '" "double""'"); + } + arg5 = static_cast<double >(val5); + ecode6 = SWIG_AsVal_double(argv[4], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(((ecode6 != SWIG_ERROR) ? ecode6 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "6"" of type '" "double""'"); + } + arg6 = static_cast<double >(val6); + if (argc > 5) { + res7 = SWIG_AsCharPtrAndSize(argv[5], &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(((res7 != SWIG_ERROR) ? res7 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "7"" of type '" "char const *""'"); + } + arg7 = buf7; + } + if (argc > 6) { + ecode8 = SWIG_AsVal_double(argv[6], &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(((ecode8 != SWIG_ERROR) ? ecode8 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "8"" of type '" "double""'"); + } + arg8 = static_cast<double >(val8); + } + if (argc > 7) { + res9 = SWIG_AsCharPtrAndSize(argv[7], &buf9, NULL, &alloc9); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(((res9 != SWIG_ERROR) ? res9 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "9"" of type '" "char const *""'"); + } + arg9 = buf9; + } + if (argc > 8) { + ecode10 = SWIG_AsVal_double(argv[8], &val10); + if (!SWIG_IsOK(ecode10)) { + SWIG_exception_fail(((ecode10 != SWIG_ERROR) ? ecode10 : SWIG_TypeError), "in method '" "SetGeogCS" "', argument " "10"" of type '" "double""'"); + } + arg10 = static_cast<double >